@@ -3,58 +3,58 @@ define( [
3
3
"ui/widgets/button"
4
4
] , function ( $ ) {
5
5
6
- module ( "button: core" ) ;
6
+ module ( "button: core" ) ;
7
7
8
- test ( "checkbox" , function ( assert ) {
8
+ test ( "checkbox" , function ( assert ) {
9
9
expect ( 4 ) ;
10
- var input = $ ( "#check" ) ,
11
- label = $ ( "label[for=check]" ) ;
12
- ok ( input . is ( ":visible" ) ) ;
13
- ok ( label . is ( ":not(.ui-button)" ) ) ;
10
+ var input = $ ( "#check" ) ,
11
+ label = $ ( "label[for=check]" ) ;
12
+ ok ( input . is ( ":visible" ) ) ;
13
+ ok ( label . is ( ":not(.ui-button)" ) ) ;
14
14
input . button ( ) ;
15
15
assert . hasClasses ( input , "ui-helper-hidden-accessible" ) ;
16
16
assert . hasClasses ( label , "ui-button" ) ;
17
- } ) ;
17
+ } ) ;
18
18
19
- test ( "radios" , function ( assert ) {
19
+ test ( "radios" , function ( assert ) {
20
20
expect ( 8 ) ;
21
- var inputs = $ ( "#radio0 input" ) ,
22
- labels = $ ( "#radio0 label" ) ;
23
- ok ( inputs . is ( ":visible" ) ) ;
24
- ok ( labels . is ( ":not(.ui-button)" ) ) ;
21
+ var inputs = $ ( "#radio0 input" ) ,
22
+ labels = $ ( "#radio0 label" ) ;
23
+ ok ( inputs . is ( ":visible" ) ) ;
24
+ ok ( labels . is ( ":not(.ui-button)" ) ) ;
25
25
inputs . button ( ) ;
26
- inputs . each ( function ( ) {
26
+ inputs . each ( function ( ) {
27
27
assert . hasClasses ( this , "ui-helper-hidden-accessible" ) ;
28
- } ) ;
29
- labels . each ( function ( ) {
28
+ } ) ;
29
+ labels . each ( function ( ) {
30
30
assert . hasClasses ( this , "ui-button" ) ;
31
- } ) ;
32
- } ) ;
31
+ } ) ;
32
+ } ) ;
33
33
34
- test ( "radio groups" , function ( assert ) {
34
+ test ( "radio groups" , function ( assert ) {
35
35
expect ( 12 ) ;
36
36
37
- function assertClasses ( noForm , form1 , form2 ) {
38
- assert . hasClasses ( $ ( "#radio0 .ui-button" + noForm ) , "ui-state-active" ) ;
39
- assert . hasClasses ( $ ( "#radio1 .ui-button" + form1 ) , "ui-state-active" ) ;
40
- assert . hasClasses ( $ ( "#radio2 .ui-button" + form2 ) , "ui-state-active" ) ;
37
+ function assertClasses ( noForm , form1 , form2 ) {
38
+ assert . hasClasses ( $ ( "#radio0 .ui-button" + noForm ) , "ui-state-active" ) ;
39
+ assert . hasClasses ( $ ( "#radio1 .ui-button" + form1 ) , "ui-state-active" ) ;
40
+ assert . hasClasses ( $ ( "#radio2 .ui-button" + form2 ) , "ui-state-active" ) ;
41
41
}
42
42
43
- $ ( "input[type=radio]" ) . button ( ) ;
44
- assertClasses ( ":eq(0)" , ":eq(1)" , ":eq(2)" ) ;
43
+ $ ( "input[type=radio]" ) . button ( ) ;
44
+ assertClasses ( ":eq(0)" , ":eq(1)" , ":eq(2)" ) ;
45
45
46
- // click outside of forms
47
- $ ( "#radio0 .ui-button:eq(1)" ) . trigger ( "click" ) ;
48
- assertClasses ( ":eq(1)" , ":eq(1)" , ":eq(2)" ) ;
46
+ // Click outside of forms
47
+ $ ( "#radio0 .ui-button:eq(1)" ) . trigger ( "click" ) ;
48
+ assertClasses ( ":eq(1)" , ":eq(1)" , ":eq(2)" ) ;
49
49
50
- // click in first form
51
- $ ( "#radio1 .ui-button:eq(0)" ) . trigger ( "click" ) ;
52
- assertClasses ( ":eq(1)" , ":eq(0)" , ":eq(2)" ) ;
50
+ // Click in first form
51
+ $ ( "#radio1 .ui-button:eq(0)" ) . trigger ( "click" ) ;
52
+ assertClasses ( ":eq(1)" , ":eq(0)" , ":eq(2)" ) ;
53
53
54
- // click in second form
55
- $ ( "#radio2 .ui-button:eq(0)" ) . trigger ( "click" ) ;
56
- assertClasses ( ":eq(1)" , ":eq(0)" , ":eq(0)" ) ;
57
- } ) ;
54
+ // Click in second form
55
+ $ ( "#radio2 .ui-button:eq(0)" ) . trigger ( "click" ) ;
56
+ assertClasses ( ":eq(1)" , ":eq(0)" , ":eq(0)" ) ;
57
+ } ) ;
58
58
59
59
test ( "radio groups - ignore elements with same name" , function ( ) {
60
60
expect ( 1 ) ;
@@ -63,47 +63,48 @@ test( "radio groups - ignore elements with same name", function() {
63
63
checkbox = $ ( "<input>" , {
64
64
type : "checkbox" ,
65
65
name : radios . attr ( "name" )
66
- } ) ;
66
+ } ) ;
67
67
68
68
form . append ( checkbox ) ;
69
69
radios . button ( "refresh" ) ;
70
70
ok ( true , "no exception from accessing button instance of checkbox" ) ;
71
- } ) ;
71
+ } ) ;
72
72
73
- test ( "input type submit, don't create child elements" , function ( ) {
73
+ test ( "input type submit, don't create child elements" , function ( ) {
74
74
expect ( 2 ) ;
75
- var input = $ ( "#submit" ) ;
75
+ var input = $ ( "#submit" ) ;
76
76
deepEqual ( input . children ( ) . length , 0 ) ;
77
77
input . button ( ) ;
78
78
deepEqual ( input . children ( ) . length , 0 ) ;
79
- } ) ;
79
+ } ) ;
80
80
81
- test ( "buttonset" , function ( assert ) {
81
+ test ( "buttonset" , function ( assert ) {
82
82
expect ( 6 ) ;
83
- var set = $ ( "#radio1" ) . buttonset ( ) ;
83
+ var set = $ ( "#radio1" ) . buttonset ( ) ;
84
84
assert . hasClasses ( set , "ui-buttonset" ) ;
85
- deepEqual ( set . children ( ".ui-button" ) . length , 3 ) ;
86
- deepEqual ( set . children ( "input[type=radio].ui-helper-hidden-accessible" ) . length , 3 ) ;
87
- ok ( set . children ( "label:eq(0)" ) . is ( ".ui-button.ui-corner-left:not(.ui-corner-all)" ) ) ;
88
- ok ( set . children ( "label:eq(1)" ) . is ( ".ui-button:not(.ui-corner-all)" ) ) ;
89
- ok ( set . children ( "label:eq(2)" ) . is ( ".ui-button.ui-corner-right:not(.ui-corner-all)" ) ) ;
90
- } ) ;
91
-
92
- test ( "buttonset (rtl)" , function ( assert ) {
85
+ deepEqual ( set . children ( ".ui-button" ) . length , 3 ) ;
86
+ deepEqual ( set . children ( "input[type=radio].ui-helper-hidden-accessible" ) . length , 3 ) ;
87
+ ok ( set . children ( "label:eq(0)" ) . is ( ".ui-button.ui-corner-left:not(.ui-corner-all)" ) ) ;
88
+ ok ( set . children ( "label:eq(1)" ) . is ( ".ui-button:not(.ui-corner-all)" ) ) ;
89
+ ok ( set . children ( "label:eq(2)" ) . is ( ".ui-button.ui-corner-right:not(.ui-corner-all)" ) ) ;
90
+ } ) ;
91
+
92
+ test ( "buttonset (rtl)" , function ( assert ) {
93
93
expect ( 6 ) ;
94
94
var set ,
95
- parent = $ ( "#radio1" ) . parent ( ) ;
95
+ parent = $ ( "#radio1" ) . parent ( ) ;
96
+
96
97
// Set to rtl
97
- parent . attr ( "dir" , "rtl" ) ;
98
+ parent . attr ( "dir" , "rtl" ) ;
98
99
99
- set = $ ( "#radio1" ) . buttonset ( ) ;
100
+ set = $ ( "#radio1" ) . buttonset ( ) ;
100
101
assert . hasClasses ( set , "ui-buttonset" ) ;
101
- deepEqual ( set . children ( ".ui-button" ) . length , 3 ) ;
102
- deepEqual ( set . children ( "input[type=radio].ui-helper-hidden-accessible" ) . length , 3 ) ;
103
- ok ( set . children ( "label:eq(0)" ) . is ( ".ui-button.ui-corner-right:not(.ui-corner-all)" ) ) ;
104
- ok ( set . children ( "label:eq(1)" ) . is ( ".ui-button:not(.ui-corner-all)" ) ) ;
105
- ok ( set . children ( "label:eq(2)" ) . is ( ".ui-button.ui-corner-left:not(.ui-corner-all)" ) ) ;
106
- } ) ;
102
+ deepEqual ( set . children ( ".ui-button" ) . length , 3 ) ;
103
+ deepEqual ( set . children ( "input[type=radio].ui-helper-hidden-accessible" ) . length , 3 ) ;
104
+ ok ( set . children ( "label:eq(0)" ) . is ( ".ui-button.ui-corner-right:not(.ui-corner-all)" ) ) ;
105
+ ok ( set . children ( "label:eq(1)" ) . is ( ".ui-button:not(.ui-corner-all)" ) ) ;
106
+ ok ( set . children ( "label:eq(2)" ) . is ( ".ui-button.ui-corner-left:not(.ui-corner-all)" ) ) ;
107
+ } ) ;
107
108
108
109
// TODO: simulated click events don't behave like real click events in IE
109
110
// remove this when simulate properly simulates this
@@ -112,22 +113,22 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
112
113
asyncTest ( "ensure checked and aria after single click on checkbox label button, see #5518" , function ( assert ) {
113
114
expect ( 3 ) ;
114
115
115
- $ ( "#check2" ) . button ( ) . on ( "change" , function ( ) {
116
- var lbl = $ ( this ) . button ( "widget" ) ;
116
+ $ ( "#check2" ) . button ( ) . on ( "change" , function ( ) {
117
+ var lbl = $ ( this ) . button ( "widget" ) ;
117
118
ok ( this . checked , "checked ok" ) ;
118
- ok ( lbl . attr ( "aria-pressed" ) === "true" , "aria ok" ) ;
119
+ ok ( lbl . attr ( "aria-pressed" ) === "true" , "aria ok" ) ;
119
120
assert . hasClasses ( lbl , "ui-state-active" ) ;
120
- } ) ;
121
+ } ) ;
121
122
122
- // support : Opera
123
+ // Support : Opera
123
124
// Opera doesn't trigger a change event when this is done synchronously.
124
125
// This seems to be a side effect of another test, but until that can be
125
126
// tracked down, this delay will have to do.
126
- setTimeout ( function ( ) {
127
- $ ( "#check2" ) . button ( "widget" ) . simulate ( "click" ) ;
127
+ setTimeout ( function ( ) {
128
+ $ ( "#check2" ) . button ( "widget" ) . simulate ( "click" ) ;
128
129
start ( ) ;
129
130
} , 1 ) ;
130
- } ) ;
131
+ } ) ;
131
132
}
132
133
133
134
test ( "#7092 - button creation that requires a matching label does not find label in all cases" , function ( assert ) {
@@ -151,15 +152,15 @@ test( "#7092 - button creation that requires a matching label does not find labe
151
152
group = $ ( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" ) ;
152
153
group . filter ( "input[type=checkbox]" ) . button ( ) ;
153
154
assert . hasClasses ( group . find ( "label" ) , "ui-button" ) ;
154
- } ) ;
155
+ } ) ;
155
156
156
157
test ( "#5946 - buttonset should ignore buttons that are not :visible" , function ( assert ) {
157
158
expect ( 2 ) ;
158
159
$ ( "#radio01" ) . next ( ) . addBack ( ) . hide ( ) ;
159
- var set = $ ( "#radio0" ) . buttonset ( { items : "input[type=radio]:visible" } ) ;
160
+ var set = $ ( "#radio0" ) . buttonset ( { items : "input[type=radio]:visible" } ) ;
160
161
ok ( set . find ( "label:eq(0)" ) . is ( ":not(.ui-button):not(.ui-corner-left)" ) ) ;
161
162
assert . hasClasses ( set . find ( "label:eq(1)" ) , "ui-button ui-corner-left" ) ;
162
- } ) ;
163
+ } ) ;
163
164
164
165
test ( "#6262 - buttonset not applying ui-corner to invisible elements" , function ( assert ) {
165
166
expect ( 3 ) ;
@@ -169,7 +170,7 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
169
170
assert . hasClasses ( set . find ( "label:eq(1)" ) , "ui-button" ) ;
170
171
assert . hasClasses ( set . find ( "label:eq(2)" ) , "ui-button ui-corner-right" ) ;
171
172
172
- } ) ;
173
+ } ) ;
173
174
174
175
asyncTest ( "Resetting a button's form should refresh the visual state of the button widget to match." , function ( assert ) {
175
176
expect ( 2 ) ;
@@ -185,46 +186,46 @@ asyncTest( "Resetting a button's form should refresh the visual state of the but
185
186
186
187
form . get ( 0 ) . reset ( ) ;
187
188
188
- // #9213: If a button has been removed, refresh should not be called on it when
189
+ // If a button has been removed, refresh should not be called on it when
189
190
// its corresponding form is reset.
190
191
button . remove ( ) ;
191
192
192
- setTimeout ( function ( ) {
193
+ setTimeout ( function ( ) {
193
194
assert . hasClasses ( checkbox . button ( "widget" ) , "ui-state-active" ) ;
194
195
start ( ) ;
195
196
} , 1 ) ;
196
- } ) ;
197
+ } ) ;
197
198
198
199
asyncTest ( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation" , function ( assert ) {
199
200
expect ( 2 ) ;
200
201
var check = $ ( "#check" ) . button ( ) ,
201
202
label = $ ( "label[for='check']" ) ;
202
203
assert . lacksClasses ( label , "ui-state-focus" ) ;
203
204
check . trigger ( "focus" ) ;
204
- setTimeout ( function ( ) {
205
+ setTimeout ( function ( ) {
205
206
assert . hasClasses ( label , "ui-state-focus" ) ;
206
207
start ( ) ;
207
- } ) ;
208
- } ) ;
208
+ } ) ;
209
+ } ) ;
209
210
210
211
test ( "#7534 - Button label selector works for ids with \":\"" , function ( assert ) {
211
212
expect ( 1 ) ;
212
213
var group = $ ( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" ) ;
213
214
group . find ( "input" ) . button ( ) ;
214
- assert . hasClasses ( group . find ( "label" ) , "ui-button" , "Found an id with a :" ) ;
215
- } ) ;
215
+ assert . hasClasses ( group . find ( "label" ) , "ui-button" , "Found an id with a :" ) ;
216
+ } ) ;
216
217
217
218
asyncTest ( "#9169 - Disabled button maintains ui-state-focus" , function ( assert ) {
218
219
expect ( 2 ) ;
219
220
var element = $ ( "#button1" ) . button ( ) ;
220
221
element [ 0 ] . focus ( ) ;
221
- setTimeout ( function ( ) {
222
+ setTimeout ( function ( ) {
222
223
assert . hasClasses ( element , "ui-state-focus" ) ;
223
224
element . button ( "disable" ) ;
224
225
assert . lacksClasses ( element , "ui-state-focus" ,
225
226
"button does not have ui-state-focus when disabled" ) ;
226
227
start ( ) ;
227
- } ) ;
228
- } ) ;
228
+ } ) ;
229
+ } ) ;
229
230
230
231
} ) ;
0 commit comments