mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Button: Remove core event/alias and deprecated module dependencies
This commit is contained in:
parent
8b4ce807cd
commit
12df1b7dad
@ -13,7 +13,7 @@
|
||||
$(function() {
|
||||
$( "input[type=submit], a, button" )
|
||||
.button()
|
||||
.click(function( event ) {
|
||||
.on( "click", function( event ) {
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
|
@ -18,7 +18,7 @@
|
||||
$(function() {
|
||||
$( "#rerun" )
|
||||
.button()
|
||||
.click(function() {
|
||||
.on( "click", function() {
|
||||
alert( "Running the last action" );
|
||||
})
|
||||
.next()
|
||||
@ -28,7 +28,7 @@
|
||||
primary: "ui-icon-triangle-1-s"
|
||||
}
|
||||
})
|
||||
.click(function() {
|
||||
.on( "click", function() {
|
||||
var menu = $( this ).parent().next().show().position({
|
||||
my: "left top",
|
||||
at: "left bottom",
|
||||
|
@ -35,7 +35,7 @@
|
||||
primary: "ui-icon-play"
|
||||
}
|
||||
})
|
||||
.click(function() {
|
||||
.on( "click", function() {
|
||||
var options;
|
||||
if ( $( this ).text() === "play" ) {
|
||||
options = {
|
||||
@ -60,7 +60,7 @@
|
||||
primary: "ui-icon-stop"
|
||||
}
|
||||
})
|
||||
.click(function() {
|
||||
.on( "click", function() {
|
||||
$( "#play" ).button( "option", {
|
||||
label: "play",
|
||||
icons: {
|
||||
|
@ -44,15 +44,15 @@ test("radio groups", function( assert ) {
|
||||
assertClasses(":eq(0)", ":eq(1)", ":eq(2)");
|
||||
|
||||
// click outside of forms
|
||||
$("#radio0 .ui-button:eq(1)").click();
|
||||
$("#radio0 .ui-button:eq(1)").trigger( "click" );
|
||||
assertClasses(":eq(1)", ":eq(1)", ":eq(2)");
|
||||
|
||||
// click in first form
|
||||
$("#radio1 .ui-button:eq(0)").click();
|
||||
$("#radio1 .ui-button:eq(0)").trigger( "click" );
|
||||
assertClasses(":eq(1)", ":eq(0)", ":eq(2)");
|
||||
|
||||
// click in second form
|
||||
$("#radio2 .ui-button:eq(0)").click();
|
||||
$("#radio2 .ui-button:eq(0)").trigger( "click" );
|
||||
assertClasses(":eq(1)", ":eq(0)", ":eq(0)");
|
||||
});
|
||||
|
||||
@ -112,7 +112,7 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
|
||||
asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function( assert ) {
|
||||
expect( 3 );
|
||||
|
||||
$("#check2").button().change( function() {
|
||||
$("#check2").button().on( "change", function() {
|
||||
var lbl = $( this ).button("widget");
|
||||
ok( this.checked, "checked ok" );
|
||||
ok( lbl.attr("aria-pressed") === "true", "aria ok" );
|
||||
@ -200,7 +200,7 @@ asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyb
|
||||
var check = $( "#check" ).button(),
|
||||
label = $( "label[for='check']" );
|
||||
assert.lacksClasses( label, "ui-state-focus" );
|
||||
check.focus();
|
||||
check.trigger( "focus" );
|
||||
setTimeout(function() {
|
||||
assert.hasClasses( label, "ui-state-focus" );
|
||||
start();
|
||||
|
@ -8,9 +8,9 @@ module("button: events");
|
||||
test("buttonset works with single-quote named elements (#7505)", function() {
|
||||
expect( 1 );
|
||||
$("#radio3").buttonset();
|
||||
$("#radio33").click( function(){
|
||||
$("#radio33").on( "click", function(){
|
||||
ok( true, "button clicks work with single-quote named elements" );
|
||||
}).click();
|
||||
}).trigger( "click" );
|
||||
});
|
||||
|
||||
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
|
||||
element.one( "blur", function() {
|
||||
assert.lacksClasses( element, "ui-state-active", "button loses active state appropriately" );
|
||||
start();
|
||||
}).blur();
|
||||
}).trigger( "blur" );
|
||||
});
|
||||
|
||||
element.focus();
|
||||
element.trigger( "focus" );
|
||||
setTimeout(function() {
|
||||
element
|
||||
.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } )
|
||||
|
@ -146,7 +146,7 @@ test("icons", function() {
|
||||
test( "#5295 - button does not remove hoverstate if disabled" , function( assert ) {
|
||||
expect( 1 );
|
||||
var btn = $("#button").button();
|
||||
btn.hover( function() {
|
||||
btn.on( "hover", function() {
|
||||
btn.button( "disable" );
|
||||
});
|
||||
btn.trigger( "mouseenter" );
|
||||
|
28
ui/button.js
28
ui/button.js
@ -73,8 +73,8 @@ $.widget( "ui.button", {
|
||||
},
|
||||
_create: function() {
|
||||
this.element.closest( "form" )
|
||||
.unbind( "reset" + this.eventNamespace )
|
||||
.bind( "reset" + this.eventNamespace, formResetHandler );
|
||||
.off( "reset" + this.eventNamespace )
|
||||
.on( "reset" + this.eventNamespace, formResetHandler );
|
||||
|
||||
if ( typeof this.options.disabled !== "boolean" ) {
|
||||
this.options.disabled = !!this.element.prop( "disabled" );
|
||||
@ -99,7 +99,7 @@ $.widget( "ui.button", {
|
||||
this.buttonElement
|
||||
.addClass( baseClasses )
|
||||
.attr( "role", "button" )
|
||||
.bind( "mouseenter" + this.eventNamespace, function() {
|
||||
.on( "mouseenter" + this.eventNamespace, function() {
|
||||
if ( options.disabled ) {
|
||||
return;
|
||||
}
|
||||
@ -107,13 +107,13 @@ $.widget( "ui.button", {
|
||||
$( this ).addClass( "ui-state-active" );
|
||||
}
|
||||
})
|
||||
.bind( "mouseleave" + this.eventNamespace, function() {
|
||||
.on( "mouseleave" + this.eventNamespace, function() {
|
||||
if ( options.disabled ) {
|
||||
return;
|
||||
}
|
||||
$( this ).removeClass( activeClass );
|
||||
})
|
||||
.bind( "click" + this.eventNamespace, function( event ) {
|
||||
.on( "click" + this.eventNamespace, function( event ) {
|
||||
if ( options.disabled ) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
@ -132,19 +132,19 @@ $.widget( "ui.button", {
|
||||
});
|
||||
|
||||
if ( toggleButton ) {
|
||||
this.element.bind( "change" + this.eventNamespace, function() {
|
||||
this.element.on( "change" + this.eventNamespace, function() {
|
||||
that.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
if ( this.type === "checkbox" ) {
|
||||
this.buttonElement.bind( "click" + this.eventNamespace, function() {
|
||||
this.buttonElement.on( "click" + this.eventNamespace, function() {
|
||||
if ( options.disabled ) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else if ( this.type === "radio" ) {
|
||||
this.buttonElement.bind( "click" + this.eventNamespace, function() {
|
||||
this.buttonElement.on( "click" + this.eventNamespace, function() {
|
||||
if ( options.disabled ) {
|
||||
return false;
|
||||
}
|
||||
@ -162,7 +162,7 @@ $.widget( "ui.button", {
|
||||
});
|
||||
} else {
|
||||
this.buttonElement
|
||||
.bind( "mousedown" + this.eventNamespace, function() {
|
||||
.on( "mousedown" + this.eventNamespace, function() {
|
||||
if ( options.disabled ) {
|
||||
return false;
|
||||
}
|
||||
@ -172,13 +172,13 @@ $.widget( "ui.button", {
|
||||
lastActive = null;
|
||||
});
|
||||
})
|
||||
.bind( "mouseup" + this.eventNamespace, function() {
|
||||
.on( "mouseup" + this.eventNamespace, function() {
|
||||
if ( options.disabled ) {
|
||||
return false;
|
||||
}
|
||||
$( this ).removeClass( "ui-state-active" );
|
||||
})
|
||||
.bind( "keydown" + this.eventNamespace, function(event) {
|
||||
.on( "keydown" + this.eventNamespace, function(event) {
|
||||
if ( options.disabled ) {
|
||||
return false;
|
||||
}
|
||||
@ -188,15 +188,15 @@ $.widget( "ui.button", {
|
||||
})
|
||||
// see #8559, we bind to blur here in case the button element loses
|
||||
// focus between keydown and keyup, it would be left in an "active" state
|
||||
.bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
|
||||
.on( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
|
||||
$( this ).removeClass( "ui-state-active" );
|
||||
});
|
||||
|
||||
if ( this.buttonElement.is("a") ) {
|
||||
this.buttonElement.keyup(function(event) {
|
||||
this.buttonElement.on( "keyup", function(event) {
|
||||
if ( event.keyCode === $.ui.keyCode.SPACE ) {
|
||||
// TODO pass through original event correctly (just as 2nd argument doesn't work)
|
||||
$( this ).click();
|
||||
$( this ).trigger( "click" );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user