[richfaces-svn-commits] JBoss Rich Faces SVN: r467 - in trunk/richfaces/dropdown-menu/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directory.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Fri Apr 20 08:46:59 EDT 2007
Author: a.izobov
Date: 2007-04-20 08:46:59 -0400 (Fri, 20 Apr 2007)
New Revision: 467
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
Log:
highlight parent menuGroup when child menu is visible
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-20 12:43:33 UTC (rev 466)
+++ trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-04-20 12:46:59 UTC (rev 467)
@@ -182,6 +182,7 @@
UIComponent kid = (UIComponent)it.next();
String itemId = null;
int flcloseonclick=1;
+ int flagGroup = 0;
if (kid instanceof UIMenuItem) {
UIMenuItem MenuItem=(UIMenuItem)kid;
itemId = kid.getClientId(context);
@@ -189,8 +190,10 @@
flcloseonclick=0;
}
} else if (kid instanceof UIMenuGroup) {
+ UIMenuGroup menuGroup=(UIMenuGroup)kid;
itemId = "ref" + kid.getClientId(context);
flcloseonclick=0;
+ if (menuGroup.isDisabled()) flagGroup = 2; else flagGroup = 1;
}
if(itemId != null){
function = new JSFunction("addItem");
@@ -200,6 +203,9 @@
ScriptOptions options = new ScriptOptions(kid);
options.addOption("onmouseout", kid.getAttributes().get("onmouseout"));
options.addOption("onmouseover", kid.getAttributes().get("onmouseover"));
+ options.addOption("flagGroup", new Integer(flagGroup));
+ String tmp = (String)kid.getAttributes().get("selectClass");
+ if (tmp != null && tmp.length() > 0) options.addOption("selectClass", tmp);
function.addParameter(options);
buffer.append('.');
function.appendScript(buffer);
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-04-20 12:43:33 UTC (rev 466)
+++ trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-04-20 12:46:59 UTC (rev 467)
@@ -107,6 +107,7 @@
var menuLayer = this.layers[menu.id];
if (menuLayer && menuLayer.eventOnClose) menuLayer.eventOnClose();
if (menuLayer && menuLayer.eventOnCollapse) menuLayer.eventOnCollapse();
+ if (menuLayer.refItem) menuLayer.refItem.highLightGroup(false);
} else if (!visible && visibleFlag) {
var menuLayer = this.layers[menu.id];
if (menuLayer && menuLayer.eventOnOpen) menuLayer.eventOnOpen();
@@ -830,16 +831,40 @@
}
}
}
+ if (item.menu.refItem) {
+ item.menu.refItem.highLightGroup(true);
+ }
},
//addItem: function(itemId, hoverClass, plainClass, hoverStyle, plainStyle){
addItem: function(itemId, flag_close_onclick, options) {
var dis = this;
- var item = {};
+ var item = {
+ highLightGroup: function(light) {
+ if (light) {
+ Element.removeClassName(this.id,"dr-menu-item-enabled");
+ Element.addClassName(this.id,"dr-menu-item-hover");
+ Element.addClassName(this.id,"rich-menu-group-hover");
+ if (this.options.selectClass) Element.addClassName(this.id, this.options.selectClass);
+
+ Element.addClassName(this.id+":icon","rich-menu-item-icon-selected");
+ Element.addClassName(this.id+":anchor","rich-menu-item-label");
+ } else if (!this.mouseOver) {
+ Element.removeClassName(this.id,"dr-menu-item-hover");
+ Element.removeClassName(this.id,"rich-menu-group-hover");
+ Element.addClassName(this.id,"dr-menu-item-enabled");
+ if (this.options.selectClass) Element.removeClassName(this.id, this.options.selectClass);
+
+ Element.removeClassName(this.id+":icon","rich-menu-item-icon-selected");
+ Element.removeClassName(this.id+":anchor","rich-menu-item-label");
+ }
+ }
+ };
item.id = itemId;
item.obj = $(itemId);
item.menu = this;
item.options = options || {};
+ item.mouseOver = false;
if (item.options.onmouseover && item.options.onmouseover != ""){
item.eventOnMouseOver = new Function("event",item.options.onmouseover).bindAsEventListener(item);
}
@@ -851,6 +876,10 @@
var onmouseover =
function(e){
this.menu.closeMinors(this.id);
+ if (this.options.flagGroup == 1) {
+ this.mouseOver = true;
+ this.highLightGroup(true);
+ }
if (this.eventOnMouseOver) {
var reltg = (e.relatedTarget) ? e.relatedTarget : e.fromElement;
while (reltg && reltg != this.obj && reltg.nodeName != 'BODY')
@@ -862,6 +891,10 @@
var onmouseout =
function(e){
+ if (this.options.flagGroup == 1) {
+ this.mouseOver = false;
+ this.highLightGroup(false);
+ }
if (this.eventOnMouseOut) {
var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
while (reltg && reltg != this.obj && reltg.nodeName != 'BODY')
More information about the richfaces-svn-commits
mailing list