Skip to content
Permalink
Browse files

Menubar: moved mouseleave _bind call into existing _bind block, added…

… the mouseenter binding back in to help with accidental quick mouseouts causing the menu to close and use same close time for all
  • Loading branch information
fx authored and kborchers committed Oct 1, 2011
1 parent 5dcaacc commit 8d09f750a45823f7499672076eed5b19a823e309
Showing with 12 additions and 11 deletions.
  1. +12 −11 ui/jquery.ui.menubar.js
@@ -94,7 +94,7 @@ $.widget( "ui.menubar", {
}
if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" || that.options.autoExpand ) {
if( that.options.autoExpand ) {
clearTimeout( that.timer );
clearTimeout( that.closeTimer );
}

that._open( event, menu );
@@ -150,18 +150,19 @@ $.widget( "ui.menubar", {
focusout: function( event ) {
that.closeTimer = setTimeout( function() {
that._close( event );
}, 100);
}, 150);
},
"mouseleave .ui-menubar-item": function( event ) {
if ( that.options.autoExpand ) {
that.closeTimer = setTimeout( function() {
that._close( event );
}, 150);
}
},
"mouseenter .ui-menubar-item": function( event ) {
clearTimeout( that.closeTimer );
}

This comment has been minimized.

Copy link
@fx

fx Oct 1, 2011

Author Contributor

Why did you use .ui-menubar-item here? It's binding to the parent element, which is the .ui-menubar-item, so this is kinda redundant.

This comment has been minimized.

Copy link
@kborchers

kborchers Oct 1, 2011

Member

Actually "that" is the Menubar (the UL) in this case so it is .ui-menubar which when tested, if you mouse out of the right side of the "View" item in http://view.jqueryui.com/master/demos/menubar/default.html, the menu did not close with your method because technically you were still inside of the menubar but we want it to close.

This comment has been minimized.

Copy link
@fx

fx Oct 1, 2011

Author Contributor

Good spot - "that" seems to be a common reference to "this" around jQuery. I need to keep that in mind. Good job and congrats on your first pull request merge :)

});
if ( that.options.autoExpand ) {
that._bind( {
"mouseleave .ui-menubar-item": function( event ) {
that.timer = setTimeout( function() {
that._close();
}, 150 );
}
});
}
},

_destroy : function() {

0 comments on commit 8d09f75

Please sign in to comment.
You can’t perform that action at this time.