Author: a.izobov
Date: 2007-04-02 11:19:09 -0400 (Mon, 02 Apr 2007)
New Revision: 236
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
Log:
changing classes for label and icon on select
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
---
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-04-02
15:02:40 UTC (rev 235)
+++
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-04-02
15:19:09 UTC (rev 236)
@@ -26,6 +26,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.framework.renderer.ComponentVariables;
+import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.richfaces.component.UIMenuGroup;
@@ -41,4 +43,31 @@
return true;
}
+ public void initializeResources(FacesContext context, UIMenuGroup menuGroup)
+ throws IOException {
+
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(this,
menuGroup);
+
+ boolean disabled = ((Boolean)
menuGroup.getAttributes().get("disabled")).booleanValue();
+ if (!disabled) {
+ StringBuffer scriptValue = new StringBuffer();
+ scriptValue.append("document.getElementById('ref" +
menuGroup.getClientId(context) + ":icon').className='dr-menu-icon
rich-menu-item-icon ")
+ .append(getAttributeOrEmpty(menuGroup, "iconClass") + "';
")
+ .append("document.getElementById('ref" + menuGroup.getClientId(context)
+ ":anchor').className='dr-menu-label rich-menu-item-label'; ");
+ variables.setVariable("onmouseout", scriptValue);
+
+ scriptValue = new StringBuffer();
+ scriptValue.append("document.getElementById('ref" +
menuGroup.getClientId(context) + ":icon').className='dr-menu-icon
dr-menu-icon-selected rich-menu-item-icon rich-menu-item-icon-selected ")
+ .append(getAttributeOrEmpty(menuGroup, "iconClass") + "';
")
+ .append("document.getElementById('ref" + menuGroup.getClientId(context)
+ ":anchor').className='dr-menu-label dr-menu-label-selected
rich-menu-item-label rich-menu-item-label-selected'; ");
+ variables.setVariable("onmouseover", scriptValue);
+
+ }
+ }
+
+ public String getAttributeOrEmpty(UIComponent component, String attr) {
+ Object value = component.getAttributes().get(attr);
+ return value==null?"":value.toString();
+ }
+
}
Modified:
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
===================================================================
---
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-04-02
15:02:40 UTC (rev 235)
+++
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-04-02
15:19:09 UTC (rev 236)
@@ -18,6 +18,8 @@
scripts/menu.js,
scripts/css-rules.js
</h:scripts>
+
+ <f:call name="initializeResources" />
<f:clientid var="clientId"/>
<f:resource name="/org/richfaces/renderkit/html/images/spacer.gif"
var="spacer" />
@@ -29,8 +31,8 @@
<div id="ref#{clientId}"
class="dr-menu-item dr-menu-item-enabled rich-menu-group
#{component.attributes['styleClass']}"
style="#{component.attributes['style']}"
- onmouseout="this.className='dr-menu-item dr-menu-item-enabled
rich-menu-group'; #{component.attributes['onmouseout']}"
- onmouseover="this.className='dr-menu-item dr-menu-item-hover rich-menu-group
rich-menu-group-hover'; #{component.attributes['onmouseover']}"
+ onmouseout="this.className='dr-menu-item dr-menu-item-enabled
rich-menu-group'; #{onmouseout} #{component.attributes['onmouseout']}"
+ onmouseover="this.className='dr-menu-item dr-menu-item-hover rich-menu-group
rich-menu-group-hover'; #{component.attributes['selectClass']} #{onmouseover}
#{component.attributes['onmouseover']}"
onmousemove="#{component.attributes['onmousemove']}">
<span id="ref#{clientId}:icon"
Show replies by date