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);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ autoOpen: false });
|
|
|
|
|
ok( !el.dialog("widget").is(":visible"), '.dialog({ autoOpen: false })');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ autoOpen: true });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
ok( el.dialog("widget").is(":visible"), '.dialog({ autoOpen: true })');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("buttons", function() {
|
2011-03-02 17:52:21 +00:00
|
|
|
|
expect(21);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
2012-04-19 14:27:06 +00:00
|
|
|
|
var btn, i, newButtons,
|
|
|
|
|
buttons = {
|
2012-11-03 20:17:16 +00:00
|
|
|
|
"Ok": function( ev ) {
|
|
|
|
|
ok(true, "button click fires callback");
|
|
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
|
equal(ev.target, btn[0], "event target");
|
|
|
|
|
},
|
|
|
|
|
"Cancel": function( ev ) {
|
|
|
|
|
ok(true, "button click fires callback");
|
|
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
|
equal(ev.target, btn[1], "event target");
|
|
|
|
|
}
|
2009-02-04 04:35:18 +00:00
|
|
|
|
},
|
2012-11-03 20:17:16 +00:00
|
|
|
|
el = $('<div></div>').dialog({ buttons: buttons });
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
btn = $("button", el.dialog('widget'));
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(btn.length, 2, "number of buttons");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
2012-04-19 14:27:06 +00:00
|
|
|
|
i = 0;
|
2012-10-23 14:36:42 +00:00
|
|
|
|
$.each(buttons, function( key ) {
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(btn.eq(i).text(), key, "text of button " + (i+1));
|
2009-02-04 04:35:18 +00:00
|
|
|
|
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");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
|
btn.trigger("click");
|
|
|
|
|
|
2012-04-19 14:27:06 +00:00
|
|
|
|
newButtons = {
|
2012-10-23 14:36:42 +00:00
|
|
|
|
"Close": function( ev ) {
|
2009-02-04 04:35:18 +00:00
|
|
|
|
ok(true, "button click fires callback");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(this, el[0], "context of callback");
|
|
|
|
|
equal(ev.target, btn[0], "event target");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(el.dialog("option", "buttons"), buttons, '.dialog("option", "buttons") getter');
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el.dialog("option", "buttons", newButtons);
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
btn = $("button", el.dialog('widget'));
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(btn.length, 1, "number of buttons after setter");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
btn.trigger('click');
|
|
|
|
|
|
|
|
|
|
i = 0;
|
2012-10-23 14:36:42 +00:00
|
|
|
|
$.each(newButtons, function( key ) {
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(btn.eq(i).text(), key, "text of button " + (i+1));
|
2009-02-04 04:35:18 +00:00
|
|
|
|
i += 1;
|
|
|
|
|
});
|
2012-02-28 14:56:32 +00:00
|
|
|
|
|
2011-03-02 17:52:21 +00:00
|
|
|
|
el.dialog("option", "buttons", null);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
btn = $("button", el.dialog('widget'));
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(btn.length, 0, "all buttons have been removed");
|
|
|
|
|
equal(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed");
|
|
|
|
|
equal(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);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var buttons,
|
|
|
|
|
el = $("<div></div>").dialog({
|
|
|
|
|
buttons: [
|
|
|
|
|
{
|
|
|
|
|
text: "a button",
|
|
|
|
|
"class": "additional-class",
|
|
|
|
|
id: "my-button-id",
|
|
|
|
|
click: function() {
|
|
|
|
|
equal(this, el[0], "correct context");
|
|
|
|
|
}
|
2010-08-31 14:17:53 +00:00
|
|
|
|
}
|
2012-11-03 20:17:16 +00:00
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
buttons = el.dialog('widget').find("button");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(buttons.length, 1, "correct number of buttons");
|
|
|
|
|
equal(buttons.attr("id"), "my-button-id", "correct id");
|
|
|
|
|
equal(buttons.text(), "a button", "correct label");
|
2010-08-31 14:17:53 +00:00
|
|
|
|
ok(buttons.hasClass("additional-class"), "additional classes added");
|
|
|
|
|
buttons.click();
|
|
|
|
|
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
2009-02-04 04:35:18 +00:00
|
|
|
|
test("closeOnEscape", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 6 );
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ closeOnEscape: false });
|
2009-09-19 10:16:08 +00:00
|
|
|
|
ok(true, 'closeOnEscape: false');
|
2012-11-03 20:17:16 +00:00
|
|
|
|
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open before ESC');
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE })
|
|
|
|
|
.simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
|
|
|
|
|
.simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open after ESC');
|
2012-02-28 14:56:32 +00:00
|
|
|
|
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el.remove();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el = $('<div></div>').dialog({ closeOnEscape: true });
|
|
|
|
|
ok(true, 'closeOnEscape: true');
|
2012-11-03 20:17:16 +00:00
|
|
|
|
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open before ESC');
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE })
|
|
|
|
|
.simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
|
|
|
|
|
.simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog is closed after ESC');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("closeText", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog();
|
|
|
|
|
equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'close',
|
2009-02-04 04:35:18 +00:00
|
|
|
|
'default close text');
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ closeText: "foo" });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'foo',
|
2009-02-04 04:35:18 +00:00
|
|
|
|
'closeText on init');
|
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog().dialog('option', 'closeText', 'bar');
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'bar',
|
2009-02-04 04:35:18 +00:00
|
|
|
|
'closeText via option method');
|
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("dialogClass", function() {
|
|
|
|
|
expect(4);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog();
|
|
|
|
|
equal(el.dialog('widget').is(".foo"), false, 'dialogClass not specified. foo class added');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ dialogClass: "foo" });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init. foo class added');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ dialogClass: "foo bar" });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init, two classes. foo class added');
|
|
|
|
|
equal(el.dialog('widget').is(".bar"), true, 'dialogClass in init, two classes. bar class added');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("draggable", function() {
|
|
|
|
|
expect(4);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ draggable: false });
|
|
|
|
|
|
|
|
|
|
TestHelpers.dialog.testDrag(el, 50, -50, 0, 0);
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el.dialog('option', 'draggable', true);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.testDrag(el, 50, -50, 50, -50);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ draggable: true });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.testDrag(el, 50, -50, 50, -50);
|
2009-09-19 10:16:08 +00:00
|
|
|
|
el.dialog('option', 'draggable', false);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.testDrag(el, 50, -50, 0, 0);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("height", function() {
|
2011-11-28 21:52:10 +00:00
|
|
|
|
expect(4);
|
2009-02-04 04:35:18 +00:00
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog();
|
|
|
|
|
equal(el.dialog('widget').outerHeight(), 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 });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').outerHeight(), 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);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').outerHeight(), 238, "explicit height set after init");
|
2011-11-28 21:52:10 +00:00
|
|
|
|
el.remove();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
|
2011-11-28 21:52:10 +00:00
|
|
|
|
el = $('<div></div>').css("padding", "20px")
|
|
|
|
|
.dialog({ height: 240 });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').outerHeight(), 240, "explicit height with padding");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("maxHeight", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ maxHeight: 200 });
|
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-s', 1000, 1000);
|
|
|
|
|
equal(el.dialog('widget').height(), 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 });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-n', -1000, -1000);
|
|
|
|
|
equal(el.dialog('widget').height(), 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);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-s', 1000, 1000);
|
|
|
|
|
equal(el.dialog('widget').height(), 300, "maxHeight");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("maxWidth", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ maxWidth: 200 });
|
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-e', 1000, 1000);
|
|
|
|
|
equal(el.dialog('widget').width(), 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 });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-w', -1000, -1000);
|
|
|
|
|
equal(el.dialog('widget').width(), 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);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-w', -1000, -1000);
|
|
|
|
|
equal(el.dialog('widget').width(), 300, "maxWidth");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("minHeight", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ minHeight: 10 });
|
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-s', -1000, -1000);
|
|
|
|
|
equal(el.dialog('widget').height(), 10, "minHeight");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ minHeight: 10 });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-n', 1000, 1000);
|
|
|
|
|
equal(el.dialog('widget').height(), 10, "minHeight");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-n', 1000, 1000);
|
|
|
|
|
equal(el.dialog('widget').height(), 30, "minHeight");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("minWidth", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ minWidth: 10 });
|
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-e', -1000, -1000);
|
|
|
|
|
equal(el.dialog('widget').width(), 10, "minWidth");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ minWidth: 10 });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-w', 1000, 1000);
|
|
|
|
|
equal(el.dialog('widget').width(), 10, "minWidth");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.drag(el, '.ui-resizable-w', 1000, 1000);
|
|
|
|
|
equal(el.dialog('widget').width(), 30, "minWidth");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
2009-09-19 14:03:53 +00:00
|
|
|
|
test("position, default center on window", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 2 );
|
2012-04-19 14:27:06 +00:00
|
|
|
|
var el = $('<div></div>').dialog(),
|
|
|
|
|
dialog = el.dialog('widget'),
|
|
|
|
|
offset = dialog.offset();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
|
|
|
|
deepEqual(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() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 2 );
|
2012-04-19 14:27:06 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ position: "top" }),
|
|
|
|
|
dialog = el.dialog('widget'),
|
|
|
|
|
offset = dialog.offset();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
|
|
|
|
deepEqual(offset.top, $(window).scrollTop());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, left on window", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 2 );
|
2012-04-19 14:27:06 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ position: "left" }),
|
|
|
|
|
dialog = el.dialog('widget'),
|
|
|
|
|
offset = dialog.offset();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, 0);
|
|
|
|
|
deepEqual(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() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 2 );
|
2012-04-19 14:27:06 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ position: "right bottom" }),
|
|
|
|
|
dialog = el.dialog('widget'),
|
|
|
|
|
offset = dialog.offset();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
|
|
|
|
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, right bottom on window w/array", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 2 );
|
2012-04-19 14:27:06 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ position: ["right", "bottom"] }),
|
|
|
|
|
dialog = el.dialog('widget'),
|
|
|
|
|
offset = dialog.offset();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
|
|
|
|
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, offset from top left w/array", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 2 );
|
2012-04-19 14:27:06 +00:00
|
|
|
|
var el = $('<div></div>').dialog({ position: [10, 10] }),
|
|
|
|
|
dialog = el.dialog('widget'),
|
|
|
|
|
offset = dialog.offset();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, 10 + $(window).scrollLeft());
|
|
|
|
|
deepEqual(offset.top, 10 + $(window).scrollTop());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, right bottom at right bottom via ui.position args", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 2 );
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var el = $('<div></div>').dialog({
|
2012-04-19 14:27:06 +00:00
|
|
|
|
position: {
|
|
|
|
|
my: "right bottom",
|
|
|
|
|
at: "right bottom"
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
dialog = el.dialog('widget'),
|
|
|
|
|
offset = dialog.offset();
|
2010-06-06 22:00:49 +00:00
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
|
|
|
|
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
2010-06-06 22:00:49 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("position, at another element", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
|
expect( 4 );
|
2010-06-06 22:00:49 +00:00
|
|
|
|
var parent = $('<div></div>').css({
|
2012-04-19 14:27:06 +00:00
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: 400,
|
|
|
|
|
left: 600,
|
|
|
|
|
height: 10,
|
|
|
|
|
width: 10
|
|
|
|
|
}).appendTo('body'),
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({
|
|
|
|
|
position: {
|
|
|
|
|
my: "left top",
|
|
|
|
|
at: "left top",
|
|
|
|
|
of: parent
|
|
|
|
|
}
|
|
|
|
|
}),
|
2010-06-06 22:00:49 +00:00
|
|
|
|
|
2012-04-19 14:27:06 +00:00
|
|
|
|
dialog = el.dialog('widget'),
|
|
|
|
|
offset = dialog.offset();
|
2010-06-06 22:00:49 +00:00
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, 600);
|
|
|
|
|
deepEqual(offset.top, 400);
|
2010-06-06 22:00:49 +00:00
|
|
|
|
|
|
|
|
|
el.dialog('option', 'position', {
|
|
|
|
|
my: "left top",
|
|
|
|
|
at: "right bottom",
|
|
|
|
|
of: parent
|
|
|
|
|
});
|
|
|
|
|
|
2012-04-19 14:27:06 +00:00
|
|
|
|
offset = dialog.offset();
|
2010-07-16 12:50:40 +00:00
|
|
|
|
|
2012-02-28 14:56:32 +00:00
|
|
|
|
deepEqual(offset.left, 610);
|
|
|
|
|
deepEqual(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);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog();
|
|
|
|
|
TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el.dialog('option', 'resizable', false);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.shouldResize(el, 0, 0, 'disabled after init');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({ resizable: false });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.shouldResize(el, 0, 0, "disabled in init options");
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el.dialog('option', 'resizable', true);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
TestHelpers.dialog.shouldResize(el, 50, 50, 'enabled after init');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
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() {
|
2012-11-03 20:17:16 +00:00
|
|
|
|
return el.dialog('widget').find(".ui-dialog-title").html();
|
2009-02-04 04:35:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var 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
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').find(".ui-dialog-title").text(), " ", "[default]");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(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();
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(titleText(), "foo", "title in element attribute");
|
|
|
|
|
equal(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' });
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(titleText(), "foo", "title in init options");
|
|
|
|
|
equal(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' });
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(titleText(), "bar", "title in init options should override title in element attribute");
|
|
|
|
|
equal(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');
|
2012-02-28 14:56:32 +00:00
|
|
|
|
equal(titleText(), 'foo', 'title after init');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("width", function() {
|
|
|
|
|
expect(3);
|
|
|
|
|
|
2012-11-03 20:17:16 +00:00
|
|
|
|
var el = $('<div></div>').dialog();
|
|
|
|
|
equal(el.dialog('widget').width(), 300, "default width");
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
|
|
|
|
|
|
|
|
|
el = $('<div></div>').dialog({width: 437 });
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').width(), 437, "explicit width");
|
2009-11-09 01:50:23 +00:00
|
|
|
|
el.dialog('option', 'width', 438);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
equal(el.dialog('widget').width(), 438, 'explicit width after init');
|
2009-02-04 04:35:18 +00:00
|
|
|
|
el.remove();
|
2009-02-02 14:36:08 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery);
|