Skip to content

Commit 1f71646

Browse files
committed
Button: Style updates
Ref #14246 Ref gh-1588
1 parent de242d8 commit 1f71646

File tree

5 files changed

+175
-174
lines changed

5 files changed

+175
-174
lines changed

tests/unit/button/common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ common.testWidget( "button", {
1414
label: null,
1515
text: true,
1616

17-
// callbacks
17+
// Callbacks
1818
create: null
1919
}
20-
});
20+
} );
2121

2222
} );

tests/unit/button/core.js

Lines changed: 82 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,58 @@ define( [
33
"ui/widgets/button"
44
], function( $ ) {
55

6-
module("button: core");
6+
module( "button: core" );
77

8-
test("checkbox", function( assert ) {
8+
test( "checkbox", function( assert ) {
99
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)" ) );
1414
input.button();
1515
assert.hasClasses( input, "ui-helper-hidden-accessible" );
1616
assert.hasClasses( label, "ui-button" );
17-
});
17+
} );
1818

19-
test("radios", function( assert ) {
19+
test( "radios", function( assert ) {
2020
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)" ) );
2525
inputs.button();
26-
inputs.each(function() {
26+
inputs.each( function() {
2727
assert.hasClasses( this, "ui-helper-hidden-accessible" );
28-
});
29-
labels.each(function() {
28+
} );
29+
labels.each( function() {
3030
assert.hasClasses( this, "ui-button" );
31-
});
32-
});
31+
} );
32+
} );
3333

34-
test("radio groups", function( assert ) {
34+
test( "radio groups", function( assert ) {
3535
expect( 12 );
3636

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" );
4141
}
4242

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)" );
4545

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)" );
4949

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)" );
5353

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+
} );
5858

5959
test( "radio groups - ignore elements with same name", function() {
6060
expect( 1 );
@@ -63,47 +63,48 @@ test( "radio groups - ignore elements with same name", function() {
6363
checkbox = $( "<input>", {
6464
type: "checkbox",
6565
name: radios.attr( "name" )
66-
});
66+
} );
6767

6868
form.append( checkbox );
6969
radios.button( "refresh" );
7070
ok( true, "no exception from accessing button instance of checkbox" );
71-
});
71+
} );
7272

73-
test("input type submit, don't create child elements", function() {
73+
test( "input type submit, don't create child elements", function() {
7474
expect( 2 );
75-
var input = $("#submit");
75+
var input = $( "#submit" );
7676
deepEqual( input.children().length, 0 );
7777
input.button();
7878
deepEqual( input.children().length, 0 );
79-
});
79+
} );
8080

81-
test("buttonset", function( assert ) {
81+
test( "buttonset", function( assert ) {
8282
expect( 6 );
83-
var set = $("#radio1").buttonset();
83+
var set = $( "#radio1" ).buttonset();
8484
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 ) {
9393
expect( 6 );
9494
var set,
95-
parent = $("#radio1").parent();
95+
parent = $( "#radio1" ).parent();
96+
9697
// Set to rtl
97-
parent.attr("dir", "rtl");
98+
parent.attr( "dir", "rtl" );
9899

99-
set = $("#radio1").buttonset();
100+
set = $( "#radio1" ).buttonset();
100101
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+
} );
107108

108109
// TODO: simulated click events don't behave like real click events in IE
109110
// remove this when simulate properly simulates this
@@ -112,22 +113,22 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
112113
asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function( assert ) {
113114
expect( 3 );
114115

115-
$("#check2").button().on( "change", function() {
116-
var lbl = $( this ).button("widget");
116+
$( "#check2" ).button().on( "change", function() {
117+
var lbl = $( this ).button( "widget" );
117118
ok( this.checked, "checked ok" );
118-
ok( lbl.attr("aria-pressed") === "true", "aria ok" );
119+
ok( lbl.attr( "aria-pressed" ) === "true", "aria ok" );
119120
assert.hasClasses( lbl, "ui-state-active" );
120-
});
121+
} );
121122

122-
// support: Opera
123+
// Support: Opera
123124
// Opera doesn't trigger a change event when this is done synchronously.
124125
// This seems to be a side effect of another test, but until that can be
125126
// 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" );
128129
start();
129130
}, 1 );
130-
});
131+
} );
131132
}
132133

