Dialog: Remove core event/alias and deprecated module dependencies

This commit is contained in:
Alexander Schmitz 2015-05-13 21:57:04 -04:00
parent 183422bd9f
commit be0a176b1f
11 changed files with 46 additions and 44 deletions

View File

@ -31,7 +31,7 @@
}
});
$( "#opener" ).click(function() {
$( "#opener" ).on( "click", function() {
$( "#dialog" ).dialog( "open" );
});
});

View 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 ] );

View 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");

View 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 () {

View 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();
});

View 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();

View File

@ -31,7 +31,7 @@
modal: true
});
$( "#opener" ).click(function() {
$( "#opener" ).on( "click", function() {
$( "#dialog" ).dialog( "open" );
});
});

View File

@ -57,15 +57,15 @@
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();
});

View File

@ -23,11 +23,11 @@
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" );
});
});

View 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" );

View 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 );