Skip to content

Commit 12df1b7

Browse files
committed
Button: Remove core event/alias and deprecated module dependencies
1 parent 8b4ce80 commit 12df1b7

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

demos/button/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$(function() {
1414
$( "input[type=submit], a, button" )
1515
.button()
16-
.click(function( event ) {
16+
.on( "click", function( event ) {
1717
event.preventDefault();
1818
});
1919
});

demos/button/splitbutton.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$(function() {
1919
$( "#rerun" )
2020
.button()
21-
.click(function() {
21+
.on( "click", function() {
2222
alert( "Running the last action" );
2323
})
2424
.next()
@@ -28,7 +28,7 @@
2828
primary: "ui-icon-triangle-1-s"
2929
}
3030
})
31-
.click(function() {
31+
.on( "click", function() {
3232
var menu = $( this ).parent().next().show().position({
3333
my: "left top",
3434
at: "left bottom",

demos/button/toolbar.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
primary: "ui-icon-play"
3636
}
3737
})
38-
.click(function() {
38+
.on( "click", function() {
3939
var options;
4040
if ( $( this ).text() === "play" ) {
4141
options = {
@@ -60,7 +60,7 @@
6060
primary: "ui-icon-stop"
6161
}
6262
})
63-
.click(function() {
63+
.on( "click", function() {
6464
$( "#play" ).button( "option", {
6565
label: "play",
6666
icons: {

tests/unit/button/core.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ test("radio groups", function( assert ) {
4444
assertClasses(":eq(0)", ":eq(1)", ":eq(2)");
4545

4646
// click outside of forms
47-
$("#radio0 .ui-button:eq(1)").click();
47+
$("#radio0 .ui-button:eq(1)").trigger( "click" );
4848
assertClasses(":eq(1)", ":eq(1)", ":eq(2)");
4949

5050
// click in first form
51-
$("#radio1 .ui-button:eq(0)").click();
51+
$("#radio1 .ui-button:eq(0)").trigger( "click" );
5252
assertClasses(":eq(1)", ":eq(0)", ":eq(2)");
5353

5454
// click in second form
55-
$("#radio2 .ui-button:eq(0)").click();
55+
$("#radio2 .ui-button:eq(0)").trigger( "click" );
5656
assertClasses(":eq(1)", ":eq(0)", ":eq(0)");
5757
});
5858

@@ -112,7 +112,7 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
112112
asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function( assert ) {
113113
expect( 3 );
114114

115-
$("#check2").button().change( function() {
115+
$("#check2").button().on( "change", function() {
116116
var lbl = $( this ).button("widget");
117117
ok( this.checked, "checked ok" );
118118
ok( lbl.attr("aria-pressed") === "true", "aria ok" );
@@ -200,7 +200,7 @@ asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyb
200200
var check = $( "#check" ).button(),
201201
label = $( "label[for='check']" );
202202
assert.lacksClasses( label, "ui-state-focus" );
203-
check.focus();
203+
check.trigger( "focus" );
204204
setTimeout(function() {
205205
assert.hasClasses( label, "ui-state-focus" );
206206
start();

tests/unit/button/events.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ module("button: events");
88
test("buttonset works with single-quote named elements (#7505)", function() {
99
expect( 1 );
1010
$("#radio3").buttonset();
11-
$("#radio33").click( function(){
11+
$("#radio33").on( "click", function(){
1212
ok( true, "button clicks work with single-quote named elements" );
13-
}).click();
13+
}).trigger( "click" );
1414
});
1515

1616
asyncTest( "when button loses focus, ensure active state is removed (#8559)", function( assert ) {
@@ -22,10 +22,10 @@ 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-
}).blur();
25+
}).trigger( "blur" );
2626
});
2727

28-
element.focus();
28+
element.trigger( "focus" );
2929
setTimeout(function() {
3030
element
3131
.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } )

tests/unit/button/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ test("icons", function() {
146146
test( "#5295 - button does not remove hoverstate if disabled" , function( assert ) {
147147
expect( 1 );
148148
var btn = $("#button").button();
149-
btn.hover( function() {
149+
btn.on( "hover", function() {
150150
btn.button( "disable" );
151151
});
152152
btn.trigger( "mouseenter" );

ui/button.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ $.widget( "ui.button", {
7373
},
7474
_create: function() {
7575
this.element.closest( "form" )
76-
.unbind( "reset" + this.eventNamespace )
77-
.bind( "reset" + this.eventNamespace, formResetHandler );
76+
.off( "reset" + this.eventNamespace )
77+
.on( "reset" + this.eventNamespace, formResetHandler );
7878

7979
if ( typeof this.options.disabled !== "boolean" ) {
8080
this.options.disabled = !!this.element.prop( "disabled" );
@@ -99,21 +99,21 @@ $.widget( "ui.button", {
9999
this.buttonElement
100100
.addClass( baseClasses )
101101
.attr( "role", "button" )
102-
.bind( "mouseenter" + this.eventNamespace, function() {
102+
.on( "mouseenter" + this.eventNamespace, function() {
103103
if ( options.disabled ) {
104104
return;
105105
}
106106
if ( this === lastActive ) {
107107
$( this ).addClass( "ui-state-active" );
108108
}
109109
})
110-
.bind( "mouseleave" + this.eventNamespace, function() {
110+
.on( "mouseleave" + this.eventNamespace, function() {
111111
if ( options.disabled ) {
112112
return;
113113
}
114114
$( this ).removeClass( activeClass );
115115
})
116-
.bind( "click" + this.eventNamespace, function( event ) {
116+
.on( "click" + this.eventNamespace, function( event ) {
117117
if ( options.disabled ) {
118118
event.preventDefault();
119119
event.stopImmediatePropagation();
@@ -132,19 +132,19 @@ $.widget( "ui.button", {
132132
});
133133

134134
if ( toggleButton ) {
135-
this.element.bind( "change" + this.eventNamespace, function() {
135+
this.element.on( "change" + this.eventNamespace, function() {
136136
that.refresh();
137137
});
138138
}
139139

140140
if ( this.type === "checkbox" ) {
141-
this.buttonElement.bind( "click" + this.eventNamespace, function() {
141+
this.buttonElement.on( "click" + this.eventNamespace, function() {
142142
if ( options.disabled ) {
143143
return false;
144144
}
145145
});
146146
} else if ( this.type === "radio" ) {
147-
this.buttonElement.bind( "click" + this.eventNamespace, function() {
147+
this.buttonElement.on( "click" + this.eventNamespace, function() {
148148
if ( options.disabled ) {
149149
return false;
150150
}
@@ -162,7 +162,7 @@ $.widget( "ui.button", {
162162
});
163163
} else {
164164
this.buttonElement
165-
.bind( "mousedown" + this.eventNamespace, function() {
165+
.on( "mousedown" + this.eventNamespace, function() {
166166
if ( options.disabled ) {
167167
return false;
168168
}
@@ -172,13 +172,13 @@ $.widget( "ui.button", {
172172
lastActive = null;
173173
});
174174
})
175-
.bind( "mouseup" + this.eventNamespace, function() {
175+
.on( "mouseup" + this.eventNamespace, function() {
176176
if ( options.disabled ) {
177177
return false;
178178
}
179179
$( this ).removeClass( "ui-state-active" );
180180
})
181-
.bind( "keydown" + this.eventNamespace, function(event) {
181+
.on( "keydown" + this.eventNamespace, function(event) {
182182
if ( options.disabled ) {
183183
return false;
184184
}
@@ -188,15 +188,15 @@ $.widget( "ui.button", {
188188
})
189189
// see #8559, we bind to blur here in case the button element loses
190190
// focus between keydown and keyup, it would be left in an "active" state
191-
.bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
191+
.on( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
192192
$( this ).removeClass( "ui-state-active" );
193193
});
194194

195195
if ( this.buttonElement.is("a") ) {
196-
this.buttonElement.keyup(function(event) {
196+
this.buttonElement.on( "keyup", function(event) {
197197
if ( event.keyCode === $.ui.keyCode.SPACE ) {
198198
// TODO pass through original event correctly (just as 2nd argument doesn't work)
199-
$( this ).click();
199+
$( this ).trigger( "click" );
200200
}
201201
});
202202
}

0 commit comments

Comments
 (0)