Author: sergeyhalipov
Date: 2007-05-28 11:36:06 -0400 (Mon, 28 May 2007)
New Revision: 893
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
Log:
Panel menu: fix expand/collapse behaviour for groups containing disabled elements.
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-05-28
14:20:48 UTC (rev 892)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-05-28
15:36:06 UTC (rev 893)
@@ -78,7 +78,7 @@
for (Iterator iter = flatList.iterator(); iter.hasNext();) {
UIComponent child = (UIComponent) iter.next();
if ((child instanceof UIPanelMenuItem)||(child instanceof UIPanelMenuGroup)) {
- Object childDisabled = child.getAttributes().get("disabled");
+ boolean childDisabled = child instanceof UIPanelMenuGroup ?
((UIPanelMenuGroup)child).isDisabled() : ((UIPanelMenuItem)child).isDisabled();
boolean childRendered = child instanceof UIPanelMenuGroup ?
((UIPanelMenuGroup)child).isRendered() : ((UIPanelMenuItem)child).isRendered();
boolean parentRendered = true;
if (! (child.getParent() instanceof UIPanelMenu))
@@ -121,8 +121,7 @@
if (childRendered && parentRendered){
- if ( ( childDisabled==null || !childDisabled.toString().equals("true") )
&&
- !isParentDisabled(child)){
+ if ( !isParentDisabled(child) ){
buffer
.append("new PanelMenuItem({myId:'")
.append((String) child.getClientId(context))
@@ -133,6 +132,8 @@
.append(",event:\"" + event + "\"")
.append(",mode:\"" + mode + "\"")
.append(",target:\"" + targetString + "\"")
+ .append(",disabled:" +
+ new Boolean(childDisabled).toString())
.append("},{");
Modified:
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
---
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-05-28
14:20:48 UTC (rev 892)
+++
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-05-28
15:36:06 UTC (rev 893)
@@ -7,15 +7,21 @@
}
var PanelMenuStorage = new Object();
+
PanelMenu = Class.create();
+
PanelMenu.prototype = {
initialize: function(myId,so){
this.childObj = new Array();
this.expandSingle = so;
this.lastExpanded = null;
this.is = 'panelMenu';
- PanelMenuStorage[myId] = this;}};
+ PanelMenuStorage[myId] = this;
+ }
+};
+
PanelMenuItem = Class.create();
+
PanelMenuItem.prototype = {
initialize: function(ids, options, hoveredStyles, hoveredClasses, level,
haveDynamicIcon, action, opened, ajaxFunction, iconAlign, iconExpanded, iconCollapsed,
iconSpacer){
if (!ids.parentId){return};
@@ -23,6 +29,7 @@
this.onopen = options.onopen;
this.onclose = options.onclose;
this.event = options.event;
+ this.disabled = options.disabled;
this.mode = options.mode;
if (!this.mode)
@@ -92,64 +99,70 @@
},
collapse: function(){
- if (this.expanded){
- if (this._getDirectChildrenByTag(this.content,"INPUT")[0]!=null){
- this._getDirectChildrenByTag(this.content,"INPUT")[0].value="closed";}
- for (var i = 0; i < this.childObj.length; i++){
- if
(this.childObj[i]._getDirectChildrenByTag(this.childObj[i].content,"INPUT")[0]!=null){
- this.childObj[i]._getDirectChildrenByTag(this.childObj[i].content,"INPUT")[0].value="";}
- if (this.haveDynamicIcon){
- var img = null
- if (this.iconAlign=="right"){
- img =
this._getDirectChildrenByTag(this.iconswitcher.nextSibling,"IMG")[0];
- } else {
- img =
this._getDirectChildrenByTag(this.iconswitcher.previousSibling,"IMG")[0];
- }
- if (img!=null){
- if (this.iconCollapsed!="none"){
- if (this.iconCollapsed!=null) {
- img.src = this.iconCollapsed;
- } else {
- img.src = this.iconSpacer;
+ if (!this.disabled) {
+ if (this.expanded){
+ if (this._getDirectChildrenByTag(this.content,"INPUT")[0]!=null){
+ this._getDirectChildrenByTag(this.content,"INPUT")[0].value="closed";}
+ for (var i = 0; i < this.childObj.length; i++){
+ if
(this.childObj[i]._getDirectChildrenByTag(this.childObj[i].content,"INPUT")[0]!=null){
+ this.childObj[i]._getDirectChildrenByTag(this.childObj[i].content,"INPUT")[0].value="";}
+ if (this.haveDynamicIcon){
+ var img = null
+ if (this.iconAlign=="right"){
+ img =
this._getDirectChildrenByTag(this.iconswitcher.nextSibling,"IMG")[0];
+ } else {
+ img =
this._getDirectChildrenByTag(this.iconswitcher.previousSibling,"IMG")[0];
+ }
+ if (img!=null){
+ if (this.iconCollapsed!="none"){
+ if (this.iconCollapsed!=null) {
+ img.src = this.iconCollapsed;
+ } else {
+ img.src = this.iconSpacer;
+ }
}
}
- }
+ }
+ this.childObj[i].collapse();
+ this.childObj[i].hide();
+ this.childObj[i].tdhider.style.display="none";
+ this.childObj[i].tablehider.style.display="none";
}
- this.childObj[i].collapse();
- this.childObj[i].hide();
- this.childObj[i].tdhider.style.display="none";
- this.childObj[i].tablehider.style.display="none";
}
+ this.expanded = false;
}
- this.expanded = false;
},
+
hide: function(){
this.obj.style.display = 'none';
this.inputState.value="closed";
},
+
expand: function(){
- if (!this.expanded){
- if (this._getDirectChildrenByTag(this.content,"INPUT")[0]!=null){
- this.inputState.value="opened";
- }
- if (this.haveDynamicIcon){
- var img = null
- if (this.iconAlign=="right"){
- img =
this._getDirectChildrenByTag(this.iconswitcher.nextSibling,"IMG")[0];
- } else {
- img =
this._getDirectChildrenByTag(this.iconswitcher.previousSibling,"IMG")[0];
+ if (!this.disabled) {
+ if (!this.expanded) {
+ if (this._getDirectChildrenByTag(this.content,"INPUT")[0]!=null){
+ this.inputState.value="opened";
}
- if (img!=null){
- if (this.iconExpanded!="none"){
- if (this.iconExpanded!=null) {
- img.src = this.iconExpanded;
- } else {
- img.src = this.iconSpacer;}}}}
- for (var i = 0; i < this.childObj.length; i++){
- this.childObj[i].show();
+ if (this.haveDynamicIcon){
+ var img = null
+ if (this.iconAlign=="right"){
+ img =
this._getDirectChildrenByTag(this.iconswitcher.nextSibling,"IMG")[0];
+ } else {
+ img =
this._getDirectChildrenByTag(this.iconswitcher.previousSibling,"IMG")[0];
+ }
+ if (img!=null){
+ if (this.iconExpanded!="none"){
+ if (this.iconExpanded!=null) {
+ img.src = this.iconExpanded;
+ } else {
+ img.src = this.iconSpacer;}}}}
+ for (var i = 0; i < this.childObj.length; i++){
+ this.childObj[i].show();
+ }
}
+ this.expanded = true;
}
- this.expanded = true;
},
show: function(){
@@ -160,11 +173,11 @@
this.obj.style.display = "";
},
- preTrigger:function(e){
+ preTrigger: function(e){
this.inputAction.setAttribute('value', this.obj.id);
},
- trigger:function(e){
+ trigger: function(e){
if ("none" == this.mode)
return;
if (this.action !="panelMenuItemAction"){
@@ -310,12 +323,14 @@
},
_attachBehaviors: function() {
- if (this.event)
- Event.observe(this.obj, this.event, this.itemClicked.bindAsEventListener(this),
false);
- else
- Event.observe(this.obj, "click", this.itemClicked.bindAsEventListener(this),
false);
- Event.observe(this.obj, "mouseover",
this.addHoverStyles.bindAsEventListener(this), false);
- Event.observe(this.obj, "mouseout",
this.removeHoverStyles.bindAsEventListener(this), false);
+ if (!this.disabled) {
+ if (this.event)
+ Event.observe(this.obj, this.event, this.itemClicked.bindAsEventListener(this),
false);
+ else
+ Event.observe(this.obj, "click",
this.itemClicked.bindAsEventListener(this), false);
+ Event.observe(this.obj, "mouseover",
this.addHoverStyles.bindAsEventListener(this), false);
+ Event.observe(this.obj, "mouseout",
this.removeHoverStyles.bindAsEventListener(this), false);
+ }
}
};