]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: Remove core event/alias and deprecated module dependencies
authorAlexander Schmitz <arschmitz@gmail.com>
Thu, 14 May 2015 01:54:37 +0000 (21:54 -0400)
committerAlexander Schmitz <arschmitz@gmail.com>
Wed, 20 May 2015 18:27:55 +0000 (14:27 -0400)
demos/button/default.html
demos/button/splitbutton.html
demos/button/toolbar.html
tests/unit/button/core.js
tests/unit/button/events.js
tests/unit/button/options.js
ui/button.js

index 8c16909698a64bd4f90cced78485b58f2b56b62c..1bd4f91916fa163876aa6a5667c949fe8a370b3b 100644 (file)
@@ -13,7 +13,7 @@
        $(function() {
                $( "input[type=submit], a, button" )
                        .button()
-                       .click(function( event ) {
+                       .on( "click", function( event ) {
                                event.preventDefault();
                        });
        });
index 441e0a912f22a4c73333889df437f35eb0d25859..333d54bd7660aeba8162d9b0bdd57565406be8d5 100644 (file)
@@ -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",
index e2eac055c82b9268fa1c0e474416ce6156ca7bb3..e13b4a1d1c933df3a1e4569d0e38d70ad96adf5c 100644 (file)
@@ -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: {
index 4bc8d9fe5ae3fdae1eeed233d137cf014d6a9fe5..8539464baea577938a69cb9fbf9b6c8265010ef6 100644 (file)
@@ -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();
index ec930077caafaff841515c9e002472b748d1165b..63550e2f82991e3e0a7a6c1f5e28e94a95f75c28 100644 (file)
@@ -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 } )
index 70470e671a102409bf64834c7351981ddb21bb6d..23020fc100c2d62c9f33e4bef121071af45b4062 100644 (file)
@@ -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" );
index 5182b1f1201ef8d14ffb8e1d0aa431e755c3d9d8..70cc31680346d6a7060dd4de27c7a073873c95da 100644 (file)
@@ -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" );
                                        }
                                });
                        }