[richfaces-svn-commits] JBoss Rich Faces SVN: r2214 - in trunk: samples/tree-demo/src/main/webapp/pages and 1 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Sun Aug 12 19:41:51 EDT 2007
Author: nbelaevski
Date: 2007-08-12 19:41:51 -0400 (Sun, 12 Aug 2007)
New Revision: 2214
Modified:
trunk/samples/tree-demo/src/main/java/org/richfaces/Library.java
trunk/samples/tree-demo/src/main/webapp/pages/index2.jsp
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js
Log:
Tree:
- extra $(..) functions invocations removed, changed to nextSibling & rows[..].cells[..]
Performance comparison for id vs index seeking in cells collection:
by id:
FF IE
3912 12302
3899 11801
3923 12050
by index:
FF IE
3939 11863
3919 11874
4075 11952
- demo: added performance timer & changed number of nodes to 50x50
Modified: trunk/samples/tree-demo/src/main/java/org/richfaces/Library.java
===================================================================
--- trunk/samples/tree-demo/src/main/java/org/richfaces/Library.java 2007-08-12 02:20:40 UTC (rev 2213)
+++ trunk/samples/tree-demo/src/main/java/org/richfaces/Library.java 2007-08-12 23:41:51 UTC (rev 2214)
@@ -96,9 +96,9 @@
private void initData() {
pathways = new HashMap();
- for (int i = 0; i < 15; i++) {
+ for (int i = 0; i < 50; i++) {
Pathway path = getPathwayByName("PATH_" + i, this);
- for (int j = 0; j < 20; j++) {
+ for (int j = 0; j < 50; j++) {
Organism org = new Organism(getNextId());
org.setName("ORG_" + i + "." + j);
path.addOrganism(org);
Modified: trunk/samples/tree-demo/src/main/webapp/pages/index2.jsp
===================================================================
--- trunk/samples/tree-demo/src/main/webapp/pages/index2.jsp 2007-08-12 02:20:40 UTC (rev 2213)
+++ trunk/samples/tree-demo/src/main/webapp/pages/index2.jsp 2007-08-12 23:41:51 UTC (rev 2214)
@@ -13,6 +13,13 @@
<h:form>
+ <f:verbatim>
+ <script>
+ window.time = new Date();
+ </script>
+ </f:verbatim>
+
+
<rich:tree switchType="client" style="width:300px"
value="#{pathwayBean.pathwayTree}" var="item"
nodeFace="#{item.type}">
@@ -27,6 +34,13 @@
</rich:treeNode>
</rich:tree>
+ <f:verbatim>
+ <script>
+ alert(new Date() - window.time);
+ </script>
+ </f:verbatim>
+
+
</h:form>
<a4j:log hotkey="O"/>
Modified: trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
===================================================================
--- trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js 2007-08-12 02:20:40 UTC (rev 2213)
+++ trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js 2007-08-12 23:41:51 UTC (rev 2214)
@@ -2,11 +2,21 @@
Tree.Item.prototype = {
initialize: function(id, tree, parent) {
this.parent = parent;
- this.id = id;
this.tree = tree;
this.elements = {};
this.elementID = {};
- ($(this.id)).object = this;
+
+ var element;
+
+ if (typeof id == 'string') {
+ element = $(id);
+ this.id = id;
+ } else {
+ element = id;
+ this.id = element.id;
+ }
+
+ element.object = this;
this.elementID.children = this.id + Tree.ID_DEVIDER + Tree.ID_CHILDS_ROW;
this.elementID.mainRow = this.id + Tree.ID_DEVIDER + Tree.ID_MAIN_ROW;
@@ -16,7 +26,7 @@
this.elementID.icon = this.id + Tree.ID_DEVIDER + Tree.ID_ICON;
this.elementID.text = this.id + Tree.ID_DEVIDER + Tree.ID_TEXT;
- this.getElements();
+ this.getElements(element);
this.eventSelectionClick = this.toggleSelection.bindAsEventListener(this);
this.eventMouseOut = this.processMouseOut.bindAsEventListener(this);
@@ -26,7 +36,7 @@
this.eventRightClick = this.onContextMenu.bindAsEventListener();
}
- this.observeEvents();
+ this.observeEvents(element);
},
destroy: function() {
@@ -41,9 +51,11 @@
this.childs = null;
},
- observeEvents: function() {
- var eIcon = $(this.elementID.icon);
- var eText = $(this.elementID.text);
+ observeEvents: function(element) {
+ var cells = element.rows[0].cells;
+ //seeking by id seems to be miserably slow in IE than by index
+ var eIcon = cells[this.elementID.icon];
+ var eText = cells[this.elementID.text];
if (eIcon) {
Event.observe(eIcon, "mousedown", this.eventSelectionClick);
Event.observe(eIcon, "mouseout", this.eventMouseOut);
@@ -70,22 +82,22 @@
}
},
- getElements: function() {
+ getElements: function(element) {
this.childs = [];
- var contextMenu = Richfaces.getNSAttribute("oncontextmenu", $(this.elementID.icon));
+ /*var contextMenu = Richfaces.getNSAttribute("oncontextmenu", $(this.elementID.icon));
if (contextMenu && contextMenu.length > 0) {
this.onContextMenu = new Function(contextMenu + "; return true;");
- }
+ }*/
- var childsTd = $(this.elementID.children);
+ var childsTd = element.nextSibling;//$(this.elementID.children);
if (childsTd) {
var child = childsTd.firstChild;
while ( child != null )
{
if (child.nodeType == 1 && child.tagName.toLowerCase() == "table") {
- this.addChild(new Tree.Item(child.id, this.tree, this));
+ this.addChild(new Tree.Item(child, this.tree, this));
}
child = child.nextSibling;
}
Modified: trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js
===================================================================
--- trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js 2007-08-12 02:20:40 UTC (rev 2213)
+++ trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js 2007-08-12 23:41:51 UTC (rev 2214)
@@ -111,7 +111,7 @@
if (this.elements.contentTd) {
for(var child = this.elements.contentTd.firstChild; child != null; child = child.nextSibling ) {
if (child.nodeType == 1 && child.tagName.toLowerCase() == "table") {
- this.addChild(new Tree.Item(child.id, this, this));
+ this.addChild(new Tree.Item(child, this, this));
}
}
/*
More information about the richfaces-svn-commits
mailing list