]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Remove core event/alias and deprecated module dependencies
authorAlexander Schmitz <arschmitz@gmail.com>
Thu, 14 May 2015 01:57:04 +0000 (21:57 -0400)
committerAlexander Schmitz <arschmitz@gmail.com>
Wed, 20 May 2015 18:27:55 +0000 (14:27 -0400)
demos/dialog/animated.html
tests/unit/dialog/core.js
tests/unit/dialog/events.js
tests/unit/dialog/methods.js
tests/unit/dialog/options.js
tests/visual/compound/dialog_widgets.html
tests/visual/dialog/animated.html
tests/visual/dialog/complex-dialogs.html
tests/visual/dialog/form.html
tests/visual/dialog/performance.html
ui/dialog.js

index d17fef3634de23235e81b3c77853673333823582..02c3fd31fe92bbb52531dc0c7a87f238b786f050 100644 (file)
@@ -31,7 +31,7 @@
                        }
                });
 
-               $( "#opener" ).click(function() {
+               $( "#opener" ).on( "click", function() {
                        $( "#dialog" ).dialog( "open" );
                });
        });
index cb086ce8defeb86fb17fae106c376e2f5237e377..770d9f543aa4ffe918171469506a39661d263389 100644 (file)
@@ -103,7 +103,7 @@ asyncTest( "focus tabbable", function() {
                // Support: IE8
                // For some reason the focus doesn't get set properly if we don't
                // focus the body first.
-               $( "body" ).focus();
+               $( "body" ).trigger( "focus" );
 
                element = $( markup ).dialog( options );
                setTimeout(function() {
@@ -116,7 +116,7 @@ asyncTest( "focus tabbable", function() {
 
        function step1() {
                checkFocus( "<div><input><input></div>", options, function( done ) {
-                       var input = element.find( "input:last" ).focus().blur();
+                       var input = element.find( "input:last" ).trigger( "focus" ).trigger( "blur" );
                        element.dialog( "instance" )._focusTabbable();
                        setTimeout(function() {
                                equal( document.activeElement, input[ 0 ],
@@ -177,9 +177,9 @@ asyncTest( "focus tabbable", function() {
                        {
                                open: function() {
                                        var inputs = $( this ).find( "input" );
-                                       inputs.last().keydown(function( event ) {
+                                       inputs.last().on( "keydown",function( event ) {
                                                event.preventDefault();
-                                               inputs.first().focus();
+                                               inputs.first().trigger( "focus" );
                                        });
                                }
                        },
@@ -253,7 +253,7 @@ asyncTest( "#9048: multiple modal dialogs opened and closed in different order",
        $( "#dialog1" ).dialog( "close" );
        setTimeout(function() {
                $( "#dialog2" ).dialog( "close" );
-               $( "#favorite-animal" ).focus();
+               $( "#favorite-animal" ).trigger( "focus" );
                ok( true, "event handlers cleaned up (no errors thrown)" );
                start();
        });
@@ -277,20 +277,20 @@ asyncTest( "interaction between overlay and other dialogs", function() {
        // Support: IE8
        // For some reason the focus doesn't get set properly if we don't
        // focus the body first.
-       $( "body" ).focus();
+       $( "body" ).trigger( "focus" );
 
        // Wait for the modal to init
        setTimeout(function() {
                second.testWidget( "open" );
 
                // Simulate user tabbing from address bar to an element outside the dialog
-               $( "#favorite-animal" ).focus();
+               $( "#favorite-animal" ).trigger( "focus" );
                setTimeout(function() {
                        equal( document.activeElement, secondInput[ 0 ] );
 
                        // Last active dialog must receive focus
-                       firstInput.focus();
-                       $( "#favorite-animal" ).focus();
+                       firstInput.trigger( "focus" );
+                       $( "#favorite-animal" ).trigger( "focus" );
                        setTimeout(function() {
                                equal( document.activeElement, firstInput[ 0 ] );
 
index 5834b3481181189f970e14e134b231578f5176f1..0e48b7afabc6acb4ac006e2ba71243eaef3c39d0 100644 (file)
@@ -30,7 +30,7 @@ test("open", function() {
                        equal(ev.type, "dialogopen", "event type in callback");
                        deepEqual(ui, {}, "ui hash in callback");
                }
-       }).bind("dialogopen", function(ev, ui) {
+       }).on("dialogopen", function(ev, ui) {
                ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set");
                ok(true, "dialog('open') fires open event");
                equal(this, element[0], "context of event");
@@ -70,7 +70,7 @@ test( "focus", function() {
        other.dialog( "moveToTop" );
        element.dialog( "moveToTop" );
 
-       element.bind( "dialogfocus", function() {
+       element.on( "dialogfocus", function() {
                ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
        });
        other.dialog( "moveToTop" );
@@ -96,7 +96,7 @@ test("dragStart", function() {
                                ok(ui.position !== undefined, "ui.position in callback");
                                ok(ui.offset !== undefined, "ui.offset in callback");
                        }
-               }).bind("dialogdragstart", function(ev, ui) {
+               }).on("dialogdragstart", function(ev, ui) {
                        ok(true, "dragging fires dialogdragstart event");
                        equal(this, element[0], "context of event");
                        ok(ui.position !== undefined, "ui.position in callback");
@@ -148,7 +148,7 @@ test("dragStop", function() {
                                ok(ui.position !== undefined, "ui.position in callback");
                                ok(ui.offset !== undefined, "ui.offset in callback");
                        }
-               }).bind("dialogdragstop", function(ev, ui) {
+               }).on("dialogdragstop", function(ev, ui) {
                        ok(true, "dragging fires dialogdragstop event");
                        equal(this, element[0], "context of event");
                        ok(ui.position !== undefined, "ui.position in callback");
@@ -174,7 +174,7 @@ test("resizeStart", function() {
                                ok(ui.position !== undefined, "ui.position in callback");
                                ok(ui.size !== undefined, "ui.size in callback");
                        }
-               }).bind("dialogresizestart", function(ev, ui) {
+               }).on("dialogresizestart", function(ev, ui) {
                        ok(true, "resizing fires dialogresizestart event");
                        equal(this, element[0], "context of event");
                        ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
@@ -234,7 +234,7 @@ test("resizeStop", function() {
                                ok(ui.position !== undefined, "ui.position in callback");
                                ok(ui.size !== undefined, "ui.size in callback");
                        }
-               }).bind("dialogresizestop", function(ev, ui) {
+               }).on("dialogresizestop", function(ev, ui) {
                        ok(true, "resizing fires dialogresizestop event");
                        equal(this, element[0], "context of event");
                                ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
@@ -258,7 +258,7 @@ asyncTest("close", function() {
                        equal(ev.type, "dialogclose", "event type in callback");
                        deepEqual(ui, {}, "ui hash in callback");
                }
-       }).bind("dialogclose", function(ev, ui) {
+       }).on("dialogclose", function(ev, ui) {
                ok(true, ".dialog('close') fires dialogclose event");
                equal(this, element[0], "context of event");
                deepEqual(ui, {}, "ui hash in event");
@@ -276,7 +276,7 @@ asyncTest("close", function() {
                        deepEqual(ui, {}, "ui hash in callback");
                        start();
                }
-       }).bind("dialogclose", function(ev, ui) {
+       }).on("dialogclose", function(ev, ui) {
                ok(true, ".dialog('close') fires dialogclose event");
                equal(this, element[0], "context of event");
                deepEqual(ui, {}, "ui hash in event");
@@ -314,7 +314,7 @@ test("beforeClose", function() {
        ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
        element.remove();
 
-       element = $("<div></div>").dialog().bind("dialogbeforeclose", function(ev, ui) {
+       element = $("<div></div>").dialog().on("dialogbeforeclose", function(ev, ui) {
                ok(true, ".dialog('close') triggers dialogbeforeclose event");
                equal(this, element[0], "context of event");
                deepEqual(ui, {}, "ui hash in event");
index 10b0fd7bb957a4f87ab0b6fad0543d627c575982..cee0cd3a7037ebb5fd99f2c829e36659a8ee501e 100644 (file)
@@ -84,7 +84,7 @@ asyncTest("#9000: Dialog leaves broken event handler after close/destroy in cert
        expect( 1 );
        $( "#dialog1" ).dialog({ modal:true }).dialog( "close" ).dialog( "destroy" );
        setTimeout(function() {
-               $( "#favorite-animal" ).focus();
+               $( "#favorite-animal" ).trigger( "focus" );
                ok( true, "close and destroy modal dialog before its really opened" );
                start();
        });
@@ -223,23 +223,23 @@ asyncTest( "#8958: dialog can be opened while opening", function() {
        // Support: IE8
        // For some reason the #favorite-color input doesn't get focus if we don't
        // focus the body first, causing the test to hang.
-       $( "body" ).focus();
+       $( "body" ).trigger( "focus" );
 
        $( "#favorite-animal" )
                // We focus the input to start the test. Once it receives focus, the
                // dialog will open. Opening the dialog, will cause an element inside
                // the dialog to gain focus, thus blurring the input.
-               .bind( "focus", function() {
+               .on( "focus", function() {
                        element.dialog( "open" );
                })
                // When the input blurs, the dialog is in the process of opening. We
                // try to open the dialog again, to make sure that dialogs properly
                // handle a call to the open() method during the process of the dialog
                // being opened.
-               .bind( "blur", function() {
+               .on( "blur", function() {
                        element.dialog( "open" );
                })
-               .focus();
+               .trigger( "focus" );
 });
 
 test("#5531: dialog width should be at least minWidth on creation", function () {
index c33a97c01801135c7d3537ade585f10e0a5c8c97..6de336fd655345fefb0d2c90d38a96c933ad3416 100644 (file)
@@ -171,7 +171,7 @@ test("buttons - advanced", function( assert ) {
        assert.hasClasses( buttons, "additional-class" );
        deepEqual( buttons.button("option", "icons"), { primary: "ui-icon-cancel", secondary: null } );
        equal( buttons.button( "option", "text" ), false );
-       buttons.click();
+       buttons.trigger( "click" );
 
        element.remove();
 });
index fa3ffb4e4fd1171de1fd78a9f0280d1c0f31b65f..2258231e91fe71e61ac517e31a8ba7cf40e7b3da 100644 (file)
@@ -31,7 +31,7 @@
                $( "#autocomplete" ).autocomplete({
                        source: [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ]
                });
-               $( "button" ).button().click(function() {
+               $( "button" ).button().on( "click", function() {
                        $( "#dialog2" ).dialog( "open" );
                });
                $( "#datepicker" ).datepicker();
index 06c46fc8614ff81d60860e9d094cde06627e2f56..2bb0b398b968efee95e64482a06e70b5643c173c 100644 (file)
@@ -31,7 +31,7 @@
                        modal: true
                });
 
-               $( "#opener" ).click(function() {
+               $( "#opener" ).on( "click", function() {
                        $( "#dialog" ).dialog( "open" );
                });
        });
index fdc00322e37b047fba702aa708ab7b7d25d68dc7..9a6209be9f9bac0d578b94a3b7d1b1febc2f2645 100644 (file)
                                width: 600
                        });
 
-               $( "#open-dialog" ).click(function() {
+               $( "#open-dialog" ).on( "click", function() {
                        dialog.dialog( "open" );
                });
 
-               $( "#open-datepicker" ).click(function() {
+               $( "#open-datepicker" ).on( "click", function() {
                        datepickerDialog.dialog( "open" );
                });
 
-               $( "#open-autocomplete" ).click(function() {
+               $( "#open-autocomplete" ).on( "click", function() {
                        autocompleteDialog.dialog( "open" );
                });
 
@@ -81,7 +81,7 @@
                        ]
                });
 
-               $( "#destroy-dialog" ).click(function() {
+               $( "#destroy-dialog" ).on( "click", function() {
                        dialog.dialog( "destroy" ).show();
                        $( this ).remove();
                });
index eab41cdbec9f9e88e21b6608ce7dd6a0d3ab31ec..42d40f1f4d25b7645c483c814af78973f6a3fb33 100644 (file)
                        modal: true
                });
 
-               $( "#open-form" ).click(function() {
+               $( "#open-form" ).on( "click", function() {
                        $( "#form-dialog" ).dialog( "open" );
                });
 
-               $( "#open-prompt" ).click(function() {
+               $( "#open-prompt" ).on( "click", function() {
                        $( "#prompt-dialog" ).dialog( "open" );
                });
        });
index 37ff93238468e47b822f5fc6047870aab4236189..e01098ad13566339238c74e00ca223267bbe2019 100644 (file)
@@ -26,7 +26,7 @@
                });
                $( "<li>Create: " + ($.now() - start) + "ms</li>" ).appendTo( "#log" );
 
-               $( "#opener" ).click(function() {
+               $( "#opener" ).on( "click", function() {
                        start = $.now();
                        $( "#dialog" ).dialog( "open" );
                        $( "<li>Open: " + ($.now() - start) + "ms</li>" ).appendTo( "#log" );
index c7ffbd9efd724afd834a8f6eeb046599092b83fb..a9238329ed876f3e18f16d61ddf35b4d7a6d33ed 100644 (file)
@@ -207,7 +207,7 @@ $.widget( "ui.dialog", {
                this._destroyOverlay();
                this._untrackInstance();
 
-               if ( !this.opener.filter( ":focusable" ).focus().length ) {
+               if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
 
                        // Hiding a focused element doesn't trigger blur in WebKit
                        // so in case we have nothing to focus on, explicitly blur the active element
@@ -307,7 +307,7 @@ $.widget( "ui.dialog", {
                if ( !hasFocus.length ) {
                        hasFocus = this.uiDialog;
                }
-               hasFocus.eq( 0 ).focus();
+               hasFocus.eq( 0 ).trigger( "focus" );
        },
 
        _keepFocus: function( event ) {
@@ -357,12 +357,12 @@ $.widget( "ui.dialog", {
 
                                if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) && !event.shiftKey ) {
                                        this._delay( function() {
-                                               first.focus();
+                                               first.trigger( "focus" );
                                        } );
                                        event.preventDefault();
                                } else if ( ( event.target === first[ 0 ] || event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
                                        this._delay( function() {
-                                               last.focus();
+                                               last.trigger( "focus" );
                                        } );
                                        event.preventDefault();
                                }
@@ -397,7 +397,7 @@ $.widget( "ui.dialog", {
                                // causes the browser to scroll it into view, preventing the click event
                                if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
                                        // Dialog isn't getting focus when dragging (#8063)
-                                       this.uiDialog.focus();
+                                       this.uiDialog.trigger( "focus" );
                                }
                        }
                } );
@@ -476,18 +476,20 @@ $.widget( "ui.dialog", {
                        props = $.extend( { type: "button" }, props );
                        // Change the context for the click callback to be the main element
                        click = props.click;
-                       props.click = function() {
-                               click.apply( that.element[ 0 ], arguments );
-                       };
                        buttonOptions = {
                                icons: props.icons,
                                text: props.showText
                        };
                        delete props.icons;
                        delete props.showText;
+                       delete props.click;
+
                        $( "<button></button>", props )
                                .button( buttonOptions )
-                               .appendTo( that.uiButtonSet );
+                               .appendTo( that.uiButtonSet )
+                               .on( "click", function() {
+                                       click.apply( that.element[ 0 ], arguments );
+                               } );
                } );
                this._addClass( this.uiDialog, "ui-dialog-buttons" );
                this.uiDialogButtonPane.appendTo( this.uiDialog );
@@ -859,7 +861,7 @@ $.widget( "ui.dialog", {
 
                        if ( !overlays ) {
                                this.document
-                                       .unbind( "focusin" )
+                                       .off( "focusin" )
                                        .removeData( "ui-dialog-overlays" );
                        } else {
                                this.document.data( "ui-dialog-overlays", overlays );