5
5
*/
6
6
( function ( $ ) {
7
7
8
+ // TODO take non-menubar buttons into account
8
9
$ . widget ( "ui.menubar" , {
9
10
_create : function ( ) {
10
11
var self = this ;
11
12
var items = this . element . children ( "button, a" ) ;
12
13
items . next ( "ul" ) . each ( function ( i , elm ) {
13
- $ ( elm ) . flyoutmenu ( {
14
- select : self . options . select
15
- } ) . hide ( ) . addClass ( "ui-menu-flyout" ) . keydown ( function ( event ) {
14
+ $ ( elm ) . menu ( {
15
+ select : function ( event , ui ) {
16
+ ui . item . parents ( "ul:last" ) . hide ( )
17
+ self . options . select . apply ( this , arguments ) ;
18
+ }
19
+ } ) . hide ( ) . keydown ( function ( event ) {
16
20
var menu = $ ( this ) ;
17
21
if ( menu . is ( ":hidden" ) )
18
22
return ;
@@ -54,8 +58,8 @@ $.widget("ui.menubar", {
54
58
} ,
55
59
56
60
_open : function ( event , menu ) {
57
- this . active && this . active . flyoutmenu ( "hide" ) ;
58
- this . active = menu . flyoutmenu ( " show" ) . position ( {
61
+ this . active && this . active . menu ( "closeAll" ) . hide ( ) ;
62
+ this . active = menu . show ( ) . position ( {
59
63
my : "left top" ,
60
64
at : "left bottom" ,
61
65
offset : "0 -1" ,
@@ -64,20 +68,20 @@ $.widget("ui.menubar", {
64
68
} ,
65
69
66
70
left : function ( event ) {
67
- var prev = this . active . prevAll ( ".ui-menu-flyout " ) . eq ( 0 ) ;
71
+ var prev = this . active . prevAll ( ".ui-menu" ) . eq ( 0 ) ;
68
72
if ( prev . length ) {
69
73
this . _open ( event , prev ) ;
70
74
} else {
71
- this . _open ( event , this . element . children ( ".ui-menu-flyout :last" ) ) ;
75
+ this . _open ( event , this . element . children ( ".ui-menu:last" ) ) ;
72
76
}
73
77
} ,
74
78
75
79
right : function ( event ) {
76
- var next = this . active . nextAll ( ".ui-menu-flyout " ) . eq ( 0 ) ;
80
+ var next = this . active . nextAll ( ".ui-menu" ) . eq ( 0 ) ;
77
81
if ( next . length ) {
78
82
this . _open ( event , next ) ;
79
83
} else {
80
- this . _open ( event , this . element . children ( ".ui-menu-flyout :first" ) ) ;
84
+ this . _open ( event , this . element . children ( ".ui-menu:first" ) ) ;
81
85
}
82
86
}
83
87
} ) ;
0 commit comments