2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* dialog_methods.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
2009-09-15 15:42:41 +00:00
|
|
|
module("dialog: methods", {
|
|
|
|
teardown: function() {
|
|
|
|
$("body>.ui-dialog").remove();
|
|
|
|
}
|
|
|
|
});
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
test("init", function() {
|
2010-08-27 18:48:17 +00:00
|
|
|
expect(6);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
|
|
$("<div></div>").appendTo('body').dialog().remove();
|
|
|
|
ok(true, '.dialog() called on element');
|
|
|
|
|
|
|
|
$([]).dialog().remove();
|
|
|
|
ok(true, '.dialog() called on empty collection');
|
|
|
|
|
|
|
|
$('<div></div>').dialog().remove();
|
|
|
|
ok(true, '.dialog() called on disconnected DOMElement - never connected');
|
|
|
|
|
|
|
|
$('<div></div>').appendTo('body').remove().dialog().remove();
|
|
|
|
ok(true, '.dialog() called on disconnected DOMElement - removed');
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
2012-10-23 14:36:42 +00:00
|
|
|
el.dialog("option", "foo");
|
2009-02-04 04:35:18 +00:00
|
|
|
el.remove();
|
|
|
|
ok(true, 'arbitrary option getter after init');
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
$('<div></div>').dialog().dialog("option", "foo", "bar").remove();
|
2009-02-04 04:35:18 +00:00
|
|
|
ok(true, 'arbitrary option setter after init');
|
|
|
|
});
|
|
|
|
|
|
|
|
test("destroy", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 4 );
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
$("<div></div>").appendTo('body').dialog().dialog("destroy").remove();
|
|
|
|
ok(true, '.dialog("destroy") called on element');
|
|
|
|
|
|
|
|
$([]).dialog().dialog("destroy").remove();
|
|
|
|
ok(true, '.dialog("destroy") called on empty collection');
|
|
|
|
|
|
|
|
$('<div></div>').dialog().dialog("destroy").remove();
|
|
|
|
ok(true, '.dialog("destroy") called on disconnected DOMElement');
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('<div></div>').dialog(),
|
|
|
|
actual = expected.dialog('destroy');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'destroy is chainable');
|
2009-04-15 02:33:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("enable", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 3 );
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('<div></div>').dialog(),
|
|
|
|
actual = expected.dialog('enable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'enable is chainable');
|
|
|
|
|
2009-09-19 09:35:53 +00:00
|
|
|
el = $('<div></div>').dialog({ disabled: true });
|
|
|
|
el.dialog('enable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.dialog('option', 'disabled'), false, 'enable method sets disabled option to false');
|
2009-09-19 09:49:00 +00:00
|
|
|
ok(!dlg().hasClass('ui-dialog-disabled'), 'enable method removes ui-dialog-disabled class from ui-dialog element');
|
2009-04-15 02:33:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("disable", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 3 );
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('<div></div>').dialog(),
|
|
|
|
actual = expected.dialog('disable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'disable is chainable');
|
|
|
|
|
2009-09-19 09:35:53 +00:00
|
|
|
el = $('<div></div>').dialog({ disabled: false });
|
|
|
|
el.dialog('disable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.dialog('option', 'disabled'), true, 'disable method sets disabled option to true');
|
2009-09-19 09:49:00 +00:00
|
|
|
ok(dlg().hasClass('ui-dialog-disabled'), 'disable method adds ui-dialog-disabled class to ui-dialog element');
|
2009-04-15 02:33:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("close", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 3 );
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('<div></div>').dialog(),
|
|
|
|
actual = expected.dialog('close');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'close is chainable');
|
|
|
|
|
2009-09-19 09:49:00 +00:00
|
|
|
el = $('<div></div>').dialog();
|
|
|
|
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog visible before close method called');
|
|
|
|
el.dialog('close');
|
|
|
|
ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog hidden after close method called');
|
2009-02-04 04:35:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("isOpen", function() {
|
|
|
|
expect(4);
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.dialog('isOpen'), true, "dialog is open after init");
|
2009-02-04 04:35:18 +00:00
|
|
|
el.dialog('close');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.dialog('isOpen'), false, "dialog is closed");
|
2009-02-04 04:35:18 +00:00
|
|
|
el.remove();
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({autoOpen: false});
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.dialog('isOpen'), false, "dialog is closed after init");
|
2009-02-04 04:35:18 +00:00
|
|
|
el.dialog('open');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.dialog('isOpen'), true, "dialog is open");
|
2009-02-04 04:35:18 +00:00
|
|
|
el.remove();
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
test("moveToTop", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 3 );
|
|
|
|
|
2012-04-19 14:27:06 +00:00
|
|
|
var d1, d2, dlg1, dlg2,
|
|
|
|
expected = $('<div></div>').dialog(),
|
2009-04-15 02:33:28 +00:00
|
|
|
actual = expected.dialog('moveToTop');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'moveToTop is chainable');
|
2009-09-19 09:49:00 +00:00
|
|
|
|
2012-04-19 14:27:06 +00:00
|
|
|
d1 = $('<div></div>').dialog();
|
|
|
|
dlg1 = d1.parents('.ui-dialog');
|
2009-09-19 09:49:00 +00:00
|
|
|
d1.dialog('close');
|
|
|
|
d1.dialog('open');
|
2012-04-19 14:27:06 +00:00
|
|
|
d2 = $('<div></div>').dialog();
|
|
|
|
dlg2 = d2.parents('.ui-dialog');
|
2009-09-19 09:49:00 +00:00
|
|
|
d2.dialog('close');
|
|
|
|
d2.dialog('open');
|
|
|
|
ok(dlg1.css('zIndex') < dlg2.css('zIndex'), 'dialog 1 under dialog 2 before moveToTop method called');
|
|
|
|
d1.dialog('moveToTop');
|
|
|
|
ok(dlg1.css('zIndex') > dlg2.css('zIndex'), 'dialog 1 above dialog 2 after moveToTop method called');
|
2009-04-15 02:33:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("open", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 3 );
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('<div></div>').dialog(),
|
|
|
|
actual = expected.dialog('open');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'open is chainable');
|
2009-09-19 09:49:00 +00:00
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ autoOpen: false });
|
|
|
|
ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog hidden before open method called');
|
|
|
|
el.dialog('open');
|
|
|
|
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog visible after open method called');
|
2009-04-15 02:33:28 +00:00
|
|
|
});
|
|
|
|
|
2009-02-02 14:36:08 +00:00
|
|
|
})(jQuery);
|