[richfaces-svn-commits] JBoss Rich Faces SVN: r807 - in trunk/richfaces/panelmenu/src/main: java/org/richfaces/component/panelmenu and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri May 18 10:58:11 EDT 2007


Author: sergeyhalipov
Date: 2007-05-18 10:58:11 -0400 (Fri, 18 May 2007)
New Revision: 807

Modified:
   trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml
   trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
   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: add support for "event" attribute and onexpand/oncollapse attributes.

Modified: trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml
===================================================================
--- trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml	2007-05-18 13:07:07 UTC (rev 806)
+++ trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml	2007-05-18 14:58:11 UTC (rev 807)
@@ -357,6 +357,18 @@
 		&ui_input_attributes;
 		&html_events; 
 		<property>
+	    	<name>oncollapse</name>
+	    	<classname>java.lang.String</classname>
+	    	<description></description>
+	    	<defaultvalue><![CDATA[""]]></defaultvalue>
+	    </property>
+	    <property>
+	    	<name>onexpand</name>
+	    	<classname>java.lang.String</classname>
+	    	<description></description>
+	    	<defaultvalue><![CDATA[""]]></defaultvalue>
+	    </property>
+		<property>
 	    	<name>hoverClass</name>
 	    	<classname>java.lang.String</classname>
 	    	<description>Class to be applied to hovered items.</description>

Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java	2007-05-18 13:07:07 UTC (rev 806)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java	2007-05-18 14:58:11 UTC (rev 807)
@@ -67,6 +67,10 @@
 	public abstract void setIconClass(String iconClass);
 	public abstract String getIconStyle();
 	public abstract void setIconStyle(String iconStyle);
+	public abstract String getOncollapse();
+	public abstract void setOncollapse(String ongroupcollapse);
+	public abstract String getOnexpand();
+	public abstract void setOnexpand(String ongroupexpand);
 	
 	
 }

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-18 13:07:07 UTC (rev 806)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java	2007-05-18 14:58:11 UTC (rev 807)
@@ -91,10 +91,17 @@
 				}
 				
 				UIPanelMenu parentMenu = findMenu(child);
+				
+				String event = parentMenu.getEvent();
+				if ("".equals(event))
+					event = "click";
+				else if (event.startsWith("on"))
+					event = event.substring(2);
+				
 				String onopen = child instanceof UIPanelMenuGroup ? 
-						parentMenu.getOngroupexpand() : "";
+						parentMenu.getOngroupexpand() + ";" + ((UIPanelMenuGroup)child).getOnexpand() : "";
 				String onclose = child instanceof UIPanelMenuGroup ? 
-						parentMenu.getOngroupcollapse() : "";
+						parentMenu.getOngroupcollapse() + ";" + ((UIPanelMenuGroup)child).getOncollapse() : "";
 				String hoveredStyle = (child instanceof UIPanelMenuGroup ? 
 						parentMenu.getHoveredGroupStyle() : parentMenu.getHoveredItemStyle())
 						+ ";" + (child instanceof UIPanelMenuGroup ? 
@@ -116,6 +123,7 @@
 								.append((String) child.getParent().getClientId(context))
 								.append("'},{type:" + (child instanceof UIPanelMenuItem ? "\"item\"":"\"node\""))
 								.append(",onopen:"+(onopen.equals("") ? "\"\"" : "\"" + onopen + "\"")+",onclose:"+(onclose.equals("") ? "\"\"" : "\"" + onclose + "\""))
+								.append(",event:\"" + event + "\"")
 								.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-18 13:07:07 UTC (rev 806)
+++ trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js	2007-05-18 14:58:11 UTC (rev 807)
@@ -22,6 +22,7 @@
 		this.type = options.type;
 		this.onopen = options.onopen;
 		this.onclose = options.onclose;
+		this.event = options.event;
 		this.hoveredStyles = hoveredStyles;
 		this.hoveredClasses = hoveredClasses;
 		this.tdhider = $("tdhide"+ids.myId);
@@ -160,7 +161,7 @@
 		if(this.action){
 			if (this.action=='panelMenuNodeAction'){
 				if (this.expanded){
-					if (this.type="node"){
+					if ("node" == this.type){
 						if (new Function(this.onclose+";return true;")()){
 							this.collapse();
 						} 
@@ -173,7 +174,7 @@
 						if (this.parentObj.lastExpanded!=null){
 							this.parentObj.lastExpanded.collapse();
 						}
-						if (this.type="node"){
+						if ("node" == this.type){
 							if (new Function(this.onopen+";return true;")()){
 								this.expand();
 							} 
@@ -183,7 +184,7 @@
 						}
 						this.parentObj.lastExpanded = this;
 					} else {
-						if (this.type="node"){
+						if ("node" == this.type){
 							if (new Function(this.onopen+";return true;")()){
 								this.expand();
 							} 
@@ -196,8 +197,8 @@
 			}
 		} else {
 			if (this.expanded){
-				if (this.type="node"){
-					if (new Function(this.onopen+";return true;")()){
+				if ("node" == this.type){
+					if (new Function(this.onclose + ";return true;")()){
 						this.collapse();
 					} 
 				}
@@ -209,7 +210,7 @@
 					if (this.parentObj.lastExpanded!=null){
 						this.parentObj.lastExpanded.collapse();
 					}
-					if (this.type="node"){
+					if ("node" == this.type){
 						if (new Function(this.onopen+";return true;")()){
 							this.expand();
 						} 
@@ -219,7 +220,7 @@
 					}
 					this.parentObj.lastExpanded = this;
 				} else {
-					if (this.type="node"){
+					if ("node" == this.type){
 						if (new Function(this.onopen+";return true;")()){
 							this.expand();
 						} 
@@ -269,7 +270,10 @@
 	}, 
    
  	_attachBehaviors: function() {
-		Event.observe(this.obj, "click", this.itemClicked.bindAsEventListener(this), false);
+ 		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);
 	}




More information about the richfaces-svn-commits mailing list