14
14
*/
15
15
( function ( $ , undefined ) {
16
16
17
- var uid = 0 ,
18
- hideProps = { } ,
19
- showProps = { } ;
20
-
21
- hideProps . height = hideProps . paddingTop = hideProps . paddingBottom =
22
- hideProps . borderTopWidth = hideProps . borderBottomWidth = "hide" ;
23
- showProps . height = showProps . paddingTop = showProps . paddingBottom =
24
- showProps . borderTopWidth = showProps . borderBottomWidth = "show" ;
25
-
26
17
$ . widget ( "ui.accordion" , {
27
18
version : "@VERSION" ,
28
19
options : {
@@ -42,6 +33,22 @@ $.widget( "ui.accordion", {
42
33
beforeActivate : null
43
34
} ,
44
35
36
+ hideProps : {
37
+ borderTopWidth : "hide" ,
38
+ borderBottomWidth : "hide" ,
39
+ paddingTop : "hide" ,
40
+ paddingBottom : "hide" ,
41
+ height : "hide"
42
+ } ,
43
+
44
+ showProps : {
45
+ borderTopWidth : "show" ,
46
+ borderBottomWidth : "show" ,
47
+ paddingTop : "show" ,
48
+ paddingBottom : "show" ,
49
+ height : "show"
50
+ } ,
51
+
45
52
_create : function ( ) {
46
53
var options = this . options ;
47
54
this . prevShow = this . prevHide = $ ( ) ;
@@ -99,31 +106,27 @@ $.widget( "ui.accordion", {
99
106
100
107
// clean up headers
101
108
this . headers
102
- . removeClass ( "ui-accordion-header ui-accordion-header-active ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
109
+ . removeClass ( "ui-accordion-header ui-accordion-header-active ui-state-default " +
110
+ "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
103
111
. removeAttr ( "role" )
104
112
. removeAttr ( "aria-selected" )
105
113
. removeAttr ( "aria-controls" )
106
114
. removeAttr ( "tabIndex" )
107
- . each ( function ( ) {
108
- if ( / ^ u i - a c c o r d i o n / . test ( this . id ) ) {
109
- this . removeAttribute ( "id" ) ;
110
- }
111
- } ) ;
115
+ . removeUniqueId ( ) ;
116
+
112
117
this . _destroyIcons ( ) ;
113
118
114
119
// clean up content panels
115
120
contents = this . headers . next ( )
121
+ . removeClass ( "ui-helper-reset ui-widget-content ui-corner-bottom " +
122
+ "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
116
123
. css ( "display" , "" )
117
124
. removeAttr ( "role" )
118
125
. removeAttr ( "aria-expanded" )
119
126
. removeAttr ( "aria-hidden" )
120
127
. removeAttr ( "aria-labelledby" )
121
- . removeClass ( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
122
- . each ( function ( ) {
123
- if ( / ^ u i - a c c o r d i o n / . test ( this . id ) ) {
124
- this . removeAttribute ( "id" ) ;
125
- }
126
- } ) ;
128
+ . removeUniqueId ( ) ;
129
+
127
130
if ( this . options . heightStyle !== "content" ) {
128
131
contents . css ( "height" , "" ) ;
129
132
}
@@ -259,9 +262,7 @@ $.widget( "ui.accordion", {
259
262
var maxHeight ,
260
263
options = this . options ,
261
264
heightStyle = options . heightStyle ,
262
- parent = this . element . parent ( ) ,
263
- accordionId = this . accordionId = "ui-accordion-" +
264
- ( this . element . attr ( "id" ) || ++ uid ) ;
265
+ parent = this . element . parent ( ) ;
265
266
266
267
this . active = this . _findActive ( options . active )
267
268
. addClass ( "ui-accordion-header-active ui-state-active ui-corner-top" )
@@ -272,19 +273,11 @@ $.widget( "ui.accordion", {
272
273
273
274
this . headers
274
275
. attr ( "role" , "tab" )
275
- . each ( function ( i ) {
276
+ . each ( function ( ) {
276
277
var header = $ ( this ) ,
277
- headerId = header . attr ( "id" ) ,
278
+ headerId = header . uniqueId ( ) . attr ( "id" ) ,
278
279
panel = header . next ( ) ,
279
- panelId = panel . attr ( "id" ) ;
280
- if ( ! headerId ) {
281
- headerId = accordionId + "-header-" + i ;
282
- header . attr ( "id" , headerId ) ;
283
- }
284
- if ( ! panelId ) {
285
- panelId = accordionId + "-panel-" + i ;
286
- panel . attr ( "id" , panelId ) ;
287
- }
280
+ panelId = panel . uniqueId ( ) . attr ( "id" ) ;
288
281
header . attr ( "aria-controls" , panelId ) ;
289
282
panel . attr ( "aria-labelledby" , headerId ) ;
290
283
} )
@@ -520,14 +513,14 @@ $.widget( "ui.accordion", {
520
513
duration = duration || options . duration || animate . duration ;
521
514
522
515
if ( ! toHide . length ) {
523
- return toShow . animate ( showProps , duration , easing , complete ) ;
516
+ return toShow . animate ( this . showProps , duration , easing , complete ) ;
524
517
}
525
518
if ( ! toShow . length ) {
526
- return toHide . animate ( hideProps , duration , easing , complete ) ;
519
+ return toHide . animate ( this . hideProps , duration , easing , complete ) ;
527
520
}
528
521
529
522
total = toShow . show ( ) . outerHeight ( ) ;
530
- toHide . animate ( hideProps , {
523
+ toHide . animate ( this . hideProps , {
531
524
duration : duration ,
532
525
easing : easing ,
533
526
step : function ( now , fx ) {
@@ -536,7 +529,7 @@ $.widget( "ui.accordion", {
536
529
} ) ;
537
530
toShow
538
531
. hide ( )
539
- . animate ( showProps , {
532
+ . animate ( this . showProps , {
540
533
duration : duration ,
541
534
easing : easing ,
542
535
complete : complete ,
0 commit comments