Author: konstantin.mishin
Date: 2009-11-18 14:08:09 -0500 (Wed, 18 Nov 2009)
New Revision: 15924
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
Log:
RF-7865
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
===================================================================
---
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2009-11-18
16:53:20 UTC (rev 15923)
+++
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2009-11-18
19:08:09 UTC (rev 15924)
@@ -26,7 +26,7 @@
for (var j = 0; !rule && j < sheets.length; j++) {
var rules = sheets[j].cssRules ? sheets[j].cssRules: sheets[j].rules;
for (var i = 0; !rule && i < rules.length; i++) {
- if (rules[i].selectorText.toLowerCase() == (className.toLowerCase())) {
+ if (rules[i].selectorText && rules[i].selectorText.toLowerCase() ==
className.toLowerCase()) {
rule = rules[i];
}
}
@@ -35,40 +35,49 @@
};
richfaces.ExtendedDataTable = function(id) {
- this.id = id;
- this.element = document.getElementById(id);
- this.bodyElement = document.getElementById(id + ":b");
- this.contentElement = document.getElementById(id + ":c");
- this.marginElement = this.contentElement.firstChild;//TODO this.marginElement =
Richfaces.firstDescendant(this.contentElement);
- this.dataTableElement = this.contentElement.lastChild;//TODO this.dataTableElement =
Richfaces.lastDescendant(this.contentElement);
- this.frozenHeaderPartElement = document.getElementById(id + ":fhpe");
+ var element = document.getElementById(id);
+ var bodyElement = document.getElementById(id + ":b");
+ var contentElement = document.getElementById(id + ":c");
+ var marginElement = contentElement.firstChild;//TODO this.marginElement =
Richfaces.firstDescendant(this.contentElement);
+ var dataTableElement = contentElement.lastChild;//TODO this.dataTableElement =
Richfaces.lastDescendant(this.contentElement);
+ var frozenHeaderPartElement = document.getElementById(id + ":fhpe");
- this.normalPartStyle =
richfaces.getCSSRule(".rich-extable-part-width").style;
- this.idSuffixs = [":nhpe", ":nbpe", ":nfpe"];
+ var normalPartStyle =
richfaces.getCSSRule(".rich-extable-part-width").style;
+ var idSuffixs = [":nhpe", ":nbpe", ":nfpe"];
- this.scrollElement = document.getElementById(this.id + this.idSuffixs[2]);
+ var scrollElement = document.getElementById(id + idSuffixs[2]);
- this.rows = document.getElementById(id + ":nbte").rows.length;
+ var rows = document.getElementById(id + ":nbte").rows.length;
- this.updateLayout = function() {
- var offsetWidth = this.frozenHeaderPartElement ?
this.frozenHeaderPartElement.offsetWidth : 0;
- this.normalPartStyle.width = this.element.clientWidth - offsetWidth + "px";
- var height = this.element.clientHeight;
- var element = this.element.firstChild;
- while (element) {
- if(element.nodeName.toUpperCase() == "DIV" && element !=
this.bodyElement) {
- height -= element.offsetHeight;
+ var updateLayout = function() {
+ var offsetWidth = frozenHeaderPartElement ? frozenHeaderPartElement.offsetWidth : 0;
+ normalPartStyle.width = element.clientWidth - offsetWidth + "px";
+ var height = element.clientHeight;
+ var el = element.firstChild;
+ while (el) {
+ if(el.nodeName.toUpperCase() == "DIV" && el != bodyElement) {
+ height -= el.offsetHeight;
}
- element = element.nextSibling;
+ el = el.nextSibling;
}
- this.bodyElement.style.height = height + "px";
+ bodyElement.style.height = height + "px";
};
+
+ var initializeLayout = function() {
+ //TODO contentElement.style.height = (rowCount * dataTableElement.offsetHeight / rows)
+ "px";
+ updateLayout();
+ };
+
+ var updateScrollPosition = function() {
+ var scrollLeft = scrollElement.scrollLeft;
+ for (var i = 0; i < idSuffixs.length; i++) {
+ document.getElementById(id + idSuffixs[i]).scrollLeft = scrollLeft;//TODO Not use
getElementById here
+ }
+ };
- var table = this;
- jQuery(document).ready(function(){
- table.contentElement.style.height = (table.rowCount *
table.dataTableElement.offsetHeight / table.rows) + "px";
- table.updateLayout();
- });
+ jQuery(document).ready(initializeLayout);
+ jQuery(window).bind("resize", updateLayout);
+ jQuery(scrollElement).bind("scroll", updateScrollPosition);
};
}(window.RichFaces, jQuery));