Author: abelevich
Date: 2011-01-25 10:00:17 -0500 (Tue, 25 Jan 2011)
New Revision: 21211
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu-base.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuKeyNavigation.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menugroup.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuitem.js
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java
Log:
https://issues.jboss.org/browse/RF-10235 DropDownMenu: popup is never getting hidden in IE
and Google Chrome. Client code are cleaned up.
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu-base.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu-base.js 2011-01-25
14:41:20 UTC (rev 21210)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu-base.js 2011-01-25
15:00:17 UTC (rev 21211)
@@ -49,7 +49,6 @@
this.selectedGroup = null;
-
rf.Event.bindById(this.id, "mouseenter", $.proxy(this.__overHandler,
this), this);
rf.Event.bindById(this.id, "mouseleave", $.proxy(this.__leaveHandler,
@@ -112,41 +111,40 @@
this.popupElement.focus();
},
- __hidePopup : function() {
- window.clearTimeout(this.showTimeoutId);
- this.showTimeoutId=null;
- if (this.__isShown()) {
- this.invokeEvent("hide", rf.getDomElement(this.id), null);
- this.__closeChildGroups();
- this.popup.hide();
- this.displayed = false;
- this.__deselectCurrentItem();
- this.currentSelectedItemIndex = -1;
- jqueryParentMenu = this.__getParentMenu();
- parentMenu = rf.$(this.__getParentMenu());
- if (this.id != parentMenu.id) {
- parentMenu.popupElement.focus();
- rf.ui.MenuManager.setActiveSubMenu(parentMenu);
- }
- }
- },
+ __hidePopup : function() {
+ window.clearTimeout(this.showTimeoutId);
+ this.showTimeoutId = null;
+ if (this.__isShown()) {
+ this.invokeEvent("hide", rf.getDomElement(this.id), null);
+ this.__closeChildGroups();
+ this.popup.hide();
+ this.displayed = false;
+ this.__deselectCurrentItem();
+ this.currentSelectedItemIndex = -1;
+ parentMenu = rf.$(this.__getParentMenu());
+ if (this.id != parentMenu.id) {
+ parentMenu.popupElement.focus();
+ rf.ui.MenuManager.setActiveSubMenu(parentMenu);
+ }
+ }
+ },
- __closeChildGroups : function() {
+ __closeChildGroups : function() {
var i = 0;
- var menuItem;
- for (i in this.items) {
- menuItem = this.items.eq(i);
- if (this.__isGroup(menuItem)) {
- rf.$(menuItem).hide();
- }
- }
+ var menuItem;
+ for (i in this.items) {
+ menuItem = this.items.eq(i);
+ if (this.__isGroup(menuItem)) {
+ rf.$(menuItem).hide();
+ }
+ }
},
__getParentMenuFromItem : function(item) {
- var menu;
- if (item)
- menu = item.parents('div.rf-ddm-itm')
- .has('div.rf-ddm-lst-bg').eq(1);
+ var menu;
+ if (item)
+ menu = item.parents('div.rf-ddm-itm')
+ .has('div.rf-ddm-lst-bg').eq(1);
if (menu && menu.length > 0)
return menu;
else {
@@ -159,8 +157,8 @@
},
__getParentMenu : function() {
- var menu = $(this.element).parents('div.rf-ddm-itm')
- .has('div.rf-ddm-lst-bg').eq(0);
+ var menu = $(this.element).parents('div.rf-ddm-itm')
+ .has('div.rf-ddm-lst-bg').eq(0);
if (menu && menu.length > 0)
return menu;
else {
@@ -170,8 +168,7 @@
},
__isGroup : function(item) {
- var group = item.find('div.' + this.options.listCss);
- return group.length > 0;
+ return item.find('div.' + this.options.listCss).length > 0;
},
__isDisabled : function(item) {
@@ -206,13 +203,11 @@
},
__showHandler : function(e) {
- if (!this.__isShown()){
+ if (!this.__isShown()) {
this.showTimeoutId = window.setTimeout($.proxy(function() {
- this.show();
- }, this), this.options.showDelay);
+ this.show();
+ }, this), this.options.showDelay);
}
-
-
},
__leaveHandler : function() {
@@ -224,12 +219,15 @@
__overHandler : function() {
window.clearTimeout(this.hideTimeoutId);
+ this.hideTimeoutId = null;
},
destroy : function() {
// clean up code here
this.detach(this.id);
+ rf.Event.unbind(this.popupElement, "keydown" + this.namespace)
+
// call parent's destroy method
$super.destroy.call(this);
}
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js 2011-01-25
14:41:20 UTC (rev 21210)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js 2011-01-25
15:00:17 UTC (rev 21211)
@@ -2,23 +2,9 @@
rf.ui = rf.ui || {};
var defaultOptions = {
- mode : 'server',
- attachToBody : false,
- showDelay : 50,
- hideDelay : 300,
- verticalOffset : 0,
- horisantalOffset : 0,
- showEvent : 'mouseover',
- positionOffset : [0, 0],
direction : "AA",
jointPoint : "AA",
- positionType : "DROPDOWN",
- itemCss : "rf-ddm-itm",
- selectItemCss : "rf-ddm-itm-sel",
- unselectItemCss : "rf-ddm-itm-unsel",
- disabledItemCss : "rf-ddm-itm-dis",
- listCss : "rf-ddm-lst",
- listContainerCss : "rf-ddm-lst-bg"
+ positionType : "DROPDOWN"
};
// constructor definition
@@ -30,10 +16,10 @@
this.namespace = this.namespace || "."
+ rf.Event.createNamespace(this.name, this.id);
this.groupList = new Array();
-
- rf.Event.bindById(this.id+"_label", this.options.showEvent, $.proxy(
+
+ rf.Event.bindById(this.id + "_label", this.options.showEvent, $.proxy(
this.__showHandler, this), this);
-
+
this.attachToDom(componentId);
if (!rf.ui.MenuManager)
rf.ui.MenuManager = {};
@@ -48,52 +34,53 @@
$.extend(rf.ui.Menu.prototype, rf.ui.MenuKeyNavigation);
$.extend(rf.ui.Menu.prototype, (function() {
- return {
- name : "Menu",
- initiateGroups : function(groupOptions) {
+ return {
+ name : "Menu",
+ initiateGroups : function(groupOptions) {
+ for (var i in groupOptions) {
+ var groupId = groupOptions[i].id;
+ var positionOffset = [groupOptions[i].horizontalOffset,
+ groupOptions[i].verticalOffset];
+ if (null != groupId) {
+ this.groupList[groupId] = new RichFaces.ui.MenuGroup(
+ groupId, {
+ rootMenuId : this.id,
+ onshow : groupOptions[i].onshow,
+ onhide : groupOptions[i].onhide,
+ positionOffset : positionOffset,
+ jointPoint : groupOptions[i].jointPoint,
+ direction : groupOptions[i].direction
+ });
+ }
+ }
+ },
- for (var i in groupOptions) {
- var groupId = groupOptions[i].id;
- var positionOffset = [
- groupOptions[i].horizontalOffset,
- groupOptions[i].verticalOffset];
- if (null != groupId) {
- this.groupList[groupId] = new
RichFaces.ui.MenuGroup(groupId,
- {
- rootMenuId : this.id,
- onshow : groupOptions[i].onshow,
- onhide : groupOptions[i].onhide,
- positionOffset: positionOffset,
- jointPoint : groupOptions[i].jointPoint,
- direction : groupOptions[i].direction
- });
- }
- }
- },
+ show : function(e) {
+ if (this.menuManager.openedMenu != this.id) {
+ this.menuManager.shutdownMenu();
+ this.menuManager.addMenuId(this.id);
+ this.__showPopup(e);
+ }
+ },
- show : function(e) {
- if (this.menuManager.openedMenu != this.id) {
- this.menuManager.shutdownMenu();
- this.menuManager.addMenuId(this.id);
- this.__showPopup(e);
- }
- },
+ hide : function() {
+ this.__hidePopup();
+ this.menuManager.deletedMenuId();
+ },
- hide : function() {
- this.__hidePopup();
- this.menuManager.deletedMenuId();
- },
+ destroy : function() {
+ // clean up code here
+ this.detach(this.id);
- destroy : function() {
- // clean up code here
- this.detach(this.id);
+ rf.Event.unbindById(this.id + "_label", this.options.showEvent);
- // call parent's destroy method
- $super.destroy.call(this);
- }
- };
- })());
+ // call parent's destroy method
+ $super.destroy.call(this);
+ }
+ };
+ })());
+
rf.ui.MenuManager = {
openedMenu : null,
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuKeyNavigation.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuKeyNavigation.js 2011-01-25
14:41:20 UTC (rev 21210)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuKeyNavigation.js 2011-01-25
15:00:17 UTC (rev 21211)
@@ -1,174 +1,170 @@
-(function ($, rf) {
-
+(function($, rf) {
+
rf.ui = rf.ui || {};
//rf.ui.MenuKeyNavigation = rf.ui.MenuKeyNavigation || {};
-
-
- rf.ui.MenuKeyNavigation={
-
- __updateItemsList : function() {
- var items =
$('.'+this.options.listContainerCss+':first',this.popup.popup).find('>.'+this.options.itemCss)
- .not('.'+this.options.disabledItemCss);
- return (this.items = items);
- },
-
- __selectPrev : function() {
- if (-1 == this.currentSelectedItemIndex){
- this.currentSelectedItemIndex=this.items.length-1;
- } else {
- this.__deselectCurrentItem();
- }
-
- if (this.currentSelectedItemIndex > 0){
- this.currentSelectedItemIndex--;
- }
- else {
- this.currentSelectedItemIndex=this.items.length-1;
- }
-
- this.__selectCurrentItem();
- },
-
- __selectNext : function() {
- if (-1 != this.currentSelectedItemIndex){
- this.__deselectCurrentItem();
- }
- if (this.currentSelectedItemIndex < this.items.length-1){
- this.currentSelectedItemIndex++;
- }
- else {
- this.currentSelectedItemIndex = 0;
- }
-
- this.__selectCurrentItem();
- },
-
- __deselectCurrentItem : function () {
- this.__deselectByIndex(this.currentSelectedItemIndex);
- },
-
- __selectCurrentItem : function () {
- this.__selectByIndex(this.currentSelectedItemIndex);
- },
-
- __selectFirstItem : function () {
+
+ rf.ui.MenuKeyNavigation = {
+
+ __updateItemsList : function() {
+ var items = $('.' + this.options.listContainerCss + ':first',
+ this.popup.popup).find('>.' + this.options.itemCss).not(
+ '.' + this.options.disabledItemCss);
+ return (this.items = items);
+ },
+
+ __selectPrev : function() {
+ if (-1 == this.currentSelectedItemIndex) {
+ this.currentSelectedItemIndex = this.items.length - 1;
+ } else {
+ this.__deselectCurrentItem();
+ }
+
+ if (this.currentSelectedItemIndex > 0) {
+ this.currentSelectedItemIndex--;
+ } else {
+ this.currentSelectedItemIndex = this.items.length - 1;
+ }
+
+ this.__selectCurrentItem();
+ },
+
+ __selectNext : function() {
+ if (-1 != this.currentSelectedItemIndex) {
+ this.__deselectCurrentItem();
+ }
+ if (this.currentSelectedItemIndex < this.items.length - 1) {
+ this.currentSelectedItemIndex++;
+ } else {
this.currentSelectedItemIndex = 0;
- this.__selectCurrentItem();
- },
-
- __selectByIndex : function(index) {
- if( -1 != index ){
- rf.$(this.items.eq(index)).select();
+ }
+
+ this.__selectCurrentItem();
+ },
+
+ __deselectCurrentItem : function() {
+ this.__deselectByIndex(this.currentSelectedItemIndex);
+ },
+
+ __selectCurrentItem : function() {
+ this.__selectByIndex(this.currentSelectedItemIndex);
+ },
+
+ __selectFirstItem : function() {
+ this.currentSelectedItemIndex = 0;
+ this.__selectCurrentItem();
+ },
+
+ __selectByIndex : function(index) {
+ if (-1 != index) {
+ rf.$(this.items.eq(index)).select();
+ }
+ },
+
+ __deselectByIndex : function(index) {
+ if (index > -1) {
+ rf.$(this.items.eq(index)).unselect();
+ }
+
+ },
+
+ __openGroup : function() {
+ var item = this.__getItemByIndex(this.currentSelectedItemIndex);
+ if (this.__isGroup(item)) {
+ rf.$(item).show();
+ rf.$(item).__selectFirstItem();
+ this.active = false;
+ }
+ },
+
+ __closeGroup : function() {
+ var item = this.__getItemByIndex(this.currentSelectedItemIndex);
+ if (this.__isGroup(item)) {
+ rf.$(item).__deselectCurrentItem();
+ rf.$(item).hide();
+ this.active = true;
+ }
+ },
+
+ __returnToParentMenu : function() {
+ var item = this.__getItemByIndex(this.currentSelectedItemIndex);
+ var menu;
+ menu = this.__getParentMenu() || this.__getParentMenuFromItem(item);
+ if (menu != null && this.id != rf.$(menu).id) {
+ this.hide();
+ rf.$(menu).popupElement.focus();
+ } else {
+ this.hide();
+ }
+ },
+
+ __activateMenuItem : function() {
+ var item = this.__getCurrentItem();
+ if (item) {
+ menuItemId = item.attr('id');
+ this.activateItem(menuItemId);
+ }
+ },
+
+ __getItemByIndex : function(index) {
+ if (index > -1) {
+ return this.items.eq(index);
+ } else {
+ return null;
+ }
+ },
+
+ __getCurrentItem : function() {
+ return this.__getItemByIndex(this.currentSelectedItemIndex);
+ },
+
+ __keydownHandler : function(e) {
+ var code;
+
+ if (e.keyCode) {
+ code = e.keyCode;
+ } else if (e.which) {
+ code = e.which;
+ }
+
+ activeMenu = rf.ui.MenuManager.getActiveSubMenu();
+
+ if (this.popup.isVisible()) {
+ switch (code) {
+ case rf.KEYS.DOWN:
+ e.preventDefault();
+ activeMenu.__selectNext();
+ //this.__setInputFocus();
+ break;
+
+ case rf.KEYS.UP:
+ e.preventDefault();
+ activeMenu.__selectPrev();
+ //this.__setInputFocus();
+ break;
+ case rf.KEYS.LEFT:
+ e.preventDefault();
+ activeMenu.__returnToParentMenu();
+ break;
+
+ case rf.KEYS.RIGHT:
+ e.preventDefault();
+ activeMenu.__openGroup();
+ break;
+
+ case rf.KEYS.ESC:
+ e.preventDefault();
+ activeMenu.__returnToParentMenu();
+ break;
+
+ case rf.KEYS.RETURN:
+ e.preventDefault();
+ activeMenu.__activateMenuItem();
+ //this.__setInputFocus();
+ //return false;
+ break;
}
- },
-
- __deselectByIndex : function (index) {
- if( index > -1 ){
- rf.$(this.items.eq(index)).unselect();
- }
-
- },
-
- __openGroup : function () {
- var item = this.__getItemByIndex(this.currentSelectedItemIndex);
- if (this.__isGroup(item)){
- rf.$(item).show();
- rf.$(item).__selectFirstItem();
- this.active = false;
- }
- },
-
- __closeGroup : function () {
- var item = this.__getItemByIndex(this.currentSelectedItemIndex);
- if (this.__isGroup(item)){
- rf.$(item).__deselectCurrentItem();
- rf.$(item).hide();
- this.active = true;
- }
- },
-
- __returnToParentMenu : function () {
- var item = this.__getItemByIndex(this.currentSelectedItemIndex);
- var menu;
- menu = this.__getParentMenu()||this.__getParentMenuFromItem(item);
- if (menu != null && this.id != rf.$(menu).id){
- this.hide();
- rf.$(menu).popupElement.focus();
- } else {
- this.hide();
- }
- },
-
- __activateMenuItem : function () {
- var item = this.__getCurrentItem();
- if (item){
- menuItemId=item.attr('id');
- this.activateItem(menuItemId);
- }
- },
-
- __getItemByIndex : function(index) {
- if (index > -1){
- return this.items.eq(index);
- } else{
- return null;
- }
- },
-
- __getCurrentItem : function() {
- return this.__getItemByIndex(this.currentSelectedItemIndex);
- },
-
- __keydownHandler : function (e){
- var code;
-
- if(e.keyCode) {
- code = e.keyCode;
- } else if(e.which) {
- code = e.which;
- }
-
- activeMenu=rf.ui.MenuManager.getActiveSubMenu();
-
-// console.info('__keydownHandler. this.id='+this.id+';' )
-// console.info('__keydownHandler.focId:'+document.activeElement+';
this.id:'+this.id+'; parent menu
id:'+this.__getParentMenu().attr('id'));
- if(this.popup.isVisible()) {
- switch(code) {
- case rf.KEYS.DOWN:
- e.preventDefault();
- activeMenu.__selectNext();
- //this.__setInputFocus();
- break;
-
- case rf.KEYS.UP:
- e.preventDefault();
- activeMenu.__selectPrev();
- //this.__setInputFocus();
- break;
- case rf.KEYS.LEFT:
- e.preventDefault();
- activeMenu.__returnToParentMenu();
- break;
-
- case rf.KEYS.RIGHT:
- e.preventDefault();
- activeMenu.__openGroup();
- break;
-
- case rf.KEYS.ESC:
- e.preventDefault();
- activeMenu.__returnToParentMenu();
- break;
-
- case rf.KEYS.RETURN:
- e.preventDefault();
- activeMenu.__activateMenuItem();
- //this.__setInputFocus();
- //return false;
- break;
- }
- e.stopPropagation();
- }
+ e.stopPropagation();
}
}
+ }
})(jQuery, RichFaces);
\ No newline at end of file
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menugroup.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menugroup.js 2011-01-25
14:41:20 UTC (rev 21210)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menugroup.js 2011-01-25
15:00:17 UTC (rev 21211)
@@ -3,16 +3,9 @@
var defaultOptions = {
showEvent : 'mouseenter',
showDelay : 300,
- attachToBody : false,
- positionOffset : [0, 0],
-
- selectItemCss : "rf-ddm-itm-sel",
- itemCss : "rf-ddm-itm",
- disabledItemCss : "rf-ddm-itm-dis",
- listCss : "rf-ddm-lst",
- listContainerCss : "rf-ddm-lst-bg"
+ itemCss : "rf-ddm-itm"
}
- //constructor definition
+ // constructor definition
rf.ui.MenuGroup = function(componentId, options) {
this.id = componentId;
this.options = {};
@@ -21,10 +14,10 @@
this.namespace = this.namespace || "."
+ rf.Event.createNamespace(this.name, this.id);
this.attachToDom(componentId);
-
+
rf.Event.bindById(this.id, this.options.showEvent, $.proxy(
- this.__showHandler, this), this);
-
+ this.__showHandler, this), this);
+
this.rootMenu = rf.$(this.options.rootMenuId);
this.shown = false;
@@ -53,7 +46,6 @@
}
},
hide : function() {
- var id = this.id;
var menu = this.rootMenu;
if (menu.groupList[this.id] && this.shown) {
menu.invokeEvent("grouphide", rf
@@ -78,6 +70,7 @@
},
__leaveHandler : function() {
window.clearTimeout(this.showTimeoutId);
+ this.showTimeoutId = null;
this.hideTimeoutId = window.setTimeout($.proxy(
function() {
this.hide();
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuitem.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuitem.js 2011-01-25
14:41:20 UTC (rev 21210)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuitem.js 2011-01-25
15:00:17 UTC (rev 21211)
@@ -1,88 +1,90 @@
(function($, rf) {
- rf.ui = rf.ui || {};
-
- var defaultOptions = {
- mode : "server"
- }
+ rf.ui = rf.ui || {};
- // constructor definition
+ var defaultOptions = {
+ mode : "server"
+ }
- rf.ui.MenuItem = function(componentId, options) {
- this.options = {};
+ // constructor definition
+
+ rf.ui.MenuItem = function(componentId, options) {
+ this.options = {};
$.extend(this.options, defaultOptions, options || {});
- $super.constructor.call(this, componentId);
- this.attachToDom(componentId);
- this.element = $(rf.getDomElement(componentId));
- rf.Event.bindById(this.id, 'click', this.__clickHandler, this);
- rf.Event.bindById(this.id, 'mouseenter', this.select, this);
- rf.Event.bindById(this.id, 'mouseleave', this.unselect, this);
- this.selected = false;
- };
+ $super.constructor.call(this, componentId);
+ this.attachToDom(componentId);
+ this.element = $(rf.getDomElement(componentId));
+ rf.Event.bindById(this.id, 'click', this.__clickHandler, this);
+ rf.Event.bindById(this.id, 'mouseenter', this.select, this);
+ rf.Event.bindById(this.id, 'mouseleave', this.unselect, this);
+ this.selected = false;
+ };
- rf.BaseComponent.extend(rf.ui.MenuItem);
+ rf.BaseComponent.extend(rf.ui.MenuItem);
- // define super class link
- var $super = rf.ui.MenuItem.$super;
+ // define super class link
+ var $super = rf.ui.MenuItem.$super;
- $.extend(rf.ui.MenuItem.prototype, (function() {
+ $.extend(rf.ui.MenuItem.prototype, (function() {
- return {
- name : "MenuItem",
- select : function() {
- this.element.removeClass('rf-ddm-itm-unsel');
- this.element.addClass('rf-ddm-itm-sel');
- this.selected = true;
- },
- unselect : function() {
- this.element.removeClass('rf-ddm-itm-sel');
- this.element.addClass('rf-ddm-itm-unsel');
- this.selected = false;
- },
- activate : function() {
- this.invokeEvent('click', rf.getDomElement(this.id));
- },
+ return {
+ name : "MenuItem",
+ select : function() {
+ this.element.removeClass('rf-ddm-itm-unsel');
+ this.element.addClass('rf-ddm-itm-sel');
+ this.selected = true;
+ },
+ unselect : function() {
+ this.element.removeClass('rf-ddm-itm-sel');
+ this.element.addClass('rf-ddm-itm-unsel');
+ this.selected = false;
+ },
+ activate : function() {
+ this.invokeEvent('click', rf.getDomElement(this.id));
+ },
- isSelected : function() {
- return this.selected;
- },
+ isSelected : function() {
+ return this.selected;
+ },
- __clickHandler : function (e) {
- var parentMenu = this.__getParentMenu();
- if (parentMenu) {
- parentMenu.processItem(this.element);
- }
+ __clickHandler : function(e) {
+ var parentMenu = this.__getParentMenu();
+ if (parentMenu) {
+ parentMenu.processItem(this.element);
+ }
- this.__submitForm(rf.getDomElement(this.id), e, this.options.params);
- },
+ this.__submitForm(rf.getDomElement(this.id), e,
+ this.options.params);
+ },
- /**
- *
- * @param item DOM element
- */
- __submitForm : function(item, e, params) {
- var form = this.__getParentForm(item);
- var itemId = {};
- itemId[item.id] = item.id;
- $.extend(itemId, params || {});
- if (this.options.mode == "server") {
- rf.submitForm(form, itemId);
- }
- if (this.options.mode == "ajax" &&
this.options.submitFunction) {
- this.options.submitFunction.call(this, e);
- }
- },
+ /**
+ *
+ * @param item DOM element
+ */
+ __submitForm : function(item, e, params) {
+ var form = this.__getParentForm(item);
+ var itemId = {};
+ itemId[item.id] = item.id;
+ $.extend(itemId, params || {});
+ if (this.options.mode == "server") {
+ rf.submitForm(form, itemId);
+ }
+ if (this.options.mode == "ajax" && this.options.submitFunction) {
+ this.options.submitFunction.call(this, e);
+ }
+ },
- __getParentForm : function(item) {
- return $($(item).parents("form").get(0));
- },
+ __getParentForm : function(item) {
+ return $($(item).parents("form").get(0));
+ },
- __getParentMenu : function () {
- var menu = this.element.parents('div.rf-ddm-lbl');
- if (menu && menu.length > 0) return rf.$(menu);
- else return null;
+ __getParentMenu : function() {
+ var menu = this.element.parents('div.rf-ddm-lbl');
+ if (menu && menu.length > 0)
+ return rf.$(menu);
+ else
+ return null;
+ }
+ };
+ })());
- }
- };
- })());
-
})(jQuery, RichFaces);
\ No newline at end of file
Modified:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java
===================================================================
---
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java 2011-01-25
14:41:20 UTC (rev 21210)
+++
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java 2011-01-25
15:00:17 UTC (rev 21211)
@@ -75,13 +75,11 @@
@Test
public void testAjaxClick() throws IOException, SAXException {
HtmlPage page = environment.getPage("/menuItem_ajaxMode.jsf");
- System.out.print(page.asXml());
HtmlDivision item = (HtmlDivision)
page.getElementById("form:menuItem");
assertNotNull(item);
DropDownMenuBean.setCurrent("none");
item.click();
item = (HtmlDivision) page.getElementById("form:menuItem");
- System.out.print(item.asXml());
assertNotNull(item);
assertEquals("action", DropDownMenuBean.getCurrent());
}