16
16
//>>css.structure: ../themes/base/accordion.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"
30
30
// Browser globals
31
31
factory ( jQuery ) ;
32
32
}
33
- } ( function ( $ ) {
33
+ } ( function ( $ ) {
34
34
35
35
return $ . widget ( "ui.accordion" , {
36
36
version : "@VERSION" ,
@@ -80,7 +80,7 @@ return $.widget( "ui.accordion", {
80
80
this . element . attr ( "role" , "tablist" ) ;
81
81
82
82
// don't allow collapsible: false and active: false / null
83
- if ( ! options . collapsible && ( options . active === false || options . active == null ) ) {
83
+ if ( ! options . collapsible && ( options . active === false || options . active == null ) ) {
84
84
options . active = 0 ;
85
85
}
86
86
@@ -200,24 +200,24 @@ return $.widget( "ui.accordion", {
200
200
toFocus = false ;
201
201
202
202
switch ( event . keyCode ) {
203
- case keyCode . RIGHT :
204
- case keyCode . DOWN :
205
- toFocus = this . headers [ ( currentIndex + 1 ) % length ] ;
206
- break ;
207
- case keyCode . LEFT :
208
- case keyCode . UP :
209
- toFocus = this . headers [ ( currentIndex - 1 + length ) % length ] ;
210
- break ;
211
- case keyCode . SPACE :
212
- case keyCode . ENTER :
213
- this . _eventHandler ( event ) ;
214
- break ;
215
- case keyCode . HOME :
216
- toFocus = this . headers [ 0 ] ;
217
- break ;
218
- case keyCode . END :
219
- toFocus = this . headers [ length - 1 ] ;
220
- break ;
203
+ case keyCode . RIGHT :
204
+ case keyCode . DOWN :
205
+ toFocus = this . headers [ ( currentIndex + 1 ) % length ] ;
206
+ break ;
207
+ case keyCode . LEFT :
208
+ case keyCode . UP :
209
+ toFocus = this . headers [ ( currentIndex - 1 + length ) % length ] ;
210
+ break ;
211
+ case keyCode . SPACE :
212
+ case keyCode . ENTER :
213
+ this . _eventHandler ( event ) ;
214
+ break ;
215
+ case keyCode . HOME :
216
+ toFocus = this . headers [ 0 ] ;
217
+ break ;
218
+ case keyCode . END :
219
+ toFocus = this . headers [ length - 1 ] ;
220
+ break ;
221
221
}
222
222
223
223
if ( toFocus ) {
@@ -248,7 +248,7 @@ return $.widget( "ui.accordion", {
248
248
// was active, but active panel is gone
249
249
} else if ( this . active . length && ! $ . contains ( this . element [ 0 ] , this . active [ 0 ] ) ) {
250
250
// all remaining panel are disabled
251
- if ( this . headers . length === this . headers . find ( ".ui-state-disabled" ) . length ) {
251
+ if ( this . headers . length === this . headers . find ( ".ui-state-disabled" ) . length ) {
252
252
options . active = false ;
253
253
this . active = $ ( ) ;
254
254
// activate previous panel
@@ -298,43 +298,43 @@ return $.widget( "ui.accordion", {
298
298
299
299
this . headers
300
300
. attr ( "role" , "tab" )
301
- . each ( function ( ) {
301
+ . each ( function ( ) {
302
302
var header = $ ( this ) ,
303
303
headerId = header . uniqueId ( ) . attr ( "id" ) ,
304
304
panel = header . next ( ) ,
305
305
panelId = panel . uniqueId ( ) . attr ( "id" ) ;
306
306
header . attr ( "aria-controls" , panelId ) ;
307
307
panel . attr ( "aria-labelledby" , headerId ) ;
308
- } )
308
+ } )
309
309
. next ( )
310
310
. attr ( "role" , "tabpanel" ) ;
311
311
312
312
this . headers
313
313
. not ( this . active )
314
- . attr ( {
315
- "aria-selected" : "false" ,
316
- "aria-expanded" : "false" ,
317
- tabIndex : - 1
318
- } )
319
- . next ( )
320
- . attr ( {
321
- "aria-hidden" : "true"
322
- } )
323
- . hide ( ) ;
314
+ . attr ( {
315
+ "aria-selected" : "false" ,
316
+ "aria-expanded" : "false" ,
317
+ tabIndex : - 1
318
+ } )
319
+ . next ( )
320
+ . attr ( {
321
+ "aria-hidden" : "true"
322
+ } )
323
+ . hide ( ) ;
324
324
325
325
// make sure at least one header is in the tab order
326
326
if ( ! this . active . length ) {
327
327
this . headers . eq ( 0 ) . attr ( "tabIndex" , 0 ) ;
328
328
} else {
329
- this . active . attr ( {
329
+ this . active . attr ( {
330
330
"aria-selected" : "true" ,
331
331
"aria-expanded" : "true" ,
332
332
tabIndex : 0
333
- } )
334
- . next ( )
335
- . attr ( {
336
- "aria-hidden" : "false"
337
- } ) ;
333
+ } )
334
+ . next ( )
335
+ . attr ( {
336
+ "aria-hidden" : "false"
337
+ } ) ;
338
338
}
339
339
340
340
this . _createIcons ( ) ;
@@ -343,32 +343,32 @@ return $.widget( "ui.accordion", {
343
343
344
344
if ( heightStyle === "fill" ) {
345
345
maxHeight = parent . height ( ) ;
346
- this . element . siblings ( ":visible" ) . each ( function ( ) {
346
+ this . element . siblings ( ":visible" ) . each ( function ( ) {
347
347
var elem = $ ( this ) ,
348
348
position = elem . css ( "position" ) ;
349
349
350
350
if ( position === "absolute" || position === "fixed" ) {
351
351
return ;
352
352
}
353
353
maxHeight -= elem . outerHeight ( true ) ;
354
- } ) ;
354
+ } ) ;
355
355
356
- this . headers . each ( function ( ) {
356
+ this . headers . each ( function ( ) {
357
357
maxHeight -= $ ( this ) . outerHeight ( true ) ;
358
- } ) ;
358
+ } ) ;
359
359
360
360
this . headers . next ( )
361
- . each ( function ( ) {
361
+ . each ( function ( ) {
362
362
$ ( this ) . height ( Math . max ( 0 , maxHeight -
363
363
$ ( this ) . innerHeight ( ) + $ ( this ) . height ( ) ) ) ;
364
- } )
364
+ } )
365
365
. css ( "overflow" , "auto" ) ;
366
366
} else if ( heightStyle === "auto" ) {
367
367
maxHeight = 0 ;
368
368
this . headers . next ( )
369
- . each ( function ( ) {
369
+ . each ( function ( ) {
370
370
maxHeight = Math . max ( maxHeight , $ ( this ) . css ( "height" , "" ) . height ( ) ) ;
371
- } )
371
+ } )
372
372
. height ( maxHeight ) ;
373
373
}
374
374
} ,
@@ -384,11 +384,11 @@ return $.widget( "ui.accordion", {
384
384
// trying to collapse, simulate a click on the currently active header
385
385
active = active || this . active [ 0 ] ;
386
386
387
- this . _eventHandler ( {
387
+ this . _eventHandler ( {
388
388
target : active ,
389
389
currentTarget : active ,
390
390
preventDefault : $ . noop
391
- } ) ;
391
+ } ) ;
392
392
} ,
393
393
394
394
_findActive : function ( selector ) {
@@ -402,12 +402,12 @@ return $.widget( "ui.accordion", {
402
402
if ( event ) {
403
403
$ . each ( event . split ( " " ) , function ( index , eventName ) {
404
404
events [ eventName ] = "_eventHandler" ;
405
- } ) ;
405
+ } ) ;
406
406
}
407
407
408
408
this . _off ( this . headers . add ( this . headers . next ( ) ) ) ;
409
409
this . _on ( this . headers , events ) ;
410
- this . _on ( this . headers . next ( ) , { keydown : "_panelKeyDown" } ) ;
410
+ this . _on ( this . headers . next ( ) , { keydown : "_panelKeyDown" } ) ;
411
411
this . _hoverable ( this . headers ) ;
412
412
this . _focusable ( this . headers ) ;
413
413
} ,
@@ -484,36 +484,36 @@ return $.widget( "ui.accordion", {
484
484
this . _toggleComplete ( data ) ;
485
485
}
486
486
487
- toHide . attr ( {
487
+ toHide . attr ( {
488
488
"aria-hidden" : "true"
489
- } ) ;
490
- toHide . prev ( ) . attr ( {
489
+ } ) ;
490
+ toHide . prev ( ) . attr ( {
491
491
"aria-selected" : "false" ,
492
492
"aria-expanded" : "false"
493
- } ) ;
493
+ } ) ;
494
494
// if we're switching panels, remove the old header from the tab order
495
495
// if we're opening from collapsed state, remove the previous header from the tab order
496
496
// if we're collapsing, then keep the collapsing header in the tab order
497
497
if ( toShow . length && toHide . length ) {
498
- toHide . prev ( ) . attr ( {
498
+ toHide . prev ( ) . attr ( {
499
499
"tabIndex" : - 1 ,
500
500
"aria-expanded" : "false"
501
- } ) ;
501
+ } ) ;
502
502
} else if ( toShow . length ) {
503
- this . headers . filter ( function ( ) {
503
+ this . headers . filter ( function ( ) {
504
504
return parseInt ( $ ( this ) . attr ( "tabIndex" ) , 10 ) === 0 ;
505
- } )
506
- . attr ( "tabIndex" , - 1 ) ;
505
+ } )
506
+ . attr ( "tabIndex" , - 1 ) ;
507
507
}
508
508
509
509
toShow
510
510
. attr ( "aria-hidden" , "false" )
511
511
. prev ( )
512
- . attr ( {
512
+ . attr ( {
513
513
"aria-selected" : "true" ,
514
514
"aria-expanded" : "true" ,
515
515
tabIndex : 0
516
- } ) ;
516
+ } ) ;
517
517
} ,
518
518
519
519
_animate : function ( toShow , toHide , data ) {
@@ -553,7 +553,7 @@ return $.widget( "ui.accordion", {
553
553
step : function ( now , fx ) {
554
554
fx . now = Math . round ( now ) ;
555
555
}
556
- } ) ;
556
+ } ) ;
557
557
toShow
558
558
. hide ( )
559
559
. animate ( this . showProps , {
@@ -571,7 +571,7 @@ return $.widget( "ui.accordion", {
571
571
adjust = 0 ;
572
572
}
573
573
}
574
- } ) ;
574
+ } ) ;
575
575
} ,
576
576
577
577
_toggleComplete : function ( data ) {
@@ -588,6 +588,6 @@ return $.widget( "ui.accordion", {
588
588
}
589
589
this . _trigger ( "activate" , null , data ) ;
590
590
}
591
- } ) ;
591
+ } ) ;
592
592
593
- } ) ) ;
593
+ } ) ) ;
0 commit comments