From 44f73628e29f318a0e421ccc6da741532fbfe709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Sun, 26 Jun 2011 14:57:05 +0000 Subject: [PATCH] Implemented unregistering ActionImplementations when ActionObject.remove is called, ActionObject.clear now calls 'remove' on all child objects. --- phpgwapi/js/egw_action/egw_action.js | 24 ++++++++++++++++++- phpgwapi/js/egw_action/egw_action_dragdrop.js | 19 +++++++++++---- phpgwapi/js/egw_action/egw_grid_view.js | 16 ++++++------- .../js/egw_action/test/test_grid_view.html | 24 ++++++++++++++++--- 4 files changed, 66 insertions(+), 17 deletions(-) diff --git a/phpgwapi/js/egw_action/egw_action.js b/phpgwapi/js/egw_action/egw_action.js index f3cf47c77e..2e7d0eef42 100644 --- a/phpgwapi/js/egw_action/egw_action.js +++ b/phpgwapi/js/egw_action/egw_action.js @@ -845,7 +845,12 @@ egwActionObject.prototype.insertObject = function(_index, _id, _iface, _flags) * Deletes all children of the egwActionObject */ egwActionObject.prototype.clear = function() { - this.children = []; + // Remove all children + while (this.children.length > 0) { + this.children[0].remove(); + } + + // Delete all other references this.selectedChildren = []; this.focusedChild = null; } @@ -859,6 +864,9 @@ egwActionObject.prototype.remove = function() { this.setSelected(false); this.setAllSelected(false); + // Unregister all registered action implementations + this.unregisterActions(); + // Clear the child-list this.clear(); @@ -1566,6 +1574,20 @@ egwActionObject.prototype.registerActions = function() } } +/** + * Unregisters all action implementations registerd to this element + */ +egwActionObject.prototype.unregisterActions = function() +{ + while (this.registeredImpls.length > 0) { + var impl = this.registeredImpls.pop(); + if (this.iface) { + impl.unregisterAction(this.iface); + } + } +} + + /** * Calls the onBeforeTrigger function - if it is set - or returns false. */ diff --git a/phpgwapi/js/egw_action/egw_action_dragdrop.js b/phpgwapi/js/egw_action/egw_action_dragdrop.js index 199c777ade..1aefce7876 100644 --- a/phpgwapi/js/egw_action/egw_action_dragdrop.js +++ b/phpgwapi/js/egw_action/egw_action_dragdrop.js @@ -137,7 +137,11 @@ function egwDragActionImplementation() ai.doUnregisterAction = function(_aoi) { - // + var node = _aoi.getDOMNode(); + + if (node) { + $(node).draggable("destroy"); + } } /** @@ -266,6 +270,7 @@ function egwDropActionImplementation() ai.doRegisterAction = function(_aoi, _callback, _context) { var node = _aoi.getDOMNode(); + var self = this; if (node) { @@ -274,8 +279,8 @@ function egwDropActionImplementation() "accept": function(_draggable) { if (typeof _draggable.data("ddTypes") != "undefined") { - var accepted = ai._fetchAccepted( - _callback.call(_context, "links", ai, EGW_AO_EXEC_THIS)); + var accepted = self._fetchAccepted( + _callback.call(_context, "links", self, EGW_AO_EXEC_THIS)); // Check whether all drag types of the selected objects // are accepted @@ -297,7 +302,7 @@ function egwDropActionImplementation() var ddTypes = draggable.data("ddTypes"); var selected = draggable.data("selected"); - var links = _callback.call(_context, "links", ai, EGW_AO_EXEC_THIS); + var links = _callback.call(_context, "links", self, EGW_AO_EXEC_THIS); // Disable all links which only accept types which are not // inside ddTypes @@ -370,7 +375,11 @@ function egwDropActionImplementation() ai.doUnregisterAction = function(_aoi) { - // + var node = _aoi.getDOMNode(); + + if (node) { + $(node).droppable("destroy"); + } } ai._fetchAccepted = function(_links) diff --git a/phpgwapi/js/egw_action/egw_grid_view.js b/phpgwapi/js/egw_action/egw_grid_view.js index 61423d1e8c..60d0b32927 100644 --- a/phpgwapi/js/egw_action/egw_grid_view.js +++ b/phpgwapi/js/egw_action/egw_grid_view.js @@ -887,7 +887,7 @@ function egwGridViewGrid_beginUpdate() function egwGridViewGrid_triggerUpdateAssumedHeights() { - this.triggerID++; +/* this.triggerID++; var self = this; var id = this.triggerID; window.setTimeout(function() { @@ -898,7 +898,7 @@ function egwGridViewGrid_triggerUpdateAssumedHeights() } }, EGW_GRID_UPDATE_HEIGHTS_TIMEOUT - ); + );*/ } function egwGridViewGrid_endUpdate(_recPrev) @@ -1005,9 +1005,9 @@ function egwGridViewGrid_setupContainer() this.scrollarea.scroll(this, function(e) { e.data.scrollEvents++; var cnt = e.data.scrollEvents; - window.setTimeout(function() { +/* window.setTimeout(function() { e.data.scrollCallback(cnt); - }, EGW_GRID_SCROLL_TIMEOUT); + }, EGW_GRID_SCROLL_TIMEOUT);*/ }); } @@ -1129,9 +1129,9 @@ function egwGridViewGrid_updateAssumedHeights(_maxCount) // Otherwise, all elements have been checked - we'll now call "setViewArea" // which may check whether new objects are now in the currently visible range var self = this; - window.setTimeout(function() { +/* window.setTimeout(function() { self.setViewArea(self.viewArea); - }, EGW_GRID_UPDATE_HEIGHTS_TIMEOUT); + }, EGW_GRID_UPDATE_HEIGHTS_TIMEOUT);*/ } } @@ -1707,10 +1707,10 @@ function egwGridViewRow_doUpdateData(_immediate) icon.load({"item": this, "cntr": iconContainer}, function(e) { e.data.cntr.css("min-height", ""); var icon = $(this); - window.setTimeout(function() { +/* window.setTimeout(function() { e.data.item.grid.setIconWidth(icon.width()); e.data.item.grid.addIconHeightToAvg(icon.height()); - }, 100); + }, 100);*/ e.data.item.callHeightChangeProc(); }); diff --git a/phpgwapi/js/egw_action/test/test_grid_view.html b/phpgwapi/js/egw_action/test/test_grid_view.html index 1094465e19..2b167a9022 100644 --- a/phpgwapi/js/egw_action/test/test_grid_view.html +++ b/phpgwapi/js/egw_action/test/test_grid_view.html @@ -30,6 +30,8 @@

Test for dynamically displaying and loading grid lines

Simulates network trafic by using window.setTimeout(), 100ms network latency + +