Author: nbelaevski
Date: 2008-05-08 12:07:32 -0400 (Thu, 08 May 2008)
New Revision: 8504
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
Log:
http://jira.jboss.com/jira/browse/RF-1948
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2008-05-08
15:43:52 UTC (rev 8503)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2008-05-08
16:07:32 UTC (rev 8504)
@@ -120,12 +120,12 @@
flatten(component.getChildren(), flatList, levels, 0);
- panelMenu.append("new PanelMenu('")
+ panelMenu.append("var ids = new PanelMenu('")
.append(component.getClientId(context).toString())
.append("',")
.append(new Boolean(expandSingle).toString())
.append(",").append("'").append(selectedChild).append("'")
- .append(");\n");
+ .append(").getIds();\n");
for (Iterator iter = flatList.iterator(); iter.hasNext();) {
UIComponent child = (UIComponent) iter.next();
@@ -204,7 +204,7 @@
}
buffer
- .append("new PanelMenuItem(params,{myId:'")
+ .append("new PanelMenuItem(ids, params,{myId:'")
.append((String) child.getClientId(context))
.append("',parentId:'")
.append((String) child.getParent().getClientId(context))
Modified:
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
---
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2008-05-08
15:43:52 UTC (rev 8503)
+++
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2008-05-08
16:07:32 UTC (rev 8504)
@@ -12,6 +12,8 @@
PanelMenu.prototype = {
initialize: function(myId, so, selectedChild){
+ this.myId = myId;
+
this.childObj = new Array();
this.expandSingle = so;
this.lastExpanded = null;
@@ -21,13 +23,53 @@
this.is = 'panelMenu';
this.selectedNameInput = $(myId + 'selectedItemName');
PanelMenuStorage[myId] = this;
+ },
+
+ _getIds: function(elt, ids) {
+ var child = Richfaces.firstDescendant(elt);
+ while (child) {
+ if (child.id) {
+ ids[child.id] = child;
+
+ if (child.tagName) {
+ var tagName = child.tagName.toLowerCase();
+
+ if (tagName == 'div') {
+ this._getIds(child, ids);
+ } else if (child.rows) {
+ var rows = child.rows;
+ for (var i = 0; i < rows.length; i++ ) {
+ var cells = rows[i].cells;
+ for (var j = 0; j < cells.length; j++ ) {
+ var cell = cells[j];
+ if (/^icon/.test(cell.id)) {
+ ids[cell.id] = cell;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ child = Richfaces.next(child);
+ }
+ },
+
+ getIds: function() {
+ var root = $(this.myId);
+ var ids = {};
+ ids[root.id] = root;
+
+ this._getIds(root, ids);
+
+ return ids;
}
};
PanelMenuItem = Class.create();
PanelMenuItem.prototype = {
- initialize: function(params,ids, options, hoveredStyles, hoveredClasses, level,
haveDynamicIcon, action, opened, ajaxFunction, onItemHover, iconAlign, iconExpanded,
iconCollapsed, iconSpacer){
+ initialize: function(idsMap, params,ids, options, hoveredStyles, hoveredClasses, level,
haveDynamicIcon, action, opened, ajaxFunction, onItemHover, iconAlign, iconExpanded,
iconCollapsed, iconSpacer){
if (!ids.parentId){return};
this.type = options.type;
this.onopen = options.onopen;
@@ -49,11 +91,19 @@
this.hoveredStyles = hoveredStyles;
this.hoveredClasses = hoveredClasses;
- this.tdhider = $(ids.myId);
+ this.tdhider = Element.extend(idsMap[ids.myId]);
+ if (!this.tdhider) {
+ this.tdhider = $(ids.myId);
+ }
this.tablehider = Richfaces.firstDescendant(this.tdhider);
this.haveDynamicIcon = haveDynamicIcon;
- if (this.haveDynamicIcon==true)
- this.iconswitcher = $("icon"+ids.myId);
+ if (this.haveDynamicIcon==true) {
+ var iconSwitcherId = "icon" + ids.myId;
+ this.iconswitcher = Element.extend(idsMap[iconSwitcherId]);
+ if (!this.iconswitcher) {
+ this.iconswitcher = $(iconSwitcherId);
+ }
+ }
this.childObj = new Array();
this.parentObj = PanelMenuStorage[ids.parentId];
this.parentObj.childObj.push(this);