}
});
- $( "#opener" ).click(function() {
+ $( "#opener" ).on( "click", function() {
$( "#dialog" ).dialog( "open" );
});
});
// 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() {
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 ],
{
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" );
});
}
},
$( "#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();
});
// 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 ] );
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");
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" );
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");
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");
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");
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");
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");
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");
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");
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();
});
// 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 () {
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();
});
$( "#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();
modal: true
});
- $( "#opener" ).click(function() {
+ $( "#opener" ).on( "click", function() {
$( "#dialog" ).dialog( "open" );
});
});
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" );
});
]
});
- $( "#destroy-dialog" ).click(function() {
+ $( "#destroy-dialog" ).on( "click", function() {
dialog.dialog( "destroy" ).show();
$( this ).remove();
});
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" );
});
});
});
$( "<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" );
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
if ( !hasFocus.length ) {
hasFocus = this.uiDialog;
}
- hasFocus.eq( 0 ).focus();
+ hasFocus.eq( 0 ).trigger( "focus" );
},
_keepFocus: function( event ) {
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();
}
// 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" );
}
}
} );
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 );
if ( !overlays ) {
this.document
- .unbind( "focusin" )
+ .off( "focusin" )
.removeData( "ui-dialog-overlays" );
} else {
this.document.data( "ui-dialog-overlays", overlays );