mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Dialog: Fixed tests for position option.
This commit is contained in:
parent
05368115bb
commit
2366a81740
@ -242,8 +242,8 @@ test("modal", function() {
|
|||||||
|
|
||||||
test("position, default center on window", function() {
|
test("position, default center on window", function() {
|
||||||
var el = $('<div></div>').dialog();
|
var el = $('<div></div>').dialog();
|
||||||
var offset = el.parent().offset();
|
var dialog = el.dialog('widget');
|
||||||
// use .position() instead to avoid replicating center-logic?
|
var offset = dialog.offset();
|
||||||
same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
||||||
same(offset.top, Math.floor($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
|
same(offset.top, Math.floor($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
|
||||||
el.remove();
|
el.remove();
|
||||||
@ -251,16 +251,16 @@ test("position, default center on window", function() {
|
|||||||
|
|
||||||
test("position, top on window", function() {
|
test("position, top on window", function() {
|
||||||
var el = $('<div></div>').dialog({ position: "top" });
|
var el = $('<div></div>').dialog({ position: "top" });
|
||||||
var dialog = el.closest('.ui-dialog');
|
var dialog = el.dialog('widget');
|
||||||
var offset = dialog.offset();
|
var offset = dialog.offset();
|
||||||
same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2));
|
same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
||||||
same(offset.top, $(window).scrollTop());
|
same(offset.top, $(window).scrollTop());
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("position, left on window", function() {
|
test("position, left on window", function() {
|
||||||
var el = $('<div></div>').dialog({ position: "left" });
|
var el = $('<div></div>').dialog({ position: "left" });
|
||||||
var dialog = el.closest('.ui-dialog');
|
var dialog = el.dialog('widget');
|
||||||
var offset = dialog.offset();
|
var offset = dialog.offset();
|
||||||
same(offset.left, 0);
|
same(offset.left, 0);
|
||||||
same(offset.top, Math.floor($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
|
same(offset.top, Math.floor($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
|
||||||
@ -269,27 +269,27 @@ test("position, left on window", function() {
|
|||||||
|
|
||||||
test("position, right bottom on window", function() {
|
test("position, right bottom on window", function() {
|
||||||
var el = $('<div></div>').dialog({ position: "right bottom" });
|
var el = $('<div></div>').dialog({ position: "right bottom" });
|
||||||
var dialog = el.closest('.ui-dialog');
|
var dialog = el.dialog('widget');
|
||||||
var offset = dialog.offset();
|
var offset = dialog.offset();
|
||||||
same(offset.left, $(window).width() - dialog.outerWidth());
|
same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
||||||
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("position, right bottom on window w/array", function() {
|
test("position, right bottom on window w/array", function() {
|
||||||
var el = $('<div></div>').dialog({ position: ["right", "bottom"] });
|
var el = $('<div></div>').dialog({ position: ["right", "bottom"] });
|
||||||
var dialog = el.closest('.ui-dialog');
|
var dialog = el.dialog('widget');
|
||||||
var offset = dialog.offset();
|
var offset = dialog.offset();
|
||||||
same(offset.left, $(window).width() - dialog.outerWidth());
|
same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
||||||
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("position, offset from top left w/array", function() {
|
test("position, offset from top left w/array", function() {
|
||||||
var el = $('<div></div>').dialog({ position: [10, 10] });
|
var el = $('<div></div>').dialog({ position: [10, 10] });
|
||||||
var dialog = el.closest('.ui-dialog');
|
var dialog = el.dialog('widget');
|
||||||
var offset = dialog.offset();
|
var offset = dialog.offset();
|
||||||
same(offset.left, 10);
|
same(offset.left, 10 + $(window).scrollLeft());
|
||||||
same(offset.top, 10 + $(window).scrollTop());
|
same(offset.top, 10 + $(window).scrollTop());
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
@ -302,10 +302,10 @@ test("position, right bottom at right bottom via ui.position args", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog = el.closest('.ui-dialog');
|
var dialog = el.dialog('widget');
|
||||||
var offset = dialog.offset();
|
var offset = dialog.offset();
|
||||||
|
|
||||||
same(offset.left, $(window).width() - dialog.outerWidth());
|
same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
||||||
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
@ -317,22 +317,21 @@ test("position, at another element", function() {
|
|||||||
left: 600,
|
left: 600,
|
||||||
height: 10,
|
height: 10,
|
||||||
width: 10
|
width: 10
|
||||||
});
|
}).appendTo('body');
|
||||||
|
|
||||||
var el = $('<div></div>').dialog({
|
var el = $('<div></div>').dialog({
|
||||||
position: {
|
position: {
|
||||||
my: "left top",
|
my: "left top",
|
||||||
at: "top left",
|
at: "left top",
|
||||||
of: parent
|
of: parent
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var dialog = el.closest('.ui-dialog');
|
var dialog = el.dialog('widget');
|
||||||
var offset = dialog.offset();
|
var offset = dialog.offset();
|
||||||
var parentOffset = parent.offset();
|
|
||||||
|
|
||||||
same(offset.left, parentOffset.left);
|
same(offset.left, 600);
|
||||||
same(offset.top, parentOffset.top);
|
same(offset.top, 400);
|
||||||
|
|
||||||
el.dialog('option', 'position', {
|
el.dialog('option', 'position', {
|
||||||
my: "left top",
|
my: "left top",
|
||||||
@ -340,18 +339,15 @@ test("position, at another element", function() {
|
|||||||
of: parent
|
of: parent
|
||||||
});
|
});
|
||||||
|
|
||||||
same(offset.left, parentOffset.left + parent.outerWidth());
|
var offset = dialog.offset();
|
||||||
same(offset.top, parentOffset.top + parent.outerHeight());
|
|
||||||
|
same(offset.left, 610);
|
||||||
|
same(offset.top, 410);
|
||||||
|
|
||||||
el.remove();
|
el.remove();
|
||||||
parent.remove();
|
parent.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("position, others", function() {
|
|
||||||
ok(false, 'missing test - untested code is broken code');
|
|
||||||
});
|
|
||||||
|
|
||||||
test("resizable", function() {
|
test("resizable", function() {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user