2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* dialog_events.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("dialog: events");
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
test("open", function() {
|
2010-09-02 12:35:40 +00:00
|
|
|
expect(13);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
|
|
el = $("<div></div>");
|
|
|
|
el.dialog({
|
|
|
|
open: function(ev, ui) {
|
2010-09-02 12:35:40 +00:00
|
|
|
ok(el.data("dialog")._isOpen, "interal _isOpen flag is set");
|
2009-02-04 04:35:18 +00:00
|
|
|
ok(true, 'autoOpen: true fires open callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogopen', 'event type in callback');
|
|
|
|
deepEqual(ui, {}, 'ui hash in callback');
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
el = $("<div></div>");
|
|
|
|
el.dialog({
|
|
|
|
autoOpen: false,
|
|
|
|
open: function(ev, ui) {
|
|
|
|
ok(true, '.dialog("open") fires open callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogopen', 'event type in callback');
|
|
|
|
deepEqual(ui, {}, 'ui hash in callback');
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2009-07-04 03:39:19 +00:00
|
|
|
}).bind('dialogopen', function(ev, ui) {
|
2010-09-02 12:35:40 +00:00
|
|
|
ok(el.data("dialog")._isOpen, "interal _isOpen flag is set");
|
2009-02-04 04:35:18 +00:00
|
|
|
ok(true, 'dialog("open") fires open event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], 'context of event');
|
|
|
|
deepEqual(ui, {}, 'ui hash in event');
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
2009-07-04 03:39:19 +00:00
|
|
|
el.dialog("open");
|
2009-02-04 04:35:18 +00:00
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("dragStart", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(9);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2009-07-10 20:00:06 +00:00
|
|
|
el = $('<div></div>').dialog({
|
2009-02-04 04:35:18 +00:00
|
|
|
dragStart: function(ev, ui) {
|
|
|
|
ok(true, 'dragging fires dragStart callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogdragstart', 'event type in callback');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2009-07-11 00:30:46 +00:00
|
|
|
}).bind('dialogdragstart', function(ev, ui) {
|
|
|
|
ok(true, 'dragging fires dialogdragstart event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], 'context of event');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
var handle = $(".ui-dialog-titlebar", dlg());
|
|
|
|
drag(handle, 50, 50);
|
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("drag", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(9);
|
2012-04-19 14:27:06 +00:00
|
|
|
var handle,
|
|
|
|
hasDragged = false;
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2009-07-10 20:00:06 +00:00
|
|
|
el = $('<div></div>').dialog({
|
2009-02-04 04:35:18 +00:00
|
|
|
drag: function(ev, ui) {
|
2009-07-10 20:00:06 +00:00
|
|
|
if (!hasDragged) {
|
|
|
|
ok(true, 'dragging fires drag callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogdrag', 'event type in callback');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2009-07-10 20:00:06 +00:00
|
|
|
hasDragged = true;
|
|
|
|
}
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2009-07-10 20:00:06 +00:00
|
|
|
}).one('dialogdrag', function(ev, ui) {
|
|
|
|
ok(true, 'dragging fires dialogdrag event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], 'context of event');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
2012-04-19 14:27:06 +00:00
|
|
|
handle = $(".ui-dialog-titlebar", dlg());
|
2009-02-04 04:35:18 +00:00
|
|
|
drag(handle, 50, 50);
|
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("dragStop", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(9);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2009-07-10 20:00:06 +00:00
|
|
|
el = $('<div></div>').dialog({
|
2009-09-14 14:54:15 +00:00
|
|
|
dragStop: function(ev, ui) {
|
2009-02-04 04:35:18 +00:00
|
|
|
ok(true, 'dragging fires dragStop callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogdragstop', 'event type in callback');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2009-07-11 00:30:46 +00:00
|
|
|
}).bind('dialogdragstop', function(ev, ui) {
|
|
|
|
ok(true, 'dragging fires dialogdragstop event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], 'context of event');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
var handle = $(".ui-dialog-titlebar", dlg());
|
|
|
|
drag(handle, 50, 50);
|
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("resizeStart", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(13);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2009-07-10 20:00:06 +00:00
|
|
|
el = $('<div></div>').dialog({
|
2009-02-04 04:35:18 +00:00
|
|
|
resizeStart: function(ev, ui) {
|
|
|
|
ok(true, 'resizing fires resizeStart callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogresizestart', 'event type in callback');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
|
|
|
|
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
|
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.size !== undefined, "ui.size in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2009-07-11 00:30:46 +00:00
|
|
|
}).bind('dialogresizestart', function(ev, ui) {
|
|
|
|
ok(true, 'resizing fires dialogresizestart event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], 'context of event');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
|
|
|
|
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
|
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.size !== undefined, "ui.size in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
var handle = $(".ui-resizable-se", dlg());
|
|
|
|
drag(handle, 50, 50);
|
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("resize", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(13);
|
2012-04-19 14:27:06 +00:00
|
|
|
var handle,
|
|
|
|
hasResized = false;
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2009-07-10 20:00:06 +00:00
|
|
|
el = $('<div></div>').dialog({
|
2009-02-04 04:35:18 +00:00
|
|
|
resize: function(ev, ui) {
|
2009-07-10 20:00:06 +00:00
|
|
|
if (!hasResized) {
|
|
|
|
ok(true, 'resizing fires resize callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogresize', 'event type in callback');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
|
|
|
|
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
|
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.size !== undefined, "ui.size in callback");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2009-07-10 20:00:06 +00:00
|
|
|
hasResized = true;
|
|
|
|
}
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2009-07-10 20:00:06 +00:00
|
|
|
}).one('dialogresize', function(ev, ui) {
|
|
|
|
ok(true, 'resizing fires dialogresize event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], 'context of event');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
|
|
|
|
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
|
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.size !== undefined, "ui.size in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
2012-04-19 14:27:06 +00:00
|
|
|
handle = $(".ui-resizable-se", dlg());
|
2009-02-04 04:35:18 +00:00
|
|
|
drag(handle, 50, 50);
|
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("resizeStop", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(13);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2009-07-10 20:00:06 +00:00
|
|
|
el = $('<div></div>').dialog({
|
2009-02-04 04:35:18 +00:00
|
|
|
resizeStop: function(ev, ui) {
|
|
|
|
ok(true, 'resizing fires resizeStop callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogresizestop', 'event type in callback');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
|
|
|
|
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
|
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.size !== undefined, "ui.size in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2009-07-11 00:30:46 +00:00
|
|
|
}).bind('dialogresizestop', function(ev, ui) {
|
|
|
|
ok(true, 'resizing fires dialogresizestop event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], 'context of event');
|
2010-03-11 20:48:21 +00:00
|
|
|
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
|
|
|
|
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
|
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.size !== undefined, "ui.size in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
var handle = $(".ui-resizable-se", dlg());
|
|
|
|
drag(handle, 50, 50);
|
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
|
2012-10-17 13:28:51 +00:00
|
|
|
asyncTest("close", function() {
|
|
|
|
expect(14);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
|
|
el = $('<div></div>').dialog({
|
|
|
|
close: function(ev, ui) {
|
|
|
|
ok(true, '.dialog("close") fires close callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogclose', 'event type in callback');
|
|
|
|
deepEqual(ui, {}, 'ui hash in callback');
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2009-07-04 03:39:19 +00:00
|
|
|
}).bind('dialogclose', function(ev, ui) {
|
2009-02-04 04:35:18 +00:00
|
|
|
ok(true, '.dialog("close") fires dialogclose event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], 'context of event');
|
|
|
|
deepEqual(ui, {}, 'ui hash in event');
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
el.dialog('close');
|
|
|
|
el.remove();
|
2012-10-17 13:28:51 +00:00
|
|
|
|
|
|
|
// Close event with an effect
|
|
|
|
el = $('<div></div>').dialog({
|
|
|
|
hide: 10,
|
|
|
|
close: function(ev, ui) {
|
|
|
|
ok(true, '.dialog("close") fires close callback');
|
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogclose', 'event type in callback');
|
|
|
|
deepEqual(ui, {}, 'ui hash in callback');
|
|
|
|
start();
|
|
|
|
}
|
|
|
|
}).bind('dialogclose', function(ev, ui) {
|
|
|
|
ok(true, '.dialog("close") fires dialogclose event');
|
|
|
|
equal(this, el[0], 'context of event');
|
|
|
|
deepEqual(ui, {}, 'ui hash in event');
|
|
|
|
});
|
|
|
|
el.dialog('close');
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
2009-07-11 00:36:36 +00:00
|
|
|
test("beforeClose", function() {
|
2010-01-27 10:31:17 +00:00
|
|
|
expect(14);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
|
|
el = $('<div></div>').dialog({
|
2009-07-11 00:36:36 +00:00
|
|
|
beforeClose: function(ev, ui) {
|
|
|
|
ok(true, '.dialog("close") fires beforeClose callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogbeforeclose', 'event type in callback');
|
|
|
|
deepEqual(ui, {}, 'ui hash in callback');
|
2009-02-04 04:35:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
el.dialog('close');
|
2009-07-11 00:36:36 +00:00
|
|
|
isOpen('beforeClose callback should prevent dialog from closing');
|
2009-02-04 04:35:18 +00:00
|
|
|
el.remove();
|
|
|
|
|
2010-01-27 10:31:17 +00:00
|
|
|
el = $('<div></div>').dialog();
|
|
|
|
el.dialog('option', 'beforeClose', function(ev, ui) {
|
|
|
|
ok(true, '.dialog("close") fires beforeClose callback');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
equal(ev.type, 'dialogbeforeclose', 'event type in callback');
|
|
|
|
deepEqual(ui, {}, 'ui hash in callback');
|
2010-01-27 10:31:17 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
el.dialog('close');
|
|
|
|
isOpen('beforeClose callback should prevent dialog from closing');
|
|
|
|
el.remove();
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
|
|
|
|
ok(true, '.dialog("close") triggers dialogbeforeclose event');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(this, el[0], "context of event");
|
|
|
|
deepEqual(ui, {}, 'ui hash in event');
|
2009-02-04 04:35:18 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
el.dialog('close');
|
|
|
|
isOpen('dialogbeforeclose event should prevent dialog from closing');
|
|
|
|
el.remove();
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|