Author: nbelaevski
Date: 2008-01-16 21:45:39 -0500 (Wed, 16 Jan 2008)
New Revision: 5443
Modified:
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js
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
trunk/ui/tree/src/main/templates/htmlTreeNode.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1850
Modified:
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js
===================================================================
---
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js 2008-01-17
02:44:42 UTC (rev 5442)
+++
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js 2008-01-17
02:45:39 UTC (rev 5443)
@@ -54,7 +54,7 @@
},
getDropzoneOptions: function() {
- var attr = Richfaces.getNSAttribute("dropzoneoptions", this.iconElement);
+ var attr = Richfaces.getNSAttribute("dropzoneoptions",
this.elements.iconElement);
if (attr) {
return attr.parseJSON(EventHandlersWalk);
}
@@ -108,7 +108,7 @@
return window.drag.treeDraggableOptions;
}
- var attr = Richfaces.getNSAttribute("draggableoptions", this.iconElement);
+ var attr = Richfaces.getNSAttribute("draggableoptions",
this.elements.iconElement);
if (attr) {
var opts = attr.parseJSON(EventHandlersWalk);
if (window.drag) {
@@ -131,6 +131,6 @@
getElement: function() {
//returns <tr> holding node without children
- return this.textElement.parentNode;
+ return this.elements.textElement.parentNode;
}
});
\ No newline at end of file
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 2008-01-17
02:44:42 UTC (rev 5442)
+++
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js 2008-01-17
02:45:39 UTC (rev 5443)
@@ -4,7 +4,6 @@
this.parent = parent;
this.tree = tree;
this.elements = {};
- this.elementID = {};
var element;
@@ -17,40 +16,61 @@
}
element.object = this;
+
+ var rows = element.rows;
+ this.elements.mainRow = rows[0];
+
+ var sibling = element.nextSibling;
+ var siblingId = this.id + Tree.ID_DEVIDER + Tree.ID_CHILDS_ROW;
+ while (sibling && sibling.id != siblingId) {
+ sibling = sibling.nextSibling
+ };
- this.elementID.children = this.id + Tree.ID_DEVIDER + Tree.ID_CHILDS_ROW;
- this.elementID.mainRow = this.id + Tree.ID_DEVIDER + Tree.ID_MAIN_ROW;
- this.elementID.handle = this.id + Tree.ID_DEVIDER + Tree.ID_HANDLE;
- this.elementID.handleImgExpanded = this.elementID.handle + Tree.ID_DEVIDER +
Tree.ID_HANDLE_IMG_EXPANDED;
- this.elementID.handleImgCollapsed = this.elementID.handle + Tree.ID_DEVIDER +
Tree.ID_HANDLE_IMG_COLLAPSED;
- this.elementID.icon = this.id + Tree.ID_DEVIDER + Tree.ID_ICON;
- this.elementID.text = this.id + Tree.ID_DEVIDER + Tree.ID_TEXT;
+ this.elements.childrenRow = sibling;
+ var handlesId = this.id + Tree.ID_DEVIDER + Tree.ID_HANDLES;
+ var iconId = this.id + Tree.ID_DEVIDER + Tree.ID_ICON;
+ var textId = this.id + Tree.ID_DEVIDER + Tree.ID_TEXT;
+
this.getElements(element, ajaxUpdate);
- var cells = element.rows[0].cells;
- var eIcon = null;
- var eText = null;
+ var handles = null;
+ var cells = this.elements.mainRow.cells;
if ("NETSCAPE" == RichFaces.navigatorType()) {
for (var i = 0; i < cells.length; i++) {
- if (cells[i].id == this.elementID.icon) {
- eIcon = cells[i];
- } else if (cells[i].id == this.elementID.text) {
- eText = cells[i];
+ if (cells[i].id == iconId) {
+ this.elements.iconElement = cells[i];
+ } else if (cells[i].id == textId) {
+ this.elements.textElement = cells[i];
+ } else if (cells[i].id == handlesId) {
+ handles = cells[i];
}
- if (eIcon && eText) {
+ if (this.elements.iconElement && this.elements.textElement &&
handles) {
break;
}
}
} else {
- var cells = element.rows[0].cells;
//seeking by id seems to be miserably slow in IE than by index
- eIcon = cells[this.elementID.icon];
- eText = cells[this.elementID.text];
+ this.elements.iconElement = cells[iconId];
+ this.elements.textElement = cells[textId];
+ handles = cells[handlesId];
}
- this.iconElement = eIcon;
- this.textElement = eText;
+ var handleId = this.id + Tree.ID_DEVIDER + Tree.ID_HANDLE;
+ var handleImgExpandedId = handleId + Tree.ID_DEVIDER + Tree.ID_HANDLE_IMG_EXPANDED;
+ var handleImgCollapsedId = handleId + Tree.ID_DEVIDER + Tree.ID_HANDLE_IMG_COLLAPSED;
+
+ this.elements.handle = Element.firstDescendant(Element.firstDescendant(handles));
+ if (this.elements.handle.id == handleId) {
+ this.elements.handleImgCollapsed = this.elements.handle.firstDescendant();
+ this.elements.handleImgExpanded = this.elements.handleImgCollapsed.next();
+
+ if (this.elements.handleImgExpanded.id != handleImgExpandedId ||
+ this.elements.handleImgCollapsed.id != handleImgCollapsedId) {
+
+ throw "Script inconsistency detected! Please inform developers...";
+ }
+ }
this.eventSelectionClick = this.toggleSelection.bindAsEventListener(this);
this.eventMouseOut = this.processMouseOut.bindAsEventListener(this);
@@ -66,7 +86,7 @@
this.enableDropzoneCursors(dropOpts.acceptCursor, dropOpts.rejectCursor);
}
- this.observeEvents(eIcon, eText);
+ this.observeEvents();
},
destroy: function() {
@@ -79,37 +99,38 @@
}
this.childs = null;
+ this.elements = null;
},
- observeEvents: function(eIcon, eText) {
- if (eIcon) {
- var contextMenu = Richfaces.getNSAttribute("oncontextmenu", eIcon);
+ observeEvents: function() {
+ if (this.elements.iconElement) {
+ var contextMenu = Richfaces.getNSAttribute("oncontextmenu",
this.elements.iconElement);
if (contextMenu && contextMenu.length > 0) {
this.onContextMenu = new Function("event", contextMenu + "; return
true;").bindAsEventListener(this);
}
- Event.observe(eIcon, "mousedown", this.eventSelectionClick);
- Event.observe(eIcon, "mouseout", this.eventMouseOut);
- Event.observe(eIcon, "mouseover", this.eventMouseOver);
+ Event.observe(this.elements.iconElement, "mousedown",
this.eventSelectionClick);
+ Event.observe(this.elements.iconElement, "mouseout", this.eventMouseOut);
+ Event.observe(this.elements.iconElement, "mouseover", this.eventMouseOver);
if (this.onContextMenu) {
- eIcon.oncontextmenu = this.onContextMenu;
+ this.elements.iconElement.oncontextmenu = this.onContextMenu;
}
}
- if (eText)
+ if (this.elements.textElement)
{
- Event.observe(eText, "mousedown", this.eventSelectionClick);
- Event.observe(eText, "mouseout", this.eventMouseOut);
- Event.observe(eText, "mouseover", this.eventMouseOver);
+ Event.observe(this.elements.textElement, "mousedown",
this.eventSelectionClick);
+ Event.observe(this.elements.textElement, "mouseout", this.eventMouseOut);
+ Event.observe(this.elements.textElement, "mouseover", this.eventMouseOver);
if (this.onContextMenu) {
- eText.oncontextmenu = this.onContextMenu;
+ this.elements.textElement.oncontextmenu = this.onContextMenu;
}
}
if (this.tree.switchType=="client" && this.childs.length > 0) {
this.eventCollapsionClick = this.toggleCollapsion.bindAsEventListener(this);
- var handleElt = this.tree.toggleOnClick ? this.elementID.mainRow :
this.elementID.handle;
+ var handleElt = this.tree.toggleOnClick ? this.elements.mainRow :
this.elements.handle;
Event.observe(handleElt, "click", this.eventCollapsionClick);
}
},
@@ -117,7 +138,7 @@
getElements: function(element, ajaxUpdate) {
this.childs = [];
- var childsTd = element.nextSibling;//$(this.elementID.children);
+ var childsTd = element.nextSibling;
if (ajaxUpdate && this.tree.showConnectingLines) {
var cell = element.rows[0].cells[0];
@@ -180,7 +201,7 @@
if (this.hasChilds()) Element.toggle(row);
// Rerender main row to avoid bad representation in Opera and Konqueror/Safari
- var e = $(this.elementID.mainRow)
+ var e = this.elements.mainRow;
if (e) {
Element.hide(e);
Element.show(e);
@@ -188,11 +209,11 @@
var nodeStateInput = $(this.id + "NodeExpanded");
- var eIcon = $(this.elementID.icon);
+ var eIcon = this.elements.iconElement;
if (this.isCollapsed()) {
- Element.hide(this.elementID.handleImgExpanded);
- Element.show(this.elementID.handleImgCollapsed);
+ Element.hide(this.elements.handleImgExpanded);
+ Element.show(this.elements.handleImgCollapsed);
if( eIcon && Element.hasClassName(eIcon, Tree.CLASS_ITEM_EXPANDED)) {
Element.removeClassName(eIcon, Tree.CLASS_ITEM_EXPANDED);
Element.addClassName(eIcon, Tree.CLASS_ITEM_COLLAPSED);
@@ -204,8 +225,8 @@
this.fireCollapsionEvent();
} else {
- Element.show(this.elementID.handleImgExpanded);
- Element.hide(this.elementID.handleImgCollapsed);
+ Element.show(this.elements.handleImgExpanded);
+ Element.hide(this.elements.handleImgCollapsed);
if(eIcon && Element.hasClassName(eIcon, Tree.CLASS_ITEM_COLLAPSED)) {
Element.removeClassName(eIcon, Tree.CLASS_ITEM_COLLAPSED);
Element.addClassName(eIcon, Tree.CLASS_ITEM_EXPANDED);
@@ -221,22 +242,22 @@
},
getRichAttribute: function(name) {
- return Richfaces.getNSAttribute(name, $(this.elementID.icon));
+ return Richfaces.getNSAttribute(name, this.elements.iconElement);
},
collapse: function() {
if (!this.isCollapsed() && this.tree.switchType!="client") {
- var handleElt = $(this.tree.toggleOnClick ? this.elementID.mainRow :
this.elementID.handle);
+ var handleElt = $(this.tree.toggleOnClick ? this.elements.mainRow :
this.elements.handle);
if (handleElt) {
handleElt.onclick();
}
}
if (this.hasChilds() && !this.isCollapsed()) {
- Element.hide(this.elementID.children);
- Element.hide(this.elementID.handleImgExpanded);
- Element.show(this.elementID.handleImgCollapsed);
- var eIcon = $(this.elementID.icon);
+ Element.hide(this.elements.childrenRow);
+ Element.hide(this.elements.handleImgExpanded);
+ Element.show(this.elements.handleImgCollapsed);
+ var eIcon = this.elements.iconElement;
if(eIcon && Element.hasClassName(eIcon, Tree.CLASS_ITEM_EXPANDED)) {
Element.removeClassName(eIcon, Tree.CLASS_ITEM_EXPANDED);
Element.addClassName(eIcon, Tree.CLASS_ITEM_COLLAPSED);
@@ -248,17 +269,17 @@
expand: function() {
if (this.isCollapsed() && this.tree.switchType!="client") {
- var handleElt = $(this.tree.toggleOnClick ? this.elementID.mainRow :
this.elementID.handle);
+ var handleElt = $(this.tree.toggleOnClick ? this.elements.mainRow :
this.elements.handle);
if (handleElt) {
handleElt.onclick();
}
}
if (this.hasChilds() && this.isCollapsed()) {
- Element.show(this.elementID.children);
- Element.show(this.elementID.handleImgExpanded);
- Element.hide(this.elementID.handleImgCollapsed);
- var eIcon = $(this.elementID.icon);
+ Element.show(this.elements.childrenRow);
+ Element.show(this.elements.handleImgExpanded);
+ Element.hide(this.elements.handleImgCollapsed);
+ var eIcon = this.elements.iconElement;
if(eIcon && Element.hasClassName(eIcon, Tree.CLASS_ITEM_COLLAPSED)) {
Element.removeClassName(eIcon, Tree.CLASS_ITEM_COLLAPSED);
Element.addClassName(eIcon, Tree.CLASS_ITEM_EXPANDED);
@@ -269,7 +290,7 @@
},
isCollapsed: function() {
- var e = $(this.elementID.children);
+ var e = this.elements.childrenRow;
if (e) {
return e.style.display == "none";
} else {
@@ -280,7 +301,7 @@
processMouseOut: function(e) {
if (this.isMouseIn) {
this.isMouseIn = false;
- var eText = $(this.elementID.text);
+ var eText = this.elements.textElement;
var hClass = Richfaces.getNSAttribute("highlightedclass", eText);
if (hClass) {
var classNames = hClass.split(' ')
@@ -297,7 +318,7 @@
processMouseOver: function(e) {
if(!this.isMouseIn) {
this.isMouseIn = true;
- var eText = $(this.elementID.text);
+ var eText = this.elements.textElement;
var hClass = Richfaces.getNSAttribute("highlightedclass", eText);
if (hClass) {
var classNames = hClass.split(' ')
@@ -352,7 +373,7 @@
alert(s);
*/
- var eText = $(this.elementID.text);
+ var eText = this.elements.textElement;
var sClass = Richfaces.getNSAttribute("selectedclass", eText);
if (sClass) {
@@ -376,11 +397,11 @@
},
isSelected: function() {
- return Element.hasClassName(this.elementID.text, Tree.CLASS_ITEM_SELECTED);
+ return Element.hasClassName(this.elements.textElement, Tree.CLASS_ITEM_SELECTED);
},
deselect: function() {
- var eText = $(this.elementID.text);
+ var eText = this.elements.textElement;
var sClass = Richfaces.getNSAttribute("selectedclass", eText);
if (sClass) {
var classNames = sClass.split(' ')
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 2008-01-17
02:44:42 UTC (rev 5442)
+++
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js 2008-01-17
02:45:39 UTC (rev 5443)
@@ -7,6 +7,7 @@
Tree.ID_CONTENT = "content";
Tree.ID_CHILDS_ROW = "childs";
Tree.ID_CHILDS_TD = "td";
+Tree.ID_HANDLES = "handles";
Tree.ID_HANDLE = "handle";
Tree.ID_HANDLE_IMG_EXPANDED = "img:expanded";
Tree.ID_HANDLE_IMG_COLLAPSED = "img:collapsed";
Modified: trunk/ui/tree/src/main/templates/htmlTreeNode.jspx
===================================================================
--- trunk/ui/tree/src/main/templates/htmlTreeNode.jspx 2008-01-17 02:44:42 UTC (rev 5442)
+++ trunk/ui/tree/src/main/templates/htmlTreeNode.jspx 2008-01-17 02:45:39 UTC (rev 5443)
@@ -40,7 +40,7 @@
<f:call name="utils.encodePassThruWithExclusions">
<f:parameter value="id,onclick"/>
</f:call>
- <td class="dr-tree-h-ic rich-tree-node-handleicon #{line}">
+ <td class="dr-tree-h-ic rich-tree-node-handleicon #{line}"
id="#{clientId}:handles">
<jsp:scriptlet>
<![CDATA[
if (Boolean.TRUE.equals(component.getAttributes().get("isAjaxUpdateRoot"))
&& component.getUITree().isShowConnectingLines()) {
@@ -55,19 +55,6 @@
<div>
<jsp:scriptlet>
- <![CDATA[
- if
(org.richfaces.component.UITree.SWITCH_CLIENT.equals(component.getUITree().getSwitchType()))
{
- ]]>
- </jsp:scriptlet>
- <input class="dr-tree-h-input" type="hidden"
id="#{clientId}NodeExpanded" name="#{clientId}NodeExpanded"
value="#{this:getExpandedValue(context,component)}" />
- <jsp:scriptlet>
- <![CDATA[
- }
- ]]>
- </jsp:scriptlet>
-
-
- <jsp:scriptlet>
<![CDATA[
boolean leaf = component.getUITree().isLeaf();
if (leaf) {
@@ -150,6 +137,19 @@
}
]]>
</jsp:scriptlet>
+
+ <jsp:scriptlet>
+ <![CDATA[
+ if
(org.richfaces.component.UITree.SWITCH_CLIENT.equals(component.getUITree().getSwitchType()))
{
+ ]]>
+ </jsp:scriptlet>
+ <input class="dr-tree-h-input" type="hidden"
id="#{clientId}NodeExpanded" name="#{clientId}NodeExpanded"
value="#{this:getExpandedValue(context,component)}" />
+ <jsp:scriptlet>
+ <![CDATA[
+ }
+ ]]>
+ </jsp:scriptlet>
+
</div>
</td>