[richfaces-svn-commits] JBoss Rich Faces SVN: r249 - in trunk/richfaces/dropdown-menu/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Apr 3 10:14:49 EDT 2007


Author: d.bulahov
Date: 2007-04-03 10:14:48 -0400 (Tue, 03 Apr 2007)
New Revision: 249

Removed:
   trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/css-rules.js
Modified:
   trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
   trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
Log:
Development add events attributes in javascript, remove css-rules.js 

Modified: trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java	2007-04-03 14:08:52 UTC (rev 248)
+++ trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java	2007-04-03 14:14:48 UTC (rev 249)
@@ -39,7 +39,10 @@
 import org.richfaces.component.UIMenuGroup;
 import org.richfaces.component.UIMenuItem;
 import org.richfaces.component.UIMenuSeparator;
+import org.richfaces.renderkit.ScriptOptions;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
 
+
 public class DropDownMenuRendererBase extends HeaderResourcesRendererBase {	
 	
 	protected Class getComponentClass() {
@@ -124,81 +127,62 @@
 	}
 
 	public void encodeScript(FacesContext context, UIComponent component) throws IOException {
-		StringBuffer buffer = 
-			new StringBuffer("new Exadel.Menu.Layer('")	
-				.append(component.getClientId(context)+"_menu")
-				.append("','")
-				.append(component.getAttributes().get("showDelay"))
-				.append("',");
-                if (component instanceof UIDropDownMenu) {
-                	buffer.append("'")
-                	.append(component.getAttributes().get("hideDelay"))
-                	.append("'");
-                }
-                else{
-                	buffer.append("null");
-                }
-                buffer.append( ")");
-		if (component instanceof UIMenuGroup) {
-			buffer.append(".asSubMenu('")
-				.append(component.getParent().getClientId(context)+"_menu")
-				.append("','")	
-				.append("ref")
-				.append(component.getClientId(context))
-				.append("',");
-				 String evt = (String) component.getAttributes().get("event");
-			     if(evt == null || evt.trim().length() == 0){
+		
+		
+		StringBuffer buffer = new StringBuffer();
+		JSFunction function = new JSFunction("new Exadel.Menu.Layer");
+		function.addParameter(component.getClientId(context)+"_menu");
+		function.addParameter(component.getAttributes().get("showDelay"));
+        if (component instanceof UIDropDownMenu) {
+    		function.addParameter(component.getAttributes().get("hideDelay"));
+        }
+        else{
+        	function.addParameter("null");
+        }
+        function.appendScript(buffer);        
+		if (component instanceof UIMenuGroup) {		
+			  buffer.append(".");
+			  function = new JSFunction("asSubMenu");
+			  function.addParameter(component.getParent().getClientId(context)+"_menu");
+			  function.addParameter("ref"+component.getClientId(context));
+	 		  String evt = (String) component.getAttributes().get("event");
+			  if(evt == null || evt.trim().length() == 0){
 				     evt = "onmouseover";
-			     }
-			    buffer.append("'").append(evt).append("',")				
-				.append("{")
-			    .append("onmouseout:'" + component.getAttributes().get("onmouseout")+"'")
-			    .append(",")
-			    .append("onmousemove:'" + component.getAttributes().get("onmousemove")+"'")
-			    .append(",")
-			    .append("onmouseover:'" + component.getAttributes().get("onmouseover")+"'")
-			    .append(",")
-			    .append("onopen:'" + component.getAttributes().get("onopen")+"'")
-			    .append(",")
-			    .append("onclose:'" + component.getAttributes().get("onclose")+"'")
-				.append("}")
-				.append(")");
+			  }
+			  function.addParameter(evt);
+			  ScriptOptions Optionssub = new ScriptOptions(component);
+			  Optionssub.addOption("onopen", component.getAttributes().get("onopen"));
+			  Optionssub.addOption("onclose", component.getAttributes().get("onclose"));
+			  function.addParameter(Optionssub);
+			  function.appendScript(buffer);
+			  
 		} else {
-		    buffer
-	         .append(".asDropDown('")
-	         .append(component.getClientId(context))		         
-	         .append("'");
-	    
-			String evt = (String) component.getAttributes().get("event");
-			if(evt == null || evt.trim().length() == 0){
-				evt = "onmouseover";
-			}
-			buffer.append(",'").append(evt).append("','onmouseout',")
-			.append("{")
-			.append("direction:'" + component.getAttributes().get("direction")+"'")
-			.append(",")
-			.append("jointPoint:'" + component.getAttributes().get("jointPoint")+"'")
-			.append(",")
-			.append("verticalOffset:'" + component.getAttributes().get("verticalOffset")+"'")
-			.append(",")		
-			.append("horizontalOffset:'" + component.getAttributes().get("horizontalOffset")+"'")
-			.append(",")
-			.append("oncollapse:'" + component.getAttributes().get("oncollapse")+"'")
-			.append(",")
-            .append("onexpand:'" + component.getAttributes().get("onexpand")+"'")
-			.append(",")
-            .append("onmouseout:'" + component.getAttributes().get("onmouseout")+"'")
-			.append(",")
-            .append("onmousemove:'" + component.getAttributes().get("onmousemove")+"'")
-			.append(",")
-            .append("onmouseover:'" + component.getAttributes().get("onmouseover")+"'")
-			.append(",")
-            .append("onitemselect:'" + component.getAttributes().get("onitemselect")+"'")            
-			.append(",")
-            .append("ongroupactivate:'" + component.getAttributes().get("ongroupactivate")+"'")
-			.append("}")
-			.append(")");			
+			  buffer.append(".");
+			  function = new JSFunction("asDropDown");
+			  function.addParameter(component.getClientId(context));
+  			  String evt = (String) component.getAttributes().get("event");
+			  if(evt == null || evt.trim().length() == 0){
+					evt = "onmouseover";
+			  }
+			  function.addParameter(evt);
+			  function.addParameter("onmouseout");
+			  ScriptOptions Options = new ScriptOptions(component);
+			  
+			  Options.addOption("direction", component.getAttributes().get("direction"));
+			  Options.addOption("jointPoint", component.getAttributes().get("jointPoint"));
+			  Options.addOption("verticalOffset", component.getAttributes().get("verticalOffset"));			  
+			  
+			  
+			  Options.addOption("horizontalOffset", component.getAttributes().get("horizontalOffset"));
+			  Options.addOption("oncollapse", component.getAttributes().get("oncollapse"));
+			  Options.addOption("onexpand", component.getAttributes().get("onexpand"));
+			  Options.addOption("onitemselect", component.getAttributes().get("onitemselect"));
+			  Options.addOption("ongroupactivate", component.getAttributes().get("ongroupactivate"));
+			  function.addParameter(Options);
+			  function.appendScript(buffer);
+			  
 		}
+        
 		List children = component.getChildren();
 		for(Iterator it = children.iterator();it.hasNext();) {
 			UIComponent kid = (UIComponent)it.next();
@@ -215,9 +199,13 @@
 					.append("')");
 			}
 		}
+		
 		ResponseWriter out = context.getResponseWriter();
 		String script =buffer.append(";").toString();
 		out.write(script); 
+		  
+		  
+		  
 	}
 	
 	

Deleted: trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/css-rules.js
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/css-rules.js	2007-04-03 14:08:52 UTC (rev 248)
+++ trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/css-rules.js	2007-04-03 14:14:48 UTC (rev 249)
@@ -1,49 +0,0 @@
-if(!Exadel) var Exadel = {};
-Exadel.extractRules = function(style){
-	var rules = style.split(";");
-	var rulesHash = {};
-	$A(rules).each(
-		function(rule){
-			if(!rule) return;
-			var i = rule.indexOf(':');
-			if(i > 0){
-				var nam = Exadel.trimString(rule.substr(0, i));
-				val = Exadel.trimString(rule.substr(i + 1));
-				rulesHash[nam] = val;
-			}
-			
-		}
-	);
-	return rulesHash;
-}
-Exadel.extractCamelizedRules = function(style){
-	var hash = Exadel.extractRules(style);
-	var newHash = {};
-	for(key in hash){
-		newHash[key.camelize()] = hash[key];
-	}
-	return newHash;
-}
-Exadel.trimString = function(s){
-	return s.replace(/^\s+/, '').replace(/\s+$/, '');
-}
-
-Exadel.replaceStyleHash = function(obj, hash1, hash2){
-	for(key in hash1){
-		obj.style[key] = '';
-	}
-	for(key in hash2){
-		obj.style[key] = hash2[key];
-	}
-}
-
-Exadel.replaceStyle = function(obj, style1, style2){
-	var hash1 = Exadel.extractRules(style1);
-	for(key in hash1){
-		hash1[key] = '';
-	}
-	var hash2 = Exadel.extractRules(style2);
-	Element.setStyle(obj, hash1);
-	Element.setStyle(obj, hash2);
-	return $H(obj.style).inspect();
-}
\ No newline at end of file

Modified: trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx	2007-04-03 14:08:52 UTC (rev 248)
+++ trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx	2007-04-03 14:14:48 UTC (rev 249)
@@ -14,8 +14,7 @@
    	<h:scripts>
 			new org.ajax4jsf.framework.resource.PrototypeScript(),
 			new org.ajax4jsf.framework.ajax.AjaxScript(),
-			scripts/menu.js,
-			scripts/css-rules.js
+			scripts/menu.js			
 	</h:scripts>
 	
 	<f:clientid var="clientId"/>
@@ -24,8 +23,9 @@
     </jsp:scriptlet>	
     <div id="#{clientId}" class="dr-menu-label dr-menu-label-unselect rich-menu-label rich-menu-label-unselect #{component.attributes['styleClass']}"
          style="#{component.attributes['style']};" 
-         onmouseover="this.className='dr-menu-label dr-menu-label-select rich-menu-label rich-menu-label-select'" 
-         onmouseout="this.className='dr-menu-label dr-menu-label-unselect rich-menu-label rich-menu-label-unselect'">         
+         onmouseover="this.className='dr-menu-label dr-menu-label-select rich-menu-label rich-menu-label-select' ; #{component.attributes['onmouseover']}" 
+         onmouseout="this.className='dr-menu-label dr-menu-label-unselect rich-menu-label rich-menu-label-unselect'; #{component.attributes['onmouseout']}"         
+         onmousemove="#{component.attributes['onmousemove']}">
 		 <jsp:scriptlet>
 					<![CDATA[if(component.getFacet("label")!=null && component.getFacet("label").isRendered()) {]]>
 		 </jsp:scriptlet>




More information about the richfaces-svn-commits mailing list