Author: konstantin.mishin
Date: 2007-06-06 12:20:04 -0400 (Wed, 06 Jun 2007)
New Revision: 1054
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
Log:
fix ids for DOM elements.
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js 2007-06-06
15:03:07 UTC (rev 1053)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js 2007-06-06
16:20:04 UTC (rev 1054)
@@ -50,7 +50,7 @@
initialize: function(element, dataModel, templates) {
ClientUI.controls.grid.Grid.parentClass.constructor().call(this, element);
- if(!element || !element.id)
+ if(!this.element || !this.element.id)
this.element.id = "ClientUI_Grid" +
ClientUI_controls_grid_Grid_idGenerator++;
this.dataModel = dataModel;
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-06-06
15:03:07 UTC (rev 1053)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-06-06
16:20:04 UTC (rev 1054)
@@ -721,12 +721,6 @@
return options;
},
_getRowIndex: function(rowId) {
- // prefix:row_2
- var index = -1;
- var match, pattern = /\:row_(\d*)/i;
- if (match = rowId.match(pattern)) {
- index = parseFloat(match[1]);
- }
- return index;
+ return Number(rowId.split(this.grid.getElement().id)[1].split(":")[2]);
}
});
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-06
15:03:07 UTC (rev 1053)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Selection.js 2007-06-06
16:20:04 UTC (rev 1054)
@@ -187,16 +187,16 @@
Object.extend(ClientUI.controls.grid.SelectionManager.prototype, {
initialize: function(gridElement) {
- this.rowPrefix =
$("ClientUI_Box8").parentNode.id.split(":body:FrozenBox")[0];//gridElement.id;
+ this.rowPrefix = gridElement.id;
this.selection = new ClientUI.controls.grid.Selection();
// this.restoreState();
this.eventKeyPress = this.processKeyDown.bindAsEventListener(this);
Event.observe(document, "keypress", this.eventKeyPress);
- var frows = $("ClientUI_Box8").rows;
- var nrows = $("ClientUI_Box9").rows;
+ var frows = $(this.rowPrefix + ":f").rows;
+ var nrows = $(this.rowPrefix + ":n").rows;
var rowIndex;
for(var i = 0; i < frows.length; i++) {
- rowIndex = Number(frows[i].id.split("_")[2]);
+ rowIndex = Number(frows[i].id.split(this.rowPrefix)[1].split(":")[2]);
this.addListener(frows[i], rowIndex);
this.addListener(nrows[i], rowIndex);
}
@@ -316,7 +316,7 @@
break;
case 65: case 97: // Ctrl-A
if (this.inFocus && event.ctrlKey) {
- range = [0, $("ClientUI_Box8").rows.length];
+ range = [0, $(this.rowPrefix + ":f").rows.length];
this.setSelection(range);
noDefault = true;
}
@@ -384,7 +384,7 @@
for (; i <= range[1]; i++) {
this.addRowToSelection(i);
}
- for (; i < $("ClientUI_Box8").rows.length; i++) {
+ for (; i < $(this.rowPrefix + ":f").rows.length; i++) {
this.removeRowFromSelection(i);
}
},
@@ -397,16 +397,16 @@
addRowToSelection: function(rowIndex) {
this.selection.addId(rowIndex);
- var fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
- var nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ var fElement = $(this.rowPrefix + ":f:" + rowIndex);
+ var nElement = $(this.rowPrefix + ":n:" + rowIndex);
fElement.style.backgroundColor = "#DDDDFF";
nElement.style.backgroundColor = "#DDDDFF";
},
removeRowFromSelection: function(rowIndex) {
this.selection.removeId(rowIndex);
- var fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
- var nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ var fElement = $(this.rowPrefix + ":f:" + rowIndex);
+ var nElement = $(this.rowPrefix + ":n:" + rowIndex);
fElement.style.backgroundColor = "#FFFFFF";
nElement.style.backgroundColor = "#FFFFFF";
},
@@ -414,13 +414,13 @@
setActiveRow: function(rowIndex) {
var fElement, nElement;
if(this.activeRow) {
- fElement = $(this.rowPrefix + ":f:row_" + this.activeRow);
- nElement = $(this.rowPrefix + ":n:row_" + this.activeRow);
+ fElement = $(this.rowPrefix + ":f:" + this.activeRow);
+ nElement = $(this.rowPrefix + ":n:" + this.activeRow);
fElement.style.color = "#000000";
nElement.style.color = "#000000";
}
- fElement = $(this.rowPrefix + ":f:row_" + rowIndex);
- nElement = $(this.rowPrefix + ":n:row_" + rowIndex);
+ fElement = $(this.rowPrefix + ":f:" + rowIndex);
+ nElement = $(this.rowPrefix + ":n:" + rowIndex);
fElement.style.color = "#0000AA";
nElement.style.color = "#0000AA";
this.activeRow = rowIndex;