Implemented unregistering ActionImplementations when ActionObject.remove is called, ActionObject.clear now calls 'remove' on all child objects.

This commit is contained in:
Andreas Stöckel 2011-06-26 14:57:05 +00:00
parent 7f47700c13
commit 44f73628e2
4 changed files with 66 additions and 17 deletions

View File

@ -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.
*/

View File

@ -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)

View File

@ -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();
});

View File

@ -30,6 +30,8 @@
<body>
<h1>Test for dynamically displaying and loading grid lines</h1>
<b>Simulates network trafic by using window.setTimeout(), 100ms network latency</b>
<button onclick="buildGrid();">Leak</button>
<button onclick="clean();">Clean</button>
<div id="container"></div>
<script>
var grid = null;
@ -231,13 +233,25 @@
}, 100);
}
$(document).ready(function() {
function clean() {
$("#container").children().remove();
actionManager = null;
objectManager = null;
grid = null;
}
function buildGrid() {
clean();
var cnt = $(document.createElement("div"));
$("#container").append(cnt);
actionManager = new egwActionManager();
actionManager.updateActions(actions);
objectManager = new egwActionObjectManager("", actionManager);
grid = new egwGrid($("#container"), columns, objectManager, fetchDataProc,
grid = new egwGrid(cnt, columns, objectManager, fetchDataProc,
null, window);
grid.setActionLinkGroup("folder", listboxFolderLinks);
grid.dataRoot.loadData(
@ -250,8 +264,12 @@
}
]
);
grid.resize(1500, 500);
grid.resize(1000, 500);
grid.reload();
}
$(document).ready(function() {
buildGrid();
});
function check_positions(_grid, _delta)