Author: a.izobov
Date: 2007-03-30 11:05:29 -0400 (Fri, 30 Mar 2007)
New Revision: 228
Modified:
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
Log:
dropdownmenu development: menuGroup support added
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-03-30
15:00:24 UTC (rev 227)
+++
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-03-30
15:05:29 UTC (rev 228)
@@ -24,21 +24,9 @@
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.richfaces.component.UIDropDownMenu;
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
-import org.richfaces.component.UIMenuItem;
-import org.richfaces.component.UIMenuGroup;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.ajax.AjaxContainer;
-public class DropDownMenuRendererBase extends HeaderResourcesRendererBase {
+public class DropDownMenuRendererBase extends MenuRendererBase {
protected Class getComponentClass() {
return UIDropDownMenu.class;
@@ -49,147 +37,4 @@
}
-
-/*
- public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
- UIDropDownMenu uiMenu = (UIDropDownMenu) component;
- List flatListOfNodes = new LinkedList();
- MenuLayerRendererHelper helper = new MenuLayerRendererHelper(context);
-
- flatten(uiMenu.getChildren(), flatListOfNodes);
-
- helper.processLayer(uiMenu);
-
- for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
- UIMenuGroup node = (UIMenuGroup) iter.next();
-
- helper.processLayer(node);
- }
- }
-
- private class MenuLayerRendererHelper {
- private boolean ajaxRequest;
- private FacesContext context;
- //private PreparedTemplate template;
- private AjaxContainer ajaxContainer;
- public MenuLayerRendererHelper(FacesContext context) {
- super();
- this.context = context;
- ajaxRequest = AjaxRendererUtils.isAjaxRequest(context);
-
- if (ajaxRequest) {
- // ajaxContainer = AjaxRendererUtils. .getSubmittedAjaxContainer(context, null);
-
- }
-
- //template = getLayerTemplate();
- }
-
- public void processLayer(UIComponent layer) throws IOException{
- //determineLayerHasIcons(layer);
- String clientId = layer.getClientId(context);
- //template.encode(MenuRendererBase.this, context, layer);
- layer.encodeBegin(context);
- //if (ajaxContainer != null) {
- AjaxRendererUtils.addRegionByName(context, layer, clientId + "_iframe");
- AjaxRendererUtils.addRegionByName(context, layer, clientId + "_iframe1");
- AjaxRendererUtils.addRegionByName(context, layer, clientId + "_script");
- // ajaxContainer.addAjaxArea(clientId + "_iframe");
- // ajaxContainer.addAjaxArea(clientId + "_iframe1");
- // ajaxContainer.addAjaxArea(clientId + "_script");
- //}
- }
-
- }
-
-
- private void flatten(List kids, List flatList){
- if(kids != null){
- for (Iterator iter = kids.iterator(); iter.hasNext();) {
- UIComponent kid = (UIComponent) iter.next();
- if (kid instanceof UIMenuGroup) {
- UIMenuGroup node = (UIMenuGroup) kid;
- flatList.add(node);
- flatten(node.getChildren(), flatList);
- }
- }
- }
- }
-
-*/
- public void encodeScript(FacesContext context, UIComponent component) throws IOException
{
- int showdelay = 300;
- int hideDelay = 300;
- UIDropDownMenu menu = (UIDropDownMenu) component;
-
-
- try {
- showdelay =
Integer.parseInt(component.getAttributes().get("showDelay").toString());
- hideDelay =
Integer.parseInt(component.getAttributes().get("hideDelay").toString());
- } catch(Exception e) {
- }
-
- StringBuffer buffer =
- new StringBuffer("new Exadel.Menu.Layer('")
- .append(component.getClientId(context))
- .append("_menu")
- .append("',")
- .append(showdelay + ")");
- buffer
- .append(".asDropDown('")
- .append(component.getClientId(context))
- .append("'");
-
- String evt = menu.getEvent();
-
- if(evt == null || evt.trim().length() == 0){
- evt = "onmouseover";
- }
-
- buffer.append(",'").append(evt).append("')");
-
-
- List kids = component.getChildren();
- for (Iterator iter = kids.iterator(); iter.hasNext();) {
- UIComponent kid = (UIComponent) iter.next();
- String itemId = null;
- if (kid instanceof UIMenuItem) {
- itemId = kid.getClientId(context);
- }
- else if (kid instanceof UIMenuGroup) {
- itemId = "ref" + kid.getClientId(context);
- }
-
- if(itemId != null){
- // if (kid instanceof UIMenuItem) {
- //UIMenuItem styledComponent = (UIMenuItem) kid;
- buffer
- .append(".addItem('")
- .append(itemId)
- .append("','")
- .append("null")
- .append("','")
- .append("null")
- .append("','")
- .append("null")
- .append("','")
- .append("null")
- .append("')");
- // }
- }
- }
- ResponseWriter out = context.getResponseWriter();
- String script =buffer.append(";").toString();
- out.write(script);
-
- //return buffer.append(";").toString();
-
- //new
Exadel.Menu.Layer("#{clientId}","300").asDropDown("#{clientId}","onmouseover");
- }
-
-
-
-
-
-
}
Modified:
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
---
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-03-30
15:00:24 UTC (rev 227)
+++
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-03-30
15:05:29 UTC (rev 228)
@@ -446,13 +446,13 @@
}
this.event = e;
- //this.element = Event.findElement(e, 'div').firstChild();
- this.element = Event.findElement(e, 'div').childNodes[2].firstChild;
+ this.element = Event.findElement(e, 'div');
+// .childNodes[2].firstChild;
this.layer = $(layer);
this.show = function() {
if (!Exadel.Menu.Layers.isVisible(this.layer)){
- //this.reposition();
+ this.reposition();
Exadel.Menu.Layers.LMPopUp(this.layer, false);
}
}.bind(this);
@@ -574,13 +574,12 @@
Exadel.Menu.Layer.prototype = {
- initialize: function(id,showDelay,hideDelay){
+ initialize: function(id,delay){
Exadel.Menu.Layers.listl.push(id);
this.id = id;
this.layer = $(id);
this.level = 0;
- this.showDelay = showDelay;
- this.hideDelay=hideDelay;
+ this.delay = delay;
Exadel.Menu.fitLayerToContent(this.layer);
this.items = new Array();
Exadel.Menu.Layers.layers[id] = this;
@@ -670,7 +669,7 @@
showMe: function(e){
this.closeSiblings(e);
//LOG.a4j_debug('show me ' + this.id +' ' +this.level);
- Exadel.Menu.Layers.showMenuLayer(this.id, e, this.showDelay);
+ Exadel.Menu.Layers.showMenuLayer(this.id, e, this.delay);
Exadel.Menu.Layers.levels[this.level] = this;
@@ -705,15 +704,15 @@
var item = {};
item.hoverClass = hoverClass;// = hoverClass.split(" ");
item.plainClass = plainClass;//.split(" ");
- item.hoverStyle = Exadel.extractCamelizedRules(hoverStyle);
- item.plainStyle = Exadel.extractCamelizedRules(plainStyle);
+ if (hoverStyle) item.hoverStyle = Exadel.extractCamelizedRules(hoverStyle);
+ if (plainStyle) item.plainStyle = Exadel.extractCamelizedRules(plainStyle);
item.id = itemId;
item.obj = $(itemId);
item.menu = this;
this.items[itemId] = item;
var onmouseover =
function(e){
- $(this.id).className = this.hoverClass;
+ if (this.hoverClass) $(this.id).className = this.hoverClass;
if(this.hoverStyle) {
Exadel.replaceStyleHash($(this.id), this.plainStyle, this.hoverStyle);
}
@@ -721,7 +720,7 @@
}.bindAsEventListener(item);
var onmouseout =
function(e){
- $(this.id).className = this.plainClass;
+ if (this.plainClass) $(this.id).className = this.plainClass;
if(this.hoverStyle) {
Exadel.replaceStyleHash($(this.id), this.hoverStyle, this.plainStyle);
}
@@ -754,7 +753,7 @@
if (!e) {
e = window.event;
}
- Exadel.Menu.Layers.showDropDownLayer(this.id, topLevel,
e,this.showDelay);
+ Exadel.Menu.Layers.showDropDownLayer(this.id, topLevel, e,this.delay);
}.bindAsEventListener(this);
if(!onEvt){
Modified:
trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
---
trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-03-30
15:00:24 UTC (rev 227)
+++
trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-03-30
15:05:29 UTC (rev 228)
@@ -39,28 +39,11 @@
<jsp:scriptlet>
<![CDATA[}]]>
</jsp:scriptlet>
-
- <div id="#{clientId}_menu"
- style="width: #{component.attributes['popupWidth']};
visibility: hidden; z-index:100;"
- class="dr-menu-list-border dr-menu-list-position
rich-menu-list-border rich-menu-list-position">
- <div class="dr-menu-list-bg rich-menu-list-bg">
- <script type="text/javascript">
- <f:call name="encodeScript" />
- </script>
- <f:call name="renderChildren" />
- </div>
- </div>
- <iframe class="underneath_iframe" id="#{clientId}_menu_iframe"
style="position:absolute">
- </iframe>
- <iframe class="underneath_iframe" id="#{clientId}_menu_iframe1"
style="position:absolute">
- </iframe>
+ <vcp:body>
+ <f:call name="renderChildren" />
+ </vcp:body>
</div>
-
-
-
-
-
</f:root>
\ No newline at end of file