Author: nbelaevski
Date: 2008-01-16 21:44:42 -0500 (Wed, 16 Jan 2008)
New Revision: 5442
Modified:
trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java
trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1905
Modified:
trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
---
trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2008-01-17
01:29:42 UTC (rev 5441)
+++
trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2008-01-17
02:44:42 UTC (rev 5442)
@@ -93,6 +93,7 @@
menuOptions.addEventHandler("onexpand");
menuOptions.addEventHandler("onitemselect");
menuOptions.addEventHandler("ongroupactivate");
+ menuOptions.addOption("disabled");
function.addParameter(menuOptions);
function.appendScript(buffer);
Modified: trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
---
trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2008-01-17
01:29:42 UTC (rev 5441)
+++
trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2008-01-17
02:44:42 UTC (rev 5442)
@@ -19,8 +19,8 @@
</jsp:scriptlet>
<div id="#{clientId}" style=""
class="#{component.attributes['styleClass']} dr-menu-label
dr-menu-label-unselect rich-ddmenu-label rich-ddmenu-label-unselect"
- onmouseover="this.className='dr-menu-label dr-menu-label-select
rich-ddmenu-label rich-ddmenu-label-select' ;
#{component.attributes['onmouseover']}"
- onmouseout="this.className='dr-menu-label dr-menu-label-unselect
rich-ddmenu-label rich-ddmenu-label-unselect';
#{component.attributes['onmouseout']}"
+ onmouseover="#{component.attributes['onmouseover']}"
+ onmouseout="#{component.attributes['onmouseout']}"
onmousemove="#{component.attributes['onmousemove']}">
<jsp:scriptlet>
<![CDATA[ } else { ]]>
Modified:
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java
===================================================================
---
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java 2008-01-17
01:29:42 UTC (rev 5441)
+++
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java 2008-01-17
02:44:42 UTC (rev 5442)
@@ -83,17 +83,19 @@
String itemId = null;
int flcloseonclick = 1;
int flagGroup = 0;
+ boolean disabled = false;
if (kid instanceof UIMenuItem) {
UIMenuItem menuItem = (UIMenuItem) kid;
itemId = kid.getClientId(context);
- if (menuItem.isDisabled()) {
+ disabled = menuItem.isDisabled();
+ if (disabled) {
flcloseonclick = 0;
}
} else if (kid instanceof UIMenuGroup) {
UIMenuGroup menuGroup = (UIMenuGroup) kid;
itemId = "ref" + kid.getClientId(context);
flcloseonclick = 0;
- if (menuGroup.isDisabled()) {
+ if ((disabled = menuGroup.isDisabled())) {
flagGroup = 2;
} else {
flagGroup = 1;
@@ -102,13 +104,16 @@
if (itemId != null) {
JSFunction function = new JSFunction(".addItem");
function.addParameter(itemId);
- function.addParameter(new Integer(flcloseonclick));
-
ScriptOptions options = new ScriptOptions(kid);
options.addEventHandler("onmouseout");
options.addEventHandler("onmouseover");
+ options.addOption("closeOnClick", new Integer(flcloseonclick));
options.addOption("flagGroup", new Integer(flagGroup));
options.addOption("selectClass");
+ options.addOption("style");
+ options.addOption("selectStyle");
+ options.addOption("iconClass");
+ options.addOption("disabled", Boolean.valueOf(disabled));
function.addParameter(options);
return function.toScript();
}
Modified:
trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
---
trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2008-01-17
01:29:42 UTC (rev 5441)
+++
trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2008-01-17
02:44:42 UTC (rev 5442)
@@ -1,4 +1,3 @@
-
if(!window.RichFaces) window.RichFaces = {};
if(!RichFaces.Menu) RichFaces.Menu = {};
@@ -105,13 +104,21 @@
var visible = this.isVisible(menuName);
this.setVisibility(menuName, visibleFlag);
this.ieSelectWorkAround(menuName, visibleFlag);
+ var menuLayer = this.layers[menu.id];
+
if (visible && !visibleFlag) {
- 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);
+ if (menuLayer) {
+ if (menuLayer.eventOnClose) {
+ menuLayer.eventOnClose();
+ }
+ if (menuLayer.eventOnCollapse) {
+ menuLayer.eventOnCollapse();
+ }
+ if (menuLayer.refItem) {
+ menuLayer.refItem.highLightGroup(false);
+ }
+ }
} else if (!visible && visibleFlag) {
- var menuLayer = this.layers[menu.id];
if (menuLayer) {
if (menuLayer.eventOnOpen) {
menuLayer.eventOnOpen();
@@ -119,11 +126,15 @@
if (menuLayer.eventOnExpand) {
menuLayer.eventOnExpand();
}
- if (menuLayer.level && menuLayer.level > 0) {
+
+ if (menuLayer.level>0) {
do {
menuLayer = this.layers[(this.father[menuLayer.id])];
- } while (menuLayer.level > 0)
- if (menuLayer && menuLayer.eventOnGroupActivate)
menuLayer.eventOnGroupActivate();
+ } while (menuLayer.level > 0);
+
+ if (menuLayer && menuLayer.eventOnGroupActivate) {
+ menuLayer.eventOnGroupActivate();
+ }
}
}
}
@@ -320,7 +331,7 @@
if (!e) {
e = window.event;
}
- Event.stop(e);
+ //Event.stop(e);
this.event = Object.clone(e);
this.element = Event.element(e);
this.layer = $(layer);
@@ -330,13 +341,25 @@
var win = RichFaces.Menu.getWindowDimensions();
var bodyHeight = body.height;
var bodyWidth = body.width;
+
var clientX = this.event.clientX;
var clientY = this.event.clientY;
- var top = Event.pointerY(this.event);
- var left = Event.pointerX(this.event);
+ var e = this.event;
+ var x = Event.pointerX(e);
+ var y = Event.pointerY(e);
+ var elementDim = Richfaces.Position.getOffsetDimensions(this.layer);
+
+ var offsets = Position.cumulativeOffset(this.layer);
+
+ offsets[0] -= this.layer.offsetLeft || 0;
+ offsets[1] -= this.layer.offsetTop || 0;
+
+ var toolTipX = x - offsets[0];
+ var toolTipY = y - offsets[1];
+
var layerdim = Element.getDimensions(this.layer);
- var layerLeft = left;
+ var layerLeft = toolTipX;
if (clientX + layerdim.width > win.width) {
layerLeft -= (layerdim.width - RichFaces.Menu.Layers.shadowWidth -
RichFaces.Menu.Layers.CornerRadius);
@@ -355,7 +378,7 @@
layerLeft = 0;
}
*/
- var layerTop = top;
+ var layerTop = toolTipY;
/*if (layertop + layerdim.height > bodyHeight) {
layertop = bodyHeight - layerdim.height;
}
@@ -688,18 +711,17 @@
this.items = new Array();
RichFaces.Menu.Layers.layers[id] = this;
this.bindings = new Array();
-
+
//Usually set on DD menu to true
this.highlightParent = true;
-
+
this.mouseover =
function(e){
RichFaces.Menu.MouseIn=true;
RichFaces.Menu.Layers.clearLMTO();
- if (this.highlightParent) {
- var menuNode =
RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
- menuNode.className='dr-menu-label dr-menu-label-select rich-ddmenu-label
rich-ddmenu-label-select';
+ if (this.shouldHighlightParent() && !this.isWithin(e)) {
+ this.highlightLabel();
}
Event.stop(e);
@@ -711,9 +733,8 @@
if (!RichFaces.Menu.selectOpen) {
RichFaces.Menu.Layers.setLMTO(this.hideDelay);
}
- if (this.highlightParent) {
- var menuNode =
RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
- menuNode.className='dr-menu-label dr-menu-label-unselect rich-ddmenu-label
rich-ddmenu-label-unselect';
+ if (this.shouldHighlightParent() && !this.isWithin(e)) {
+ this.unHighlightLabel();
}
Event.stop(e);
}.bindAsEventListener(this);
@@ -788,7 +809,50 @@
} */
},
+ getLabel : function() {
+ return RichFaces.Menu.Layers.layers[this.layer.id].layer.parentNode.parentNode;
+ },
+
+ highlightLabel: function() {
+ var label1 = $(this.getLabel());
+ RichFaces.Menu.Items.replaceClasses(label1,
+ ['dr-menu-label-unselect', 'rich-ddmenu-label-unselect'],
+ ['dr-menu-label-select','rich-ddmenu-label-select']);
+ },
+ unHighlightLabel: function() {
+ var label1 = $(this.getLabel());
+ RichFaces.Menu.Items.replaceClasses(label1,
+ ['dr-menu-label-select','rich-ddmenu-label-select'],
+ ['dr-menu-label-unselect', 'rich-ddmenu-label-unselect']);
+ },
+
+ shouldHighlightParent : function() {
+ var result = this.highlightParent;
+ var parent = null;
+ if (result && (parent = this.getParentLayer())) {
+ result &= parent.shouldHighlightParent();
+ }
+ return result;
+ },
+
+ getParentLayer: function() {
+ return this.level > 0 ?
RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[this.id])] : null;
+ },
+
+ isWithin : function(event){
+ var within = true;
+ var targetElement = event.relatedTarget;
+ var srcElement = event.target;
+ var layer = $(this.id);
+ if (targetElement) {
+ within = $(targetElement).descendantOf(layer);
+ }
+
+ within &= $(srcElement).descendantOf(layer);
+
+ return within;
+ },
openSelect: function(event){
RichFaces.Menu.selectOpen = true;
@@ -798,6 +862,7 @@
},
+
closeSelect: function(event){
RichFaces.Menu.selectOpen = false;
var ClickInputb = this.ClickInput.bindAsEventListener(this);
@@ -881,104 +946,11 @@
},
//addItem: function(itemId, hoverClass, plainClass, hoverStyle, plainStyle){
- addItem: function(itemId, flag_close_onclick, options) {
+ addItem: function(itemId, options) {
var dis = this;
- 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);
- }
- if (item.options.onmouseout && item.options.onmouseout != ""){
- item.eventOnMouseOut = new
Function("event",item.options.onmouseout).bindAsEventListener(item);
- }
+ var item = new RichFaces.Menu.Item(itemId, this, options || {});
+ //item.menu = this;
this.items[itemId] = item;
-
- 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')
- reltg = reltg.parentNode;
- if (reltg == this.obj) return;
- this.eventOnMouseOver();
- }
- }.bindAsEventListener(item);
-
- 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')
- reltg = reltg.parentNode;
- if (reltg == this.obj) return;
- this.eventOnMouseOut();
- }
- }.bindAsEventListener(item);
-
- var onmouseclick =
- function(e){
- var menuLayer = item.menu;
- while (menuLayer.level > 0) {
- menuLayer =
RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[menuLayer.id])];
- }
- if (menuLayer && menuLayer.eventOnItemSelect) menuLayer.eventOnItemSelect();
- RichFaces.Menu.Layers.shutdown();
- }.bindAsEventListener(item);
-
- var binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "mouseover",
- onmouseover);
- this.bindings.push(binding);
- binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "mouseout",
- onmouseout);
- this.bindings.push(binding);
- binding.refresh();
- if (flag_close_onclick==1){
- binding = new RichFaces.Menu.Layer.Binding (
- item.id,
- "click",
- onmouseclick);
- this.bindings.push(binding);
- binding.refresh();
- }
-
return this;
},
hideMe: function(e){
@@ -1007,7 +979,12 @@
if (!e) {
e = window.event;
}
+
RichFaces.Menu.Layers.showDropDownLayer(this.id, topLevel,
e,this.delay);
+ if (options.disabled == false && !RichFaces.Menu.isWithin(e,
$(topLevel))) {
+ this.highlightLabel();
+ }
+
}.bindAsEventListener(this);
if(!onEvt){
@@ -1024,6 +1001,9 @@
function(e){
RichFaces.Menu.Layers.setLMTO(this.hideDelay);
RichFaces.Menu.Layers.clearPopUpTO();
+ if (options.disabled == false && !RichFaces.Menu.isWithin(e,
$(topLevel))) {
+ this.unHighlightLabel();
+ }
}.bindAsEventListener(this);
// var item = $(topLevel);
@@ -1074,39 +1054,27 @@
this.hideDelay=menuLayer.hideDelay;
}
- this.highlightParent = options.highlightParent;
return this;
},
- asContextMenu: function(parent, evt){
- var refLayer = $(parent);
- if(!refLayer) return this;
+ asContextMenu: function(options){
+ this.highlightParent = false;
+ this.options = options || {};
+ if (this.options.ongroupactivate){
+ this.eventOnGroupActivate = this.options.ongroupactivate.bindAsEventListener(this);
+ }
+ if (this.options.onitemselect){
+ this.eventOnItemSelect = this.options.onitemselect.bindAsEventListener(this);
+ }
+ if (this.options.oncollapse){
+ this.eventOnCollapse = this.options.oncollapse.bindAsEventListener(this);
+ }
+ if (this.options.onexpand){
+ this.eventOnExpand = this.options.onexpand.bindAsEventListener(this);
+ }
-
- var id = this.id;
- this.highlightParent = false;
- if(!evt){
- evt = 'onclick';
- }
- var offEvt = 'onmouseout';
- offEvt = this.eventJsToPrototype(offEvt);
-
- var dis = this;
- var onmouseout =
- function(e){
- RichFaces.Menu.Layers.setLMTO(this.hideDelay);
- RichFaces.Menu.Layers.clearPopUpTO();
- }.bindAsEventListener(this);
- evt = this.eventJsToPrototype(evt);
- var handler = function(e){new RichFaces.Menu.DelayedContextMenu(this.id,
e).show();}.bindAsEventListener(this);
- var binding = new RichFaces.Menu.Layer.Binding (parent, evt, handler);
- this.bindings.push(binding);
- binding.refresh();
- binding = new RichFaces.Menu.Layer.Binding (parent, offEvt, onmouseout);
- this.bindings.push(binding);
- binding.refresh();
-
- return this;
+ //TODO: clarify
+ return this;
},
eventJsToPrototype: function(evtName){
var indexof = evtName.indexOf('on');
@@ -1128,7 +1096,7 @@
refresh:function(){
/*LOG.a4j_debug("rebinding " + $H(this).inspect());*/
var obj = $(this.objectId);
- if (obj && obj.tagName) {
+ if(obj){
Event.stopObserving(obj, this.eventname, this.handler);
Event.observe(obj, this.eventname, this.handler);
return true;
@@ -1136,84 +1104,208 @@
return false;
}
};
-if(!RichFaces.Menu.Item) RichFaces.Menu.Item = {};
+RichFaces.Menu.Items = {
+ classNames: ['dr-menu-item-enabled', 'rich-menu-item-enabled'],
+ hoverClassNames : ['dr-menu-item-hover', 'rich-menu-item-hover'],
+ iconClassNames : [],
+ hoverIconClassNames: ['dr-menu-icon-selected',
'rich-menu-item-icon-selected'],
+ labelClassNames: [],
+ hoverLabelClassNames: ['rich-menu-item-label-selected'],
+
+ replaceClasses: function(element, toRemove, toAdd) {
+ var e = $(element);
+ $A(toRemove).each(function(className) {e.removeClassName(className)});
+ $A(toAdd).each(function(className) {e.addClassName(className)});
+ },
+
+ onmouseover: function(item) {
+ var element = item.getElement();
+ var icon = item.getIcon();
+ var labl = item.getLabel();
-/**
- *
- */
-RichFaces.Menu.Item.Onclick = function(evt, item, action, params, target) {
- var form = Event.findElement(evt, 'form');
+ var hoverClass = item.getHoverClasses();
+ var iconHoverClass = item.getIconHoverClasses();
+ var labelHoverClass = item.getLabelHoverClasses();
+
+ var inlineStyle = item.getInlineStyle();
+ var hoverStyle = item.getHoverStyle();
+ element.style.cssText = inlineStyle.concat(hoverStyle);
+
+ this.replaceClasses(element, this.classNames,
this.hoverClassNames.concat(hoverClass));
+ this.replaceClasses(icon, this.iconClassNames,
this.hoverIconClassNames.concat(iconHoverClass));
+ this.replaceClasses(labl, this.labelClassNames,
this.hoverLabelClassNames.concat(labelHoverClass));
+ },
+ onmouseout : function(item) {
+ var element = item.getElement();
+ var icon = item.getIcon();
+ var labl = item.getLabel();
- /*if(!form || typeof(form) == 'undefined' || !form.nodeName ||
form.nodeName.toLowerCase() != 'form'){
- form = document.createElement('form');
- form.setAttribute('method', 'post');
- form.setAttribute('enctype', 'application/x-www-form-urlencoded');
- form.action = action;
- document.body.appendChild(form);
- }*/
- var objectsCreated = new Array();
- var oldValues = new Object();
- RichFaces.Menu.Item._createOrInitHiddenInput(item + ":submit", item +
":submit", objectsCreated, oldValues, form);
+ var hoverClass = item.getHoverClasses();
+ var iconHoverClass = item.getIconHoverClasses();
+ var labelHoverClass = item.getLabelHoverClasses();
- if (params) {
+ var inlineStyle = item.getInlineStyle();
+ element.style.cssText = inlineStyle;
- for (var param in params) {
- var paramName = param;
- var paramValue = params[paramName];
- if (typeof(paramValue) != 'function') {
- if (paramValue) {
- paramValue = String(paramValue);
+ this.replaceClasses(element, this.hoverClassNames.concat(hoverClass),
this.classNames);
+ this.replaceClasses(icon, this.hoverIconClassNames.concat(iconHoverClass),
this.iconClassNames);
+ this.replaceClasses(labl, this.hoverLabelClassNames.concat(labelHoverClass),
this.labelClassNames);
}
- RichFaces.Menu.Item._createOrInitHiddenInput(paramName, paramValue, objectsCreated,
oldValues, form);
- }
- }
+};
+RichFaces.Menu.isWithin = function (event, element) {
+ var within = false;
+ Event.extend(event);
+ var targetElement = event.relatedTarget;
+ var srcElement = Event.element(event);
+
+ if (targetElement) {
+ within = targetElement == element ||
+ $(targetElement).descendantOf(element);
}
- var l = objectsCreated.length;
+ return within;
+};
- for (var i = 0; i < l; i++) {
- var kid = objectsCreated[i];
- form.appendChild(kid);
- }
+RichFaces.Menu.Item = Class.create({
+ initialize: function(id, menu, options) {
+ this.options = options;
+ this.id = id;
+ this.menu = menu;
+ this.mouseOver = false;
+
- var targ = form.target;
- if (target) {
- form.target = target;
- }
+ var binding;
- form.submit();
+ binding = new RichFaces.Menu.Layer.Binding (
+ id,
+ "mouseover",
+ this.onmouseover.bindAsEventListener(this));
+ menu.bindings.push(binding);
+ binding.refresh();
+
+ binding = new RichFaces.Menu.Layer.Binding (
+ id,
+ "mouseout",
+ this.onmouseout.bindAsEventListener(this));
+ menu.bindings.push(binding);
+ binding.refresh();
- form.target = targ;
+ binding = new RichFaces.Menu.Layer.Binding (
+ id,
+ "click",
+ this.onclick.bindAsEventListener(this));
+ menu.bindings.push(binding);
+ binding.refresh();
+ },
- for (var j = 0; j < l; j++) {
- var kid = objectsCreated[j];
- if (form && kid) {
- form.removeChild(kid);
+
+ onclick: function(e){
+ if (this.options.closeOnClick == 1) {
+ var menuLayer = this.menu;
+ while (menuLayer.level > 0) {
+ menuLayer =
RichFaces.Menu.Layers.layers[(RichFaces.Menu.Layers.father[menuLayer.id])];
}
+ if (menuLayer && menuLayer.eventOnItemSelect) menuLayer.eventOnItemSelect();
+ RichFaces.Menu.Layers.shutdown();
}
+ RichFaces.Menu.Items.onmouseout(this);
+ },
+ getElement: function() {
+ return $(this.id);
+ },
+ getIcon: function() {
+ return $(this.id + ":icon");
+ },
+ getLabel: function() {
+ return $(this.id + ":anchor");
+ },
+ getInlineStyle: function() {
+ return this.options.style || "";
+ },
+ getHoverStyle: function() {
+ return this.options.selectStyle || "";
+ },
+ getHoverClasses: function() {
+ return $A(this.options.selectClass).compact();
+ },
+ getIconHoverClasses : function() {
+ return $A(this.options.iconHoverClass).compact();
+ },
+ getLabelHoverClasses : function() {
+ return $A(this.options.labelHoverClass).compact();
+ },
- for (var key in oldValues) {
- var value = oldValues[key];
- if (typeof(value) != 'function') {
- ($(key) || form[key]).value = value;
+ isDisabled : function() {
+ //console.log(this.id + (this.options.disabled));
+ return this.options.disabled || false;
+ },
+ onmouseover : function(event) {
+ var element = this.getElement();
+
+ if (this.options.onmouseover) {
+ if (this.options.onmouseover.call(element, event) == false) {
+ Event.stop(event);
+ return;
+ };
+ }
+ if (RichFaces.Menu.isWithin(event, element)) {
+ return;
+ }
+ this.menu.closeMinors(this.id);
+ if (this.isDisabled()) {
+ return;
+ }
+ if (this.options.flagGroup == 1) {
+ this.mouseOver = true;
+ this.highLightGroup(true);
+ }
+ RichFaces.Menu.Items.onmouseover(this);
+ },
+ onmouseout : function(event) {
+ Event.extend(event);
+ //window.status = $(event.relatedTarget).inspect();
+ if (this.options.onmouseout) {
+ if (this.options.onmouseover.call(element, event) == false) {
+ Event.stop(event);
+ return;
+ };
}
+ var element = this.getElement();
+ if (RichFaces.Menu.isWithin(event, element)) {
+ return;
+ }
+ if (this.isDisabled()) {
+ return;
+ }
+ if (this.options.flagGroup == 1) {
+ this.mouseOver = false;
+ this.highLightGroup(false);
}
+ RichFaces.Menu.Items.onmouseout(this);
+ },
+ 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);
}
-RichFaces.Menu.Item._createOrInitHiddenInput = function(name, value, list, oldValues,
form) {
- var hiddenObj = $(name) || form[name];
-
- if (!hiddenObj) {
- hiddenObj = document.createElement('input');
- hiddenObj.setAttribute('type', 'hidden');
- hiddenObj.setAttribute('name', name);
- hiddenObj.setAttribute('id', name);
- list.push(hiddenObj);
- } else {
- oldValues[name] = hiddenObj.value;
+ 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");
}
- hiddenObj.value = value;
}
+});
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2008-01-17
01:29:42 UTC (rev 5441)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2008-01-17
02:44:42 UTC (rev 5442)
@@ -62,7 +62,7 @@
$('#{clientId}:icon').className='dr-menu-icon dr-menu-icon-selected
rich-menu-item-icon rich-menu-item-icon-selected
#{component.attributes['iconClass']}';
$('#{clientId}:anchor').className='rich-menu-item-label
rich-menu-item-label-selected';"
style="#{component.attributes['style']}"
- onclick="this.className='dr-menu-item dr-menu-item-enabled rich-menu-item
rich-menu-item-enabled #{component.attributes['styleClass']}'; #{onselect}
#{onclick}; Event.stop(event);"
+ onclick="this.className='dr-menu-item dr-menu-item-enabled rich-menu-item
rich-menu-item-enabled #{component.attributes['styleClass']}'; #{onselect}
#{onclick}; Event.stop(event);"
onmouseup="Event.stop(event);
#{component.attributes['onmouseup']}">
<f:call name="utils.encodeAttributes">
<f:parameter value="onmousedown,onmousemove" />