@@ -37,53 +37,40 @@ $.widget( "ui.menu", {
37
37
. attr ( {
38
38
id : this . menuId ,
39
39
role : "menu"
40
- } )
41
- . bind ( "click.menu" , function ( event ) {
42
- var item = $ ( event . target ) . closest ( ".ui-menu-item:has(a)" ) ;
43
- if ( self . options . disabled ) {
44
- return false ;
45
- }
46
- if ( ! item . length ) {
47
- return ;
48
- }
40
+ } ) ;
41
+ this . element . bind ( "click.menu" , function ( event ) {
42
+ if ( self . options . disabled ) {
43
+ event . preventDefault ( ) ;
44
+ }
45
+ } ) ;
46
+ this . _bind ( {
47
+ "click .ui-menu-item:has(a)" : function ( event ) {
48
+ event . stopImmediatePropagation ( ) ;
49
+ var target = $ ( event . currentTarget ) ;
49
50
// it's possible to click an item without hovering it (#7085)
50
- if ( ! self . active || ( self . active [ 0 ] !== item [ 0 ] ) ) {
51
- self . focus ( event , item ) ;
52
- }
53
- self . select ( event ) ;
54
- } )
55
- . bind ( "mouseover.menu" , function ( event ) {
56
- if ( self . options . disabled ) {
57
- return ;
58
- }
59
- var target = $ ( event . target ) . closest ( ".ui-menu-item" ) ;
60
- if ( target . length ) {
61
- //Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
62
- target . siblings ( ) . children ( ".ui-state-active" ) . removeClass ( "ui-state-active" ) ;
63
- self . focus ( event , target ) ;
51
+ if ( ! this . active || ( this . active [ 0 ] !== target [ 0 ] ) ) {
52
+ this . focus ( event , target ) ;
64
53
}
65
- } )
66
- . bind ( "mouseout.menu" , function ( event ) {
67
- if ( self . options . disabled ) {
68
- return ;
69
- }
70
- var target = $ ( event . target ) . closest ( ".ui-menu-item" ) ;
71
- if ( target . length ) {
72
- self . blur ( event ) ;
73
- }
74
- } )
75
- . bind ( "focus.menu" , function ( event ) {
76
- if ( self . options . disabled ) {
77
- return ;
78
- }
79
- self . focus ( event , $ ( event . target ) . children ( ".ui-menu-item:first" ) ) ;
80
- } )
81
- . bind ( "blur.menu" , function ( event ) {
82
- if ( self . options . disabled ) {
83
- return ;
84
- }
85
- self . collapseAll ( event ) ;
86
- } ) ;
54
+ this . select ( event ) ;
55
+ } ,
56
+ "mouseover .ui-menu-item" : function ( event ) {
57
+ event . stopImmediatePropagation ( ) ;
58
+ var target = $ ( event . currentTarget ) ;
59
+ // Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
60
+ target . siblings ( ) . children ( ".ui-state-active" ) . removeClass ( "ui-state-active" ) ;
61
+ this . focus ( event , target ) ;
62
+ } ,
63
+ "mouseout .ui-menu-item" : function ( event ) {
64
+ this . blur ( event ) ;
65
+ } ,
66
+ "focus" : function ( event ) {
67
+ this . focus ( event , $ ( event . target ) . children ( ".ui-menu-item:first" ) ) ;
68
+ } ,
69
+ "blur" : function ( event ) {
70
+ this . collapseAll ( event ) ;
71
+ }
72
+ } ) ;
73
+
87
74
this . refresh ( ) ;
88
75
89
76
this . element . attr ( "tabIndex" , 0 ) . bind ( "keydown.menu" , function ( event ) {
0 commit comments