mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-12-07 06:14:24 +00:00
e1230997aa
Squashed commit of the following: commit7f19f92c64
Author: Mike Sherov <mike.sherov@gmail.com> Date: Tue Oct 23 10:34:28 2012 -0400 put back in fake args for signatures that we want to keep commit257505a9e6
Author: Mike Sherov <mike.sherov@gmail.com> Date: Tue Oct 23 08:10:20 2012 -0400 changes per @scott_gonzalez commit12725480cb
Author: Mike Sherov <mike.sherov@gmail.com> Date: Mon Oct 22 22:54:05 2012 -0400 clean up unused vars in ui directory commit563595e7ae
Author: Mike Sherov <mike.sherov@gmail.com> Date: Mon Oct 22 22:37:42 2012 -0400 clean up unused vars in grunt and tests
117 lines
2.9 KiB
JavaScript
117 lines
2.9 KiB
JavaScript
/*
|
|
* dialog_core.js
|
|
*/
|
|
|
|
var el,
|
|
offsetBefore, offsetAfter,
|
|
heightBefore, heightAfter,
|
|
widthBefore, widthAfter,
|
|
dragged;
|
|
|
|
function dlg() {
|
|
return el.dialog('widget');
|
|
}
|
|
|
|
TestHelpers.isOpen = function(why) {
|
|
ok(dlg().is(":visible"), why);
|
|
};
|
|
|
|
TestHelpers.isNotOpen = function(why) {
|
|
ok(!dlg().is(":visible"), why);
|
|
};
|
|
|
|
function drag(handle, dx, dy) {
|
|
var d = dlg();
|
|
offsetBefore = d.offset();
|
|
heightBefore = d.height();
|
|
widthBefore = d.width();
|
|
//this mouseover is to work around a limitation in resizable
|
|
//TODO: fix resizable so handle doesn't require mouseover in order to be used
|
|
$(handle, d).simulate("mouseover");
|
|
$(handle, d).simulate("drag", {
|
|
dx: dx || 0,
|
|
dy: dy || 0
|
|
});
|
|
dragged = { dx: dx, dy: dy };
|
|
offsetAfter = d.offset();
|
|
heightAfter = d.height();
|
|
widthAfter = d.width();
|
|
}
|
|
|
|
TestHelpers.dialogMoved = function(dx, dy, msg) {
|
|
msg = msg ? msg + "." : "";
|
|
var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) },
|
|
expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) };
|
|
deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
|
|
};
|
|
|
|
TestHelpers.shouldmove = function(why) {
|
|
var handle = $(".ui-dialog-titlebar", dlg());
|
|
drag(handle, 50, -50);
|
|
TestHelpers.dialogMoved(50, -50, why);
|
|
};
|
|
|
|
TestHelpers.shouldnotmove = function(why) {
|
|
var handle = $(".ui-dialog-titlebar", dlg());
|
|
drag(handle, 50, -50);
|
|
TestHelpers.dialogMoved(0, 0, why);
|
|
};
|
|
|
|
TestHelpers.resized = function(dw, dh, msg) {
|
|
msg = msg ? msg + "." : "";
|
|
var actual = { width: widthAfter, height: heightAfter },
|
|
expected = { width: widthBefore + dw, height: heightBefore + dh };
|
|
deepEqual(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
|
|
};
|
|
|
|
TestHelpers.shouldresize = function(why) {
|
|
var handle = $(".ui-resizable-se", dlg());
|
|
drag(handle, 50, 50);
|
|
TestHelpers.resized(50, 50, why);
|
|
};
|
|
|
|
TestHelpers.shouldnotresize = function(why) {
|
|
var handle = $(".ui-resizable-se", dlg());
|
|
drag(handle, 50, 50);
|
|
TestHelpers.resized(0, 0, why);
|
|
};
|
|
|
|
(function($) {
|
|
|
|
module("dialog: core");
|
|
|
|
test("title id", function() {
|
|
expect(1);
|
|
|
|
el = $('<div></div>').dialog();
|
|
var titleId = dlg().find('.ui-dialog-title').attr('id');
|
|
ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id');
|
|
el.remove();
|
|
});
|
|
|
|
test("ARIA", function() {
|
|
expect(4);
|
|
|
|
el = $('<div></div>').dialog();
|
|
|
|
equal(dlg().attr('role'), 'dialog', 'dialog role');
|
|
|
|
var labelledBy = dlg().attr('aria-labelledby');
|
|
ok(labelledBy.length > 0, 'has aria-labelledby attribute');
|
|
equal(dlg().find('.ui-dialog-title').attr('id'), labelledBy,
|
|
'proper aria-labelledby attribute');
|
|
|
|
equal(dlg().find('.ui-dialog-titlebar-close').attr('role'), 'button',
|
|
'close link role');
|
|
|
|
el.remove();
|
|
});
|
|
|
|
test("widget method", function() {
|
|
expect( 1 );
|
|
var dialog = $("<div>").appendTo("#main").dialog();
|
|
deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]);
|
|
});
|
|
|
|
})(jQuery);
|