133134
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
151152
group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" );
152153
group.filter( "input[type=checkbox]" ).button();
153154
assert.hasClasses( group.find( "label" ), "ui-button" );
154-
});
155+
} );
155156

156157
test( "#5946 - buttonset should ignore buttons that are not :visible", function( assert ) {
157158
expect( 2 );
158159
$( "#radio01" ).next().addBack().hide();
159-
var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
160+
var set = $( "#radio0" ).buttonset( { items: "input[type=radio]:visible" } );
160161
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
161162
assert.hasClasses( set.find( "label:eq(1)" ), "ui-button ui-corner-left" );
162-
});
163+
} );
163164

164165
test( "#6262 - buttonset not applying ui-corner to invisible elements", function( assert ) {
165166
expect( 3 );
@@ -169,7 +170,7 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
169170
assert.hasClasses( set.find( "label:eq(1)" ), "ui-button" );
170171
assert.hasClasses( set.find( "label:eq(2)" ), "ui-button ui-corner-right" );
171172

172-
});
173+
} );
173174

174175
asyncTest( "Resetting a button's form should refresh the visual state of the button widget to match.", function( assert ) {
175176
expect( 2 );
@@ -185,46 +186,46 @@ asyncTest( "Resetting a button's form should refresh the visual state of the but
185186

186187
form.get( 0 ).reset();
187188

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
189190
// its corresponding form is reset.
190191
button.remove();
191192

192-
setTimeout(function() {
193+
setTimeout( function() {
193194
assert.hasClasses( checkbox.button( "widget" ), "ui-state-active" );
194195
start();
195196
}, 1 );
196-
});
197+
} );
197198

198199
asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function( assert ) {
199200
expect( 2 );
200201
var check = $( "#check" ).button(),
201202
label = $( "label[for='check']" );
202203
assert.lacksClasses( label, "ui-state-focus" );
203204
check.trigger( "focus" );
204-
setTimeout(function() {
205+
setTimeout( function() {
205206
assert.hasClasses( label, "ui-state-focus" );
206207
start();
207-
});
208-
});
208+
} );
209+
} );
209210

210211
test( "#7534 - Button label selector works for ids with \":\"", function( assert ) {
211212
expect( 1 );
212213
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
213214
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+
} );
216217

217218
asyncTest( "#9169 - Disabled button maintains ui-state-focus", function( assert ) {
218219
expect( 2 );
219220
var element = $( "#button1" ).button();
220221
element[ 0 ].focus();
221-
setTimeout(function() {
222+
setTimeout( function() {
222223
assert.hasClasses( element, "ui-state-focus" );
223224
element.button( "disable" );
224225
assert.lacksClasses( element, "ui-state-focus",
225226
"button does not have ui-state-focus when disabled" );
226227
start();
227-
});
228-
});
228+
} );
229+
} );
229230

230231
} );

tests/unit/button/events.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ define( [
33
"ui/widgets/button"
44
], function( $ ) {
55

6-
module("button: events");
6+
module( "button: events" );
77

8-
test("buttonset works with single-quote named elements (#7505)", function() {
8+
test( "buttonset works with single-quote named elements (#7505)", function() {
99
expect( 1 );
10-
$("#radio3").buttonset();
11-
$("#radio33").on( "click", function(){
10+
$( "#radio3" ).buttonset();
11+
$( "#radio33" ).on( "click", function() {
1212
ok( true, "button clicks work with single-quote named elements" );
13-
}).trigger( "click" );
14-
});
13+
} ).trigger( "click" );
14+
} );
1515

1616
asyncTest( "when button loses focus, ensure active state is removed (#8559)", function( assert ) {
1717
expect( 1 );
@@ -22,15 +22,15 @@ asyncTest( "when button loses focus, ensure active state is removed (#8559)", fu
2222
element.one( "blur", function() {
2323
assert.lacksClasses( element, "ui-state-active", "button loses active state appropriately" );
2424
start();
25-
}).trigger( "blur" );
26-
});
25+
} ).trigger( "blur" );
26+
} );
2727

2828
element.trigger( "focus" );
29-
setTimeout(function() {
29+
setTimeout( function() {
3030
element
3131
.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } )
3232
.simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } );
33-
});
34-
});
33+
} );
34+
} );
3535

3636
} );

0 commit comments

Comments
 (0)