Skip to content

Commit 954419f

Browse files
committed
Merge remote branch 'kborchers/menubar-autoExpand'
2 parents 0245b72 + 40aa8f5 commit 954419f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

demos/menubar/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
});
2424

2525
$(".menubar-icons").menubar({
26+
autoExpand: true,
2627
menuIcon: true,
2728
buttons: true,
2829
position: {

ui/jquery.ui.menubar.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
$.widget( "ui.menubar", {
2121
version: "@VERSION",
2222
options: {
23+
autoExpand: false,
2324
buttons: false,
2425
menuIcon: false,
2526
position: {
@@ -89,7 +90,11 @@ $.widget( "ui.menubar", {
8990
that._close();
9091
return;
9192
}
92-
if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" ) {
93+
if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" || that.options.autoExpand ) {
94+
if( that.options.autoExpand ) {
95+
clearTimeout( that.timer );
96+
}
97+
9398
that._open( event, menu );
9499
}
95100
})
@@ -115,6 +120,22 @@ $.widget( "ui.menubar", {
115120
.attr( "role", "menuitem" )
116121
.attr( "aria-haspopup", "true" )
117122
.wrapInner( "<span class='ui-button-text'></span>" );
123+
124+
if ( that.options.autoExpand ) {
125+
input.bind( "mouseleave.menubar", function( event ) {
126+
that.timer = setTimeout( function() {
127+
that._close();
128+
}, 150 );
129+
});
130+
menu.bind( "mouseleave.menubar", function( event ) {
131+
that.timer = setTimeout( function() {
132+
that._close();
133+
}, 150 );
134+
})
135+
.bind( "mouseenter.menubar", function( event ) {
136+
clearTimeout( that.timer );
137+
});
138+
}
118139

119140
// TODO review if these options are a good choice, maybe they can be merged
120141
if ( that.options.menuIcon ) {

0 commit comments

Comments
 (0)