Author: nbelaevski
Date: 2008-06-03 10:35:47 -0400 (Tue, 03 Jun 2008)
New Revision: 8890
Modified:
branches/3.1.x/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
branches/3.1.x/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
Log:
http://jira.jboss.com/jira/browse/RF-1948
http://jira.jboss.com/jira/browse/RF-3621
Modified:
branches/3.1.x/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
---
branches/3.1.x/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2008-06-03
14:33:00 UTC (rev 8889)
+++
branches/3.1.x/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2008-06-03
14:35:47 UTC (rev 8890)
@@ -119,12 +119,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();
@@ -203,7 +203,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:
branches/3.1.x/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
---
branches/3.1.x/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2008-06-03
14:33:00 UTC (rev 8889)
+++
branches/3.1.x/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2008-06-03
14:35:47 UTC (rev 8890)
@@ -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.tablehider = $("tablehide"+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);
@@ -74,13 +124,18 @@
this.selected = false;
}
this.clientId = ids.myId;
- this.obj = $(ids.myId);
- this.leftIcon = $('leftIcon' + ids.myId);
- this.rightIcon = $('rightIcon' + ids.myId);
- this.labelArea = $('icon' + ids.myId);
- this.content = document.getElementsByClassName("dr-pmenu-group-self-label",
this.obj)[0];
+
+ this.mainRow = this.tablehider.rows[0];
+ Element.extend(this.mainRow);
+
+ var mainCells = this.mainRow.cells;
+
+ this.leftIcon = Richfaces.lastDescendant(mainCells[0]);
+ this.labelArea = mainCells[1];
+ this.rightIcon = Richfaces.firstDescendant(mainCells[2]);
+ this.content = document.getElementsByClassName("dr-pmenu-group-self-label",
this.tdhider)[0];
this.iconAlign = iconAlign;
- this.mainRow = $("row_" + ids.myId);
+
/*
if (level == 0){
this.tdhider.style.display = "";
@@ -158,7 +213,7 @@
},
hide: function(){
- this.obj.style.display = 'none';
+ this.tdhider.style.display = 'none';
// if(this.inputState){
// this.inputState.value="closed";
// }
@@ -196,11 +251,11 @@
// this.inputState.value="opened";
this.tdhider.style.display="";
this.tablehider.style.display="";
- this.obj.style.display = "";
+ this.tdhider.style.display = "";
},
preTrigger: function(e){
- //this.inputAction.setAttribute('value', this.obj.id);
+ //this.inputAction.setAttribute('value', this.tdhider.id);
this.inputAction.setAttribute('value', this.clientId);
},
@@ -389,7 +444,7 @@
else
Event.observe(this.tablehider, "click",
this.itemClicked.bindAsEventListener(this), false);
- Event.observe(this.obj, "mouseover",
this.hoverItem.bindAsEventListener(this), false);
+ Event.observe(this.tdhider, "mouseover",
this.hoverItem.bindAsEventListener(this), false);
Event.observe(this.tablehider, "mouseover",
this.addHoverStyles.bindAsEventListener(this), false);
Event.observe(this.tablehider, "mouseout",
this.removeHoverStyles.bindAsEventListener(this), false);