]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Remove core event/alias and deprecated module dependencies
authorAlexander Schmitz <arschmitz@gmail.com>
Thu, 14 May 2015 02:02:32 +0000 (22:02 -0400)
committerAlexander Schmitz <arschmitz@gmail.com>
Wed, 20 May 2015 18:27:57 +0000 (14:27 -0400)
demos/widget/default.html
tests/unit/widget/core.js
ui/widget.js

index 885960abfbdfc02d824547c4b3af508a58a68aa6..62a373114cccfcb9d6cdcc244d1079f75c1eaa41 100644 (file)
                });
 
                // click to toggle enabled/disabled
-               $( "#disable" ).click(function() {
+               $( "#disable" ).on( "click", function() {
                        // use the custom selector created for each widget to find all instances
                        // all instances are toggled together, so we can check the state from the first
                        if ( $( ":custom-colorize" ).colorize( "option", "disabled" ) ) {
                });
 
                // click to set options after initialization
-               $( "#green" ).click( function() {
+               $( "#green" ).on( "click", function() {
                        $( ":custom-colorize" ).colorize( "option", {
                                red: 64,
                                green: 250,
index c1fb44f3c46c4df928202fd364b77146879aaa7d..235bc6bb6821699a263aeb5167a22aaaf6f37937 100644 (file)
@@ -131,7 +131,7 @@ test( "jQuery usage", function() {
 
        shouldCreate = true;
        elem = $( "<div>" )
-               .bind( "testwidgetcreate", function() {
+               .on( "testwidgetcreate", function() {
                        ok( shouldCreate, "create event triggered on instantiation" );
                })
                .testWidget();
@@ -902,7 +902,7 @@ test( "_on() with delegate", function() {
                _create: function() {
                        var uuid = this.uuid;
                        this.element = {
-                               bind: function( event, handler ) {
+                               on: function( event, handler ) {
                                        equal( event, "click.testWidget" + uuid );
                                        ok( $.isFunction(handler) );
                                },
@@ -910,7 +910,7 @@ test( "_on() with delegate", function() {
                        };
                        this.widget = function() {
                                return {
-                                       delegate: function( selector, event, handler ) {
+                                       on: function( event, selector, handler ) {
                                                equal( selector, "a" );
                                                equal( event, "click.testWidget" + uuid );
                                                ok( $.isFunction(handler) );
@@ -923,7 +923,7 @@ test( "_on() with delegate", function() {
                        });
                        this.widget = function() {
                                return {
-                                       delegate: function( selector, event, handler ) {
+                                       on: function( event, selector, handler ) {
                                                equal( selector, "form fieldset > input" );
                                                equal( event, "change.testWidget" + uuid );
                                                ok( $.isFunction(handler) );
@@ -1005,7 +1005,7 @@ test( "_off() - single event", function() {
        widget._on( element, { foo: function() {
                ok( shouldTriggerWidget, "foo called from _on" );
        }});
-       element.bind( "foo", function() {
+       element.on( "foo", function() {
                ok( shouldTriggerOther, "foo called from bind" );
        });
        shouldTriggerWidget = true;
@@ -1031,7 +1031,7 @@ test( "_off() - multiple events", function() {
                        ok( shouldTriggerWidget, "bar called from _on" );
                }
        });
-       element.bind( "foo bar", function( event ) {
+       element.on( "foo bar", function( event ) {
                ok( shouldTriggerOther, event.type + " called from bind" );
        });
        shouldTriggerWidget = true;
@@ -1059,7 +1059,7 @@ test( "_off() - all events", function() {
                        ok( shouldTriggerWidget, "bar called from _on" );
                }
        });
-       element.bind( "foo bar", function( event ) {
+       element.on( "foo bar", function( event ) {
                ok( shouldTriggerOther, event.type + " called from bind" );
        });
        shouldTriggerWidget = true;
@@ -1152,7 +1152,7 @@ test( "._trigger() - no event, no ui", function() {
                }
        });
        $( document ).add( "#widget-wrapper" ).add( "#widget" )
-               .bind( "testwidgetfoo", function( event, ui ) {
+               .on( "testwidgetfoo", function( event, ui ) {
                        deepEqual( ui, {}, "empty ui hash passed" );
                        handlers.push( this );
                });
@@ -1165,7 +1165,7 @@ test( "._trigger() - no event, no ui", function() {
                "callback"
        ], "event bubbles and then invokes callback" );
 
-       $( document ).unbind( "testwidgetfoo" );
+       $( document ).off( "testwidgetfoo" );
 });
 
 test( "._trigger() - cancelled event", function() {
@@ -1180,7 +1180,7 @@ test( "._trigger() - cancelled event", function() {
                        ok( true, "callback invoked even if event is cancelled" );
                }
        })
-       .bind( "testwidgetfoo", function() {
+       .on( "testwidgetfoo", function() {
                ok( true, "event was triggered" );
                return false;
        });
@@ -1227,7 +1227,7 @@ test( "._trigger() - provide event and ui", function() {
                        }, "ui object modified" );
                }
        });
-       $( "#widget" ).bind( "testwidgetfoo", function( event, ui ) {
+       $( "#widget" ).on( "testwidgetfoo", function( event, ui ) {
                equal( event.originalEvent, originalEvent, "original event object passed" );
                deepEqual( ui, {
                        foo: "bar",
@@ -1238,7 +1238,7 @@ test( "._trigger() - provide event and ui", function() {
                }, "ui hash passed" );
                ui.foo = "notbar";
        });
-       $( "#widget-wrapper" ).bind( "testwidgetfoo", function( event, ui ) {
+       $( "#widget-wrapper" ).on( "testwidgetfoo", function( event, ui ) {
                equal( event.originalEvent, originalEvent, "original event object passed" );
                deepEqual( ui, {
                        foo: "notbar",
@@ -1285,7 +1285,7 @@ test( "._trigger() - array as ui", function() {
                        this._trigger( "foo", null, [ ui, extra ] );
                }
        });
-       $( "#widget" ).bind( "testwidgetfoo", function( event, ui, extra ) {
+       $( "#widget" ).on( "testwidgetfoo", function( event, ui, extra ) {
                deepEqual( ui, {
                        foo: "bar",
                        baz: {
@@ -1328,7 +1328,7 @@ test( "._trigger() - instance as element", function() {
                        deepEqual( ui, { foo: "bar" }, "ui object passed to callback" );
                }
        });
-       $( instance ).bind( "testwidgetfoo", function( event, ui ) {
+       $( instance ).on( "testwidgetfoo", function( event, ui ) {
                equal( event.type, "testwidgetfoo", "event object passed to event handler" );
                deepEqual( ui, { foo: "bar" }, "ui object passed to event handler" );
        });
index ae72c709b1a0ae6ed123538637789353bd1175b2..603a49136ed476d1cd210cffadc83c911ea2b098 100644 (file)
@@ -313,14 +313,14 @@ $.Widget.prototype = {
                // we can probably remove the unbind calls in 2.0
                // all event bindings should go through this._on()
                this.element
-                       .unbind( this.eventNamespace )
+                       .off( this.eventNamespace )
                        .removeData( this.widgetFullName );
                this.widget()
-                       .unbind( this.eventNamespace )
+                       .off( this.eventNamespace )
                        .removeAttr( "aria-disabled" );
 
                // clean up events and states
-               this.bindings.unbind( this.eventNamespace );
+               this.bindings.off( this.eventNamespace );
        },
        _destroy: $.noop,
 
@@ -535,9 +535,9 @@ $.Widget.prototype = {
                                eventName = match[ 1 ] + instance.eventNamespace,
                                selector = match[ 2 ];
                        if ( selector ) {
-                               delegateElement.delegate( selector, eventName, handlerProxy );
+                               delegateElement.on( eventName, selector, handlerProxy );
                        } else {
-                               element.bind( eventName, handlerProxy );
+                               element.on( eventName, handlerProxy );
                        }
                } );
        },
@@ -545,7 +545,7 @@ $.Widget.prototype = {
        _off: function( element, eventName ) {
                eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
                        this.eventNamespace;
-               element.unbind( eventName ).undelegate( eventName );
+               element.off( eventName ).off( eventName );
 
                // Clear the stack to avoid memory leaks (#10056)
                this.bindings = $( this.bindings.not( element ).get() );