Author: pyaschenko
Date: 2011-02-17 14:49:18 -0500 (Thu, 17 Feb 2011)
New Revision: 21746
Modified:
trunk/examples/output-demo/src/main/webapp/examples/panelMenu.xhtml
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenuGroup.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenuItem.js
Log:
https://jira.jboss.org/browse/RF-10320
https://jira.jboss.org/browse/RF-10551
Modified: trunk/examples/output-demo/src/main/webapp/examples/panelMenu.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/panelMenu.xhtml 2011-02-17
19:25:22 UTC (rev 21745)
+++ trunk/examples/output-demo/src/main/webapp/examples/panelMenu.xhtml 2011-02-17
19:49:18 UTC (rev 21746)
@@ -49,11 +49,21 @@
itemDisabledLeftIcon="triangleLeft"
topItemDisabledLeftIcon="triangleUp"
topItemLeftIcon="triangleDown"
- groupMode="client" activeItem="item41"
+ groupMode="server" activeItem="item41"
bubbleSelection="true"
expandSingle="true">
- <rich:panelMenuGroup id="group1" label="Group 1">
- <rich:panelMenuItem id="item11" label="Item 1.1" />
+ <rich:panelMenuGroup id="group1" label="Group 1"
selectable="true"
+ onbeforecollapse="alert('onbeforecollapse')"
+ onbeforeexpand="alert('onbeforeexpand')"
+ onbeforeselect="alert('onbeforeselect')"
+ oncollapse="alert('oncollapse')"
+ onexpand="alert('onexpand')"
+ onselect="alert('onselect')"
+ onswitch="alert('onswitch')"
+ onbeforeswitch="alert('onbeforeswitch')">
+ <rich:panelMenuItem id="item11" label="Item 1.1"
+ onbeforeselect="alert('onbeforeselect')"
+ onselect="alert('onselectItem')"/>
<rich:panelMenuItem id="item12" label="Item 1.2" />
</rich:panelMenuGroup>
<rich:panelMenuItem id="item2" label="Item 2"
disabled="true" />
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2011-02-17
19:25:22 UTC (rev 21745)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2011-02-17
19:49:18 UTC (rev 21746)
@@ -67,6 +67,7 @@
public static final String BEFORE_COLLAPSE = "beforecollapse";
public static final String BEFORE_EXPAND = "beforeexpand";
public static final String BEFORE_SWITCH = "beforeswitch";
+ public static final String SELECT = "select";
private static final String CSS_CLASS_PREFIX = "rf-pm-gr";
//TODO nick - shouldn't this be rf-pm-gr-top?
@@ -210,6 +211,7 @@
addEventOption(context, panelMenuGroup, options, BEFORE_COLLAPSE);
addEventOption(context, panelMenuGroup, options, BEFORE_EXPAND);
addEventOption(context, panelMenuGroup, options, BEFORE_SWITCH);
+ addEventOption(context, panelMenuGroup, options, SELECT);
return options;
}
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenuGroup.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenuGroup.js 2011-02-17
19:25:22 UTC (rev 21745)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenuGroup.js 2011-02-17
19:49:18 UTC (rev 21746)
@@ -149,6 +149,33 @@
}
});
}
+ } else {
+
+ if (this.options.expandEvent == this.options.collapseEvent) {
+ if (this.options.expandEvent != 'click') {
+ this.__header().bind(this.options.expandEvent, function () {
+ menuGroup.switchExpantion();
+ });
+ }
+
+ } else {
+ if (this.options.expandEvent != 'click') {
+ this.__header().bind(this.options.expandEvent, function () {
+ if (menuGroup.collapsed()) {
+ return menuGroup.expand();
+ }
+ });
+ }
+
+ if (this.options.collapseEvent != 'click') {
+ this.__header().bind(this.options.collapseEvent, function () {
+ if (menuGroup.expanded()) {
+ return menuGroup.collapse();
+ }
+ });
+ }
+ }
+
}
if (this.options.selectable || this.options.bubbleSelection) {
@@ -301,10 +328,11 @@
__switch : function (expand) {
if (expand) {
- this.expand();
+ this.__expand();
} else {
- this.collapse();
+ this.__collapse();
}
+ return this.__fireEvent("switch");
},
/***************************** Private Methods
****************************************************************/
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenuItem.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenuItem.js 2011-02-17
19:25:22 UTC (rev 21745)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/panelMenuItem.js 2011-02-17
19:49:18 UTC (rev 21746)
@@ -41,6 +41,17 @@
* @return {void}
* */
exec : function (item) {
+
+ if (item.expanded) {
+ var flag = item.options.expandEvent == item.options.collapseEvent &&
item.options.collapseEvent == "click";
+ if (flag && item.__fireEvent("beforeswitch")==false) return
false;
+ if (!item.expanded()) {
+ if ( item.options.expandEvent == "click" &&
item.__fireEvent("beforeexpand")==false) return false;
+ } else {
+ if ( item.options.collapseEvent == "click" &&
item.__fireEvent("beforecollapse")==false) return false;
+ }
+ }
+
var mode = item.mode;
if (mode == "server") {
return this.execServer(item);
@@ -104,8 +115,16 @@
panelMenu.selectedItem(item.itemName);
item.__select();
-
- return item.__fireSelect();
+ var result = item.__fireSelect();
+
+ if (item.__switch) {
+ var mode = item.mode;
+ if (mode == "client" || mode == "none") {
+ item.__switch(!item.expanded());
+ }
+ }
+
+ return result;
},
/**
@@ -275,7 +294,7 @@
__restoreSelection: function() {
this.__select();
- this.__fireSelect();
+ //this.__fireSelect();
},
__isSelected: function() {