mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Deprecated beforeclose option instead of removing it for now, fixes reopened #4669 - Dialog: beforeclose option should be beforeClose.
This commit is contained in:
parent
6de9b51c57
commit
3eaf9daaca
@ -186,8 +186,40 @@ test("close", function() {
|
||||
el.remove();
|
||||
});
|
||||
|
||||
//handling of deprecated beforeclose (vs beforeClose) option
|
||||
//Ticket #4669 http://dev.jqueryui.com/ticket/4669
|
||||
//TODO: remove in 1.9pre
|
||||
test("beforeclose", function() {
|
||||
expect(10);
|
||||
|
||||
el = $('<div></div>').dialog({
|
||||
beforeclose: function(ev, ui) {
|
||||
ok(true, '.dialog("close") fires beforeClose callback');
|
||||
equals(this, el[0], "context of callback");
|
||||
equals(ev.type, 'dialogbeforeclose', 'event type in callback');
|
||||
same(ui, {}, 'ui hash in callback');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
el.dialog('close');
|
||||
isOpen('beforeclose (deprecated) callback should prevent dialog from closing');
|
||||
el.remove();
|
||||
|
||||
el = $('<div></div>').dialog();
|
||||
el.dialog('option', 'beforeclose', function(ev, ui) {
|
||||
ok(true, '.dialog("close") fires beforeClose callback');
|
||||
equals(this, el[0], "context of callback");
|
||||
equals(ev.type, 'dialogbeforeclose', 'event type in callback');
|
||||
same(ui, {}, 'ui hash in callback');
|
||||
return false;
|
||||
});
|
||||
el.dialog('close');
|
||||
isOpen('beforeclose (deprecated) callback should prevent dialog from closing');
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("beforeClose", function() {
|
||||
expect(9);
|
||||
expect(14);
|
||||
|
||||
el = $('<div></div>').dialog({
|
||||
beforeClose: function(ev, ui) {
|
||||
@ -202,6 +234,18 @@ test("beforeClose", function() {
|
||||
isOpen('beforeClose callback should prevent dialog from closing');
|
||||
el.remove();
|
||||
|
||||
el = $('<div></div>').dialog();
|
||||
el.dialog('option', 'beforeClose', function(ev, ui) {
|
||||
ok(true, '.dialog("close") fires beforeClose callback');
|
||||
equals(this, el[0], "context of callback");
|
||||
equals(ev.type, 'dialogbeforeclose', 'event type in callback');
|
||||
same(ui, {}, 'ui hash in callback');
|
||||
return false;
|
||||
});
|
||||
el.dialog('close');
|
||||
isOpen('beforeClose callback should prevent dialog from closing');
|
||||
el.remove();
|
||||
|
||||
el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
|
||||
ok(true, '.dialog("close") triggers dialogbeforeclose event');
|
||||
equals(this, el[0], "context of event");
|
||||
|
13
ui/jquery.ui.dialog.js
vendored
13
ui/jquery.ui.dialog.js
vendored
@ -137,6 +137,13 @@ $.widget("ui.dialog", {
|
||||
.html(title)
|
||||
.prependTo(uiDialogTitlebar);
|
||||
|
||||
//handling of deprecated beforeclose (vs beforeClose) option
|
||||
//Ticket #4669 http://dev.jqueryui.com/ticket/4669
|
||||
//TODO: remove in 1.9pre
|
||||
if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
|
||||
options.beforeClose = options.beforeclose;
|
||||
}
|
||||
|
||||
uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
|
||||
|
||||
(options.draggable && $.fn.draggable && self._makeDraggable());
|
||||
@ -451,6 +458,12 @@ $.widget("ui.dialog", {
|
||||
resize = false;
|
||||
|
||||
switch (key) {
|
||||
//handling of deprecated beforeclose (vs beforeClose) option
|
||||
//Ticket #4669 http://dev.jqueryui.com/ticket/4669
|
||||
//TODO: remove in 1.9pre
|
||||
case "beforeclose":
|
||||
key = "beforeClose";
|
||||
break;
|
||||
case "buttons":
|
||||
self._createButtons(value);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user