aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.menu.js
diff options
context:
space:
mode:
authorkborchers <k_borchers@yahoo.com>2011-09-12 08:43:49 -0500
committerkborchers <k_borchers@yahoo.com>2011-09-12 08:43:49 -0500
commit94317d7aa4ed439cb825d006fb461145a6d2aa5d (patch)
treebd9a5293b9b4e92ef0739e4789b32e8417e370bf /ui/jquery.ui.menu.js
parent38028f6de1ae1bb34a30d04cacab5d49a1433e7a (diff)
downloadjquery-ui-94317d7aa4ed439cb825d006fb461145a6d2aa5d.tar.gz
jquery-ui-94317d7aa4ed439cb825d006fb461145a6d2aa5d.zip
Menu: Added autoCollapse as the default and added a unit test
Diffstat (limited to 'ui/jquery.ui.menu.js')
-rw-r--r--ui/jquery.ui.menu.js45
1 files changed, 29 insertions, 16 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 27e76d909..549eb5fae 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -62,6 +62,8 @@ $.widget( "ui.menu", {
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
this.focus( event, target );
},
+ "mouseleave": "_mouseleave",
+ "mouseleave .ui-menu": "_mouseleave",
"mouseout .ui-menu-item": "blur",
"focus": function( event ) {
this.focus( event, $( event.target ).children( ".ui-menu-item:first" ) );
@@ -346,21 +348,30 @@ $.widget( "ui.menu", {
},
collapseAll: function( event ) {
- this.element
- .find( "ul" )
- .hide()
- .attr( "aria-hidden", "true" )
- .attr( "aria-expanded", "false" )
- .end()
- .find( "a.ui-state-active" )
- .removeClass( "ui-state-active" );
+ var currentMenu = false;
+ if ( event ) {
+ var target = $( event.target );
+ if ( target.is( "ui.menu" ) ) {
+ currentMenu = target;
+ } else if ( target.closest( ".ui-menu" ).length ) {
+ currentMenu = target.closest( ".ui-menu" );
+ }
+ }
- this.blur( event );
- this.activeMenu = this.element;
+ this._close( currentMenu );
+
+ if( !currentMenu ) {
+ this.blur( event );
+ this.activeMenu = this.element;
+ }
},
- _close: function() {
- this.active.parent()
+ _close: function( startMenu ) {
+ if( !startMenu ) {
+ startMenu = this.active ? this.active.parent() : this.element;
+ }
+
+ startMenu
.find( "ul" )
.hide()
.attr( "aria-hidden", "true" )
@@ -373,10 +384,7 @@ $.widget( "ui.menu", {
collapse: function( event ) {
var newItem = this.active && this.active.parents("li:not(.ui-menubar-item)").first();
if ( newItem && newItem.length ) {
- this.active.parent()
- .attr("aria-hidden", "true")
- .attr("aria-expanded", "false")
- .hide();
+ this._close();
this.focus( event, newItem );
return true;
}
@@ -486,6 +494,11 @@ $.widget( "ui.menu", {
return this.element.height() < this.element.prop( "scrollHeight" );
},
+ _mouseleave: function( event ) {
+ this.collapseAll( event );
+ this.blur();
+ },
+
select: function( event ) {
// save active reference before collapseAll triggers blur
var ui = {