Author: nbelaevski
Date: 2008-05-08 14:12:10 -0400 (Thu, 08 May 2008)
New Revision: 8515
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
Log:
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2008-05-08
17:19:26 UTC (rev 8514)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2008-05-08
18:12:10 UTC (rev 8515)
@@ -28,9 +28,9 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.ajax4jsf.renderkit.compiler.TemplateContext;
-import org.richfaces.skin.Skin;
import org.ajax4jsf.util.style.CSSFormat;
import org.richfaces.component.UIPanelMenu;
import org.richfaces.component.UIPanelMenuGroup;
@@ -47,7 +47,6 @@
import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleDown;
import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleLeft;
import org.richfaces.renderkit.html.iconimages.PanelMenuIconTriangleUp;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author hans
@@ -271,10 +270,13 @@
* @param component
* @throws IOException
*/
- public void drawIcon(ResponseWriter writer, String iconType, String imageSrc,
UIComponent component, String id) throws IOException{
+ public void drawIcon(ResponseWriter writer, String iconType, String imageSrc,
UIComponent component, String id, boolean drawHidden) throws IOException{
if (iconType != null && !iconType.equals("") &&
!iconType.equals("none")){
int h = 16; //width(context);
writer.startElement("img", component);
+ if (drawHidden) {
+ writer.writeAttribute("style", "display: none;", null);
+ }
writer.writeAttribute("src", imageSrc, null);
writer.writeAttribute("alt", "", null);
writer.writeAttribute("vspace", "0", null);
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2008-05-08
17:19:26 UTC (rev 8514)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2008-05-08
18:12:10 UTC (rev 8515)
@@ -83,7 +83,7 @@
} else {
String iconType = PANEL_MENU_SPACER_ICON_NAME;
String imageSrc = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(context.getResponseWriter(), iconType, imageSrc, component, from +
"Icon" + component.getClientId(context));
+ drawIcon(context.getResponseWriter(), iconType, imageSrc, component, from +
"Icon" + component.getClientId(context), false);
}
}
@@ -165,7 +165,12 @@
if ("".equals(icon))
icon = "custom";
String source = getIconByType(icon, isTopLevel, context, component);
- drawIcon(writer, icon, source, component, id);
+ boolean drawHidden = false;
+ if (source != null && source.trim().length() == 0) {
+ source = getIconByType(PANEL_MENU_SPACER_ICON_NAME, isTopLevel, context, component);
+ drawHidden = true;
+ }
+ drawIcon(writer, icon, source, component, id, drawHidden);
}
public String getFullStyleClass(FacesContext context, UIComponent component) {
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2008-05-08
17:19:26 UTC (rev 8514)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2008-05-08
18:12:10 UTC (rev 8515)
@@ -80,7 +80,7 @@
} else {
String iconType = PANEL_MENU_SPACER_ICON_NAME;
String imageSrc = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(context.getResponseWriter(), iconType, imageSrc, component, from +
"Icon" + component.getClientId(context));
+ drawIcon(context.getResponseWriter(), iconType, imageSrc, component, from +
"Icon" + component.getClientId(context), false);
}
}
@@ -90,7 +90,6 @@
UIPanelMenu panelMenu = findMenu(component);
ResponseWriter writer = context.getResponseWriter();
boolean isTopLevel = isTopLevel(component);
- String source = null;
String iconType = null;
UIPanelMenuItem item = (UIPanelMenuItem)component;
@@ -127,8 +126,13 @@
iconType = defaultItemIcon;
} else iconType = customItemIcon;
- source = getIconByType(iconType, isTopLevel, context, component);
- drawIcon(writer, iconType, source, component, from + "Icon" +
component.getClientId(context));
+ boolean drawHidden = false;
+ String source = getIconByType(iconType, isTopLevel, context, component);
+ if (source != null && source.trim().length() == 0) {
+ source = getIconByType(PANEL_MENU_SPACER_ICON_NAME, isTopLevel, context, component);
+ drawHidden = true;
+ }
+ drawIcon(writer, iconType, source, component, from + "Icon" +
component.getClientId(context), drawHidden);
}
Modified:
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
---
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2008-05-08
17:19:26 UTC (rev 8514)
+++
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2008-05-08
18:12:10 UTC (rev 8515)
@@ -194,15 +194,23 @@
} else {
img = this.leftIcon;
}
- if (img!=null){
- if (this.iconCollapsed!="none"){
- if (this.iconCollapsed!=null) {
+
+ if (img!=null){
+ if (this.iconCollapsed!="none"){
+ if (this.iconCollapsed!=null) {
+ if (this.iconCollapsed.length != 0) {
+ Element.show(img);
img.src = this.iconCollapsed;
} else {
+ Element.hide(img);
img.src = this.iconSpacer;
}
+ } else {
+ Element.show(img);
+ img.src = this.iconSpacer;
}
}
+ }
}
this.childObj[i].collapse();
this.childObj[i].hide();
@@ -234,6 +242,7 @@
if (this._getDirectChildrenByTag(this.content,"INPUT")[0]!=null){
this.inputState.value="opened";
}
+
if (this.haveDynamicIcon){
var img = null
if (this.iconAlign=="right"){
@@ -244,9 +253,21 @@
if (img!=null){
if (this.iconExpanded!="none"){
if (this.iconExpanded!=null) {
- img.src = this.iconExpanded;
+ if (this.iconExpanded.length != 0) {
+ Element.show(img);
+ img.src = this.iconExpanded;
+ } else {
+ Element.hide(img);
+ img.src = this.iconSpacer;
+ }
} else {
- img.src = this.iconSpacer;}}}}
+ Element.show(img);
+ img.src = this.iconSpacer;
+ }
+ }
+ }
+ }
+
for (var i = 0; i < this.childObj.length; i++){
this.childObj[i].show();
}