1
- /*
2
- * accordion_core.js
3
- */
4
-
5
-
6
- ( function ( $ ) {
7
-
8
- module ( "accordion (deprecated): expanded active option, activate method" , accordionSetupTeardown ( ) ) ;
9
-
10
- test ( "activate" , function ( ) {
11
- var expected = $ ( '#list1' ) . accordion ( ) ,
12
- actual = expected . accordion ( 'activate' , 2 ) ;
13
- equals ( actual , expected , 'activate is chainable' ) ;
14
- } ) ;
15
-
16
- test ( "activate, numeric" , function ( ) {
17
- var ac = $ ( '#list1' ) . accordion ( { active : 1 } ) ;
18
- state ( ac , 0 , 1 , 0 ) ;
19
- ac . accordion ( "activate" , 2 ) ;
20
- state ( ac , 0 , 0 , 1 ) ;
21
- ac . accordion ( "activate" , 0 ) ;
22
- state ( ac , 1 , 0 , 0 ) ;
23
- ac . accordion ( "activate" , 1 ) ;
24
- state ( ac , 0 , 1 , 0 ) ;
25
- ac . accordion ( "activate" , 2 ) ;
26
- state ( ac , 0 , 0 , 1 ) ;
27
- } ) ;
28
-
29
- test ( "activate, boolean and numeric, collapsible:true" , function ( ) {
30
- var ac = $ ( '#list1' ) . accordion ( { collapsible : true } ) . accordion ( "activate" , 2 ) ;
31
- state ( ac , 0 , 0 , 1 ) ;
32
- ok ( "x" , "----" ) ;
33
- ac . accordion ( "activate" , 0 ) ;
34
- state ( ac , 1 , 0 , 0 ) ;
35
- ok ( "x" , "----" ) ;
36
- ac . accordion ( "activate" , - 1 ) ;
37
- state ( ac , 0 , 0 , 0 ) ;
38
- } ) ;
39
-
40
- test ( "activate, boolean, collapsible: false" , function ( ) {
41
- var ac = $ ( '#list1' ) . accordion ( ) . accordion ( "activate" , 2 ) ;
42
- state ( ac , 0 , 0 , 1 ) ;
43
- ac . accordion ( "activate" , false ) ;
44
- state ( ac , 0 , 0 , 1 ) ;
45
- } ) ;
46
-
47
- test ( "activate, string expression" , function ( ) {
48
- var ac = $ ( '#list1' ) . accordion ( { active : "h3:last" } ) ;
49
- state ( ac , 0 , 0 , 1 ) ;
50
- ac . accordion ( "activate" , ":first" ) ;
51
- state ( ac , 1 , 0 , 0 ) ;
52
- ac . accordion ( "activate" , ":eq(1)" ) ;
53
- state ( ac , 0 , 1 , 0 ) ;
54
- ac . accordion ( "activate" , ":last" ) ;
55
- state ( ac , 0 , 0 , 1 ) ;
56
- } ) ;
57
-
58
- test ( "activate, jQuery or DOM element" , function ( ) {
59
- var ac = $ ( '#list1' ) . accordion ( { active : $ ( "#list1 h3:last" ) } ) ;
60
- state ( ac , 0 , 0 , 1 ) ;
61
- ac . accordion ( "activate" , $ ( "#list1 h3:first" ) ) ;
62
- state ( ac , 1 , 0 , 0 ) ;
63
- ac . accordion ( "activate" , $ ( "#list1 h3" ) [ 1 ] ) ;
64
- state ( ac , 0 , 1 , 0 ) ;
65
- } ) ;
66
-
67
- test ( "{ active: Selector }" , function ( ) {
1
+ ( function ( $ ) {
2
+
3
+ module ( "accordion (deprecated): expanded active option, activate method" , accordionSetupTeardown ( ) ) ;
4
+
5
+ test ( "activate, numeric" , function ( ) {
6
+ var ac = $ ( "#list1" ) . accordion ( { active : 1 } ) ;
7
+ state ( ac , 0 , 1 , 0 ) ;
8
+ ac . accordion ( "activate" , 2 ) ;
9
+ state ( ac , 0 , 0 , 1 ) ;
10
+ ac . accordion ( "activate" , 0 ) ;
11
+ state ( ac , 1 , 0 , 0 ) ;
12
+ ac . accordion ( "activate" , 1 ) ;
13
+ state ( ac , 0 , 1 , 0 ) ;
14
+ ac . accordion ( "activate" , 2 ) ;
15
+ state ( ac , 0 , 0 , 1 ) ;
16
+ } ) ;
17
+
18
+ test ( "activate, numeric, collapsible:true" , function ( ) {
19
+ var ac = $ ( "#list1" ) . accordion ( { collapsible : true } ) ;
20
+ ac . accordion ( "activate" , 2 ) ;
21
+ state ( ac , 0 , 0 , 1 ) ;
22
+ ac . accordion ( "activate" , 0 ) ;
23
+ state ( ac , 1 , 0 , 0 ) ;
24
+ ac . accordion ( "activate" , - 1 ) ;
25
+ state ( ac , 0 , 0 , 0 ) ;
26
+ } ) ;
27
+
28
+ test ( "activate, boolean, collapsible: true" , function ( ) {
29
+ var ac = $ ( "#list1" ) . accordion ( { collapsible : true } ) ;
30
+ ac . accordion ( "activate" , 2 ) ;
31
+ state ( ac , 0 , 0 , 1 ) ;
32
+ ac . accordion ( "activate" , false ) ;
33
+ state ( ac , 0 , 0 , 0 ) ;
34
+ } ) ;
35
+
36
+ test ( "activate, boolean, collapsible: false" , function ( ) {
37
+ var ac = $ ( "#list1" ) . accordion ( ) ;
38
+ ac . accordion ( "activate" , 2 ) ;
39
+ state ( ac , 0 , 0 , 1 ) ;
40
+ ac . accordion ( "activate" , false ) ;
41
+ state ( ac , 0 , 0 , 1 ) ;
42
+ } ) ;
43
+
44
+ test ( "activate, string expression" , function ( ) {
45
+ var ac = $ ( "#list1" ) . accordion ( { active : "h3:last" } ) ;
46
+ state ( ac , 0 , 0 , 1 ) ;
47
+ ac . accordion ( "activate" , ":first" ) ;
48
+ state ( ac , 1 , 0 , 0 ) ;
49
+ ac . accordion ( "activate" , ":eq(1)" ) ;
50
+ state ( ac , 0 , 1 , 0 ) ;
51
+ ac . accordion ( "activate" , ":last" ) ;
52
+ state ( ac , 0 , 0 , 1 ) ;
53
+ } ) ;
54
+
55
+ test ( "activate, jQuery or DOM element" , function ( ) {
56
+ var ac = $ ( "#list1" ) . accordion ( { active : $ ( "#list1 h3:last" ) } ) ;
57
+ state ( ac , 0 , 0 , 1 ) ;
58
+ ac . accordion ( "activate" , $ ( "#list1 h3:first" ) ) ;
59
+ state ( ac , 1 , 0 , 0 ) ;
60
+ ac . accordion ( "activate" , $ ( "#list1 h3" ) [ 1 ] ) ;
61
+ state ( ac , 0 , 1 , 0 ) ;
62
+ } ) ;
63
+
64
+ test ( "{ active: Selector }" , function ( ) {
68
65
var ac = $ ( "#list1" ) . accordion ( {
69
66
active : "h3:last"
70
67
} ) ;
71
- state ( ac , 0 , 0 , 1 ) ;
72
- ac . accordion ( ' option' , ' active' , "h3:eq(1)" ) ;
73
- state ( ac , 0 , 1 , 0 ) ;
68
+ state ( ac , 0 , 0 , 1 ) ;
69
+ ac . accordion ( " option" , " active" , "h3:eq(1)" ) ;
70
+ state ( ac , 0 , 1 , 0 ) ;
74
71
} ) ;
75
72
76
- test ( "{ active: Element }" , function ( ) {
77
- var ac = $ ( "#list1" ) . accordion ( {
78
- active : $ ( "#list1 h3:last" ) [ 0 ]
73
+ test ( "{ active: Element }" , function ( ) {
74
+ var ac = $ ( "#list1" ) . accordion ( {
75
+ active : $ ( "#list1 h3:last" ) [ 0 ]
79
76
} ) ;
80
- state ( ac , 0 , 0 , 1 ) ;
81
- ac . accordion ( ' option' , ' active' , $ ( "#list1 h3:eq(1)" ) [ 0 ] ) ;
82
- state ( ac , 0 , 1 , 0 ) ;
77
+ state ( ac , 0 , 0 , 1 ) ;
78
+ ac . accordion ( " option" , " active" , $ ( "#list1 h3:eq(1)" ) [ 0 ] ) ;
79
+ state ( ac , 0 , 1 , 0 ) ;
83
80
} ) ;
84
81
85
- test ( "{ active: jQuery Object }" , function ( ) {
86
- var ac = $ ( "#list1" ) . accordion ( {
87
- active : $ ( "#list1 h3:last" )
82
+ test ( "{ active: jQuery Object }" , function ( ) {
83
+ var ac = $ ( "#list1" ) . accordion ( {
84
+ active : $ ( "#list1 h3:last" )
88
85
} ) ;
89
- state ( ac , 0 , 0 , 1 ) ;
90
- ac . accordion ( ' option' , ' active' , $ ( "#list1 h3:eq(1)" ) ) ;
91
- state ( ac , 0 , 1 , 0 ) ;
86
+ state ( ac , 0 , 0 , 1 ) ;
87
+ ac . accordion ( " option" , " active" , $ ( "#list1 h3:eq(1)" ) ) ;
88
+ state ( ac , 0 , 1 , 0 ) ;
92
89
} ) ;
93
90
94
91
95
92
96
93
97
94
95
+ module ( "accordion (deprecated) - height options" , accordionSetupTeardown ( ) ) ;
98
96
99
- module ( "accordion (deprecated) - height options" , accordionSetupTeardown ( ) ) ;
100
-
101
- test ( "{ autoHeight: true }, default" , function ( ) {
97
+ test ( "{ autoHeight: true }, default" , function ( ) {
102
98
equalHeights ( $ ( '#navigation' ) . accordion ( { autoHeight : true } ) , 95 , 130 ) ;
103
99
} ) ;
104
100
@@ -113,42 +109,67 @@ test("{ autoHeight: false }", function() {
113
109
ok ( sizes [ 2 ] >= 42 && sizes [ 2 ] <= 54 , "was " + sizes [ 2 ] ) ;
114
110
} ) ;
115
111
116
- // fillSpace: false == autoHeight: true, covered above
117
- test ( "{ fillSpace: true }" , function ( ) {
118
- $ ( "#navigationWrapper" ) . height ( 500 ) ;
119
- equalHeights ( $ ( '#navigation' ) . accordion ( { fillSpace : true } ) , 446 , 458 ) ;
120
- } ) ;
121
-
122
- test ( "{ fillSpace: true } with sibling" , function ( ) {
123
- $ ( "#navigationWrapper" ) . height ( 500 ) ;
124
- var sibling = $ ( "<p>Lorem Ipsum</p>" ) ;
125
- $ ( "#navigationWrapper" ) . prepend ( sibling . height ( 100 ) ) ;
126
- //sibling.outerHeight(true) == 126
127
- equalHeights ( $ ( '#navigation' ) . accordion ( { fillSpace : true } ) , 320 , 332 ) ;
128
- } ) ;
129
-
130
- test ( "{ fillSpace: true } with multiple siblings" , function ( ) {
131
- $ ( "#navigationWrapper" ) . height ( 500 ) ;
132
- var sibling = $ ( "<p>Lorem Ipsum</p>" ) ;
133
- $ ( "#navigationWrapper" )
134
- . prepend ( sibling . clone ( ) . height ( 100 ) )
135
- . prepend ( sibling . clone ( ) . height ( 100 ) . css ( "position" , "absolute" ) )
136
- . prepend ( sibling . clone ( ) . height ( 50 ) ) ;
137
- //sibling.outerHeight(true) == 126
138
- equalHeights ( $ ( '#navigation' ) . accordion ( { fillSpace : true } ) , 244 , 256 ) ;
139
- } ) ;
140
-
141
-
142
-
143
-
144
- module ( "accordion (deprecated) - icons" , accordionSetupTeardown ( ) ) ;
145
-
146
- test ( "change headerSelected option after creation" , function ( ) {
147
- var list = $ ( "#list1" ) ;
148
- list . accordion ( { icons : { "activeHeader" : "test" } } ) ;
149
- equals ( $ ( "#list1 span.test" ) . length , 1 ) ;
150
- list . accordion ( "option" , "icons" , { "headerSelected" : "deprecated" } ) ;
151
- equals ( $ ( "#list1 span.deprecated" ) . length , 1 ) ;
112
+ test ( "{ fillSpace: true }" , function ( ) {
113
+ $ ( "#navigationWrapper" ) . height ( 500 ) ;
114
+ var ac = $ ( "#navigation" ) . accordion ( { fillSpace : true } ) ;
115
+ equalHeights ( ac , 446 , 458 ) ;
116
+ } ) ;
117
+
118
+ test ( "{ fillSapce: true } with sibling" , function ( ) {
119
+ $ ( "#navigationWrapper" ) . height ( 500 ) ;
120
+ $ ( "<p>Lorem Ipsum</p>" )
121
+ . css ( {
122
+ height : 50 ,
123
+ marginTop : 20 ,
124
+ marginBottom : 30
125
+ } )
126
+ . prependTo ( "#navigationWrapper" ) ;
127
+ var ac = $ ( "#navigation" ) . accordion ( { fillSpace : true } ) ;
128
+ equalHeights ( ac , 346 , 358 ) ;
129
+ } ) ;
130
+
131
+ test ( "{ fillSpace: true } with multiple siblings" , function ( ) {
132
+ $ ( "#navigationWrapper" ) . height ( 500 ) ;
133
+ $ ( "<p>Lorem Ipsum</p>" )
134
+ . css ( {
135
+ height : 50 ,
136
+ marginTop : 20 ,
137
+ marginBottom : 30
138
+ } )
139
+ . prependTo ( "#navigationWrapper" ) ;
140
+ $ ( "<p>Lorem Ipsum</p>" )
141
+ . css ( {
142
+ height : 50 ,
143
+ marginTop : 20 ,
144
+ marginBottom : 30 ,
145
+ position : "absolute"
146
+ } )
147
+ . prependTo ( "#navigationWrapper" ) ;
148
+ $ ( "<p>Lorem Ipsum</p>" )
149
+ . css ( {
150
+ height : 25 ,
151
+ marginTop : 10 ,
152
+ marginBottom : 15
153
+ } )
154
+ . prependTo ( "#navigationWrapper" ) ;
155
+ var ac = $ ( "#navigation" ) . accordion ( { fillSpace : true } ) ;
156
+ equalHeights ( ac , 296 , 308 ) ;
157
+ } ) ;
158
+
159
+
160
+
161
+
162
+
163
+ module ( "accordion (deprecated) - icons" , accordionSetupTeardown ( ) ) ;
164
+
165
+ test ( "icons, headerSelected" , function ( ) {
166
+ var list = $ ( "#list1" ) . accordion ( {
167
+ icons : { headerSelected : "a1" , header : "h1" }
168
+ } ) ;
169
+ ok ( list . find ( ".ui-accordion-header.ui-state-active span.ui-icon" ) . hasClass ( "a1" ) ) ;
170
+ list . accordion ( "option" , "icons" , { headerSelected : "a2" , header : "h2" } ) ;
171
+ ok ( ! list . find ( ".ui-accordion-header.ui-state-active span.ui-icon" ) . hasClass ( "a1" ) ) ;
172
+ ok ( list . find ( ".ui-accordion-header.ui-state-active span.ui-icon" ) . hasClass ( "a2" ) ) ;
152
173
} ) ;
153
174
154
175
@@ -175,26 +196,29 @@ test( "resize", function() {
175
196
176
197
177
198
199
+
178
200
module ( "accordion (deprecated) - navigation" , accordionSetupTeardown ( ) ) ;
179
201
180
- test ( "{ navigation: true, navigationFilter: header }" , function ( ) {
181
- $ ( "#navigation" ) . accordion ( {
202
+ test ( "{ navigation: true, navigationFilter: header }" , function ( ) {
203
+ var ac = $ ( "#navigation" ) . accordion ( {
182
204
navigation : true ,
183
205
navigationFilter : function ( ) {
184
- return / \? p = 1 \. 1 \. 3 $ / . test ( this . href ) ;
206
+ return / \? p = 1 \. 1 \. 3 $ / . test ( this . href ) ;
185
207
}
186
208
} ) ;
187
- equals ( $ ( "#navigation .ui-accordion-content:eq(2)" ) . size ( ) , 1 , "third content active" ) ;
209
+ equal ( ac . accordion ( "option" , "active" ) , 2 ) ;
210
+ state ( ac , 0 , 0 , 1 ) ;
188
211
} ) ;
189
212
190
- test ( "{ navigation: true, navigationFilter: content }" , function ( ) {
191
- $ ( "#navigation" ) . accordion ( {
213
+ test ( "{ navigation: true, navigationFilter: content }" , function ( ) {
214
+ var ac = $ ( "#navigation" ) . accordion ( {
192
215
navigation : true ,
193
216
navigationFilter : function ( ) {
194
217
return / \? p = 1 \. 1 \. 3 \. 2 $ / . test ( this . href ) ;
195
218
}
196
219
} ) ;
197
- equals ( $ ( "#navigation .ui-accordion-content:eq(2)" ) . size ( ) , 1 , "third content active" ) ;
220
+ equal ( ac . accordion ( "option" , "active" ) , 2 ) ;
221
+ state ( ac , 0 , 0 , 1 ) ;
198
222
} ) ;
199
223
200
224
} ) ( jQuery ) ;
0 commit comments