Author: pgolawski
Date: 2008-07-30 03:23:41 -0400 (Wed, 30 Jul 2008)
New Revision: 9820
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableHeader.js
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableSelection.js
Log:
null all references to DOM elements on destroy
improve performance by changing "for" loops
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
===================================================================
---
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-07-29
22:32:17 UTC (rev 9819)
+++
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-07-30
07:23:41 UTC (rev 9820)
@@ -35,13 +35,44 @@
},
destroy: function() {
- var rows = this.tableB.rows;
- rowCount = rows.length;
- for(var i = 0; i < rowCount; i++) {
- this.header.removeListeners();
- Utils.DOM.Event.removeListeners(rows[i]);
- }
+ //var rows = this.tableB.rows;
+ //rowCount = rows.length;
+ //for(var i = 0; i < rowCount; i++) {
+ // Utils.DOM.Event.removeListeners(rows[i]);
+ //}
+
+ //remove listeners
+ this.selectionManager.removeListeners();
this.header.removeListeners();
+
+ var l = this.groupRows.length;
+ for(var i = 0; i < l; i++) {
+ Utils.DOM.Event.removeListeners(this.groupRows[i]);
+ }
+
+ var headerChildren = this.header.getColumnCells();
+ l = headerChildren.length;
+ for (var i=0; i<l-1; i++) {
+ Utils.DOM.Event.removeListeners(headerChildren[i]);
+ };
+
+ //null all references to DOM elements
+ delete this.selectionManager;
+ delete this.header;
+ delete this.footer;
+
+ $(this.id).component = null;
+ this.table = null;
+ this.splashScreen = null;
+ this.mainDiv = null;
+ this.outerDiv = null;
+ this.tableB = null;
+ this.fakeIeRow = null;
+ this.fakeIeBodyRow = null;
+ this.cols = null;
+ this.scrollingDiv = null;
+ this.groupRows = null;
+ this.groups = null;
},
/**
@@ -113,8 +144,8 @@
preSendAjaxRequest: function(){
//remove listeners
Event.stopObserving(window, 'resize', this.eventContainerResize);
- Event.stopObserving(document, 'mousemove', this.header.eventSepMouseMove);
- Event.stopObserving(document, 'mouseup', this.header.eventSepMouseUp);
+ //Event.stopObserving(document, 'mousemove', this.header.eventSepMouseMove);
+ //Event.stopObserving(document, 'mouseup', this.header.eventSepMouseUp);
//show splash screen
this.showSplashScreen();
},
@@ -205,7 +236,8 @@
//prevent IE from showing borders of cells
//which parents have been hidden :|
var cells = group[i].childNodes;
- for (var j=0; j<cells.length; j++) {
+ var l = cells.length;
+ for (var j = 0; j < l; j++) {
cells[j].style.borderStyle = sBorderStyle;
}
}
@@ -300,7 +332,6 @@
updateLayout: function() {
var table = this.table.getElement();
- this.grid = table;
var outerDiv = this.outerDiv.getElement();
var cols = this.getColumns();
var header = this.header;
@@ -349,7 +380,8 @@
newHeight -= this.header.getCaptionHeight();
ClientUILib.log(ClientUILogger.INFO, "footerHeight: " + footerHeight);
scrollingDiv.setStyle('height:'+ newHeight +'px;');
- for (var i=0; i<headerChildren.length-1; i++) {
+ var l = headerChildren.length;
+ for (var i=0; i < l-1; i++) {
var headerChild = headerChildren[i];
Utils.DOM.Event.removeListeners(headerChild);
Utils.DOM.Event.observe(headerChild,'mouseover',this.header.eventHeaderCellMouseOver);
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableHeader.js
===================================================================
---
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableHeader.js 2008-07-29
22:32:17 UTC (rev 9819)
+++
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableHeader.js 2008-07-30
07:23:41 UTC (rev 9820)
@@ -52,7 +52,8 @@
removeListeners: function() {
var columnCells = this.getColumnCells();
- for (var i=0; i<columnCells.length-1; i++) {
+ var l = columnCells.length;
+ for (var i = 0; i< l-1; i++) {
var headerChild = columnCells[i];
var headerChildChildren = headerChild.childElements();
var sepSpan = headerChildChildren[2];
@@ -65,7 +66,8 @@
getVisibleWidth: function() {
var sum = 0;
- for(var i=0; i<this.getColumnsNumber()-1; i++){
+ var l = this.getColumnsNumber();
+ for(var i = 0; i < l-1; i++){
sum += this.getColumnWidth(i);
}
return sum;
@@ -161,7 +163,8 @@
var columnCells = this.getColumnCells();
this._redrawTable(this.extDt.table.getElement());
this._redrawTable(this.extDt.tableB);
- for (var i=0; i<columnCells.length-1; i++) {
+ var l = columnCells.length;
+ for (var i=0; i<l-1; i++) {
var headerChild = columnCells[i];
var headerNextChild = columnCells[i+1];
var headerChildChildren = headerChild.childElements();
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableSelection.js
===================================================================
---
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableSelection.js 2008-07-29
22:32:17 UTC (rev 9819)
+++
trunk/sandbox/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableSelection.js 2008-07-30
07:23:41 UTC (rev 9820)
@@ -69,7 +69,8 @@
getSelectedIdsQuantity: function() {
var number = 0;
- for (var i = 0; i < this.ranges.length; i++) {
+ var l = this.ranges.length;
+ for (var i = 0; i < l; i++) {
number+= this.ranges[i].size();
}
return number;
@@ -123,15 +124,17 @@
clone: function() {
var ret = Object.extend(new Object(),this);
- ret.ranges = new Array(ret.ranges.length);
- for (var i = 0; i < ret.ranges.length; i++) {
+ var l = ret.ranges.length;
+ ret.ranges = new Array(l);
+ for (var i = 0; i < l; i++) {
ret.ranges[i] = this.ranges[i].clone();
}
return ret;
},
each: function(iterator) {
- for (var i = 0; i < this.ranges.length; i++) {
+ var l = this.ranges.length;
+ for (var i = 0; i < l; i++) {
this.ranges[i].each(iterator);
}
},
@@ -151,7 +154,8 @@
}
this.ranges = new Array(rangeStrRArray.length);
var indexStrRArray;
- for(var i = 0; i < this.ranges.length; i++) {
+ var l = this.ranges.length;
+ for(var i = 0; i < l; i++) {
indexStrRArray = rangeStrRArray[i].split(",");
this.ranges[i] = new ExtendedDataTable.Range(parseInt(indexStrRArray[0]),
parseInt(indexStrRArray[1]));
}
@@ -234,7 +238,8 @@
}.bind(this)
});
if (document.selection) {
- Event.observe(this.gridElement, "click",
this.resetSelection.bindAsEventListener(this));
+ this.eventResetSelection = this.resetSelection.bindAsEventListener(this);
+ Event.observe(this.gridElement, "click", this.eventResetSelection);
}
this.eventLostFocus = this.processLostFocus.bindAsEventListener(this);
@@ -330,7 +335,8 @@
//prevent IE from showing borders of cells
//which parents have been hidden :|
var cells = nrows[i].childNodes;
- for (var j=0; j<cells.length; j++) {
+ var l = cells.length;
+ for (var j = 0; j < l; j++) {
cells[j].style.borderStyle = 'none';
}
}
@@ -360,6 +366,22 @@
}
},
+ removeListeners: function(){
+ Event.stopObserving(document, "keydown", this.eventKeyPress);
+ if (document.selection) {
+ Event.stopObserving(this.gridElement, "click", this.eventResetSelection);
+ }
+ Event.stopObserving(document, "click", this.eventLostFocus);
+ Event.stopObserving(this.gridElement, "click", this.eventPreventLostFocus);
+ if(this.options.selectionMode != "none") {
+ var nrows = $(this.prefix + ":n").rows;
+ var rowCount = nrows.length;
+ for(var i = 0; i < this.rowCount; i++) {
+ Utils.DOM.Event.removeListeners(nrows[i]);
+ }
+ }
+ },
+
/* getGridSelection: function() {
return this.selection.getRanges();
},*/
@@ -548,7 +570,8 @@
setSelection: function(range) {
//TODO test for extreemes - first rows, last rows, all rows
- for(var i = this.selection.ranges.length - 1;i >= 0;i--) {
+ var l = this.selection.ranges.length;
+ for(var i = l - 1;i >= 0; i--) {
var selection = this.selection.ranges[i].indexes;
if(selection == range) {
continue;