16
16
//>>css.structure: ../themes/base/menu.css
17
17
//>>css.theme: ../themes/base/theme.css
18
18
19
- ( function ( factory ) {
19
+ ( function ( factory ) {
20
20
if ( typeof define === "function" && define . amd ) {
21
21
22
22
// AMD. Register as an anonymous module.
23
- define ( [
23
+ define ( [
24
24
"jquery" ,
25
25
"./core" ,
26
26
"./widget" ,
31
31
// Browser globals
32
32
factory ( jQuery ) ;
33
33
}
34
- } ( function ( $ ) {
34
+ } ( function ( $ ) {
35
35
36
36
return $ . widget ( "ui.menu" , {
37
37
version : "@VERSION" ,
@@ -64,18 +64,18 @@ return $.widget( "ui.menu", {
64
64
this . mouseHandled = false ;
65
65
this . element
66
66
. uniqueId ( )
67
- . attr ( {
67
+ . attr ( {
68
68
role : this . options . role ,
69
69
tabIndex : 0
70
- } ) ;
70
+ } ) ;
71
71
72
72
if ( this . options . disabled ) {
73
73
this . _addClass ( null , "ui-state-disabled" ) ;
74
74
this . element . attr ( "aria-disabled" , "true" ) ;
75
75
}
76
76
77
77
this . _addClass ( "ui-menu" , "ui-widget ui-widget-content" ) ;
78
- this . _on ( {
78
+ this . _on ( {
79
79
80
80
// Prevent focus from sticking to links inside menu after clicking
81
81
// them (focus should always stay on UL during navigation).
@@ -134,14 +134,14 @@ return $.widget( "ui.menu", {
134
134
}
135
135
} ,
136
136
blur : function ( event ) {
137
- this . _delay ( function ( ) {
138
- if ( ! $ . contains ( this . element [ 0 ] , $ . ui . safeActiveElement ( this . document [ 0 ] ) ) ) {
137
+ this . _delay ( function ( ) {
138
+ if ( ! $ . contains ( this . element [ 0 ] , $ . ui . safeActiveElement ( this . document [ 0 ] ) ) ) {
139
139
this . collapseAll ( event ) ;
140
140
}
141
- } ) ;
141
+ } ) ;
142
142
} ,
143
143
keydown : "_keydown"
144
- } ) ;
144
+ } ) ;
145
145
146
146
this . refresh ( ) ;
147
147
@@ -155,7 +155,7 @@ return $.widget( "ui.menu", {
155
155
// Reset the mouseHandled flag
156
156
this . mouseHandled = false ;
157
157
}
158
- } ) ;
158
+ } ) ;
159
159
} ,
160
160
161
161
_destroy : function ( ) {
@@ -181,12 +181,12 @@ return $.widget( "ui.menu", {
181
181
. removeUniqueId ( )
182
182
. show ( ) ;
183
183
184
- submenus . children ( ) . each ( function ( ) {
184
+ submenus . children ( ) . each ( function ( ) {
185
185
var elem = $ ( this ) ;
186
186
if ( elem . data ( "ui-menu-submenu-caret" ) ) {
187
187
elem . remove ( ) ;
188
188
}
189
- } ) ;
189
+ } ) ;
190
190
} ,
191
191
192
192
_keydown : function ( event ) {
@@ -256,7 +256,7 @@ return $.widget( "ui.menu", {
256
256
if ( match . length ) {
257
257
this . focus ( event , match ) ;
258
258
this . previousFilter = character ;
259
- this . filterTimer = this . _delay ( function ( ) {
259
+ this . filterTimer = this . _delay ( function ( ) {
260
260
delete this . previousFilter ;
261
261
} , 1000 ) ;
262
262
} else {
@@ -290,12 +290,12 @@ return $.widget( "ui.menu", {
290
290
// Initialize nested menus
291
291
newSubmenus = submenus . filter ( ":not(.ui-menu)" )
292
292
. hide ( )
293
- . attr ( {
293
+ . attr ( {
294
294
role : this . options . role ,
295
295
"aria-hidden" : "true" ,
296
296
"aria-expanded" : "false"
297
- } )
298
- . each ( function ( ) {
297
+ } )
298
+ . each ( function ( ) {
299
299
var menu = $ ( this ) ,
300
300
item = menu . prev ( ) ,
301
301
submenuCaret = $ ( "<span>" ) . data ( "ui-menu-submenu-caret" , true ) ;
@@ -305,30 +305,30 @@ return $.widget( "ui.menu", {
305
305
. attr ( "aria-haspopup" , "true" )
306
306
. prepend ( submenuCaret ) ;
307
307
menu . attr ( "aria-labelledby" , item . attr ( "id" ) ) ;
308
- } ) ;
308
+ } ) ;
309
309
310
310
this . _addClass ( newSubmenus , "ui-menu" , "ui-widget ui-widget-content ui-front" ) ;
311
311
312
312
menus = submenus . add ( this . element ) ;
313
313
items = menus . find ( this . options . items ) ;
314
314
315
315
// Initialize menu-items containing spaces and/or dashes only as dividers
316
- items . not ( ".ui-menu-item" ) . each ( function ( ) {
316
+ items . not ( ".ui-menu-item" ) . each ( function ( ) {
317
317
var item = $ ( this ) ;
318
318
if ( that . _isDivider ( item ) ) {
319
319
that . _addClass ( item , "ui-menu-divider" , "ui-widget-content" ) ;
320
320
}
321
- } ) ;
321
+ } ) ;
322
322
323
323
// Don't refresh list items that are already adapted
324
324
newItems = items . not ( ".ui-menu-item, .ui-menu-divider" ) ;
325
325
newWrappers = newItems . children ( )
326
326
. not ( ".ui-menu" )
327
327
. uniqueId ( )
328
- . attr ( {
328
+ . attr ( {
329
329
tabIndex : - 1 ,
330
330
role : this . _itemRole ( )
331
- } ) ;
331
+ } ) ;
332
332
this . _addClass ( newItems , "ui-menu-item" )
333
333
. _addClass ( newWrappers , "ui-menu-item-wrapper" ) ;
334
334
@@ -388,14 +388,14 @@ return $.widget( "ui.menu", {
388
388
if ( event && event . type === "keydown" ) {
389
389
this . _close ( ) ;
390
390
} else {
391
- this . timer = this . _delay ( function ( ) {
391
+ this . timer = this . _delay ( function ( ) {
392
392
this . _close ( ) ;
393
393
} , this . delay ) ;
394
394
}
395
395
396
396
nested = item . children ( ".ui-menu" ) ;
397
397
if ( nested . length && event && ( / ^ m o u s e / . test ( event . type ) ) ) {
398
- this . _startOpening ( nested ) ;
398
+ this . _startOpening ( nested ) ;
399
399
}
400
400
this . activeMenu = item . parent ( ) ;
401
401
@@ -405,8 +405,8 @@ return $.widget( "ui.menu", {
405
405
_scrollIntoView : function ( item ) {
406
406
var borderTop , paddingTop , offset , scroll , elementHeight , itemHeight ;
407
407
if ( this . _hasScroll ( ) ) {
408
- borderTop = parseFloat ( $ . css ( this . activeMenu [ 0 ] , "borderTopWidth" ) ) || 0 ;
409
- paddingTop = parseFloat ( $ . css ( this . activeMenu [ 0 ] , "paddingTop" ) ) || 0 ;
408
+ borderTop = parseFloat ( $ . css ( this . activeMenu [ 0 ] , "borderTopWidth" ) ) || 0 ;
409
+ paddingTop = parseFloat ( $ . css ( this . activeMenu [ 0 ] , "paddingTop" ) ) || 0 ;
410
410
offset = item . offset ( ) . top - this . activeMenu . offset ( ) . top - borderTop - paddingTop ;
411
411
scroll = this . activeMenu . scrollTop ( ) ;
412
412
elementHeight = this . activeMenu . height ( ) ;
@@ -445,14 +445,14 @@ return $.widget( "ui.menu", {
445
445
return ;
446
446
}
447
447
448
- this . timer = this . _delay ( function ( ) {
448
+ this . timer = this . _delay ( function ( ) {
449
449
this . _close ( ) ;
450
450
this . _open ( submenu ) ;
451
451
} , this . delay ) ;
452
452
} ,
453
453
454
454
_open : function ( submenu ) {
455
- var position = $ . extend ( {
455
+ var position = $ . extend ( {
456
456
of : this . active
457
457
} , this . options . position ) ;
458
458
@@ -470,7 +470,7 @@ return $.widget( "ui.menu", {
470
470
471
471
collapseAll : function ( event , all ) {
472
472
clearTimeout ( this . timer ) ;
473
- this . timer = this . _delay ( function ( ) {
473
+ this . timer = this . _delay ( function ( ) {
474
474
// If we were passed an event, look for the submenu that contains the event
475
475
var currentMenu = all ? this . element :
476
476
$ ( event && event . target ) . closest ( this . element . find ( ".ui-menu" ) ) ;
@@ -527,16 +527,16 @@ return $.widget( "ui.menu", {
527
527
var newItem = this . active &&
528
528
this . active
529
529
. children ( ".ui-menu " )
530
- . find ( this . options . items )
531
- . first ( ) ;
530
+ . find ( this . options . items )
531
+ . first ( ) ;
532
532
533
533
if ( newItem && newItem . length ) {
534
534
this . _open ( newItem . parent ( ) ) ;
535
535
536
536
// Delay so Firefox will not hide activedescendant change in expanding submenu from AT
537
- this . _delay ( function ( ) {
537
+ this . _delay ( function ( ) {
538
538
this . focus ( event , newItem ) ;
539
- } ) ;
539
+ } ) ;
540
540
}
541
541
} ,
542
542
@@ -589,10 +589,10 @@ return $.widget( "ui.menu", {
589
589
if ( this . _hasScroll ( ) ) {
590
590
base = this . active . offset ( ) . top ;
591
591
height = this . element . height ( ) ;
592
- this . active . nextAll ( ".ui-menu-item" ) . each ( function ( ) {
592
+ this . active . nextAll ( ".ui-menu-item" ) . each ( function ( ) {
593
593
item = $ ( this ) ;
594
594
return item . offset ( ) . top - base - height < 0 ;
595
- } ) ;
595
+ } ) ;
596
596
597
597
this . focus ( event , item ) ;
598
598
} else {
@@ -613,10 +613,10 @@ return $.widget( "ui.menu", {
613
613
if ( this . _hasScroll ( ) ) {
614
614
base = this . active . offset ( ) . top ;
615
615
height = this . element . height ( ) ;
616
- this . active . prevAll ( ".ui-menu-item" ) . each ( function ( ) {
616
+ this . active . prevAll ( ".ui-menu-item" ) . each ( function ( ) {
617
617
item = $ ( this ) ;
618
618
return item . offset ( ) . top - base + height > 0 ;
619
- } ) ;
619
+ } ) ;
620
620
621
621
this . focus ( event , item ) ;
622
622
} else {
@@ -646,13 +646,13 @@ return $.widget( "ui.menu", {
646
646
return this . activeMenu
647
647
. find ( this . options . items )
648
648
649
- // Only match on items, not dividers or other content (#10571)
650
- . filter ( ".ui-menu-item" )
651
- . filter ( function ( ) {
652
- return regex . test (
653
- $ . trim ( $ ( this ) . children ( ".ui-menu-item-wrapper" ) . text ( ) ) ) ;
654
- } ) ;
649
+ // Only match on items, not dividers or other content (#10571)
650
+ . filter ( ".ui-menu-item" )
651
+ . filter ( function ( ) {
652
+ return regex . test (
653
+ $ . trim ( $ ( this ) . children ( ".ui-menu-item-wrapper" ) . text ( ) ) ) ;
654
+ } ) ;
655
655
}
656
- } ) ;
656
+ } ) ;
657
657
658
- } ) ) ;
658
+ } ) ) ;
0 commit comments