2015-04-07 00:23:50 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
2015-04-07 14:55:52 +00:00
|
|
|
"./helper",
|
2015-07-15 01:59:10 +00:00
|
|
|
"ui/widgets/dialog"
|
2015-04-07 14:30:07 +00:00
|
|
|
], function( $, testHelper ) {
|
2009-02-02 14:36:08 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
var element = $("<div></div>");
|
|
|
|
element.dialog({
|
2009-02-04 04:35:18 +00:00
|
|
|
open: function(ev, ui) {
|
2013-03-19 15:53:35 +00:00
|
|
|
ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set");
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "autoOpen: true fires open callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogopen", "event type in callback");
|
|
|
|
deepEqual(ui, {}, "ui hash in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
|
|
|
});
|
2013-01-31 05:38:20 +00:00
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>");
|
|
|
|
element.dialog({
|
2009-02-04 04:35:18 +00:00
|
|
|
autoOpen: false,
|
|
|
|
open: function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".dialog('open') fires open callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogopen", "event type in callback");
|
|
|
|
deepEqual(ui, {}, "ui hash in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2015-05-14 01:57:04 +00:00
|
|
|
}).on("dialogopen", function(ev, ui) {
|
2013-03-19 15:53:35 +00:00
|
|
|
ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set");
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "dialog('open') fires open event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of event");
|
2012-12-26 13:08:48 +00:00
|
|
|
deepEqual(ui, {}, "ui hash in event");
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog("open");
|
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
2012-11-09 17:44:29 +00:00
|
|
|
test( "focus", function() {
|
|
|
|
expect( 5 );
|
2013-01-31 05:38:20 +00:00
|
|
|
var element, other;
|
|
|
|
element = $("#dialog1").dialog({
|
2012-11-09 17:44:29 +00:00
|
|
|
autoOpen: false
|
|
|
|
});
|
|
|
|
other = $("#dialog2").dialog({
|
|
|
|
autoOpen: false
|
|
|
|
});
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
element.one( "dialogopen", function() {
|
2012-11-09 17:44:29 +00:00
|
|
|
ok( true, "open, just once" );
|
|
|
|
});
|
2013-01-31 05:38:20 +00:00
|
|
|
element.one( "dialogfocus", function() {
|
2012-11-09 17:44:29 +00:00
|
|
|
ok( true, "focus on open" );
|
|
|
|
});
|
|
|
|
other.dialog( "open" );
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
element.one( "dialogfocus", function() {
|
2012-11-09 17:44:29 +00:00
|
|
|
ok( true, "when opening and already open and wasn't on top" );
|
|
|
|
});
|
|
|
|
other.dialog( "open" );
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog( "open" );
|
2012-11-09 17:44:29 +00:00
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
element.one( "dialogfocus", function() {
|
2012-11-09 17:44:29 +00:00
|
|
|
ok( true, "when calling moveToTop and wasn't on top" );
|
|
|
|
});
|
|
|
|
other.dialog( "moveToTop" );
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog( "moveToTop" );
|
2012-11-09 17:44:29 +00:00
|
|
|
|
2015-05-14 01:57:04 +00:00
|
|
|
element.on( "dialogfocus", function() {
|
2012-11-09 17:44:29 +00:00
|
|
|
ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
|
|
|
|
});
|
|
|
|
other.dialog( "moveToTop" );
|
2013-01-31 05:38:20 +00:00
|
|
|
element.trigger( "mousedown" );
|
2012-11-09 17:44:29 +00:00
|
|
|
|
2015-08-21 04:11:21 +00:00
|
|
|
// Triggers just once when already on top
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog( "open" );
|
|
|
|
element.dialog( "moveToTop" );
|
|
|
|
element.trigger( "mousedown" );
|
2012-11-09 17:44:29 +00:00
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
element.add( other ).remove();
|
2012-11-09 17:44:29 +00:00
|
|
|
});
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
test("dragStart", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(9);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
var handle,
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>").dialog({
|
2012-11-03 20:17:16 +00:00
|
|
|
dragStart: function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "dragging fires dragStart callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogdragstart", "event type in callback");
|
2012-11-03 20:17:16 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
|
|
|
}
|
2015-05-14 01:57:04 +00:00
|
|
|
}).on("dialogdragstart", function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "dragging fires dialogdragstart event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[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");
|
2012-11-03 20:17:16 +00:00
|
|
|
});
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag(element, handle, 50, 50);
|
2013-01-31 05:38:20 +00:00
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("drag", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(9);
|
2012-04-19 14:27:06 +00:00
|
|
|
var handle,
|
2012-11-03 20:17:16 +00:00
|
|
|
hasDragged = false,
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>").dialog({
|
2012-11-03 20:17:16 +00:00
|
|
|
drag: function(ev, ui) {
|
|
|
|
if (!hasDragged) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "dragging fires drag callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogdrag", "event type in callback");
|
2012-11-03 20:17:16 +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
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
hasDragged = true;
|
|
|
|
}
|
2009-07-10 20:00:06 +00:00
|
|
|
}
|
2012-12-26 13:08:48 +00:00
|
|
|
}).one("dialogdrag", function(ev, ui) {
|
|
|
|
ok(true, "dragging fires dialogdrag event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of event");
|
2012-11-03 20:17:16 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
|
|
|
});
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag(element, handle, 50, 50);
|
2013-01-31 05:38:20 +00:00
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("dragStop", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(9);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
var handle,
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>").dialog({
|
2012-11-03 20:17:16 +00:00
|
|
|
dragStop: function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "dragging fires dragStop callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogdragstop", "event type in callback");
|
2012-11-03 20:17:16 +00:00
|
|
|
ok(ui.position !== undefined, "ui.position in callback");
|
|
|
|
ok(ui.offset !== undefined, "ui.offset in callback");
|
|
|
|
}
|
2015-05-14 01:57:04 +00:00
|
|
|
}).on("dialogdragstop", function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "dragging fires dialogdragstop event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[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");
|
2012-11-03 20:17:16 +00:00
|
|
|
});
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
handle = $(".ui-dialog-titlebar", element.dialog("widget"));
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag(element, handle, 50, 50);
|
2013-01-31 05:38:20 +00:00
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("resizeStart", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(13);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
var handle,
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>").dialog({
|
2012-11-03 20:17:16 +00:00
|
|
|
resizeStart: function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "resizing fires resizeStart callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogresizestart", "event type in callback");
|
2012-11-03 20:17:16 +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");
|
|
|
|
}
|
2015-05-14 01:57:04 +00:00
|
|
|
}).on("dialogresizestart", function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "resizing fires dialogresizestart event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[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");
|
2012-11-03 20:17:16 +00:00
|
|
|
});
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
handle = $(".ui-resizable-se", element.dialog("widget"));
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag(element, handle, 50, 50);
|
2013-01-31 05:38:20 +00:00
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("resize", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(13);
|
2012-04-19 14:27:06 +00:00
|
|
|
var handle,
|
2012-11-03 20:17:16 +00:00
|
|
|
hasResized = false,
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>").dialog({
|
2012-11-03 20:17:16 +00:00
|
|
|
resize: function(ev, ui) {
|
|
|
|
if (!hasResized) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "resizing fires resize callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogresize", "event type in callback");
|
2012-11-03 20:17:16 +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
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
hasResized = true;
|
|
|
|
}
|
2009-07-10 20:00:06 +00:00
|
|
|
}
|
2012-12-26 13:08:48 +00:00
|
|
|
}).one("dialogresize", function(ev, ui) {
|
|
|
|
ok(true, "resizing fires dialogresize event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of event");
|
2012-11-03 20:17:16 +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");
|
|
|
|
});
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
handle = $(".ui-resizable-se", element.dialog("widget"));
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag(element, handle, 50, 50);
|
2013-01-31 05:38:20 +00:00
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("resizeStop", function() {
|
2010-03-11 20:48:21 +00:00
|
|
|
expect(13);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
var handle,
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>").dialog({
|
2012-11-03 20:17:16 +00:00
|
|
|
resizeStop: function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "resizing fires resizeStop callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogresizestop", "event type in callback");
|
2012-11-03 20:17:16 +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");
|
|
|
|
}
|
2015-05-14 01:57:04 +00:00
|
|
|
}).on("dialogresizestop", function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "resizing fires dialogresizestop event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of event");
|
2012-11-03 20:17:16 +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");
|
|
|
|
});
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
handle = $(".ui-resizable-se", element.dialog("widget"));
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag(element, handle, 50, 50);
|
2013-01-31 05:38:20 +00:00
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
2012-10-17 13:28:51 +00:00
|
|
|
asyncTest("close", function() {
|
|
|
|
expect(14);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
var element = $("<div></div>").dialog({
|
2009-02-04 04:35:18 +00:00
|
|
|
close: function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".dialog('close') fires close callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogclose", "event type in callback");
|
|
|
|
deepEqual(ui, {}, "ui hash in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
}
|
2015-05-14 01:57:04 +00:00
|
|
|
}).on("dialogclose", function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".dialog('close') fires dialogclose event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of event");
|
2012-12-26 13:08:48 +00:00
|
|
|
deepEqual(ui, {}, "ui hash in event");
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog("close");
|
|
|
|
element.remove();
|
2012-10-17 13:28:51 +00:00
|
|
|
|
|
|
|
// Close event with an effect
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>").dialog({
|
2012-10-17 13:28:51 +00:00
|
|
|
hide: 10,
|
|
|
|
close: function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".dialog('close') fires close callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogclose", "event type in callback");
|
|
|
|
deepEqual(ui, {}, "ui hash in callback");
|
2012-10-17 13:28:51 +00:00
|
|
|
start();
|
|
|
|
}
|
2015-05-14 01:57:04 +00:00
|
|
|
}).on("dialogclose", function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".dialog('close') fires dialogclose event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of event");
|
2012-12-26 13:08:48 +00:00
|
|
|
deepEqual(ui, {}, "ui hash in event");
|
2012-10-17 13:28:51 +00:00
|
|
|
});
|
2013-01-31 05:38:20 +00:00
|
|
|
element.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
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
var element = $("<div></div>").dialog({
|
2009-07-11 00:36:36 +00:00
|
|
|
beforeClose: function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".dialog('close') fires beforeClose callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogbeforeclose", "event type in callback");
|
|
|
|
deepEqual(ui, {}, "ui hash in callback");
|
2009-02-04 04:35:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2012-11-03 20:17:16 +00:00
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog("close");
|
|
|
|
ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
|
|
|
|
element.remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
element = $("<div></div>").dialog();
|
|
|
|
element.dialog("option", "beforeClose", function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".dialog('close') fires beforeClose callback");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of callback");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(ev.type, "dialogbeforeclose", "event type in callback");
|
|
|
|
deepEqual(ui, {}, "ui hash in callback");
|
2010-01-27 10:31:17 +00:00
|
|
|
return false;
|
|
|
|
});
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog("close");
|
2012-11-03 20:17:16 +00:00
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
|
|
|
|
element.remove();
|
2010-01-27 10:31:17 +00:00
|
|
|
|
2015-05-14 01:57:04 +00:00
|
|
|
element = $("<div></div>").dialog().on("dialogbeforeclose", function(ev, ui) {
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".dialog('close') triggers dialogbeforeclose event");
|
2013-01-31 05:38:20 +00:00
|
|
|
equal(this, element[0], "context of event");
|
2012-12-26 13:08:48 +00:00
|
|
|
deepEqual(ui, {}, "ui hash in event");
|
2009-02-04 04:35:18 +00:00
|
|
|
return false;
|
|
|
|
});
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog("close");
|
|
|
|
ok( element.dialog("widget").is(":visible"), "dialogbeforeclose event should prevent dialog from closing");
|
|
|
|
element.remove();
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
2012-11-25 05:18:51 +00:00
|
|
|
// #8789 and #8838
|
|
|
|
asyncTest("ensure dialog's container doesn't scroll on resize and focus", function() {
|
|
|
|
expect(2);
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
var element = $("#dialog1").dialog(),
|
2012-11-25 05:18:51 +00:00
|
|
|
initialScroll = $(window).scrollTop();
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog("option", "height", 600);
|
2012-11-25 05:18:51 +00:00
|
|
|
equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after height change");
|
|
|
|
setTimeout( function(){
|
2012-12-26 13:08:48 +00:00
|
|
|
$(".ui-dialog-titlebar-close").simulate("mousedown");
|
2012-11-25 05:18:51 +00:00
|
|
|
equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog");
|
2013-01-31 05:38:20 +00:00
|
|
|
element.dialog("destroy");
|
2012-11-25 05:18:51 +00:00
|
|
|
start();
|
2015-02-17 15:11:58 +00:00
|
|
|
});
|
2012-11-25 05:18:51 +00:00
|
|
|
});
|
|
|
|
|
2012-12-08 01:06:29 +00:00
|
|
|
test("#5184: isOpen in dialogclose event is true", function() {
|
|
|
|
expect( 3 );
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
var element = $( "<div></div>" ).dialog({
|
2012-12-08 01:06:29 +00:00
|
|
|
close: function() {
|
2013-01-31 05:38:20 +00:00
|
|
|
ok( !element.dialog("isOpen"), "dialog is not open during close" );
|
2012-12-08 01:06:29 +00:00
|
|
|
}
|
|
|
|
});
|
2013-01-31 05:38:20 +00:00
|
|
|
ok( element.dialog("isOpen"), "dialog is open after init" );
|
|
|
|
element.dialog( "close" );
|
|
|
|
ok( !element.dialog("isOpen"), "dialog is not open after close" );
|
|
|
|
element.remove();
|
2012-12-08 01:06:29 +00:00
|
|
|
});
|
|
|
|
|
2013-01-31 05:17:45 +00:00
|
|
|
test("ensure dialog keeps focus when clicking modal overlay", function() {
|
|
|
|
expect( 2 );
|
|
|
|
|
2013-01-31 05:38:20 +00:00
|
|
|
var element = $( "<div></div>" ).dialog({
|
2013-01-31 05:17:45 +00:00
|
|
|
modal: true
|
|
|
|
});
|
2013-12-02 20:54:29 +00:00
|
|
|
equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is in dialog" );
|
2013-01-31 05:17:45 +00:00
|
|
|
$(".ui-widget-overlay").simulate("mousedown");
|
2013-12-02 20:54:29 +00:00
|
|
|
equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is still in dialog" );
|
2013-01-31 05:38:20 +00:00
|
|
|
element.remove();
|
2013-01-31 05:17:45 +00:00
|
|
|
});
|
|
|
|
|
2015-04-07 00:23:50 +00:00
|
|
|
} );
|