JBoss Rich Faces SVN: r967 - trunk/richfaces-samples/inputNumberSliderDemo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-31 13:40:35 -0400 (Thu, 31 May 2007)
New Revision: 967
Modified:
trunk/richfaces-samples/inputNumberSliderDemo/src/main/webapp/pages/index.jsp
Log:
http://jira.jboss.com/jira/browse/RF-127 fixed
Modified: trunk/richfaces-samples/inputNumberSliderDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/richfaces-samples/inputNumberSliderDemo/src/main/webapp/pages/index.jsp 2007-05-31 17:40:29 UTC (rev 966)
+++ trunk/richfaces-samples/inputNumberSliderDemo/src/main/webapp/pages/index.jsp 2007-05-31 17:40:35 UTC (rev 967)
@@ -57,7 +57,7 @@
</f:verbatim>
<rich:inputNumberSlider showInput="true" showBoundaryValues="true" showToolTip="true"
- value="2.5" step="0.5" minValue="0.0" maxValue="10.0" />
+ value="2.5" step="0.5" minValue="0.0" maxValue="10.0" inputSize="30" />
<f:verbatim>
<br />
17 years, 7 months
JBoss Rich Faces SVN: r966 - trunk/richfaces/inputnumber-slider/src/main/templates.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-31 13:40:29 -0400 (Thu, 31 May 2007)
New Revision: 966
Modified:
trunk/richfaces/inputnumber-slider/src/main/templates/inputNumberSlider.jspx
Log:
http://jira.jboss.com/jira/browse/RF-127 fixed
Modified: trunk/richfaces/inputnumber-slider/src/main/templates/inputNumberSlider.jspx
===================================================================
--- trunk/richfaces/inputnumber-slider/src/main/templates/inputNumberSlider.jspx 2007-05-31 17:22:24 UTC (rev 965)
+++ trunk/richfaces/inputnumber-slider/src/main/templates/inputNumberSlider.jspx 2007-05-31 17:40:29 UTC (rev 966)
@@ -55,6 +55,8 @@
variables.setVariable("color", "");
}
+ variables.setVariable("inputSize", component.getAttributes().get("inputSize"));
+
//if (showInput || manualInput) {
if (showInput) {
]]></jsp:scriptlet>
@@ -70,7 +72,7 @@
onfocus="#{component.attributes['onfocus']}"
onblur="#{component.attributes['onblur']}"
accesskey="#{component.attributes['accesskey']}"
- size="#{component.attributes['inputSize']}"
+ size="#{inputSize}"
maxlength="#{component.attributes['maxlength']}"
/>
<jsp:scriptlet><![CDATA[
17 years, 7 months
JBoss Rich Faces SVN: r965 - trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-31 13:22:24 -0400 (Thu, 31 May 2007)
New Revision: 965
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
Log:
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-05-31 17:21:43 UTC (rev 964)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-05-31 17:22:24 UTC (rev 965)
@@ -48,11 +48,11 @@
<f:facet name="splash">
<h:panelGroup id="splash">
- <div style="display:none; background-color: #A0D1FF; border: 1px solid #0027C4; width: 200px; height: 50px; text-align: center; vertical-align: middle;"><font size='4' color='white'>Loading...</font></div>
+ <div style="background-color: #A0D1FF; border: 1px solid #0027C4; width: 200px; height: 50px; text-align: center; vertical-align: middle;"><font size='4' color='white'>Loading...</font></div>
</h:panelGroup>
</f:facet>
- <sg:column width="200px">
+ <sg:column width="100px" sortable="false">
<f:facet name="header">
<h:outputText value="Index"></h:outputText>
</f:facet>
@@ -134,6 +134,9 @@
</sg:column>
</sg:scrollable-grid>
+
+
+
</h:form>
</f:view>
17 years, 7 months
JBoss Rich Faces SVN: r964 - trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-31 13:21:43 -0400 (Thu, 31 May 2007)
New Revision: 964
Modified:
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx 2007-05-31 17:21:30 UTC (rev 963)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx 2007-05-31 17:21:43 UTC (rev 964)
@@ -6,7 +6,8 @@
xmlns:u=" http://ajax4jsf.org/cdk/u"
xmlns:x=" http://ajax4jsf.org/cdk/x"
xmlns:h=" http://ajax4jsf.org/cdk/headers"
- xmlns:vcp="http://ajax4jsf.org/cdk/vcp"
+ xmlns:vcp="http://ajax4jsf.org/cdk/vcp"
+
class="org.richfaces.renderkit.html.ScrollableGridHeaderCellRenderer"
component="javax.faces.component.UIComponent"
>
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-05-31 17:21:30 UTC (rev 963)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-05-31 17:21:43 UTC (rev 964)
@@ -167,6 +167,13 @@
},
getCurrentOptions: function() {
+ if(!this.curr_options) {
+ this.curr_options = {
+ count: grid.getBody().templFrozen.getElement().rows.length,
+ index: 0,
+ startRow: 0
+ }
+ }
return this.curr_options;
},
@@ -216,7 +223,7 @@
var columns_count = '#{columns_count}';
function onSorted(sortEvent) {
- alert("onSorted column: " + sortEvent.column + " by order: " + sortEvent.order + ", row:" + sortEvent.startRow + ", index:" + sortEvent.index);
+ // alert("onSorted column: " + sortEvent.column + " by order: " + sortEvent.order + ", row:" + sortEvent.startRow + ", index:" + sortEvent.index);
var event = null;
#{this:onSortAjaxUpdate(context,component)}
}
@@ -255,10 +262,39 @@
},
onCompleteGridInvalidation : function(request, event, data){
- var local = dataModel.getCurrentOptions();
- dataModel.eventDataReady.fire(local);
- }
- }
+
+ var theDoc = document;
+ var getEl = theDoc.getElementById;
+ var options = dataModel.getCurrentOptions();
+ var rowCount = grid.getBody().templFrozen.getElement().rows.length;
+ var startRow = options.startRow;
+ var count = options.count;
+ var row, id, rowindex, i;
+ for(i=0; i<count; i++) {
+ rowindex = startRow + i;
+ if(rowindex >= rowCount) rowindex -= rowCount;
+ id = "f:row_" + rowindex;
+ row = request.getElementById(id);
+ if(ClientUILib.isIE) {
+ getEl(id).innerText = row.innerHTML;
+ }
+ else {
+ theDoc.getElementById(id).innerHTML = row.innerHTML;
+ }
+
+ id = "n:row_" + rowindex;
+ row = request.getElementById(id);
+ if(ClientUILib.isIE) {
+ getEl(id).innerText = row.innerHTML;
+ }
+ else {
+ theDoc.getElementById(id).innerHTML = row.innerHTML;
+ }
+ }
+
+ dataModel.eventDataReady.fire(options);
+ }
+ }
}();
#{this:getScriptContributions(context, component)};
Event.observe(window, 'load', #{this:getJavaScriptVarName(context, component)}.init);
17 years, 7 months
JBoss Rich Faces SVN: r963 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-31 13:21:30 -0400 (Thu, 31 May 2007)
New Revision: 963
Added:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
Removed:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-31 17:21:16 UTC (rev 962)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-31 17:21:30 UTC (rev 963)
@@ -181,10 +181,6 @@
if(ClientUILib.isGecko) {
this.defaultRowHeight -= this.getBorderWidth("tb") + this.getPadding("tb");
}
- for(var i=0; i<this.rowsCount; i++) {
- templFrozen.rows[i].index = i;
- templNormal.rows[i].index = i;
- }
this.helpObj = new ClientUI.common.box.Box(templFrozen, null, true);
this.countToLoad = 0;
this.startRow = 0;
@@ -283,7 +279,7 @@
else if(to == this.grid.dataModel.getCount()) {
from = to - this.rowsCount;
}
-
+
var range = $R(from, to);
if(this.currRange.start == from && this.currRange.end == to) {
@@ -375,7 +371,7 @@
}
if(switchType === 0) {
- startRowIndx = this.templFrozen.getElement().rows[0].index;
+ startRowIndx = this._getRowIndex(this.templFrozen.getElement().rows[0].id);
startIndex = range.start;
countToLoad = range.end - range.start;
}
@@ -389,7 +385,7 @@
switchType = 1;
countToLoad = range.start - this.currRange.start;
if(countToLoad > 0) {
- startRowIndx = frozenTbl.rows[0].index;
+ startRowIndx = this._getRowIndex(frozenTbl.rows[0].id);
startIndex = this.currRange.end;
}
}
@@ -399,7 +395,7 @@
if(countToLoad > 0) {
startIndex = this.currRange.end;
var restCount = this.rowsCount - countToLoad;
- startRowIndx = frozenTbl.rows[restCount].index;
+ startRowIndx = this._getRowIndex(frozenTbl.rows[restCount].id);
}
}
else {
@@ -408,7 +404,7 @@
if(countToLoad > 0) {
startIndex = range.start;
var restCount = this.rowsCount - countToLoad;
- startRowIndx = frozenTbl.rows[restCount].index;
+ startRowIndx = this._getRowIndex(frozenTbl.rows[restCount].id);
}
}
}
@@ -430,6 +426,7 @@
this.taskDefineTime = (new Date()).getTime();
this.showSplash();
+ this.container.hide();
var options = {
index: startIndex,
@@ -437,13 +434,18 @@
startRow: startRowIndx,
switchType: switchType
};
+ var opt = {
+ index: options.index,
+ count: options.count,
+ startRow: options.startRow,
+ switchType: options.switchType
+ };
options = this.processCashedValues(options);
if(options.count > 0) {
// Make timer to handle quick clicks on scrollbar arrows
setTimeout(function() {
// 4. start data loading
- this.container.hide();
this.updateInterval = screen.updateInterval;
screen.updateInterval = 1000;
@@ -451,6 +453,7 @@
}.bind(this), 10);
}
else {
+ this.invalidate(opt);
this.updateStarted = false;
}
}
@@ -596,10 +599,10 @@
setTimeout(function () {
this.rearrangeRows(options, true, true);
+ this.container.show();
this.splash.hide();
this.updateStarted = false;
-
}.bind(this), 10);
/*if(this.processedPos != this.currentPos) {
@@ -626,55 +629,90 @@
}
return this.cash;
},
+ _restoreFromCash: function(options) {
+ var count = options.count;
+ var index = options.index;
+ var startRow = options.startRow;
+ var cash = this.getCash();
+ var frows = this.templFrozen.getElement().rows;
+ var nrows = this.templNormal.getElement().rows;
+
+ var row, rowU, i=0;
+ var rowC = cash.getRow(index);
+ do {
+ row = frows[startRow];
+ rowU = row.cloneNode(true);
+ rowU.innerHTML = rowC.f;
+ row.parentNode.replaceChild(rowU, row);
+
+ row = nrows[startRow];
+ rowU = row.cloneNode(true);
+ rowU.innerHTML = rowC.n;
+ row.parentNode.replaceChild(rowU, row);
+
+ i++;
+ startRow++;
+ if(startRow >= this.rowsCount) startRow = 0;
+ rowC = cash.getRow(index + i);
+ } while(i<count && rowC);
+
+ setTimeout(function () {
+ this.rearrangeRows(options);
+ this.container.show();
+ this.splash.hide();
+ this.updateStarted = false;
+
+ }.bind(this), 10);
+ },
processCashedValues: function(options) {
return options;
+ var opt = {switchType: options.switchType };
var cash = this.getCash();
- var opt = {};
- var frows = this.templFrozen.getElement().rows;
- var nrows = this.templNormal.getElement().rows;
+ var count = options.count;
+ var index = options.index;
+ var startRow = options.startRow;
+
+ var i = 0;
+ var rowC;
- var i = 0;
- var count = opt.count;
- var index = opt.index;
- var startRow = opt.startRow;
- var rowC, row, rowU;
- while(i<count && !(rowC = cash.getRow(index + i))) i++;
- if(i<count) {
- if(i > 0) {
- options.count = i;
- }
- opt.count = count - i;
- opt.index = index + i;
- startRow += i;
- if(startRow >= this.rowsCount) startRow -= this.rowsCount;
+ while(i<count && (rowC = cash.getRow(index + i))!=null) i++;
+ if(i>0) { // there are cashed rows from start
+ opt.count = i;
+ opt.index = index;
opt.startRow = startRow;
+ this._restoreFromCash(opt);
- do {
- row = frows[startRow];
- rowU = row.cloneNode(true);
- rowU.innerHTML = rowC.f;
- row.parentNode.replaceChild(rowU, row);
-
- row = nrows[startRow];
- rowU = row.cloneNode(true);
- rowU.innerHTML = rowC.n;
- row.parentNode.replaceChild(rowU, row);
+ options.count -= i;
+ options.index = index+i;
+ options.startRow = startRow+i;
+ if(options.startRow >= this.rowsCount) options.startRow -= this.rowsCount;
+ }
+
+ var cnt = 0;
+ while(i<count && !(rowC = cash.getRow(index + i))) { i++; cnt++; }
+ if(i<count) { // there are cashed rows at the end of range
+ opt.count = options.count - cnt;
+ opt.index = index+i;
+ opt.startRow = startRow+i;
+ if(opt.startRow >= this.rowsCount) opt.startRow -= this.rowsCount;
+ this._restoreFromCash(opt);
- i++;
- startRow++;
- if(startRow >= this.rowsCount) startRow = 0;
- rowC = cash.getRow(index + i);
- } while(i<count && rowC);
-
- if(i<=count) {
- options.count = count - i;
- options.index = index + i;
- opt.count = i;
- }
- this.rearrangeRows(opt);
+ options.count = cnt;
+ options.index = index+(i-cnt);
+ options.startRow = startRow+(i-cnt);
+ if(options.startRow >= this.rowsCount) options.startRow -= this.rowsCount;
}
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;
}
});
Deleted: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-31 17:21:16 UTC (rev 962)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-31 17:21:30 UTC (rev 963)
@@ -1,437 +0,0 @@
-/*
- * TODO: Copyright (c) 2007 Denis Morozov <dmorozov(a)exadel.com>
- *
- * ...
- */
-ClientUILib.declarePackage("ClientUI.controls.grid.GridHeader");
-
-ClientUILib.requireClass("ClientUI.common.box.Box");
-ClientUILib.requireClass("ClientUI.common.box.InlineBox");
-
-/*
- * GridHeader.js - Grid control header pane
- * TODO: add comments
- */
-ClientUI.controls.grid.GridHeader = Class.create({
- CLASSDEF: {
- name: 'ClientUI.controls.grid.GridHeader',
- parent: ClientUI.common.box.Box,
- sepStyleClass: "ClientUI_Grid_HSep"
- }
-
-});
-
-Object.extend(ClientUI.controls.grid.GridHeader.prototype, {
- // internal variables
- _columns: [],
-
- // constructor
- initialize: function(template, grid) {
- this.grid = grid;
-
- ClientUI.controls.grid.GridHeader.parentClass.constructor().call(this, template);
-
- // register event handlers
- this.eventSepDblClick = this.OnSepDblClick.bindAsEventListener(this);
- this.eventSepMouseDown = this.OnSepMouseDown.bindAsEventListener(this);
- this.eventSepMouseUp = this.OnSepMouseUp.bindAsEventListener(this);
- this.eventSepMouseMove = this.OnSepMouseMove.bindAsEventListener(this);
- this.eventCellMouseDown = this.OnCellMouseDown.bindAsEventListener(this);
- Event.observe(document, 'mousemove', this.eventSepMouseMove, true);
- Event.observe(document, 'mouseup', this.eventSepMouseUp, true);
-
- this.createControl(template);
- },
-
- // create grid header control
- createControl: function(template) {
- var errMsg = "";
- if(!template) {
- errMsg = "Invalid template specified for GridHeader.";
- ClientUILib.log(ClientUILogger.ERROR, errMsg);
- throw(errMsg);
- }
-
- if(!this.parseTemplate(template)) {
- errMsg = "Unable to parse template. GridHeader requires template specified over table element with one row.";
- ClientUILib.log(ClientUILogger.ERROR, errMsg);
- throw(errMsg);
- }
-
- // Set dimensions
- this.setHeight(this.defaultHeight);
- this.setWidth(this.defaultWidth);
- this.controlCreated = true;
- this.updateLayout();
- this.hide();
- this.show();
- },
- parseTemplate: function(template) {
- if(!template) {
- return false;
- }
-
- var childs = template.childNodes;
- for(var i=0; i<childs.length; i++) {
- if(childs[i].tagName && childs[i].tagName.toLowerCase() == "div") {
- this.container = $(childs[i]);
- break;
- }
- }
-
- var normal = null, frozen = null;
- var childs = this.container.childNodes;
- for(var i=0; i<childs.length; i++) {
- if(childs[i].id && childs[i].id.indexOf("FrozenBox")>=0) {
- frozen = childs[i];
- }
- else if(childs[i].id && childs[i].id.indexOf("NormalBox")>=0){
- normal = childs[i];
- }
- }
-
- if(!normal || !frozen) {
- errMsg = "Unable to parse template for GridHeader. Unable to find FrozenBox or NormalBox.";
- ClientUILib.log(ClientUILogger.ERROR, errMsg);
- throw(errMsg);
- }
- this.contentBox = new ClientUI.common.box.Box(normal);
- this.contentBox.makeAbsolute();
- this.frozenContentBox = new ClientUI.common.box.Box(frozen);
- this.frozenContentBox.makeAbsolute();
-
- // create row template
- var ch = this.contentBox.getElement().firstChild;
- while(ch) {
- if(ch.tagName && ch.tagName.toLowerCase()=="table") {
- this.headerRow = new ClientUI.common.box.Box($(ch), null, true);
- break;
- }
- ch = ch.nextSibling;
- }
- ch = this.frozenContentBox.getElement().firstChild;
- while(ch) {
- if(ch.tagName && ch.tagName.toLowerCase()=="table") {
- this.headerFrozenRow = new ClientUI.common.box.Box($(ch), null, true);
- break;
- }
- ch = ch.nextSibling;
- }
-
- this.helpObj = new ClientUI.common.box.Box(this.frozenContentBox.getElement(), null, true);
-
- var columns = [];
- var defaultWidth = 0;
- var defaultHeight = 0;
-
- var eventCellMouseDown = this.eventCellMouseDown.bind(this);
-
- // Get columns information
- var i = 0, h;
- var cells = $A(this.headerFrozenRow.getElement().rows[0].cells);
- cells.each(function(cell) {
- columns[i] = {
- width: Element.getWidth(cell),
- innerHTML: cell.innerHTML,
- styleClass: cell.className,
- id: cell.id,
- align: cell.align,
- valign: cell.vAlign,
- title: cell.title,
- minWidth: 10,
- frozen: true,
- fixedWidth: Validators.getBoolean(cell.getAttribute("fixedWidth"), false),
- sortable: Validators.getBoolean(cell.getAttribute("sortable"), true),
- sorted: Validators.getBoolean(cell.getAttribute("sorted"), "desc")
- };
-
- if(columns[i].sortable)
- Event.observe(cell, 'click', eventCellMouseDown);
- h = Element.getHeight(cell);
- if(h > defaultHeight) defaultHeight = h;
- defaultWidth += columns[i].width;
- columns[i].object = new ClientUI.common.box.InlineBox(cell, null, true);
- columns[i].sortDesc = document.getElementsByClassName("sort-desc", cell)[0];
- columns[i].sortAsc = document.getElementsByClassName("sort-asc", cell)[0];
- if(ClientUILib.isIE && columns[i].sortDesc) {
- Element.setStyle(columns[i].sortDesc, {left: "-10px"});
- Element.setStyle(columns[i].sortAsc, {left: "-10px"});
- }
- i++;
- });
-
- cells = $A(this.headerRow.getElement().rows[0].cells);
- cells.each(function(cell) {
- columns[i] = {
- width: Element.getWidth(cell),
- innerHTML: cell.innerHTML,
- styleClass: cell.className,
- id: cell.id,
- align: cell.align,
- valign: cell.vAlign,
- title: cell.title,
- minWidth: 10,
- frozen: false,
- fixedWidth: Validators.getBoolean(cell.getAttribute("fixedWidth"), false),
- sortable: Validators.getBoolean(cell.getAttribute("sortable"), true),
- sorted: Validators.getBoolean(cell.getAttribute("sorted"), "desc")
- };
-
- if(columns[i].sortable)
- Event.observe(cell, 'click', eventCellMouseDown);
- h = Element.getHeight(cell);
- if(h > defaultHeight) defaultHeight = h;
- defaultWidth += columns[i].width;
- columns[i].object = new ClientUI.common.box.InlineBox(cell, null, true);
- columns[i].sortDesc = document.getElementsByClassName("sort-desc", cell)[0];
- columns[i].sortAsc = document.getElementsByClassName("sort-asc", cell)[0];
- if(ClientUILib.isIE && columns[i].sortDesc) {
- Element.setStyle(columns[i].sortDesc, {left: "-10px"});
- Element.setStyle(columns[i].sortAsc, {left: "-10px"});
- }
- i++;
- });
-
- columns.pop(); // remove last fake column
- this._columns = columns;
- this.defaultHeight = defaultHeight;
- this.defaultWidth = defaultWidth;
- if(ClientUILib.isGecko) {
- this.defaultWidth -= this.getBorderWidth("lr") + this.getPadding("lr");
- this.defaultHeight -= this.getBorderWidth("tb") + this.getPadding("tb");
- }
-
- var sep, column;
- var seps = document.getElementsByClassName("ClientUI_Grid_HSep", this.getElement());
- for(i = 0; i<seps.length; i++) {
- sep = seps[i];
- column = parseInt(sep.getAttribute("column"));
- this._columns[column].sep = new ClientUI.common.box.InlineBox(sep, null, true);
- sep.columnIndex = column;
- if(!this._columns[column].fixedWidth) {
- Event.observe(sep, 'dblclick', this.eventSepDblClick);
- Event.observe(sep, 'mousedown', this.eventSepMouseDown);
- }
- else {
- sep.setStyle({cursor: 'auto'});
- }
- }
- this.agjustSeparators();
-
- if(ClientUILib.isIE) {
- this.frozenSubstrate = new ClientUI.common.box.Substrate(null, this.getElement());
- this.frozenSubstrate.getElement().name = this.getElement().id + "HRFrm";
- Element.addClassName(this.frozenSubstrate.getElement(), "ClientUI_HRFrm");
- this.frozenSubstrate.setHeight(this.headerRow.getViewportHeight());
- }
-
- return true;
- },
- agjustSeparators: function() {
- var offset = 0;
- var fcnt = this.headerFrozenRow.getElement().rows[0].cells.length;
- for(var i=0; i<this._columns.length - 1; i++) {
- if(i == fcnt) offset = 0;
- offset += this._columns[i].width;
- this._columns[i].sep.moveToX(offset - 4);
- }
- },
- updateLayout: function() {
- if(!this.controlCreated || !this.grid.controlCreated) {
- return;
- }
- ClientUI.controls.grid.GridHeader.parentClass.method("updateLayout").call(this);
- var height = this.getViewportHeight();
- var totalWidth = this.grid.getColumnsTotalWidth();
- var frozenContentWidth = this.grid.getColumnsFrozenWidth();
-
- this.contentBox.setWidth(Math.max(this.getWidth(), totalWidth));
- this.contentBox.setHeight(height);
- this.contentBox.moveTo(frozenContentWidth, 0);
- this.frozenContentBox.setWidth(frozenContentWidth);
- this.frozenContentBox.setHeight(height);
- this.frozenContentBox.moveTo(0, 0);
- if(ClientUILib.isIE)
- this.frozenSubstrate.setWidth(frozenContentWidth);
- },
- getColumns: function() {
- return this._columns;
- },
- // lets implement column resizer
- OnSepMouseDown: function(event) {
- this.dragColumnInfo = {
- srcElement: Event.element(event),
- dragStarted: false,
- mouseDown: true,
- startX: Event.pointerX(event),
- originalX: 0
- };
- this.dragColumnInfo.object = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].object;
- this.dragColumnInfo.sep = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].sep;
- this.dragColumnInfo.minWidth = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].minWidth;
-
- Event.stop(event);
- },
- OnSepMouseUp: function(event) {
- if(this.dragColumnInfo && this.dragColumnInfo.dragStarted) {
- this.dragColumnInfo.dragStarted = false;
- this.dragColumnInfo.mouseDown = false;
- var delta = Event.pointerX(event) - this.dragColumnInfo.startX;
- var newWidth = this.dragColumnInfo.object.getWidth() + delta;
- setTimeout(function() {
- this.grid.adjustColumnWidth(this.dragColumnInfo.srcElement.columnIndex, newWidth);
- }.bind(this), 10);
- }
- this._hideSplitter();
- },
- OnSepMouseMove: function(event) {
- if(this.dragColumnInfo && this.dragColumnInfo.mouseDown) {
- if(!this.dragColumnInfo.dragStarted) {
- this.dragColumnInfo.dragStarted = true;
- this._showSplitter(this.dragColumnInfo.srcElement.columnIndex);
- }
- else {
- var delta = Event.pointerX(event) - this.dragColumnInfo.startX;
- var minColumnWidth = this.dragColumnInfo.object.getWidth() - this.dragColumnInfo.minWidth;
- if(delta >= -minColumnWidth) {
- var x = this.dragColumnInfo.originalX + delta;
- this.columnSplitter.moveToX(x - 6);
- }
- }
- Event.stop(event);
- }
- },
- OnSepDblClick: function(event) {
- ClientUILib.log(ClientUILogger.INFO, "OnSepDblClick");
- },
- _showSplitter: function(index) {
- if(!this.columnSplitter) {
- this._createSplitter();
- }
-
- var pos = this.dragColumnInfo.sep.getX();
- if(!this.getColumns()[index].frozen) {
- pos += this.grid.getColumnsFrozenWidth() - this.grid.getScrollOffset();
- }
- this.dragColumnInfo.originalX = pos;
- this.columnSplitter.show();
- this.columnSplitter.setHeight(this.defaultHeight + this.grid.getBody().contentBox.getHeight());
- this.columnSplitter.moveTo(pos, 0);
- },
- _hideSplitter: function() {
- if(this.columnSplitter) {
- this.columnSplitter.hide();
- }
- },
- _createSplitter: function() {
- this.columnSplitter = new ClientUI.common.box.Box(null, this.grid.getElement());
- this.columnSplitter.makeAbsolute();
- this.columnSplitter.getElement().addClassName("ClientUI_Grid_HSplit");
- this.columnSplitter.setWidth(10);
- this.columnSplitter.getElement().setStyle({backgroundColor: ''});
- this.columnSplitter.getElement().setStyle({zIndex: '100'});
- this.columnSplitter.hide();
- },
- adjustScrollPosition: function(pos) {
- this.contentBox.moveToX(this.grid.getColumnsFrozenWidth()-pos);
- },
- OnCellMouseDown: function(event) {
- var el = Event.element(event);
- while(el && !Element.hasClassName(el, "ClientUI_Grid_HC")) {
- el = el.parentNode;
- }
-
- if(el) {
- var index = parseInt(el.getAttribute("columnIndex"));
- if(index>=0) {
- var dir = this.getColumns()[index].sorted;
- dir = (dir == "asc") ? "desc" : "asc";
- this.getColumns()[index].sorted = dir;
-
- for(var i = 0, len = this.getColumns().length; i < len; i++) {
- var h = this.getColumns()[i];
- if(i != index) {
- Element.setStyle(h.sortDesc, {display: 'none'});
- Element.setStyle(h.sortAsc, {display: 'none'});
- } else{
- Element.setStyle(h.sortDesc, {display: (dir == 'desc' ? 'block' : 'none')});
- Element.setStyle(h.sortAsc, {display: (dir == 'asc' ? 'block' : 'none')});
- }
- }
-
- this.grid.eventOnSort.fire({
- column: index,
- order: dir,
- startRow: this.grid.getBody().templFrozen.getElement().rows[0].index,
- index: this.grid.getBody().currRange.start
- });
- Event.stop(event);
- }
- }
- },
- _getVisibleHeaderControls: function() {
- var controls = [];
- var columns = this.getColumns();
- columns.each(function(column){
- var ctrls = column.object.getElement().getElementsByTagName("select");
- if(ctrls && ctrls.length>0) {
- ctrls = $A(ctrls);
- ctrls.each(function(ctrl){
- if(Element.visible(ctrl)) {
- controls.push(ctrl);
- }
- });
- }
- });
- return controls;
- },
- adjustColumnWidth: function(column, width) {
- var w = width, ch;
- var frozenColumns = this.headerFrozenRow.getElement().rows[0].cells.length;
- var realColumn = column;
- var table = null;
- if(column < frozenColumns) {
- table = this.headerFrozenRow.getElement();
- }
- else {
- table = this.headerRow.getElement();
- realColumn -= frozenColumns;
- }
-
- // Hide controls in IE that flipped in other case
- var ctrlsIE = [];
- if(ClientUILib.isIE) {
- ctrlsIE = this._getVisibleHeaderControls();
- ctrlsIE.each(function(ctrl){
- Element.hide(ctrl);
- });
- }
-
- var childs = table.rows[0].cells[realColumn].childNodes;
- this.helpObj.element = $(table.rows[0].cells[realColumn]);
- var delta = 0;
- if(ClientUILib.isGecko) {
- delta = this.helpObj.getBorderWidth("lr") + this.helpObj.getPadding("lr");
- }
- this.helpObj.setWidth(width - delta);
- delta *= 2;
-
- for (var j=0; j<childs.length; j++) {
- ch = childs[j];
- if(ch.tagName && ch.tagName.toLowerCase() == "span") {
- this.helpObj.element = $(ch);
- this.helpObj.setWidth(width - delta);
- break;
- }
- }
-
- if(ClientUILib.isIE) {
- ctrlsIE.each(function(ctrl){
- Element.show(ctrl);
- });
- }
-
- this._columns[column].width = width;
- this.agjustSeparators();
- }
-});
Added: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-31 17:21:30 UTC (rev 963)
@@ -0,0 +1,437 @@
+/*
+ * TODO: Copyright (c) 2007 Denis Morozov <dmorozov(a)exadel.com>
+ *
+ * ...
+ */
+ClientUILib.declarePackage("ClientUI.controls.grid.GridHeader");
+
+ClientUILib.requireClass("ClientUI.common.box.Box");
+ClientUILib.requireClass("ClientUI.common.box.InlineBox");
+
+/*
+ * GridHeader.js - Grid control header pane
+ * TODO: add comments
+ */
+ClientUI.controls.grid.GridHeader = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.GridHeader',
+ parent: ClientUI.common.box.Box,
+ sepStyleClass: "ClientUI_Grid_HSep"
+ }
+
+});
+
+Object.extend(ClientUI.controls.grid.GridHeader.prototype, {
+ // internal variables
+ _columns: [],
+
+ // constructor
+ initialize: function(template, grid) {
+ this.grid = grid;
+
+ ClientUI.controls.grid.GridHeader.parentClass.constructor().call(this, template);
+
+ // register event handlers
+ this.eventSepDblClick = this.OnSepDblClick.bindAsEventListener(this);
+ this.eventSepMouseDown = this.OnSepMouseDown.bindAsEventListener(this);
+ this.eventSepMouseUp = this.OnSepMouseUp.bindAsEventListener(this);
+ this.eventSepMouseMove = this.OnSepMouseMove.bindAsEventListener(this);
+ this.eventCellMouseDown = this.OnCellMouseDown.bindAsEventListener(this);
+ Event.observe(document, 'mousemove', this.eventSepMouseMove, true);
+ Event.observe(document, 'mouseup', this.eventSepMouseUp, true);
+
+ this.createControl(template);
+ },
+
+ // create grid header control
+ createControl: function(template) {
+ var errMsg = "";
+ if(!template) {
+ errMsg = "Invalid template specified for GridHeader.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+
+ if(!this.parseTemplate(template)) {
+ errMsg = "Unable to parse template. GridHeader requires template specified over table element with one row.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+
+ // Set dimensions
+ this.setHeight(this.defaultHeight);
+ this.setWidth(this.defaultWidth);
+ this.controlCreated = true;
+ this.updateLayout();
+ this.hide();
+ this.show();
+ },
+ parseTemplate: function(template) {
+ if(!template) {
+ return false;
+ }
+
+ var childs = template.childNodes;
+ for(var i=0; i<childs.length; i++) {
+ if(childs[i].tagName && childs[i].tagName.toLowerCase() == "div") {
+ this.container = $(childs[i]);
+ break;
+ }
+ }
+
+ var normal = null, frozen = null;
+ var childs = this.container.childNodes;
+ for(var i=0; i<childs.length; i++) {
+ if(childs[i].id && childs[i].id.indexOf("FrozenBox")>=0) {
+ frozen = childs[i];
+ }
+ else if(childs[i].id && childs[i].id.indexOf("NormalBox")>=0){
+ normal = childs[i];
+ }
+ }
+
+ if(!normal || !frozen) {
+ errMsg = "Unable to parse template for GridHeader. Unable to find FrozenBox or NormalBox.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+ this.contentBox = new ClientUI.common.box.Box(normal);
+ this.contentBox.makeAbsolute();
+ this.frozenContentBox = new ClientUI.common.box.Box(frozen);
+ this.frozenContentBox.makeAbsolute();
+
+ // create row template
+ var ch = this.contentBox.getElement().firstChild;
+ while(ch) {
+ if(ch.tagName && ch.tagName.toLowerCase()=="table") {
+ this.headerRow = new ClientUI.common.box.Box($(ch), null, true);
+ break;
+ }
+ ch = ch.nextSibling;
+ }
+ ch = this.frozenContentBox.getElement().firstChild;
+ while(ch) {
+ if(ch.tagName && ch.tagName.toLowerCase()=="table") {
+ this.headerFrozenRow = new ClientUI.common.box.Box($(ch), null, true);
+ break;
+ }
+ ch = ch.nextSibling;
+ }
+
+ this.helpObj = new ClientUI.common.box.Box(this.frozenContentBox.getElement(), null, true);
+
+ var columns = [];
+ var defaultWidth = 0;
+ var defaultHeight = 0;
+
+ var eventCellMouseDown = this.eventCellMouseDown.bind(this);
+
+ // Get columns information
+ var i = 0, h;
+ var cells = $A(this.headerFrozenRow.getElement().rows[0].cells);
+ cells.each(function(cell) {
+ columns[i] = {
+ width: Element.getWidth(cell),
+ innerHTML: cell.innerHTML,
+ styleClass: cell.className,
+ id: cell.id,
+ align: cell.align,
+ valign: cell.vAlign,
+ title: cell.title,
+ minWidth: 10,
+ frozen: true,
+ fixedWidth: Validators.getBoolean(cell.getAttribute("fixedWidth"), false),
+ sortable: Validators.getBoolean(cell.getAttribute("sortable"), false),
+ sorted: Validators.getBoolean(cell.getAttribute("sorted"), "desc")
+ };
+
+ if(columns[i].sortable)
+ Event.observe(cell, 'click', eventCellMouseDown);
+ h = Element.getHeight(cell);
+ if(h > defaultHeight) defaultHeight = h;
+ defaultWidth += columns[i].width;
+ columns[i].object = new ClientUI.common.box.InlineBox(cell, null, true);
+ columns[i].sortDesc = document.getElementsByClassName("sort-desc", cell)[0];
+ columns[i].sortAsc = document.getElementsByClassName("sort-asc", cell)[0];
+ if(ClientUILib.isIE && columns[i].sortDesc) {
+ Element.setStyle(columns[i].sortDesc, {left: "-10px"});
+ Element.setStyle(columns[i].sortAsc, {left: "-10px"});
+ }
+ i++;
+ });
+
+ cells = $A(this.headerRow.getElement().rows[0].cells);
+ cells.each(function(cell) {
+ columns[i] = {
+ width: Element.getWidth(cell),
+ innerHTML: cell.innerHTML,
+ styleClass: cell.className,
+ id: cell.id,
+ align: cell.align,
+ valign: cell.vAlign,
+ title: cell.title,
+ minWidth: 10,
+ frozen: false,
+ fixedWidth: Validators.getBoolean(cell.getAttribute("fixedWidth"), false),
+ sortable: Validators.getBoolean(cell.getAttribute("sortable"), false),
+ sorted: Validators.getBoolean(cell.getAttribute("sorted"), "desc")
+ };
+
+ if(columns[i].sortable)
+ Event.observe(cell, 'click', eventCellMouseDown);
+ h = Element.getHeight(cell);
+ if(h > defaultHeight) defaultHeight = h;
+ defaultWidth += columns[i].width;
+ columns[i].object = new ClientUI.common.box.InlineBox(cell, null, true);
+ columns[i].sortDesc = document.getElementsByClassName("sort-desc", cell)[0];
+ columns[i].sortAsc = document.getElementsByClassName("sort-asc", cell)[0];
+ if(ClientUILib.isIE && columns[i].sortDesc) {
+ Element.setStyle(columns[i].sortDesc, {left: "-10px"});
+ Element.setStyle(columns[i].sortAsc, {left: "-10px"});
+ }
+ i++;
+ });
+
+ columns.pop(); // remove last fake column
+ this._columns = columns;
+ this.defaultHeight = defaultHeight;
+ this.defaultWidth = defaultWidth;
+ if(ClientUILib.isGecko) {
+ this.defaultWidth -= this.getBorderWidth("lr") + this.getPadding("lr");
+ this.defaultHeight -= this.getBorderWidth("tb") + this.getPadding("tb");
+ }
+
+ var sep, column;
+ var seps = document.getElementsByClassName("ClientUI_Grid_HSep", this.getElement());
+ for(i = 0; i<seps.length; i++) {
+ sep = seps[i];
+ column = parseInt(sep.getAttribute("column"));
+ this._columns[column].sep = new ClientUI.common.box.InlineBox(sep, null, true);
+ sep.columnIndex = column;
+ if(!this._columns[column].fixedWidth) {
+ Event.observe(sep, 'dblclick', this.eventSepDblClick);
+ Event.observe(sep, 'mousedown', this.eventSepMouseDown);
+ }
+ else {
+ sep.setStyle({cursor: 'auto'});
+ }
+ }
+ this.agjustSeparators();
+
+ if(ClientUILib.isIE) {
+ this.frozenSubstrate = new ClientUI.common.box.Substrate(null, this.getElement());
+ this.frozenSubstrate.getElement().name = this.getElement().id + "HRFrm";
+ Element.addClassName(this.frozenSubstrate.getElement(), "ClientUI_HRFrm");
+ this.frozenSubstrate.setHeight(this.headerRow.getViewportHeight());
+ }
+
+ return true;
+ },
+ agjustSeparators: function() {
+ var offset = 0;
+ var fcnt = this.headerFrozenRow.getElement().rows[0].cells.length;
+ for(var i=0; i<this._columns.length; i++) {
+ if(i == fcnt) offset = 0;
+ offset += this._columns[i].width;
+ this._columns[i].sep.moveToX(offset - 4);
+ }
+ },
+ updateLayout: function() {
+ if(!this.controlCreated || !this.grid.controlCreated) {
+ return;
+ }
+ ClientUI.controls.grid.GridHeader.parentClass.method("updateLayout").call(this);
+ var height = this.getViewportHeight();
+ var totalWidth = this.grid.getColumnsTotalWidth();
+ var frozenContentWidth = this.grid.getColumnsFrozenWidth();
+
+ this.contentBox.setWidth(Math.max(this.getWidth(), totalWidth));
+ this.contentBox.setHeight(height);
+ this.contentBox.moveTo(frozenContentWidth, 0);
+ this.frozenContentBox.setWidth(frozenContentWidth);
+ this.frozenContentBox.setHeight(height);
+ this.frozenContentBox.moveTo(0, 0);
+ if(ClientUILib.isIE)
+ this.frozenSubstrate.setWidth(frozenContentWidth);
+ },
+ getColumns: function() {
+ return this._columns;
+ },
+ // lets implement column resizer
+ OnSepMouseDown: function(event) {
+ this.dragColumnInfo = {
+ srcElement: Event.element(event),
+ dragStarted: false,
+ mouseDown: true,
+ startX: Event.pointerX(event),
+ originalX: 0
+ };
+ this.dragColumnInfo.object = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].object;
+ this.dragColumnInfo.sep = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].sep;
+ this.dragColumnInfo.minWidth = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].minWidth;
+
+ Event.stop(event);
+ },
+ OnSepMouseUp: function(event) {
+ if(this.dragColumnInfo && this.dragColumnInfo.dragStarted) {
+ this.dragColumnInfo.dragStarted = false;
+ this.dragColumnInfo.mouseDown = false;
+ var delta = Event.pointerX(event) - this.dragColumnInfo.startX;
+ var newWidth = this.dragColumnInfo.object.getWidth() + delta;
+ setTimeout(function() {
+ this.grid.adjustColumnWidth(this.dragColumnInfo.srcElement.columnIndex, newWidth);
+ }.bind(this), 10);
+ }
+ this._hideSplitter();
+ },
+ OnSepMouseMove: function(event) {
+ if(this.dragColumnInfo && this.dragColumnInfo.mouseDown) {
+ if(!this.dragColumnInfo.dragStarted) {
+ this.dragColumnInfo.dragStarted = true;
+ this._showSplitter(this.dragColumnInfo.srcElement.columnIndex);
+ }
+ else {
+ var delta = Event.pointerX(event) - this.dragColumnInfo.startX;
+ var minColumnWidth = this.dragColumnInfo.object.getWidth() - this.dragColumnInfo.minWidth;
+ if(delta >= -minColumnWidth) {
+ var x = this.dragColumnInfo.originalX + delta;
+ this.columnSplitter.moveToX(x - 6);
+ }
+ }
+ Event.stop(event);
+ }
+ },
+ OnSepDblClick: function(event) {
+ ClientUILib.log(ClientUILogger.INFO, "OnSepDblClick");
+ },
+ _showSplitter: function(index) {
+ if(!this.columnSplitter) {
+ this._createSplitter();
+ }
+
+ var pos = this.dragColumnInfo.sep.getX();
+ if(!this.getColumns()[index].frozen) {
+ pos += this.grid.getColumnsFrozenWidth() - this.grid.getScrollOffset();
+ }
+ this.dragColumnInfo.originalX = pos;
+ this.columnSplitter.show();
+ this.columnSplitter.setHeight(this.defaultHeight + this.grid.getBody().contentBox.getHeight());
+ this.columnSplitter.moveTo(pos, 0);
+ },
+ _hideSplitter: function() {
+ if(this.columnSplitter) {
+ this.columnSplitter.hide();
+ }
+ },
+ _createSplitter: function() {
+ this.columnSplitter = new ClientUI.common.box.Box(null, this.grid.getElement());
+ this.columnSplitter.makeAbsolute();
+ this.columnSplitter.getElement().addClassName("ClientUI_Grid_HSplit");
+ this.columnSplitter.setWidth(10);
+ this.columnSplitter.getElement().setStyle({backgroundColor: ''});
+ this.columnSplitter.getElement().setStyle({zIndex: '100'});
+ this.columnSplitter.hide();
+ },
+ adjustScrollPosition: function(pos) {
+ this.contentBox.moveToX(this.grid.getColumnsFrozenWidth()-pos);
+ },
+ OnCellMouseDown: function(event) {
+ var el = Event.element(event);
+ while(el && !Element.hasClassName(el, "ClientUI_Grid_HC")) {
+ el = el.parentNode;
+ }
+
+ if(el) {
+ var index = parseInt(el.getAttribute("columnIndex"));
+ if(index>=0) {
+ var dir = this.getColumns()[index].sorted;
+ dir = (dir == "asc") ? "desc" : "asc";
+ this.getColumns()[index].sorted = dir;
+
+ for(var i = 0, len = this.getColumns().length; i < len; i++) {
+ var h = this.getColumns()[i];
+ if(i != index) {
+ Element.setStyle(h.sortDesc, {display: 'none'});
+ Element.setStyle(h.sortAsc, {display: 'none'});
+ } else{
+ Element.setStyle(h.sortDesc, {display: (dir == 'desc' ? 'block' : 'none')});
+ Element.setStyle(h.sortAsc, {display: (dir == 'asc' ? 'block' : 'none')});
+ }
+ }
+
+ this.grid.eventOnSort.fire({
+ column: index,
+ order: dir,
+ startRow: this.grid.getBody()._getRowIndex(this.grid.getBody().templFrozen.getElement().rows[0].id),
+ index: this.grid.getBody().currRange.start
+ });
+ Event.stop(event);
+ }
+ }
+ },
+ _getVisibleHeaderControls: function() {
+ var controls = [];
+ var columns = this.getColumns();
+ columns.each(function(column){
+ var ctrls = column.object.getElement().getElementsByTagName("select");
+ if(ctrls && ctrls.length>0) {
+ ctrls = $A(ctrls);
+ ctrls.each(function(ctrl){
+ if(Element.visible(ctrl)) {
+ controls.push(ctrl);
+ }
+ });
+ }
+ });
+ return controls;
+ },
+ adjustColumnWidth: function(column, width) {
+ var w = width, ch;
+ var frozenColumns = this.headerFrozenRow.getElement().rows[0].cells.length;
+ var realColumn = column;
+ var table = null;
+ if(column < frozenColumns) {
+ table = this.headerFrozenRow.getElement();
+ }
+ else {
+ table = this.headerRow.getElement();
+ realColumn -= frozenColumns;
+ }
+
+ // Hide controls in IE that flipped in other case
+ var ctrlsIE = [];
+ if(ClientUILib.isIE) {
+ ctrlsIE = this._getVisibleHeaderControls();
+ ctrlsIE.each(function(ctrl){
+ Element.hide(ctrl);
+ });
+ }
+
+ var childs = table.rows[0].cells[realColumn].childNodes;
+ this.helpObj.element = $(table.rows[0].cells[realColumn]);
+ var delta = 0;
+ if(ClientUILib.isGecko) {
+ delta = this.helpObj.getBorderWidth("lr") + this.helpObj.getPadding("lr");
+ }
+ this.helpObj.setWidth(width - delta);
+ delta *= 2;
+
+ for (var j=0; j<childs.length; j++) {
+ ch = childs[j];
+ if(ch.tagName && ch.tagName.toLowerCase() == "span") {
+ this.helpObj.element = $(ch);
+ this.helpObj.setWidth(width - delta);
+ break;
+ }
+ }
+
+ if(ClientUILib.isIE) {
+ ctrlsIE.each(function(ctrl){
+ Element.show(ctrl);
+ });
+ }
+
+ this._columns[column].width = width;
+ this.agjustSeparators();
+ }
+});
17 years, 7 months
JBoss Rich Faces SVN: r962 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-31 13:21:16 -0400 (Thu, 31 May 2007)
New Revision: 962
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-05-31 17:20:44 UTC (rev 961)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/AjaxFunctionBuilder.java 2007-05-31 17:21:16 UTC (rev 962)
@@ -14,8 +14,6 @@
public class AjaxFunctionBuilder {
-// public static final String DATA_READY = ;
-
private static final JSReference request = new JSReference("request");
private static final JSReference event = new JSReference("event");
private static final JSReference data = new JSReference("data");
@@ -32,6 +30,7 @@
public static JSFunctionDefinition getOnDataReady(FacesContext context, UIScrollableGrid grid, RendererBase renderer) {
ScrollableGridBaseRenderer sr = (ScrollableGridBaseRenderer)renderer;
+
JSFunction function = createFunction(sr.getJavaScriptVarName(context, grid) + ".onCompleteGridInvalidation");
// JSFunction function = createFunction(sr.getJavaScriptVarName(context, grid) + ".getModel().fireEvent");
JSFunctionDefinition functionDefinition = new JSFunctionDefinition();
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-05-31 17:20:44 UTC (rev 961)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-05-31 17:21:16 UTC (rev 962)
@@ -17,7 +17,7 @@
* @author Anton Belevich
*
*/
-public class ColumnWalker {
+public class ColumnWalker{
static int iterateOverColumns(FacesContext context, UIComponent component, ColumnVisitor visitor,
ResponseWriter writer, GridRendererState state) throws IOException{
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-05-31 17:20:44 UTC (rev 961)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-05-31 17:21:16 UTC (rev 962)
@@ -4,6 +4,7 @@
package org.richfaces.renderkit.html;
import java.io.Serializable;
+import java.util.Collection;
import java.util.Map;
import javax.faces.FacesException;
@@ -34,6 +35,8 @@
private int _columns = 0;
+ private Collection collection;
+
private Integer sepOffset;
private int _loadedRowsCount;
@@ -371,5 +374,13 @@
public void setSepOffset(Integer sepOffset) {
this.sepOffset = sepOffset;
+ }
+
+ public Collection getCollection() {
+ return collection;
+ }
+
+ public void setCollection(Collection collection) {
+ this.collection = collection;
}
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-31 17:20:44 UTC (rev 961)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-31 17:21:16 UTC (rev 962)
@@ -1,6 +1,8 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.Map;
import javax.faces.component.UIComponent;
@@ -37,10 +39,6 @@
private final String HEADER_PART = "header";
- private final String SPLASH_FACET = "splash";
-
- private final String CELL_ID_PREFFIX ="bc_";
-
private final String COLUMN_FROZEN_TYPE = "frozen";
private final String COLUMN_NORMAL_TYPE = "normal";
@@ -165,10 +163,17 @@
grid.setRowKey(rowIndex);
if(grid.isRowAvailable()){
+ String row_id;
int index = ((Integer)rowIndex).intValue();
state.setRowIndex(index);
- String row_id = "row_" + index;
+
+ if(state.isFrozenPart()){
+ row_id = "f:row_" + index;
+ }else{
+ row_id = "n:row_" + index;
+ }
+
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HTML.TR_ELEMENT, grid);
state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
@@ -185,43 +190,78 @@
}
};
- private final ColumnVisitor ajaxCellRenderer = new ExtendedColumnVisitor(){
-
- public int visit(FacesContext context, UIScrollableGridColumn column, ResponseWriter writer, GridRendererState state) throws IOException {
- int i = state.getFrozenColumnCount();
- state.setFrozenColumnCount(i-1);
- renderContent(context, column, writer,state);
-
- return 1;
- }
-
- public void renderContent(FacesContext context, UIScrollableGridColumn column, ResponseWriter writer, GridRendererState state) throws IOException {
- writer.startElement(HTML.SPAN_ELEM, column);
-
- String cell_id = state.getClientId() + ":" + CELL_ID_PREFFIX + state.getRowIndex()+ "_" + state.getCellIndex();
- getUtils().writeAttribute(writer, "id",cell_id);
- getUtils().writeAttribute(writer, "class", "ClientUI_Grid_BCBody");
- System.out.println("cell index: " + cell_id);
- renderChildren(context, column);
- writer.endElement(HTML.SPAN_ELEM);
- AjaxContext ajaxContext = state.getAjaxContext();
- ajaxContext.addRenderedArea(cell_id);
- }
-
- };
-
private final DataVisitor ajaxRowsRenderer = new DataVisitor(){
public void process(FacesContext context, Object rowKey, Object argument) throws IOException {
+
+ GridRendererState state = (GridRendererState)argument;
- GridRendererState state = (GridRendererState)argument;
+ AjaxContext ajaxContext = state.getAjaxContext();
+ ajaxContext.getResponseData();
+
UIScrollableGrid grid = state.getGrid();
+ Collection collection = grid.getResponseData();
grid.setRowKey(rowKey);
ResponseWriter writer = context.getResponseWriter();
state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
+
+ String row_id = null;
+
+ int columnsCount = 0;
+
+ boolean frozenTRRendered = false;
+
+ boolean normalTRRendered = false;
+
System.out.println("row index: " + grid.getRowIndex());
- ColumnWalker.iterateOverColumns(context, grid, ajaxCellRenderer, writer, state);
- state.nextRow();
+
+ for (Iterator iter = grid.getChildren().iterator(); iter.hasNext(); ) {
+ UIComponent kid = (UIComponent) iter.next();
+
+ if (kid.isRendered()) {
+
+ if (kid instanceof UIScrollableGridColumn){
+
+ if(state.isFrozenColumn() && !frozenTRRendered){
+
+ state.setFrozenPart(true);
+ frozenTRRendered = true;
+ row_id = "f:row_" + state.getRowIndex();
+ writer.startElement("tr", grid);
+ getUtils().writeAttribute(writer,"id",row_id);
+ getUtils().writeAttribute(writer,"class", "ClientUI_Grid_BR");
+ collection.add(row_id);
+
+ }else if(!state.isFrozenColumn() && !normalTRRendered){
+
+ if(frozenTRRendered){
+ writer.endElement("tr");
+ }
+
+ state.setFrozenPart(false);
+ row_id = "n:row_" + state.getRowIndex();
+
+ writer.startElement("tr", grid);
+ getUtils().writeAttribute(writer,"id",row_id);
+ getUtils().writeAttribute(writer,"class", "ClientUI_Grid_BR");
+ normalTRRendered = true;
+ collection.add(row_id);
+
+ }
+
+ UIScrollableGridColumn column = (UIScrollableGridColumn)kid;
+ columnsCount += cellRenderer.visit(context, column, writer, state);
+ state.nextCell();
+
+ }
+
+ }
+
+ }
+
+ writer.endElement("tr");
+ state.setCellIndex(0);
+ state.nextRow();
}
};
@@ -342,6 +382,7 @@
options.put("parameters", parametersMap);
JSFunction function = AjaxRendererUtils.buildAjaxFunction(grid, context);
+ options.put("oncomplete", AjaxFunctionBuilder.getOnDataReady(context, grid, this));
function.addParameter(options);
String completeFunction = function.toScript() + "; return false;";
@@ -374,15 +415,16 @@
if(!sortOrder.equals("asc")){
asc = false;
}
+ UIScrollableGridColumn column = (UIScrollableGridColumn)grid.getChildren().get(sortColumn);
+ if(column.isSortable()){
+ grid.setDataIndex(new Integer(sortDataIndex));
+ grid.setStartRow(new Integer(sortStartRow));
+ grid.setRequestedRows(new Integer(grid.getRows()));
+ sorted = true;
- grid.setDataIndex(new Integer(sortDataIndex));
- grid.setStartRow(new Integer(sortStartRow));
- grid.setRequestedRows(new Integer(grid.getRows()));
- sorted = true;
-
- SortEvent sortEvent = new SortEvent(grid,sortColumn, sortStartRow, sortDataIndex, asc );
- grid.queueEvent(sortEvent);
-
+ SortEvent sortEvent = new SortEvent(grid,sortColumn, sortStartRow, sortDataIndex, asc );
+ grid.queueEvent(sortEvent);
+ }
}
if(parameters.containsKey(clientId + "_state_input") && !sorted){
@@ -441,8 +483,14 @@
System.out.println("");
System.out.println("ScrollableGridBaseRenderer.renderAjaxChildren()");
System.out.println("");
-
+ grid.getResponseData().clear();
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement("table", grid);
+ writer.startElement("tbody", grid);
grid.walk(context, ajaxRowsRenderer, state);
+ writer.endElement("tbody");
+ writer.endElement("table");
+ ajaxContext.setResponseData(grid.getResponseData());
ajaxContext.getAjaxRenderedAreas().remove(grid.getClientId(context));
grid.setRows(old);
}
17 years, 7 months
JBoss Rich Faces SVN: r961 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-31 13:20:44 -0400 (Thu, 31 May 2007)
New Revision: 961
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-05-31 13:37:13 UTC (rev 960)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-05-31 17:20:44 UTC (rev 961)
@@ -51,8 +51,18 @@
private ScrollableGridVisualModel visualModel;
+ private Collection responseData = new ArrayList();
+
+ public Collection getResponseData() {
+ return responseData;
+ }
+
+ public void setResponseData(Collection responseData) {
+ this.responseData = responseData;
+ }
+
protected DataComponentState createComponentState() {
return new DataComponentState(){
@@ -172,11 +182,12 @@
public Object saveState(FacesContext context) {
- Object values[] = new Object[4];
+ Object values[] = new Object[5];
values[0] = super.saveState(context);
values[1] = _requestedRows;
values[2] = _startRow;
values[3] = _dataIndex;
+ values[4] = responseData;
return (Object)values;
@@ -189,6 +200,7 @@
_requestedRows = (Integer)values[1];
_startRow = (Integer)values[2];
_dataIndex = (Integer)values[3];
+ responseData = (Collection)values[4];
}
17 years, 7 months
JBoss Rich Faces SVN: r960 - trunk/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-31 09:37:13 -0400 (Thu, 31 May 2007)
New Revision: 960
Modified:
trunk/richfaces/pom.xml
Log:
Modified: trunk/richfaces/pom.xml
===================================================================
--- trunk/richfaces/pom.xml 2007-05-31 13:28:01 UTC (rev 959)
+++ trunk/richfaces/pom.xml 2007-05-31 13:37:13 UTC (rev 960)
@@ -147,7 +147,6 @@
<module>datascroller</module>
<module>menu-components</module>
<module>dropdown-menu</module>
- <!--module>panelmenu</module-->
</modules>
<repositories>
<repository>
17 years, 7 months
JBoss Rich Faces SVN: r959 - trunk/sandbox.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-31 09:28:01 -0400 (Thu, 31 May 2007)
New Revision: 959
Modified:
trunk/sandbox/pom.xml
Log:
Modified: trunk/sandbox/pom.xml
===================================================================
--- trunk/sandbox/pom.xml 2007-05-31 13:24:16 UTC (rev 958)
+++ trunk/sandbox/pom.xml 2007-05-31 13:28:01 UTC (rev 959)
@@ -253,5 +253,6 @@
<module>scrollable-grid</module>
<module>panel2</module>
<module>simpleTogglePanel2</module>
+ <module>panelmenu</module>
</modules>
</project>
\ No newline at end of file
17 years, 7 months
JBoss Rich Faces SVN: r958 - trunk/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-31 09:24:16 -0400 (Thu, 31 May 2007)
New Revision: 958
Modified:
trunk/richfaces/pom.xml
Log:
Modified: trunk/richfaces/pom.xml
===================================================================
--- trunk/richfaces/pom.xml 2007-05-31 13:23:48 UTC (rev 957)
+++ trunk/richfaces/pom.xml 2007-05-31 13:24:16 UTC (rev 958)
@@ -147,7 +147,7 @@
<module>datascroller</module>
<module>menu-components</module>
<module>dropdown-menu</module>
- <module>panelmenu</module>
+ <!--module>panelmenu</module-->
</modules>
<repositories>
<repository>
17 years, 7 months