2009-02-02 14:36:08 +00:00
|
|
|
|
/*
|
|
|
|
|
* dialog_options.js
|
|
|
|
|
*/
|
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
|
|
module("dialog: options");
|
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
|
test("autoOpen", function() {
|
|
|
|
|
expect(2);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ autoOpen: false });
|
|
|
|
|
isNotOpen('.dialog({ autoOpen: false })');
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ autoOpen: true });
|
|
|
|
|
isOpen('.dialog({ autoOpen: true })');
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("buttons", function() {
|
2011-03-02 17:52:21 +00:00
|
|
|
|
expect(21);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
|
|
|
|
var buttons = {
|
|
|
|
|
"Ok": function(ev, ui) {
|
|
|
|
|
ok(true, "button click fires callback");
|
|
|
|
|
equals(this, el[0], "context of callback");
|
|
|
|
|
equals(ev.target, btn[0], "event target");
|
|
|
|
|
},
|
|
|
|
|
"Cancel": function(ev, ui) {
|
|
|
|
|
ok(true, "button click fires callback");
|
|
|
|
|
equals(this, el[0], "context of callback");
|
|
|
|
|
equals(ev.target, btn[1], "event target");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ buttons: buttons });
|
|
|
|
|
var btn = $("button", dlg());
|
|
|
|
|
equals(btn.length, 2, "number of buttons");
|
|
|
|
|
|
|
|
|
|
var i = 0;
|
|
|
|
|
$.each(buttons, function(key, val) {
|
|
|
|
|
equals(btn.eq(i).text(), key, "text of button " + (i+1));
|
|
|
|
|
i++;
|
|
|
|
|
});
|
|
|
|
|
|
2010-07-30 00:56:28 +00:00
|
|
|
|
ok(btn.parent().hasClass('ui-dialog-buttonset'), "buttons in container");
|
2011-03-02 17:52:21 +00:00
|
|
|
|
ok(el.parent().hasClass('ui-dialog-buttons'), "dialog wrapper adds class about having buttons");
|
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
|
btn.trigger("click");
|
|
|
|
|
|
|
|
|
|
var newButtons = {
|
|
|
|
|
"Close": function(ev, ui) {
|
|
|
|
|
ok(true, "button click fires callback");
|
|
|
|
|
equals(this, el[0], "context of callback");
|
|
|
|
|
equals(ev.target, btn[0], "event target");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
|
same(el.dialog("option", "buttons"), buttons, '.dialog("option", "buttons") getter');
|
|
|
|
|
el.dialog("option", "buttons", newButtons);
|
|
|
|
|
same(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
|
|
|
|
btn = $("button", dlg());
|
|
|
|
|
equals(btn.length, 1, "number of buttons after setter");
|
|
|
|
|
btn.trigger('click');
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
$.each(newButtons, function(key, val) {
|
|
|
|
|
equals(btn.eq(i).text(), key, "text of button " + (i+1));
|
|
|
|
|
i += 1;
|
|
|
|
|
});
|
2011-03-02 17:52:21 +00:00
|
|
|
|
|
|
|
|
|
el.dialog("option", "buttons", null);
|
|
|
|
|
btn = $("button", dlg());
|
|
|
|
|
equals(btn.length, 0, "all buttons have been removed");
|
|
|
|
|
equals(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed");
|
|
|
|
|
equals(el.parent().hasClass('ui-dialog-buttons'), false, "dialog wrapper removes class about having buttons");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
2010-08-31 14:17:53 +00:00
|
|
|
|
test("buttons - advanced", function() {
|
|
|
|
|
expect(5);
|
|
|
|
|
|
|
|
|
|
el = $("<div></div>").dialog({
|
|
|
|
|
buttons: [
|
|
|
|
|
{
|
|
|
|
|
text: "a button",
|
|
|
|
|
"class": "additional-class",
|
|
|
|
|
id: "my-button-id",
|
|
|
|
|
click: function() {
|
|
|
|
|
equals(this, el[0], "correct context");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
var buttons = dlg().find("button");
|
|
|
|
|
equals(buttons.length, 1, "correct number of buttons");
|
|
|
|
|
equals(buttons.attr("id"), "my-button-id", "correct id");
|
|
|
|
|
equals(buttons.text(), "a button", "correct label");
|
|
|
|
|
ok(buttons.hasClass("additional-class"), "additional classes added");
|
|
|
|
|
buttons.click();
|
|
|
|
|
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
|
test("closeOnEscape", function() {
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el = $('<div></div>').dialog({ closeOnEscape: false });
|
|
|
|
|
ok(true, 'closeOnEscape: false');
|
|
|
|
|
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC');
|
|
|
|
|
el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE })
|
|
|
|
|
.simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
|
|
|
|
|
.simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
|
|
|
|
|
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open after ESC');
|
|
|
|
|
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ closeOnEscape: true });
|
|
|
|
|
ok(true, 'closeOnEscape: true');
|
|
|
|
|
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC');
|
|
|
|
|
el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE })
|
|
|
|
|
.simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
|
|
|
|
|
.simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
|
|
|
|
|
ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog is closed after ESC');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("closeText", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
|
|
|
|
equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'close',
|
|
|
|
|
'default close text');
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ closeText: "foo" });
|
|
|
|
|
equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'foo',
|
|
|
|
|
'closeText on init');
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog().dialog('option', 'closeText', 'bar');
|
|
|
|
|
equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'bar',
|
|
|
|
|
'closeText via option method');
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("dialogClass", function() {
|
|
|
|
|
expect(4);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
|
|
|
|
equals(dlg().is(".foo"), false, 'dialogClass not specified. foo class added');
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ dialogClass: "foo" });
|
|
|
|
|
equals(dlg().is(".foo"), true, 'dialogClass in init. foo class added');
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ dialogClass: "foo bar" });
|
|
|
|
|
equals(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added');
|
|
|
|
|
equals(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added');
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("draggable", function() {
|
|
|
|
|
expect(4);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ draggable: false });
|
|
|
|
|
shouldnotmove();
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el.dialog('option', 'draggable', true);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
shouldmove();
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ draggable: true });
|
|
|
|
|
shouldmove();
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el.dialog('option', 'draggable', false);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
shouldnotmove();
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("height", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
2011-04-25 18:04:30 +00:00
|
|
|
|
equals(dlg().height(), 150, "default height");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2010-09-07 12:58:20 +00:00
|
|
|
|
el = $('<div></div>').dialog({ height: 237 });
|
|
|
|
|
equals(dlg().height(), 237, "explicit height");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
2010-09-07 12:58:20 +00:00
|
|
|
|
el.dialog('option', 'height', 238);
|
|
|
|
|
equals(dlg().height(), 238, "explicit height set after init");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("maxHeight", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
2010-09-07 12:58:20 +00:00
|
|
|
|
el = $('<div></div>').dialog({ maxHeight: 200 });
|
2009-02-04 04:35:18 +00:00
|
|
|
|
drag('.ui-resizable-s', 1000, 1000);
|
2010-09-07 12:58:20 +00:00
|
|
|
|
equals(heightAfter, 200, "maxHeight");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2010-09-07 12:58:20 +00:00
|
|
|
|
el = $('<div></div>').dialog({ maxHeight: 200 });
|
2009-02-04 04:35:18 +00:00
|
|
|
|
drag('.ui-resizable-n', -1000, -1000);
|
2010-09-07 12:58:20 +00:00
|
|
|
|
equals(heightAfter, 200, "maxHeight");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2010-09-07 12:58:20 +00:00
|
|
|
|
el = $('<div></div>').dialog({ maxHeight: 200 }).dialog('option', 'maxHeight', 300);
|
2010-09-02 12:41:28 +00:00
|
|
|
|
drag('.ui-resizable-s', 1000, 1000);
|
2010-09-07 12:58:20 +00:00
|
|
|
|
equals(heightAfter, 300, "maxHeight");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("maxWidth", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
2010-09-07 12:58:20 +00:00
|
|
|
|
el = $('<div></div>').dialog({ maxWidth: 200 });
|
2009-02-04 04:35:18 +00:00
|
|
|
|
drag('.ui-resizable-e', 1000, 1000);
|
2010-09-07 12:58:20 +00:00
|
|
|
|
equals(widthAfter, 200, "maxWidth");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2010-09-07 12:58:20 +00:00
|
|
|
|
el = $('<div></div>').dialog({ maxWidth: 200 });
|
2009-02-04 04:35:18 +00:00
|
|
|
|
drag('.ui-resizable-w', -1000, -1000);
|
2010-09-07 12:58:20 +00:00
|
|
|
|
equals(widthAfter, 200, "maxWidth");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2010-09-07 12:58:20 +00:00
|
|
|
|
el = $('<div></div>').dialog({ maxWidth: 200 }).dialog('option', 'maxWidth', 300);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
drag('.ui-resizable-w', -1000, -1000);
|
2010-09-07 12:58:20 +00:00
|
|
|
|
equals(widthAfter, 300, "maxWidth");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("minHeight", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ minHeight: 10 });
|
|
|
|
|
drag('.ui-resizable-s', -1000, -1000);
|
|
|
|
|
equals(heightAfter, 10, "minHeight");
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ minHeight: 10 });
|
|
|
|
|
drag('.ui-resizable-n', 1000, 1000);
|
|
|
|
|
equals(heightAfter, 10, "minHeight");
|
|
|
|
|
el.remove();
|
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
drag('.ui-resizable-n', 1000, 1000);
|
|
|
|
|
equals(heightAfter, 30, "minHeight");
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("minWidth", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ minWidth: 10 });
|
|
|
|
|
drag('.ui-resizable-e', -1000, -1000);
|
|
|
|
|
equals(widthAfter, 10, "minWidth");
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ minWidth: 10 });
|
|
|
|
|
drag('.ui-resizable-w', 1000, 1000);
|
|
|
|
|
equals(widthAfter, 10, "minWidth");
|
|
|
|
|
el.remove();
|
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
drag('.ui-resizable-w', 1000, 1000);
|
|
|
|
|
equals(widthAfter, 30, "minWidth");
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
2009-09-19 14:03:53 +00:00
|
|
|
|
test("position, default center on window", function() {
|
|
|
|
|
var el = $('<div></div>').dialog();
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var dialog = el.dialog('widget');
|
|
|
|
|
var offset = dialog.offset();
|
2010-12-03 14:14:27 +00:00
|
|
|
|
same(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
|
|
|
|
same(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
|
2009-09-19 14:03:53 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
2010-06-06 22:00:49 +00:00
|
|
|
|
test("position, top on window", function() {
|
|
|
|
|
var el = $('<div></div>').dialog({ position: "top" });
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var dialog = el.dialog('widget');
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var offset = dialog.offset();
|
2010-12-03 14:14:27 +00:00
|
|
|
|
same(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
same(offset.top, $(window).scrollTop());
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, left on window", function() {
|
|
|
|
|
var el = $('<div></div>').dialog({ position: "left" });
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var dialog = el.dialog('widget');
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var offset = dialog.offset();
|
|
|
|
|
same(offset.left, 0);
|
2010-12-03 14:14:27 +00:00
|
|
|
|
same(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, right bottom on window", function() {
|
|
|
|
|
var el = $('<div></div>').dialog({ position: "right bottom" });
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var dialog = el.dialog('widget');
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var offset = dialog.offset();
|
2010-07-16 12:50:40 +00:00
|
|
|
|
same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, right bottom on window w/array", function() {
|
|
|
|
|
var el = $('<div></div>').dialog({ position: ["right", "bottom"] });
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var dialog = el.dialog('widget');
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var offset = dialog.offset();
|
2010-07-16 12:50:40 +00:00
|
|
|
|
same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, offset from top left w/array", function() {
|
|
|
|
|
var el = $('<div></div>').dialog({ position: [10, 10] });
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var dialog = el.dialog('widget');
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var offset = dialog.offset();
|
2010-07-16 12:50:40 +00:00
|
|
|
|
same(offset.left, 10 + $(window).scrollLeft());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
same(offset.top, 10 + $(window).scrollTop());
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, right bottom at right bottom via ui.position args", function() {
|
|
|
|
|
var el = $('<div></div>').dialog({
|
|
|
|
|
position: {
|
|
|
|
|
my: "right bottom",
|
|
|
|
|
at: "right bottom"
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var dialog = el.dialog('widget');
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var offset = dialog.offset();
|
|
|
|
|
|
2010-07-16 12:50:40 +00:00
|
|
|
|
same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, at another element", function() {
|
|
|
|
|
var parent = $('<div></div>').css({
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: 400,
|
|
|
|
|
left: 600,
|
|
|
|
|
height: 10,
|
|
|
|
|
width: 10
|
2010-07-16 12:50:40 +00:00
|
|
|
|
}).appendTo('body');
|
2010-06-06 22:00:49 +00:00
|
|
|
|
|
|
|
|
|
var el = $('<div></div>').dialog({
|
|
|
|
|
position: {
|
|
|
|
|
my: "left top",
|
2010-07-16 12:50:40 +00:00
|
|
|
|
at: "left top",
|
2010-06-06 22:00:49 +00:00
|
|
|
|
of: parent
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var dialog = el.dialog('widget');
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var offset = dialog.offset();
|
|
|
|
|
|
2010-07-16 12:50:40 +00:00
|
|
|
|
same(offset.left, 600);
|
|
|
|
|
same(offset.top, 400);
|
2010-06-06 22:00:49 +00:00
|
|
|
|
|
|
|
|
|
el.dialog('option', 'position', {
|
|
|
|
|
my: "left top",
|
|
|
|
|
at: "right bottom",
|
|
|
|
|
of: parent
|
|
|
|
|
});
|
|
|
|
|
|
2010-07-16 12:50:40 +00:00
|
|
|
|
var offset = dialog.offset();
|
|
|
|
|
|
|
|
|
|
same(offset.left, 610);
|
|
|
|
|
same(offset.top, 410);
|
2010-06-06 22:00:49 +00:00
|
|
|
|
|
|
|
|
|
el.remove();
|
|
|
|
|
parent.remove();
|
|
|
|
|
});
|
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
|
test("resizable", function() {
|
|
|
|
|
expect(4);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
|
|
|
|
shouldresize("[default]");
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el.dialog('option', 'resizable', false);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
shouldnotresize('disabled after init');
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ resizable: false });
|
|
|
|
|
shouldnotresize("disabled in init options");
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el.dialog('option', 'resizable', true);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
shouldresize('enabled after init');
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("title", function() {
|
2010-08-27 22:02:11 +00:00
|
|
|
|
expect(9);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
|
|
|
|
function titleText() {
|
|
|
|
|
return dlg().find(".ui-dialog-title").html();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
2010-09-07 13:49:58 +00:00
|
|
|
|
// some browsers return a non-breaking space and some return " "
|
|
|
|
|
// so we get the text to normalize to the actual non-breaking space
|
|
|
|
|
equals(dlg().find(".ui-dialog-title").text(), " ", "[default]");
|
2010-08-27 22:02:11 +00:00
|
|
|
|
equals(el.dialog("option", "title"), "", "option not changed");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2011-08-04 01:43:52 +00:00
|
|
|
|
el = $('<div title="foo">').dialog();
|
2009-02-04 04:35:18 +00:00
|
|
|
|
equals(titleText(), "foo", "title in element attribute");
|
2010-08-27 22:02:11 +00:00
|
|
|
|
equals(el.dialog("option", "title"), "foo", "option updated from attribute");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ title: 'foo' });
|
|
|
|
|
equals(titleText(), "foo", "title in init options");
|
2010-08-27 22:02:11 +00:00
|
|
|
|
equals(el.dialog("option", "title"), "foo", "opiton set from options hash");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2011-08-04 01:43:52 +00:00
|
|
|
|
el = $('<div title="foo">').dialog({ title: 'bar' });
|
2009-02-04 04:35:18 +00:00
|
|
|
|
equals(titleText(), "bar", "title in init options should override title in element attribute");
|
2010-08-27 22:02:11 +00:00
|
|
|
|
equals(el.dialog("option", "title"), "bar", "opiton set from options hash");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el = $('<div></div>').dialog().dialog('option', 'title', 'foo');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
equals(titleText(), 'foo', 'title after init');
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("width", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog();
|
2011-04-25 18:04:30 +00:00
|
|
|
|
equals(dlg().width(), 300, "default width");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({width: 437 });
|
|
|
|
|
equals(dlg().width(), 437, "explicit width");
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el.dialog('option', 'width', 438);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
equals(dlg().width(), 438, 'explicit width after init');
|
|
|
|
|
el.remove();
|
2009-02-02 14:36:08 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery);
|