Merge branch 'master' into interactions

Conflicts:
	tests/unit/draggable/draggable_options.js
	ui/jquery.ui.draggable.js
	ui/jquery.ui.droppable.js
	ui/jquery.ui.sortable.js
This commit is contained in:
Mike Sherov 2013-01-01 23:43:34 -05:00
commit a3c8c19775
57 changed files with 2761 additions and 2690 deletions

View File

@ -24,7 +24,7 @@
$(function() {
var tabTitle = $( "#tab_title" ),
tabContent = $( "#tab_content" ),
tabTemplate = "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
tabTemplate = "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close' role='presentation'>Remove Tab</span></li>",
tabCounter = 2;
var tabs = $( "#tabs" ).tabs();
@ -75,11 +75,19 @@
});
// close icon: removing the tab on click
$( "#tabs span.ui-icon-close" ).live( "click", function() {
tabs.delegate( "span.ui-icon-close", "click", function() {
var panelId = $( this ).closest( "li" ).remove().attr( "aria-controls" );
$( "#" + panelId ).remove();
tabs.tabs( "refresh" );
});
tabs.bind( "keyup", function( event ) {
if ( event.altKey && event.keyCode === $.ui.keyCode.BACKSPACE ) {
var panelId = tabs.find( ".ui-tabs-active" ).remove().attr( "aria-controls" );
$( "#" + panelId ).remove();
tabs.tabs( "refresh" );
}
});
});
</script>
</head>
@ -100,7 +108,7 @@
<div id="tabs">
<ul>
<li><a href="#tabs-1">Nunc tincidunt</a> <span class="ui-icon ui-icon-close">Remove Tab</span></li>
<li><a href="#tabs-1">Nunc tincidunt</a> <span class="ui-icon ui-icon-close" role="presentation">Remove Tab</span></li>
</ul>
<div id="tabs-1">
<p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>

View File

@ -9,6 +9,7 @@
"latedef": true,
"noarg": true,
"onevar": true,
"quotmark": "double",
"trailing": true,
"undef": true,
"unused": true,

View File

@ -35,6 +35,10 @@
font-size: 12px;
line-height: 15px;
}
/* avoid IE7 oscillating between overflow visible and scroll values */
#list1 > div {
overflow: visible;
}
</style>
</head>
<body>

View File

@ -6,19 +6,19 @@
module("core - selectors");
function isFocusable(selector, msg) {
QUnit.push($(selector).is(':focusable'), null, null, msg + " - selector " + selector + " is focusable");
QUnit.push($(selector).is(":focusable"), null, null, msg + " - selector " + selector + " is focusable");
}
function isNotFocusable(selector, msg) {
QUnit.push($(selector).length && !$(selector).is(':focusable'), null, null, msg + " - selector " + selector + " is not focusable");
QUnit.push($(selector).length && !$(selector).is(":focusable"), null, null, msg + " - selector " + selector + " is not focusable");
}
function isTabbable(selector, msg) {
QUnit.push($(selector).is(':tabbable'), null, null, msg + " - selector " + selector + " is tabbable");
QUnit.push($(selector).is(":tabbable"), null, null, msg + " - selector " + selector + " is tabbable");
}
function isNotTabbable(selector, msg) {
QUnit.push($(selector).length && !$(selector).is(':tabbable'), null, null, msg + " - selector " + selector + " is not tabbable");
QUnit.push($(selector).length && !$(selector).is(":tabbable"), null, null, msg + " - selector " + selector + " is not tabbable");
}
test("data", function() {
@ -26,135 +26,135 @@ test("data", function() {
var el;
function shouldHaveData(msg) {
ok(el.is(':data(test)'), msg);
ok(el.is(":data(test)"), msg);
}
function shouldNotHaveData(msg) {
ok(!el.is(':data(test)'), msg);
ok(!el.is(":data(test)"), msg);
}
el = $('<div>');
shouldNotHaveData('data never set');
el = $("<div>");
shouldNotHaveData("data never set");
el = $('<div>').data('test', null);
shouldNotHaveData('data is null');
el = $("<div>").data("test", null);
shouldNotHaveData("data is null");
el = $('<div>').data('test', true);
shouldHaveData('data set to true');
el = $("<div>").data("test", true);
shouldHaveData("data set to true");
el = $('<div>').data('test', false);
shouldNotHaveData('data set to false');
el = $("<div>").data("test", false);
shouldNotHaveData("data set to false");
el = $('<div>').data('test', 0);
shouldNotHaveData('data set to 0');
el = $("<div>").data("test", 0);
shouldNotHaveData("data set to 0");
el = $('<div>').data('test', 1);
shouldHaveData('data set to 1');
el = $("<div>").data("test", 1);
shouldHaveData("data set to 1");
el = $('<div>').data('test', '');
shouldNotHaveData('data set to empty string');
el = $("<div>").data("test", "");
shouldNotHaveData("data set to empty string");
el = $('<div>').data('test', 'foo');
shouldHaveData('data set to string');
el = $("<div>").data("test", "foo");
shouldHaveData("data set to string");
el = $('<div>').data('test', []);
shouldHaveData('data set to empty array');
el = $("<div>").data("test", []);
shouldHaveData("data set to empty array");
el = $('<div>').data('test', [1]);
shouldHaveData('data set to array');
el = $("<div>").data("test", [1]);
shouldHaveData("data set to array");
el = $('<div>').data('test', {});
shouldHaveData('data set to empty object');
el = $("<div>").data("test", {});
shouldHaveData("data set to empty object");
el = $('<div>').data('test', {foo: 'bar'});
shouldHaveData('data set to object');
el = $("<div>").data("test", {foo: "bar"});
shouldHaveData("data set to object");
el = $('<div>').data('test', new Date());
shouldHaveData('data set to date');
el = $("<div>").data("test", new Date());
shouldHaveData("data set to date");
el = $('<div>').data('test', /test/);
shouldHaveData('data set to regexp');
el = $("<div>").data("test", /test/);
shouldHaveData("data set to regexp");
el = $('<div>').data('test', function() {});
shouldHaveData('data set to function');
el = $("<div>").data("test", function() {});
shouldHaveData("data set to function");
});
test("focusable - visible, enabled elements", function() {
expect(18);
isNotFocusable('#formNoTabindex', 'form');
isFocusable('#formTabindex', 'form with tabindex');
isFocusable('#visibleAncestor-inputTypeNone', 'input, no type');
isFocusable('#visibleAncestor-inputTypeText', 'input, type text');
isFocusable('#visibleAncestor-inputTypeCheckbox', 'input, type checkbox');
isFocusable('#visibleAncestor-inputTypeRadio', 'input, type radio');
isFocusable('#visibleAncestor-inputTypeButton', 'input, type button');
isNotFocusable('#visibleAncestor-inputTypeHidden', 'input, type hidden');
isFocusable('#visibleAncestor-button', 'button');
isFocusable('#visibleAncestor-select', 'select');
isFocusable('#visibleAncestor-textarea', 'textarea');
isFocusable('#visibleAncestor-object', 'object');
isFocusable('#visibleAncestor-anchorWithHref', 'anchor with href');
isNotFocusable('#visibleAncestor-anchorWithoutHref', 'anchor without href');
isNotFocusable('#visibleAncestor-span', 'span');
isNotFocusable('#visibleAncestor-div', 'div');
isFocusable("#visibleAncestor-spanWithTabindex", 'span with tabindex');
isFocusable("#visibleAncestor-divWithNegativeTabindex", 'div with tabindex');
isNotFocusable("#formNoTabindex", "form");
isFocusable("#formTabindex", "form with tabindex");
isFocusable("#visibleAncestor-inputTypeNone", "input, no type");
isFocusable("#visibleAncestor-inputTypeText", "input, type text");
isFocusable("#visibleAncestor-inputTypeCheckbox", "input, type checkbox");
isFocusable("#visibleAncestor-inputTypeRadio", "input, type radio");
isFocusable("#visibleAncestor-inputTypeButton", "input, type button");
isNotFocusable("#visibleAncestor-inputTypeHidden", "input, type hidden");
isFocusable("#visibleAncestor-button", "button");
isFocusable("#visibleAncestor-select", "select");
isFocusable("#visibleAncestor-textarea", "textarea");
isFocusable("#visibleAncestor-object", "object");
isFocusable("#visibleAncestor-anchorWithHref", "anchor with href");
isNotFocusable("#visibleAncestor-anchorWithoutHref", "anchor without href");
isNotFocusable("#visibleAncestor-span", "span");
isNotFocusable("#visibleAncestor-div", "div");
isFocusable("#visibleAncestor-spanWithTabindex", "span with tabindex");
isFocusable("#visibleAncestor-divWithNegativeTabindex", "div with tabindex");
});
test("focusable - disabled elements", function() {
expect(9);
isNotFocusable('#disabledElement-inputTypeNone', 'input, no type');
isNotFocusable('#disabledElement-inputTypeText', 'input, type text');
isNotFocusable('#disabledElement-inputTypeCheckbox', 'input, type checkbox');
isNotFocusable('#disabledElement-inputTypeRadio', 'input, type radio');
isNotFocusable('#disabledElement-inputTypeButton', 'input, type button');
isNotFocusable('#disabledElement-inputTypeHidden', 'input, type hidden');
isNotFocusable('#disabledElement-button', 'button');
isNotFocusable('#disabledElement-select', 'select');
isNotFocusable('#disabledElement-textarea', 'textarea');
isNotFocusable("#disabledElement-inputTypeNone", "input, no type");
isNotFocusable("#disabledElement-inputTypeText", "input, type text");
isNotFocusable("#disabledElement-inputTypeCheckbox", "input, type checkbox");
isNotFocusable("#disabledElement-inputTypeRadio", "input, type radio");
isNotFocusable("#disabledElement-inputTypeButton", "input, type button");
isNotFocusable("#disabledElement-inputTypeHidden", "input, type hidden");
isNotFocusable("#disabledElement-button", "button");
isNotFocusable("#disabledElement-select", "select");
isNotFocusable("#disabledElement-textarea", "textarea");
});
test("focusable - hidden styles", function() {
expect(8);
isNotFocusable('#displayNoneAncestor-input', 'input, display: none parent');
isNotFocusable('#displayNoneAncestor-span', 'span with tabindex, display: none parent');
isNotFocusable("#displayNoneAncestor-input", "input, display: none parent");
isNotFocusable("#displayNoneAncestor-span", "span with tabindex, display: none parent");
isNotFocusable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent');
isNotFocusable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent');
isNotFocusable("#visibilityHiddenAncestor-input", "input, visibility: hidden parent");
isNotFocusable("#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent");
isNotFocusable('#displayNone-input', 'input, display: none');
isNotFocusable('#visibilityHidden-input', 'input, visibility: hidden');
isNotFocusable("#displayNone-input", "input, display: none");
isNotFocusable("#visibilityHidden-input", "input, visibility: hidden");
isNotFocusable('#displayNone-span', 'span with tabindex, display: none');
isNotFocusable('#visibilityHidden-span', 'span with tabindex, visibility: hidden');
isNotFocusable("#displayNone-span", "span with tabindex, display: none");
isNotFocusable("#visibilityHidden-span", "span with tabindex, visibility: hidden");
});
test("focusable - natively focusable with various tabindex", function() {
expect(4);
isFocusable('#inputTabindex0', 'input, tabindex 0');
isFocusable('#inputTabindex10', 'input, tabindex 10');
isFocusable('#inputTabindex-1', 'input, tabindex -1');
isFocusable('#inputTabindex-50', 'input, tabindex -50');
isFocusable("#inputTabindex0", "input, tabindex 0");
isFocusable("#inputTabindex10", "input, tabindex 10");
isFocusable("#inputTabindex-1", "input, tabindex -1");
isFocusable("#inputTabindex-50", "input, tabindex -50");
});
test("focusable - not natively focusable with various tabindex", function() {
expect(4);
isFocusable('#spanTabindex0', 'span, tabindex 0');
isFocusable('#spanTabindex10', 'span, tabindex 10');
isFocusable('#spanTabindex-1', 'span, tabindex -1');
isFocusable('#spanTabindex-50', 'span, tabindex -50');
isFocusable("#spanTabindex0", "span, tabindex 0");
isFocusable("#spanTabindex10", "span, tabindex 10");
isFocusable("#spanTabindex-1", "span, tabindex -1");
isFocusable("#spanTabindex-50", "span, tabindex -50");
});
test("focusable - area elements", function() {
expect( 3 );
isFocusable('#areaCoordsHref', 'coords and href');
isFocusable('#areaNoCoordsHref', 'href but no coords');
isNotFocusable('#areaNoImg', 'not associated with an image');
isFocusable("#areaCoordsHref", "coords and href");
isFocusable("#areaNoCoordsHref", "href but no coords");
isNotFocusable("#areaNoImg", "not associated with an image");
});
test( "focusable - dimensionless parent with overflow", function() {
@ -166,80 +166,80 @@ test( "focusable - dimensionless parent with overflow", function() {
test("tabbable - visible, enabled elements", function() {
expect(18);
isNotTabbable('#formNoTabindex', 'form');
isTabbable('#formTabindex', 'form with tabindex');
isTabbable('#visibleAncestor-inputTypeNone', 'input, no type');
isTabbable('#visibleAncestor-inputTypeText', 'input, type text');
isTabbable('#visibleAncestor-inputTypeCheckbox', 'input, type checkbox');
isTabbable('#visibleAncestor-inputTypeRadio', 'input, type radio');
isTabbable('#visibleAncestor-inputTypeButton', 'input, type button');
isNotTabbable('#visibleAncestor-inputTypeHidden', 'input, type hidden');
isTabbable('#visibleAncestor-button', 'button');
isTabbable('#visibleAncestor-select', 'select');
isTabbable('#visibleAncestor-textarea', 'textarea');
isTabbable('#visibleAncestor-object', 'object');
isTabbable('#visibleAncestor-anchorWithHref', 'anchor with href');
isNotTabbable('#visibleAncestor-anchorWithoutHref', 'anchor without href');
isNotTabbable('#visibleAncestor-span', 'span');
isNotTabbable('#visibleAncestor-div', 'div');
isTabbable("#visibleAncestor-spanWithTabindex", 'span with tabindex');
isNotTabbable("#visibleAncestor-divWithNegativeTabindex", 'div with tabindex');
isNotTabbable("#formNoTabindex", "form");
isTabbable("#formTabindex", "form with tabindex");
isTabbable("#visibleAncestor-inputTypeNone", "input, no type");
isTabbable("#visibleAncestor-inputTypeText", "input, type text");
isTabbable("#visibleAncestor-inputTypeCheckbox", "input, type checkbox");
isTabbable("#visibleAncestor-inputTypeRadio", "input, type radio");
isTabbable("#visibleAncestor-inputTypeButton", "input, type button");
isNotTabbable("#visibleAncestor-inputTypeHidden", "input, type hidden");
isTabbable("#visibleAncestor-button", "button");
isTabbable("#visibleAncestor-select", "select");
isTabbable("#visibleAncestor-textarea", "textarea");
isTabbable("#visibleAncestor-object", "object");
isTabbable("#visibleAncestor-anchorWithHref", "anchor with href");
isNotTabbable("#visibleAncestor-anchorWithoutHref", "anchor without href");
isNotTabbable("#visibleAncestor-span", "span");
isNotTabbable("#visibleAncestor-div", "div");
isTabbable("#visibleAncestor-spanWithTabindex", "span with tabindex");
isNotTabbable("#visibleAncestor-divWithNegativeTabindex", "div with tabindex");
});
test("tabbable - disabled elements", function() {
expect(9);
isNotTabbable('#disabledElement-inputTypeNone', 'input, no type');
isNotTabbable('#disabledElement-inputTypeText', 'input, type text');
isNotTabbable('#disabledElement-inputTypeCheckbox', 'input, type checkbox');
isNotTabbable('#disabledElement-inputTypeRadio', 'input, type radio');
isNotTabbable('#disabledElement-inputTypeButton', 'input, type button');
isNotTabbable('#disabledElement-inputTypeHidden', 'input, type hidden');
isNotTabbable('#disabledElement-button', 'button');
isNotTabbable('#disabledElement-select', 'select');
isNotTabbable('#disabledElement-textarea', 'textarea');
isNotTabbable("#disabledElement-inputTypeNone", "input, no type");
isNotTabbable("#disabledElement-inputTypeText", "input, type text");
isNotTabbable("#disabledElement-inputTypeCheckbox", "input, type checkbox");
isNotTabbable("#disabledElement-inputTypeRadio", "input, type radio");
isNotTabbable("#disabledElement-inputTypeButton", "input, type button");
isNotTabbable("#disabledElement-inputTypeHidden", "input, type hidden");
isNotTabbable("#disabledElement-button", "button");
isNotTabbable("#disabledElement-select", "select");
isNotTabbable("#disabledElement-textarea", "textarea");
});
test("tabbable - hidden styles", function() {
expect(8);
isNotTabbable('#displayNoneAncestor-input', 'input, display: none parent');
isNotTabbable('#displayNoneAncestor-span', 'span with tabindex, display: none parent');
isNotTabbable("#displayNoneAncestor-input", "input, display: none parent");
isNotTabbable("#displayNoneAncestor-span", "span with tabindex, display: none parent");
isNotTabbable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent');
isNotTabbable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent');
isNotTabbable("#visibilityHiddenAncestor-input", "input, visibility: hidden parent");
isNotTabbable("#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent");
isNotTabbable('#displayNone-input', 'input, display: none');
isNotTabbable('#visibilityHidden-input', 'input, visibility: hidden');
isNotTabbable("#displayNone-input", "input, display: none");
isNotTabbable("#visibilityHidden-input", "input, visibility: hidden");
isNotTabbable('#displayNone-span', 'span with tabindex, display: none');
isNotTabbable('#visibilityHidden-span', 'span with tabindex, visibility: hidden');
isNotTabbable("#displayNone-span", "span with tabindex, display: none");
isNotTabbable("#visibilityHidden-span", "span with tabindex, visibility: hidden");
});
test("tabbable - natively tabbable with various tabindex", function() {
expect(4);
isTabbable('#inputTabindex0', 'input, tabindex 0');
isTabbable('#inputTabindex10', 'input, tabindex 10');
isNotTabbable('#inputTabindex-1', 'input, tabindex -1');
isNotTabbable('#inputTabindex-50', 'input, tabindex -50');
isTabbable("#inputTabindex0", "input, tabindex 0");
isTabbable("#inputTabindex10", "input, tabindex 10");
isNotTabbable("#inputTabindex-1", "input, tabindex -1");
isNotTabbable("#inputTabindex-50", "input, tabindex -50");
});
test("tabbable - not natively tabbable with various tabindex", function() {
expect(4);
isTabbable('#spanTabindex0', 'span, tabindex 0');
isTabbable('#spanTabindex10', 'span, tabindex 10');
isNotTabbable('#spanTabindex-1', 'span, tabindex -1');
isNotTabbable('#spanTabindex-50', 'span, tabindex -50');
isTabbable("#spanTabindex0", "span, tabindex 0");
isTabbable("#spanTabindex10", "span, tabindex 10");
isNotTabbable("#spanTabindex-1", "span, tabindex -1");
isNotTabbable("#spanTabindex-50", "span, tabindex -50");
});
test("tabbable - area elements", function() {
expect( 3 );
isTabbable('#areaCoordsHref', 'coords and href');
isTabbable('#areaNoCoordsHref', 'href but no coords');
isNotTabbable('#areaNoImg', 'not associated with an image');
isTabbable("#areaCoordsHref", "coords and href");
isTabbable("#areaNoCoordsHref", "href but no coords");
isNotTabbable("#areaNoImg", "not associated with an image");
});
test( "tabbable - dimensionless parent with overflow", function() {

View File

@ -10,12 +10,12 @@ TestHelpers.testJshint( "datepicker" );
test("initialization - Reinitialization after body had been emptied.", function() {
expect( 1 );
var bodyContent = $('body').children(), inp = $("#inp");
var bodyContent = $("body").children(), inp = $("#inp");
$("#inp").datepicker();
$('body').empty().append(inp);
$("body").empty().append(inp);
$("#inp").datepicker();
ok( $("#"+$.datepicker._mainDivId).length===1, "Datepicker container added" );
$('body').empty().append(bodyContent); // Returning to initial state for later tests
$("body").empty().append(bodyContent); // Returning to initial state for later tests
});
test( "widget method - empty collection", function() {
@ -30,46 +30,46 @@ test("widget method", function() {
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
});
asyncTest('baseStructure', function() {
asyncTest("baseStructure", function() {
expect( 58 );
var header, title, table, thead, week, panel, inl, child,
inp = TestHelpers.datepicker.init('#inp'),
dp = $('#ui-datepicker-div');
inp = TestHelpers.datepicker.init("#inp"),
dp = $("#ui-datepicker-div");
function step1() {
inp[0].focus();
setTimeout(function() {
ok(dp.is(':visible'), 'Structure - datepicker visible');
ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');
ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');
equal(dp.children().length, 2, 'Structure - child count');
ok(dp.is(":visible"), "Structure - datepicker visible");
ok(!dp.is(".ui-datepicker-rtl"), "Structure - not right-to-left");
ok(!dp.is(".ui-datepicker-multi"), "Structure - not multi-month");
equal(dp.children().length, 2, "Structure - child count");
header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure - header division');
equal(header.children().length, 3, 'Structure - header child count');
ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() !== '', 'Structure - prev link');
ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() !== '', 'Structure - next link');
header = dp.children(":first");
ok(header.is("div.ui-datepicker-header"), "Structure - header division");
equal(header.children().length, 3, "Structure - header child count");
ok(header.children(":first").is("a.ui-datepicker-prev") && header.children(":first").html() !== "", "Structure - prev link");
ok(header.children(":eq(1)").is("a.ui-datepicker-next") && header.children(":eq(1)").html() !== "", "Structure - next link");
title = header.children(':last');
ok(title.is('div.ui-datepicker-title') && title.html() !== '','Structure - title division');
equal(title.children().length, 2, 'Structure - title child count');
ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() !== '', 'Structure - month text');
ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() !== '', 'Structure - year text');
title = header.children(":last");
ok(title.is("div.ui-datepicker-title") && title.html() !== "","Structure - title division");
equal(title.children().length, 2, "Structure - title child count");
ok(title.children(":first").is("span.ui-datepicker-month") && title.children(":first").text() !== "", "Structure - month text");
ok(title.children(":last").is("span.ui-datepicker-year") && title.children(":last").text() !== "", "Structure - year text");
table = dp.children(':eq(1)');
ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table');
ok(table.children(':first').is('thead'), 'Structure - month table thead');
thead = table.children(':first').children(':first');
ok(thead.is('tr'), 'Structure - month table title row');
equal(thead.find('th').length, 7, 'Structure - month table title cells');
ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body');
ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count');
week = table.children(':eq(1)').children(':first');
ok(week.is('tr'), 'Structure - month table week row');
equal(week.children().length, 7, 'Structure - week child count');
ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell');
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
inp.datepicker('hide').datepicker('destroy');
table = dp.children(":eq(1)");
ok(table.is("table.ui-datepicker-calendar"), "Structure - month table");
ok(table.children(":first").is("thead"), "Structure - month table thead");
thead = table.children(":first").children(":first");
ok(thead.is("tr"), "Structure - month table title row");
equal(thead.find("th").length, 7, "Structure - month table title cells");
ok(table.children(":eq(1)").is("tbody"), "Structure - month table body");
ok(table.children(":eq(1)").children("tr").length >= 4, "Structure - month table week count");
week = table.children(":eq(1)").children(":first");
ok(week.is("tr"), "Structure - month table week row");
equal(week.children().length, 7, "Structure - week child count");
ok(week.children(":first").is("td.ui-datepicker-week-end"), "Structure - month table first day cell");
ok(week.children(":last").is("td.ui-datepicker-week-end"), "Structure - month table second day cell");
inp.datepicker("hide").datepicker("destroy");
step2();
});
@ -77,19 +77,19 @@ asyncTest('baseStructure', function() {
function step2() {
// Editable month/year and button panel
inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
inp = TestHelpers.datepicker.init("#inp", {changeMonth: true, changeYear: true, showButtonPanel: true});
inp.focus();
setTimeout(function() {
title = dp.find('div.ui-datepicker-title');
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector');
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector');
title = dp.find("div.ui-datepicker-title");
ok(title.children(":first").is("select.ui-datepicker-month"), "Structure - month selector");
ok(title.children(":last").is("select.ui-datepicker-year"), "Structure - year selector");
panel = dp.children(':last');
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division');
equal(panel.children().length, 2, 'Structure - button panel child count');
ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button');
ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button');
inp.datepicker('hide').datepicker('destroy');
panel = dp.children(":last");
ok(panel.is("div.ui-datepicker-buttonpane"), "Structure - button panel division");
equal(panel.children().length, 2, "Structure - button panel child count");
ok(panel.children(":first").is("button.ui-datepicker-current"), "Structure - today button");
ok(panel.children(":last").is("button.ui-datepicker-close"), "Structure - close button");
inp.datepicker("hide").datepicker("destroy");
step3();
});
@ -97,19 +97,19 @@ asyncTest('baseStructure', function() {
function step3() {
// Multi-month 2
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2});
inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: 2});
inp.focus();
setTimeout(function() {
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
equal(dp.children().length, 3, 'Structure multi [2] - child count');
child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division');
child = dp.children(':eq(1)');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division');
child = dp.children(':eq(2)');
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2] - row break');
ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2');
inp.datepicker('hide').datepicker('destroy');
ok(dp.is(".ui-datepicker-multi"), "Structure multi [2] - multi-month");
equal(dp.children().length, 3, "Structure multi [2] - child count");
child = dp.children(":first");
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2] - first month division");
child = dp.children(":eq(1)");
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2] - second month division");
child = dp.children(":eq(2)");
ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2] - row break");
ok(dp.is(".ui-datepicker-multi-2"), "Structure multi [2] - multi-2");
inp.datepicker("hide").datepicker("destroy");
step4();
});
@ -117,12 +117,12 @@ asyncTest('baseStructure', function() {
function step4() {
// Multi-month 3
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3});
inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: 3});
inp.focus();
setTimeout(function() {
ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3');
ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704');
inp.datepicker('hide').datepicker('destroy');
ok(dp.is(".ui-datepicker-multi-3"), "Structure multi [3] - multi-3");
ok(! dp.is(".ui-datepicker-multi-2"), "Structure multi [3] - Trac #6704");
inp.datepicker("hide").datepicker("destroy");
step5();
});
@ -130,53 +130,53 @@ asyncTest('baseStructure', function() {
function step5() {
// Multi-month [2, 2]
inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: [2, 2]});
inp = TestHelpers.datepicker.init("#inp", {numberOfMonths: [2, 2]});
inp.focus();
setTimeout(function() {
ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month');
equal(dp.children().length, 6, 'Structure multi [2,2] - child count');
child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division');
child = dp.children(':eq(1)');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - second month division');
child = dp.children(':eq(2)');
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break');
child = dp.children(':eq(3)');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - third month division');
child = dp.children(':eq(4)');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2,2] - fourth month division');
child = dp.children(':eq(5)');
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break');
inp.datepicker('hide').datepicker('destroy');
ok(dp.is(".ui-datepicker-multi"), "Structure multi - multi-month");
equal(dp.children().length, 6, "Structure multi [2,2] - child count");
child = dp.children(":first");
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2,2] - first month division");
child = dp.children(":eq(1)");
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2,2] - second month division");
child = dp.children(":eq(2)");
ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2,2] - row break");
child = dp.children(":eq(3)");
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure multi [2,2] - third month division");
child = dp.children(":eq(4)");
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure multi [2,2] - fourth month division");
child = dp.children(":eq(5)");
ok(child.is("div.ui-datepicker-row-break"), "Structure multi [2,2] - row break");
inp.datepicker("hide").datepicker("destroy");
// Inline
inl = TestHelpers.datepicker.init('#inl');
inl = TestHelpers.datepicker.init("#inl");
dp = inl.children();
ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');
ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');
ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month');
equal(dp.children().length, 2, 'Structure inline - child count');
header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division');
equal(header.children().length, 3, 'Structure inline - header child count');
table = dp.children(':eq(1)');
ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table');
ok(table.children(':first').is('thead'), 'Structure inline - month table thead');
ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body');
inl.datepicker('destroy');
ok(dp.is(".ui-datepicker-inline"), "Structure inline - main div");
ok(!dp.is(".ui-datepicker-rtl"), "Structure inline - not right-to-left");
ok(!dp.is(".ui-datepicker-multi"), "Structure inline - not multi-month");
equal(dp.children().length, 2, "Structure inline - child count");
header = dp.children(":first");
ok(header.is("div.ui-datepicker-header"), "Structure inline - header division");
equal(header.children().length, 3, "Structure inline - header child count");
table = dp.children(":eq(1)");
ok(table.is("table.ui-datepicker-calendar"), "Structure inline - month table");
ok(table.children(":first").is("thead"), "Structure inline - month table thead");
ok(table.children(":eq(1)").is("tbody"), "Structure inline - month table body");
inl.datepicker("destroy");
// Inline multi-month
inl = TestHelpers.datepicker.init('#inl', {numberOfMonths: 2});
inl = TestHelpers.datepicker.init("#inl", {numberOfMonths: 2});
dp = inl.children();
ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div');
equal(dp.children().length, 3, 'Structure inline multi - child count');
child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division');
child = dp.children(':eq(1)');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure inline multi - second month division');
child = dp.children(':eq(2)');
ok(child.is('div.ui-datepicker-row-break'), 'Structure inline multi - row break');
inl.datepicker('destroy');
ok(dp.is(".ui-datepicker-inline") && dp.is(".ui-datepicker-multi"), "Structure inline multi - main div");
equal(dp.children().length, 3, "Structure inline multi - child count");
child = dp.children(":first");
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-first"), "Structure inline multi - first month division");
child = dp.children(":eq(1)");
ok(child.is("div.ui-datepicker-group") && child.is("div.ui-datepicker-group-last"), "Structure inline multi - second month division");
child = dp.children(":eq(2)");
ok(child.is("div.ui-datepicker-row-break"), "Structure inline multi - row break");
inl.datepicker("destroy");
start();
});
@ -185,279 +185,279 @@ asyncTest('baseStructure', function() {
step1();
});
test('customStructure', function() {
test("customStructure", function() {
expect( 20 );
var header, panel, title, thead,
dp = $('#ui-datepicker-div'),
dp = $("#ui-datepicker-div"),
// Check right-to-left localisation
inp = TestHelpers.datepicker.init('#inp', $.datepicker.regional.he);
inp.datepicker( 'option', 'showButtonPanel', true);
inp = TestHelpers.datepicker.init("#inp", $.datepicker.regional.he);
inp.datepicker( "option", "showButtonPanel", true);
inp.focus();
ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left');
header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure RTL - header division');
equal(header.children().length, 3, 'Structure RTL - header child count');
ok(header.children(':first').is('a.ui-datepicker-next'), 'Structure RTL - prev link');
ok(header.children(':eq(1)').is('a.ui-datepicker-prev'), 'Structure RTL - next link');
panel = dp.children(':last');
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure RTL - button division');
equal(panel.children().length, 2, 'Structure RTL - button panel child count');
ok(panel.children(':first').is('button.ui-datepicker-close'), 'Structure RTL - close button');
ok(panel.children(':last').is('button.ui-datepicker-current'), 'Structure RTL - today button');
inp.datepicker('hide').datepicker('destroy');
ok(dp.is(".ui-datepicker-rtl"), "Structure RTL - right-to-left");
header = dp.children(":first");
ok(header.is("div.ui-datepicker-header"), "Structure RTL - header division");
equal(header.children().length, 3, "Structure RTL - header child count");
ok(header.children(":first").is("a.ui-datepicker-next"), "Structure RTL - prev link");
ok(header.children(":eq(1)").is("a.ui-datepicker-prev"), "Structure RTL - next link");
panel = dp.children(":last");
ok(panel.is("div.ui-datepicker-buttonpane"), "Structure RTL - button division");
equal(panel.children().length, 2, "Structure RTL - button panel child count");
ok(panel.children(":first").is("button.ui-datepicker-close"), "Structure RTL - close button");
ok(panel.children(":last").is("button.ui-datepicker-current"), "Structure RTL - today button");
inp.datepicker("hide").datepicker("destroy");
// Hide prev/next
inp = TestHelpers.datepicker.init('#inp', {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});
inp.val('02/10/2008').focus();
header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure hide prev/next - header division');
equal(header.children().length, 1, 'Structure hide prev/next - links child count');
ok(header.children(':first').is('div.ui-datepicker-title'), 'Structure hide prev/next - title division');
inp.datepicker('hide').datepicker('destroy');
inp = TestHelpers.datepicker.init("#inp", {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});
inp.val("02/10/2008").focus();
header = dp.children(":first");
ok(header.is("div.ui-datepicker-header"), "Structure hide prev/next - header division");
equal(header.children().length, 1, "Structure hide prev/next - links child count");
ok(header.children(":first").is("div.ui-datepicker-title"), "Structure hide prev/next - title division");
inp.datepicker("hide").datepicker("destroy");
// Changeable Month with read-only year
inp = TestHelpers.datepicker.init('#inp', {changeMonth: true});
inp = TestHelpers.datepicker.init("#inp", {changeMonth: true});
inp.focus();
title = dp.children(':first').children(':last');
equal(title.children().length, 2, 'Structure changeable month - title child count');
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure changeable month - month selector');
ok(title.children(':last').is('span.ui-datepicker-year'), 'Structure changeable month - read-only year');
inp.datepicker('hide').datepicker('destroy');
title = dp.children(":first").children(":last");
equal(title.children().length, 2, "Structure changeable month - title child count");
ok(title.children(":first").is("select.ui-datepicker-month"), "Structure changeable month - month selector");
ok(title.children(":last").is("span.ui-datepicker-year"), "Structure changeable month - read-only year");
inp.datepicker("hide").datepicker("destroy");
// Changeable year with read-only month
inp = TestHelpers.datepicker.init('#inp', {changeYear: true});
inp = TestHelpers.datepicker.init("#inp", {changeYear: true});
inp.focus();
title = dp.children(':first').children(':last');
equal(title.children().length, 2, 'Structure changeable year - title child count');
ok(title.children(':first').is('span.ui-datepicker-month'), 'Structure changeable year - read-only month');
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure changeable year - year selector');
inp.datepicker('hide').datepicker('destroy');
title = dp.children(":first").children(":last");
equal(title.children().length, 2, "Structure changeable year - title child count");
ok(title.children(":first").is("span.ui-datepicker-month"), "Structure changeable year - read-only month");
ok(title.children(":last").is("select.ui-datepicker-year"), "Structure changeable year - year selector");
inp.datepicker("hide").datepicker("destroy");
// Read-only first day of week
inp = TestHelpers.datepicker.init('#inp', {changeFirstDay: false});
inp = TestHelpers.datepicker.init("#inp", {changeFirstDay: false});
inp.focus();
thead = dp.find('.ui-datepicker-calendar thead tr');
equal(thead.children().length, 7, 'Structure read-only first day - thead child count');
equal(thead.find('a').length, 0, 'Structure read-only first day - thead links count');
inp.datepicker('hide').datepicker('destroy');
thead = dp.find(".ui-datepicker-calendar thead tr");
equal(thead.children().length, 7, "Structure read-only first day - thead child count");
equal(thead.find("a").length, 0, "Structure read-only first day - thead links count");
inp.datepicker("hide").datepicker("destroy");
});
test('keystrokes', function() {
test("keystrokes", function() {
expect( 26 );
var inp = TestHelpers.datepicker.init('#inp'),
var inp = TestHelpers.datepicker.init("#inp"),
date = new Date();
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke enter');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Keystroke enter - preset');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+home');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END});
ok(inp.datepicker('getDate') == null, 'Keystroke ctrl+end');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
ok(inp.datepicker('getDate') == null, 'Keystroke esc');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Keystroke esc - preset');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Keystroke esc - abandoned');
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke enter");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
"Keystroke enter - preset");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+home");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END});
ok(inp.datepicker("getDate") == null, "Keystroke ctrl+end");
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
ok(inp.datepicker("getDate") == null, "Keystroke esc");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
"Keystroke esc - preset");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
"Keystroke esc - abandoned");
// Moving by day or week
inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
inp.val("").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 1);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+left');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.LEFT}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+left");
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.LEFT}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 1);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke left');
inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke left");
inp.val("").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 1);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+right');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.RIGHT}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+right");
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.RIGHT}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 1);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke right');
inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke right");
inp.val("").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.UP}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 7);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+up');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+up");
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.UP}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 7);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke up');
inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke up");
inp.val("").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 7);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+down');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+down");
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.DOWN}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 7);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke down');
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke down");
// Moving by month or year
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 4),
'Keystroke pgup');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 4),
'Keystroke pgdn');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 4),
'Keystroke ctrl+pgup');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 4),
'Keystroke ctrl+pgdn');
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 4),
"Keystroke pgup");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 4),
"Keystroke pgdn");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 4),
"Keystroke ctrl+pgup");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 4),
"Keystroke ctrl+pgdn");
// Check for moving to short months
inp.val('03/31/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29),
'Keystroke pgup - Feb');
inp.val('01/30/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29),
'Keystroke pgdn - Feb');
inp.val('02/29/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 28),
'Keystroke ctrl+pgup - Feb');
inp.val('02/29/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 28),
'Keystroke ctrl+pgdn - Feb');
inp.val("03/31/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29),
"Keystroke pgup - Feb");
inp.val("01/30/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29),
"Keystroke pgdn - Feb");
inp.val("02/29/2008").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 28),
"Keystroke ctrl+pgup - Feb");
inp.val("02/29/2008").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 28),
"Keystroke ctrl+pgdn - Feb");
// Goto current
inp.datepicker('option', {gotoCurrent: true}).
datepicker('hide').val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Keystroke ctrl+home');
inp.datepicker("option", {gotoCurrent: true}).
datepicker("hide").val("02/04/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
"Keystroke ctrl+home");
// Change steps
inp.datepicker('option', {stepMonths: 2, gotoCurrent: false}).
datepicker('hide').val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 12 - 1, 4),
'Keystroke pgup step 2');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 4 - 1, 4),
'Keystroke pgdn step 2');
inp.datepicker("option", {stepMonths: 2, gotoCurrent: false}).
datepicker("hide").val("02/04/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 12 - 1, 4),
"Keystroke pgup step 2");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 4 - 1, 4),
"Keystroke pgdn step 2");
});
test('mouse', function() {
test("mouse", function() {
expect( 15 );
var inl,
inp = TestHelpers.datepicker.init('#inp'),
dp = $('#ui-datepicker-div'),
inp = TestHelpers.datepicker.init("#inp"),
dp = $("#ui-datepicker-div"),
date = new Date();
inp.val('').datepicker('show');
$('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {});
inp.val("").datepicker("show");
$(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {});
date.setDate(10);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Mouse click');
inp.val('02/04/2008').datepicker('show');
$('.ui-datepicker-calendar tbody a:contains(12)', dp).simulate('click', {});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 12),
'Mouse click - preset');
inp.val('02/04/2008').datepicker('show');
inp.val('').datepicker('show');
$('button.ui-datepicker-close', dp).simulate('click', {});
ok(inp.datepicker('getDate') == null, 'Mouse click - close');
inp.val('02/04/2008').datepicker('show');
$('button.ui-datepicker-close', dp).simulate('click', {});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Mouse click - close + preset');
inp.val('02/04/2008').datepicker('show');
$('a.ui-datepicker-prev', dp).simulate('click', {});
$('button.ui-datepicker-close', dp).simulate('click', {});
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Mouse click - abandoned');
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Mouse click");
inp.val("02/04/2008").datepicker("show");
$(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 12),
"Mouse click - preset");
inp.val("02/04/2008").datepicker("show");
inp.val("").datepicker("show");
$("button.ui-datepicker-close", dp).simulate("click", {});
ok(inp.datepicker("getDate") == null, "Mouse click - close");
inp.val("02/04/2008").datepicker("show");
$("button.ui-datepicker-close", dp).simulate("click", {});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
"Mouse click - close + preset");
inp.val("02/04/2008").datepicker("show");
$("a.ui-datepicker-prev", dp).simulate("click", {});
$("button.ui-datepicker-close", dp).simulate("click", {});
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4),
"Mouse click - abandoned");
// Current/previous/next
inp.val('02/04/2008').datepicker('option', {showButtonPanel: true}).datepicker('show');
$('.ui-datepicker-current', dp).simulate('click', {});
$('.ui-datepicker-calendar tbody a:contains(14)', dp).simulate('click', {});
inp.val("02/04/2008").datepicker("option", {showButtonPanel: true}).datepicker("show");
$(".ui-datepicker-current", dp).simulate("click", {});
$(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {});
date.setDate(14);
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Mouse click - current');
inp.val('02/04/2008').datepicker('show');
$('.ui-datepicker-prev', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click');
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 16),
'Mouse click - previous');
inp.val('02/04/2008').datepicker('show');
$('.ui-datepicker-next', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click');
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 18),
'Mouse click - next');
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Mouse click - current");
inp.val("02/04/2008").datepicker("show");
$(".ui-datepicker-prev", dp).simulate("click");
$(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 16),
"Mouse click - previous");
inp.val("02/04/2008").datepicker("show");
$(".ui-datepicker-next", dp).simulate("click");
$(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 18),
"Mouse click - next");
// Previous/next with minimum/maximum
inp.datepicker('option', {minDate: new Date(2008, 2 - 1, 2),
maxDate: new Date(2008, 2 - 1, 26)}).val('02/04/2008').datepicker('show');
$('.ui-datepicker-prev', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click');
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 16),
'Mouse click - previous + min/max');
inp.val('02/04/2008').datepicker('show');
$('.ui-datepicker-next', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click');
TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 18),
'Mouse click - next + min/max');
inp.datepicker("option", {minDate: new Date(2008, 2 - 1, 2),
maxDate: new Date(2008, 2 - 1, 26)}).val("02/04/2008").datepicker("show");
$(".ui-datepicker-prev", dp).simulate("click");
$(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 16),
"Mouse click - previous + min/max");
inp.val("02/04/2008").datepicker("show");
$(".ui-datepicker-next", dp).simulate("click");
$(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 18),
"Mouse click - next + min/max");
// Inline
inl = TestHelpers.datepicker.init('#inl');
dp = $('.ui-datepicker-inline', inl);
inl = TestHelpers.datepicker.init("#inl");
dp = $(".ui-datepicker-inline", inl);
date = new Date();
inl.datepicker('setDate', date);
$('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {});
inl.datepicker("setDate", date);
$(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {});
date.setDate(10);
TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline');
inl.datepicker('option', {showButtonPanel: true}).datepicker('setDate', new Date(2008, 2 - 1, 4));
$('.ui-datepicker-calendar tbody a:contains(12)', dp).simulate('click', {});
TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 2 - 1, 12), 'Mouse click inline - preset');
inl.datepicker('option', {showButtonPanel: true});
$('.ui-datepicker-current', dp).simulate('click', {});
$('.ui-datepicker-calendar tbody a:contains(14)', dp).simulate('click', {});
TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline");
inl.datepicker("option", {showButtonPanel: true}).datepicker("setDate", new Date(2008, 2 - 1, 4));
$(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {});
TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click inline - preset");
inl.datepicker("option", {showButtonPanel: true});
$(".ui-datepicker-current", dp).simulate("click", {});
$(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {});
date.setDate(14);
TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline - current');
inl.datepicker('setDate', new Date(2008, 2 - 1, 4));
$('.ui-datepicker-prev', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click');
TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 1 - 1, 16),
'Mouse click inline - previous');
inl.datepicker('setDate', new Date(2008, 2 - 1, 4));
$('.ui-datepicker-next', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click');
TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 3 - 1, 18),
'Mouse click inline - next');
TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline - current");
inl.datepicker("setDate", new Date(2008, 2 - 1, 4));
$(".ui-datepicker-prev", dp).simulate("click");
$(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click");
TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 1 - 1, 16),
"Mouse click inline - previous");
inl.datepicker("setDate", new Date(2008, 2 - 1, 4));
$(".ui-datepicker-next", dp).simulate("click");
$(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click");
TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 3 - 1, 18),
"Mouse click inline - next");
});
})(jQuery);

View File

@ -17,137 +17,137 @@ function callback(date, inst) {
function callback2(year, month, inst) {
selectedThis = this;
selectedDate = year + '/' + month;
selectedDate = year + "/" + month;
selectedInst = inst;
}
test('events', function() {
test("events", function() {
expect( 26 );
var dateStr, newMonthYear, inp2,
inp = TestHelpers.datepicker.init('#inp', {onSelect: callback}),
inp = TestHelpers.datepicker.init("#inp", {onSelect: callback}),
date = new Date();
// onSelect
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equal(selectedThis, inp[0], 'Callback selected this');
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback selected inst');
equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date');
inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
equal(selectedThis, inp[0], "Callback selected this");
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Callback selected inst");
equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date),
"Callback selected date");
inp.val("").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}).
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 7);
equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date - ctrl+down');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date - esc');
dateStr = '02/04/2008';
inp.val(dateStr).datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date),
"Callback selected date - ctrl+down");
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date),
"Callback selected date - esc");
dateStr = "02/04/2008";
inp.val(dateStr).datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
equal(dateStr, selectedDate,
'onSelect is called after enter keydown');
"onSelect is called after enter keydown");
// onChangeMonthYear
inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}).
val('').datepicker('show');
inp.datepicker("option", {onChangeMonthYear: callback2, onSelect: null}).
val("").datepicker("show");
newMonthYear = function(date) {
return date.getFullYear() + '/' + (date.getMonth() + 1);
return date.getFullYear() + "/" + (date.getMonth() + 1);
};
date = new Date();
date.setDate(1);
inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP});
inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP});
date.setMonth(date.getMonth() - 1);
equal(selectedThis, inp[0], 'Callback change month/year this');
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback change month/year inst');
equal(selectedThis, inp[0], "Callback change month/year this");
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Callback change month/year inst");
equal(selectedDate, newMonthYear(date),
'Callback change month/year date - pgup');
inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN});
"Callback change month/year date - pgup");
inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN});
date.setMonth(date.getMonth() + 1);
equal(selectedDate, newMonthYear(date),
'Callback change month/year date - pgdn');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP});
"Callback change month/year date - pgdn");
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP});
date.setFullYear(date.getFullYear() - 1);
equal(selectedDate, newMonthYear(date),
'Callback change month/year date - ctrl+pgup');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME});
"Callback change month/year date - ctrl+pgup");
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME});
date.setFullYear(date.getFullYear() + 1);
equal(selectedDate, newMonthYear(date),
'Callback change month/year date - ctrl+home');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN});
"Callback change month/year date - ctrl+home");
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN});
date.setFullYear(date.getFullYear() + 1);
equal(selectedDate, newMonthYear(date),
'Callback change month/year date - ctrl+pgdn');
inp.datepicker('setDate', new Date(2007, 1 - 1, 26));
equal(selectedDate, '2007/1', 'Callback change month/year date - setDate');
"Callback change month/year date - ctrl+pgdn");
inp.datepicker("setDate", new Date(2007, 1 - 1, 26));
equal(selectedDate, "2007/1", "Callback change month/year date - setDate");
selectedDate = null;
inp.datepicker('setDate', new Date(2007, 1 - 1, 12));
ok(selectedDate == null, 'Callback change month/year date - setDate no change');
inp.datepicker("setDate", new Date(2007, 1 - 1, 12));
ok(selectedDate == null, "Callback change month/year date - setDate no change");
// onChangeMonthYear step by 2
inp.datepicker('option', {stepMonths: 2}).
datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP});
inp.datepicker("option", {stepMonths: 2}).
datepicker("hide").val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP});
date.setMonth(date.getMonth() - 14);
equal(selectedDate, newMonthYear(date),
'Callback change month/year by 2 date - pgup');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP});
"Callback change month/year by 2 date - pgup");
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP});
date.setMonth(date.getMonth() - 12);
equal(selectedDate, newMonthYear(date),
'Callback change month/year by 2 date - ctrl+pgup');
inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN});
"Callback change month/year by 2 date - ctrl+pgup");
inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN});
date.setMonth(date.getMonth() + 2);
equal(selectedDate, newMonthYear(date),
'Callback change month/year by 2 date - pgdn');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN});
"Callback change month/year by 2 date - pgdn");
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN});
date.setMonth(date.getMonth() + 12);
equal(selectedDate, newMonthYear(date),
'Callback change month/year by 2 date - ctrl+pgdn');
"Callback change month/year by 2 date - ctrl+pgdn");
// onClose
inp.datepicker('option', {onClose: callback, onChangeMonthYear: null, stepMonths: 1}).
val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedThis, inp[0], 'Callback close this');
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback close inst');
equal(selectedDate, '', 'Callback close date - esc');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', new Date()),
'Callback close date - enter');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedDate, '02/04/2008', 'Callback close date - preset');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END});
equal(selectedDate, '', 'Callback close date - ctrl+end');
inp.datepicker("option", {onClose: callback, onChangeMonthYear: null, stepMonths: 1}).
val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedThis, inp[0], "Callback close this");
equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Callback close inst");
equal(selectedDate, "", "Callback close date - esc");
inp.val("").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", new Date()),
"Callback close date - enter");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedDate, "02/04/2008", "Callback close date - preset");
inp.val("02/04/2008").datepicker("show").
simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END});
equal(selectedDate, "", "Callback close date - ctrl+end");
inp2 = TestHelpers.datepicker.init('#inp2');
inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
inp.datepicker('show');
equal(selectedThis, inp2[0], 'Callback close this');
inp2 = TestHelpers.datepicker.init("#inp2");
inp2.datepicker().datepicker("option", {onClose: callback}).datepicker("show");
inp.datepicker("show");
equal(selectedThis, inp2[0], "Callback close this");
});
test('beforeShowDay-getDate', function() {
test("beforeShowDay-getDate", function() {
expect( 3 );
var inp = TestHelpers.datepicker.init('#inp', {beforeShowDay: function() { inp.datepicker('getDate'); return [true, '']; }}),
dp = $('#ui-datepicker-div');
inp.val('01/01/2010').datepicker('show');
var inp = TestHelpers.datepicker.init("#inp", {beforeShowDay: function() { inp.datepicker("getDate"); return [true, ""]; }}),
dp = $("#ui-datepicker-div");
inp.val("01/01/2010").datepicker("show");
// contains non-breaking space
equal($('div.ui-datepicker-title').text(),
equal($("div.ui-datepicker-title").text(),
// support: IE <9, jQuery <1.8
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
$( "<span>January&#xa0;2010</span>" ).text(), 'Initial month');
$('a.ui-datepicker-next', dp).click();
$('a.ui-datepicker-next', dp).click();
$( "<span>January&#xa0;2010</span>" ).text(), "Initial month");
$("a.ui-datepicker-next", dp).click();
$("a.ui-datepicker-next", dp).click();
// contains non-breaking space
equal($('div.ui-datepicker-title').text(),
$( "<span>March&#xa0;2010</span>" ).text(), 'After next clicks');
inp.datepicker('hide').datepicker('show');
$('a.ui-datepicker-prev', dp).click();
$('a.ui-datepicker-prev', dp).click();
equal($("div.ui-datepicker-title").text(),
$( "<span>March&#xa0;2010</span>" ).text(), "After next clicks");
inp.datepicker("hide").datepicker("show");
$("a.ui-datepicker-prev", dp).click();
$("a.ui-datepicker-prev", dp).click();
// contains non-breaking space
equal($('div.ui-datepicker-title').text(),
$( "<span>November&#xa0;2009</span>" ).text(), 'After prev clicks');
inp.datepicker('hide');
equal($("div.ui-datepicker-title").text(),
$( "<span>November&#xa0;2009</span>" ).text(), "After prev clicks");
inp.datepicker("hide");
});
})(jQuery);

View File

@ -5,121 +5,121 @@
module("datepicker: methods");
test('destroy', function() {
test("destroy", function() {
expect( 33 );
var inl,
inp = TestHelpers.datepicker.init('#inp');
ok(inp.is('.hasDatepicker'), 'Default - marker class set');
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Default - instance present');
ok(inp.next().is('#alt'), 'Default - button absent');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Default - marker class cleared');
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Default - instance absent');
ok(inp.next().is('#alt'), 'Default - button absent');
inp = TestHelpers.datepicker.init("#inp");
ok(inp.is(".hasDatepicker"), "Default - marker class set");
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Default - instance present");
ok(inp.next().is("#alt"), "Default - button absent");
inp.datepicker("destroy");
inp = $("#inp");
ok(!inp.is(".hasDatepicker"), "Default - marker class cleared");
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Default - instance absent");
ok(inp.next().is("#alt"), "Default - button absent");
// With button
inp= TestHelpers.datepicker.init('#inp', {showOn: 'both'});
ok(inp.is('.hasDatepicker'), 'Button - marker class set');
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Button - instance present');
ok(inp.next().text() === '...', 'Button - button added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared');
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Button - instance absent');
ok(inp.next().is('#alt'), 'Button - button removed');
inp= TestHelpers.datepicker.init("#inp", {showOn: "both"});
ok(inp.is(".hasDatepicker"), "Button - marker class set");
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Button - instance present");
ok(inp.next().text() === "...", "Button - button added");
inp.datepicker("destroy");
inp = $("#inp");
ok(!inp.is(".hasDatepicker"), "Button - marker class cleared");
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Button - instance absent");
ok(inp.next().is("#alt"), "Button - button removed");
// With append text
inp = TestHelpers.datepicker.init('#inp', {appendText: 'Testing'});
ok(inp.is('.hasDatepicker'), 'Append - marker class set');
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Append - instance present');
ok(inp.next().text() === 'Testing', 'Append - append text added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared');
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Append - instance absent');
ok(inp.next().is('#alt'), 'Append - append text removed');
inp = TestHelpers.datepicker.init("#inp", {appendText: "Testing"});
ok(inp.is(".hasDatepicker"), "Append - marker class set");
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Append - instance present");
ok(inp.next().text() === "Testing", "Append - append text added");
inp.datepicker("destroy");
inp = $("#inp");
ok(!inp.is(".hasDatepicker"), "Append - marker class cleared");
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Append - instance absent");
ok(inp.next().is("#alt"), "Append - append text removed");
// With both
inp= TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImageOnly: true,
buttonImage: 'img/calendar.gif', appendText: 'Testing'});
ok(inp.is('.hasDatepicker'), 'Both - marker class set');
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Both - instance present');
ok(inp.next()[0].nodeName.toLowerCase() === 'img', 'Both - button added');
ok(inp.next().next().text() === 'Testing', 'Both - append text added');
inp.datepicker('destroy');
inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared');
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Both - instance absent');
ok(inp.next().is('#alt'), 'Both - button and append text absent');
inp= TestHelpers.datepicker.init("#inp", {showOn: "both", buttonImageOnly: true,
buttonImage: "img/calendar.gif", appendText: "Testing"});
ok(inp.is(".hasDatepicker"), "Both - marker class set");
ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Both - instance present");
ok(inp.next()[0].nodeName.toLowerCase() === "img", "Both - button added");
ok(inp.next().next().text() === "Testing", "Both - append text added");
inp.datepicker("destroy");
inp = $("#inp");
ok(!inp.is(".hasDatepicker"), "Both - marker class cleared");
ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Both - instance absent");
ok(inp.next().is("#alt"), "Both - button and append text absent");
// Inline
inl = TestHelpers.datepicker.init('#inl');
ok(inl.is('.hasDatepicker'), 'Inline - marker class set');
ok(inl.html() !== '', 'Inline - datepicker present');
ok($.data(inl[0], TestHelpers.datepicker.PROP_NAME), 'Inline - instance present');
ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
inl.datepicker('destroy');
inl = $('#inl');
ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared');
ok(inl.html() === '', 'Inline - datepicker absent');
ok(!$.data(inl[0], TestHelpers.datepicker.PROP_NAME), 'Inline - instance absent');
ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
inl = TestHelpers.datepicker.init("#inl");
ok(inl.is(".hasDatepicker"), "Inline - marker class set");
ok(inl.html() !== "", "Inline - datepicker present");
ok($.data(inl[0], TestHelpers.datepicker.PROP_NAME), "Inline - instance present");
ok(inl.next().length === 0 || inl.next().is("p"), "Inline - button absent");
inl.datepicker("destroy");
inl = $("#inl");
ok(!inl.is(".hasDatepicker"), "Inline - marker class cleared");
ok(inl.html() === "", "Inline - datepicker absent");
ok(!$.data(inl[0], TestHelpers.datepicker.PROP_NAME), "Inline - instance absent");
ok(inl.next().length === 0 || inl.next().is("p"), "Inline - button absent");
});
test('enableDisable', function() {
test("enableDisable", function() {
expect( 33 );
var inl, dp,
inp = TestHelpers.datepicker.init('#inp');
ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable - field initially enabled');
inp.datepicker('disable');
ok(inp.datepicker('isDisabled'), 'Enable/disable - now marked as disabled');
ok(inp[0].disabled, 'Enable/disable - field now disabled');
inp.datepicker('enable');
ok(!inp.datepicker('isDisabled'), 'Enable/disable - now marked as enabled');
ok(!inp[0].disabled, 'Enable/disable - field now enabled');
inp.datepicker('destroy');
inp = TestHelpers.datepicker.init("#inp");
ok(!inp.datepicker("isDisabled"), "Enable/disable - initially marked as enabled");
ok(!inp[0].disabled, "Enable/disable - field initially enabled");
inp.datepicker("disable");
ok(inp.datepicker("isDisabled"), "Enable/disable - now marked as disabled");
ok(inp[0].disabled, "Enable/disable - field now disabled");
inp.datepicker("enable");
ok(!inp.datepicker("isDisabled"), "Enable/disable - now marked as enabled");
ok(!inp[0].disabled, "Enable/disable - field now enabled");
inp.datepicker("destroy");
// With a button
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button'});
ok(!inp.datepicker('isDisabled'), 'Enable/disable button - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable button - field initially enabled');
ok(!inp.next('button')[0].disabled, 'Enable/disable button - button initially enabled');
inp.datepicker('disable');
ok(inp.datepicker('isDisabled'), 'Enable/disable button - now marked as disabled');
ok(inp[0].disabled, 'Enable/disable button - field now disabled');
ok(inp.next('button')[0].disabled, 'Enable/disable button - button now disabled');
inp.datepicker('enable');
ok(!inp.datepicker('isDisabled'), 'Enable/disable button - now marked as enabled');
ok(!inp[0].disabled, 'Enable/disable button - field now enabled');
ok(!inp.next('button')[0].disabled, 'Enable/disable button - button now enabled');
inp.datepicker('destroy');
inp = TestHelpers.datepicker.init("#inp", {showOn: "button"});
ok(!inp.datepicker("isDisabled"), "Enable/disable button - initially marked as enabled");
ok(!inp[0].disabled, "Enable/disable button - field initially enabled");
ok(!inp.next("button")[0].disabled, "Enable/disable button - button initially enabled");
inp.datepicker("disable");
ok(inp.datepicker("isDisabled"), "Enable/disable button - now marked as disabled");
ok(inp[0].disabled, "Enable/disable button - field now disabled");
ok(inp.next("button")[0].disabled, "Enable/disable button - button now disabled");
inp.datepicker("enable");
ok(!inp.datepicker("isDisabled"), "Enable/disable button - now marked as enabled");
ok(!inp[0].disabled, "Enable/disable button - field now enabled");
ok(!inp.next("button")[0].disabled, "Enable/disable button - button now enabled");
inp.datepicker("destroy");
// With an image button
inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true,
buttonImage: 'img/calendar.gif'});
ok(!inp.datepicker('isDisabled'), 'Enable/disable image - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable image - field initially enabled');
ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image initially enabled');
inp.datepicker('disable');
ok(inp.datepicker('isDisabled'), 'Enable/disable image - now marked as disabled');
ok(inp[0].disabled, 'Enable/disable image - field now disabled');
ok(parseFloat(inp.next('img').css('opacity')) !== 1, 'Enable/disable image - image now disabled');
inp.datepicker('enable');
ok(!inp.datepicker('isDisabled'), 'Enable/disable image - now marked as enabled');
ok(!inp[0].disabled, 'Enable/disable image - field now enabled');
ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image now enabled');
inp.datepicker('destroy');
inp = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonImageOnly: true,
buttonImage: "img/calendar.gif"});
ok(!inp.datepicker("isDisabled"), "Enable/disable image - initially marked as enabled");
ok(!inp[0].disabled, "Enable/disable image - field initially enabled");
ok(parseFloat(inp.next("img").css("opacity")) === 1, "Enable/disable image - image initially enabled");
inp.datepicker("disable");
ok(inp.datepicker("isDisabled"), "Enable/disable image - now marked as disabled");
ok(inp[0].disabled, "Enable/disable image - field now disabled");
ok(parseFloat(inp.next("img").css("opacity")) !== 1, "Enable/disable image - image now disabled");
inp.datepicker("enable");
ok(!inp.datepicker("isDisabled"), "Enable/disable image - now marked as enabled");
ok(!inp[0].disabled, "Enable/disable image - field now enabled");
ok(parseFloat(inp.next("img").css("opacity")) === 1, "Enable/disable image - image now enabled");
inp.datepicker("destroy");
// Inline
inl = TestHelpers.datepicker.init('#inl', {changeYear: true});
dp = $('.ui-datepicker-inline', inl);
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled');
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially');
ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled initially');
inl.datepicker('disable');
ok(inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as disabled');
ok(dp.children().is('.ui-state-disabled'), 'Enable/disable inline - visually disabled');
ok(dp.find('select').prop('disabled'), 'Enable/disable inline - form element disabled');
inl.datepicker('enable');
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as enabled');
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visiually disabled');
ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled');
inl.datepicker('destroy');
inl = TestHelpers.datepicker.init("#inl", {changeYear: true});
dp = $(".ui-datepicker-inline", inl);
ok(!inl.datepicker("isDisabled"), "Enable/disable inline - initially marked as enabled");
ok(!dp.children().is(".ui-state-disabled"), "Enable/disable inline - not visually disabled initially");
ok(!dp.find("select").prop("disabled"), "Enable/disable inline - form element enabled initially");
inl.datepicker("disable");
ok(inl.datepicker("isDisabled"), "Enable/disable inline - now marked as disabled");
ok(dp.children().is(".ui-state-disabled"), "Enable/disable inline - visually disabled");
ok(dp.find("select").prop("disabled"), "Enable/disable inline - form element disabled");
inl.datepicker("enable");
ok(!inl.datepicker("isDisabled"), "Enable/disable inline - now marked as enabled");
ok(!dp.children().is(".ui-state-disabled"), "Enable/disable inline - not visiually disabled");
ok(!dp.find("select").prop("disabled"), "Enable/disable inline - form element enabled");
inl.datepicker("destroy");
});
})(jQuery);

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ TestHelpers.datepicker = {
},
equalsDate: function(d1, d2, message) {
if (!d1 || !d2) {
ok(false, message + ' - missing date');
ok(false, message + " - missing date");
return;
}
d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate());
@ -15,8 +15,8 @@ TestHelpers.datepicker = {
equal(d1.toString(), d2.toString(), message);
},
init: function(id, options) {
$.datepicker.setDefaults($.datepicker.regional['']);
return $(id).datepicker($.extend({showAnim: ''}, options || {}));
$.datepicker.setDefaults($.datepicker.regional[""]);
return $(id).datepicker($.extend({showAnim: ""}, options || {}));
},
PROP_NAME: 'datepicker'
PROP_NAME: "datepicker"
};

View File

@ -4,11 +4,11 @@ TestHelpers.commonWidgetTests( "dialog", {
autoOpen: true,
buttons: [],
closeOnEscape: true,
closeText: 'close',
closeText: "close",
disabled: false,
dialogClass: '',
dialogClass: "",
draggable: true,
height: 'auto',
height: "auto",
hide: null,
maxHeight: null,
maxWidth: null,
@ -16,10 +16,10 @@ TestHelpers.commonWidgetTests( "dialog", {
minWidth: 150,
modal: false,
position: {
my: 'center',
at: 'center',
my: "center",
at: "center",
of: window,
collision: 'fit',
collision: "fit",
using: $.ui.dialog.prototype.options.position.using
},
resizable: true,

View File

@ -10,10 +10,10 @@ test("title id", function() {
expect(1);
var titleId,
el = $('<div></div>').dialog();
el = $("<div></div>").dialog();
titleId = el.dialog('widget').find('.ui-dialog-title').attr('id');
ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id');
titleId = el.dialog("widget").find(".ui-dialog-title").attr("id");
ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id");
el.remove();
});
@ -27,7 +27,7 @@ test( "ARIA", function() {
equal( wrapper.attr( "aria-describedby" ), el.attr( "id" ), "aria-describedby added" );
el.remove();
el = $( '<div><div aria-describedby="section2"><p id="section2">descriotion</p></div></div>' ).dialog();
el = $("<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>").dialog();
strictEqual( el.dialog( "widget" ).attr( "aria-describedby" ), undefined, "no aria-describedby added, as already present in markup" );
el.remove();
});

View File

@ -34,8 +34,8 @@ test( "position, right bottom on window", function() {
test("position, offset from top left w/array", function() {
expect( 2 );
var el = $('<div></div>').dialog({ position: [10, 10] }),
dialog = el.dialog('widget'),
var el = $("<div></div>").dialog({ position: [10, 10] }),
dialog = el.dialog("widget"),
offset = dialog.offset();
closeEnough(offset.left, 10 + $(window).scrollLeft(), 1);
closeEnough(offset.top, 10 + $(window).scrollTop(), 1);
@ -44,8 +44,8 @@ test("position, offset from top left w/array", function() {
test("position, top on window", function() {
expect( 2 );
var el = $('<div></div>').dialog({ position: "top" }),
dialog = el.dialog('widget'),
var el = $("<div></div>").dialog({ position: "top" }),
dialog = el.dialog("widget"),
offset = dialog.offset();
closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1);
closeEnough(offset.top, $(window).scrollTop(), 1);
@ -54,8 +54,8 @@ test("position, top on window", function() {
test("position, left on window", function() {
expect( 2 );
var el = $('<div></div>').dialog({ position: "left" }),
dialog = el.dialog('widget'),
var el = $("<div></div>").dialog({ position: "left" }),
dialog = el.dialog("widget"),
offset = dialog.offset();
closeEnough(offset.left, 0, 1);
closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1);

View File

@ -12,10 +12,10 @@ test("open", function() {
el.dialog({
open: function(ev, ui) {
ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
ok(true, 'autoOpen: true fires open callback');
ok(true, "autoOpen: true fires open callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogopen', 'event type in callback');
deepEqual(ui, {}, 'ui hash in callback');
equal(ev.type, "dialogopen", "event type in callback");
deepEqual(ui, {}, "ui hash in callback");
}
});
el.remove();
@ -24,16 +24,16 @@ test("open", function() {
el.dialog({
autoOpen: false,
open: function(ev, ui) {
ok(true, '.dialog("open") fires open callback');
ok(true, ".dialog('open') fires open callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogopen', 'event type in callback');
deepEqual(ui, {}, 'ui hash in callback');
equal(ev.type, "dialogopen", "event type in callback");
deepEqual(ui, {}, "ui hash in callback");
}
}).bind('dialogopen', function(ev, ui) {
}).bind("dialogopen", function(ev, ui) {
ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
ok(true, 'dialog("open") fires open event');
equal(this, el[0], 'context of event');
deepEqual(ui, {}, 'ui hash in event');
ok(true, "dialog('open') fires open event");
equal(this, el[0], "context of event");
deepEqual(ui, {}, "ui hash in event");
});
el.dialog("open");
el.remove();
@ -88,22 +88,22 @@ test("dragStart", function() {
expect(9);
var handle,
el = $('<div></div>').dialog({
el = $("<div></div>").dialog({
dragStart: function(ev, ui) {
ok(true, 'dragging fires dragStart callback');
ok(true, "dragging fires dragStart callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogdragstart', 'event type in callback');
equal(ev.type, "dialogdragstart", "event type in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
}
}).bind('dialogdragstart', function(ev, ui) {
ok(true, 'dragging fires dialogdragstart event');
equal(this, el[0], 'context of event');
}).bind("dialogdragstart", function(ev, ui) {
ok(true, "dragging fires dialogdragstart event");
equal(this, el[0], "context of event");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
handle = $(".ui-dialog-titlebar", el.dialog('widget'));
handle = $(".ui-dialog-titlebar", el.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove();
});
@ -112,26 +112,26 @@ test("drag", function() {
expect(9);
var handle,
hasDragged = false,
el = $('<div></div>').dialog({
el = $("<div></div>").dialog({
drag: function(ev, ui) {
if (!hasDragged) {
ok(true, 'dragging fires drag callback');
ok(true, "dragging fires drag callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogdrag', 'event type in callback');
equal(ev.type, "dialogdrag", "event type in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
hasDragged = true;
}
}
}).one('dialogdrag', function(ev, ui) {
ok(true, 'dragging fires dialogdrag event');
equal(this, el[0], 'context of event');
}).one("dialogdrag", function(ev, ui) {
ok(true, "dragging fires dialogdrag event");
equal(this, el[0], "context of event");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
handle = $(".ui-dialog-titlebar", el.dialog('widget'));
handle = $(".ui-dialog-titlebar", el.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove();
});
@ -140,22 +140,22 @@ test("dragStop", function() {
expect(9);
var handle,
el = $('<div></div>').dialog({
el = $("<div></div>").dialog({
dragStop: function(ev, ui) {
ok(true, 'dragging fires dragStop callback');
ok(true, "dragging fires dragStop callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogdragstop', 'event type in callback');
equal(ev.type, "dialogdragstop", "event type in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
}
}).bind('dialogdragstop', function(ev, ui) {
ok(true, 'dragging fires dialogdragstop event');
equal(this, el[0], 'context of event');
}).bind("dialogdragstop", function(ev, ui) {
ok(true, "dragging fires dialogdragstop event");
equal(this, el[0], "context of event");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
handle = $(".ui-dialog-titlebar", el.dialog('widget'));
handle = $(".ui-dialog-titlebar", el.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove();
});
@ -164,26 +164,26 @@ test("resizeStart", function() {
expect(13);
var handle,
el = $('<div></div>').dialog({
el = $("<div></div>").dialog({
resizeStart: function(ev, ui) {
ok(true, 'resizing fires resizeStart callback');
ok(true, "resizing fires resizeStart callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogresizestart', 'event type in callback');
equal(ev.type, "dialogresizestart", "event type in callback");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback");
}
}).bind('dialogresizestart', function(ev, ui) {
ok(true, 'resizing fires dialogresizestart event');
equal(this, el[0], 'context of event');
}).bind("dialogresizestart", function(ev, ui) {
ok(true, "resizing fires dialogresizestart event");
equal(this, el[0], "context of event");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback");
});
handle = $(".ui-resizable-se", el.dialog('widget'));
handle = $(".ui-resizable-se", el.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove();
});
@ -192,12 +192,12 @@ test("resize", function() {
expect(13);
var handle,
hasResized = false,
el = $('<div></div>').dialog({
el = $("<div></div>").dialog({
resize: function(ev, ui) {
if (!hasResized) {
ok(true, 'resizing fires resize callback');
ok(true, "resizing fires resize callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogresize', 'event type in callback');
equal(ev.type, "dialogresize", "event type in callback");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
@ -206,16 +206,16 @@ test("resize", function() {
hasResized = true;
}
}
}).one('dialogresize', function(ev, ui) {
ok(true, 'resizing fires dialogresize event');
equal(this, el[0], 'context of event');
}).one("dialogresize", function(ev, ui) {
ok(true, "resizing fires dialogresize event");
equal(this, el[0], "context of event");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback");
});
handle = $(".ui-resizable-se", el.dialog('widget'));
handle = $(".ui-resizable-se", el.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove();
});
@ -224,26 +224,26 @@ test("resizeStop", function() {
expect(13);
var handle,
el = $('<div></div>').dialog({
el = $("<div></div>").dialog({
resizeStop: function(ev, ui) {
ok(true, 'resizing fires resizeStop callback');
ok(true, "resizing fires resizeStop callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogresizestop', 'event type in callback');
equal(ev.type, "dialogresizestop", "event type in callback");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback");
}
}).bind('dialogresizestop', function(ev, ui) {
ok(true, 'resizing fires dialogresizestop event');
equal(this, el[0], 'context of event');
}).bind("dialogresizestop", function(ev, ui) {
ok(true, "resizing fires dialogresizestop event");
equal(this, el[0], "context of event");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback");
});
handle = $(".ui-resizable-se", el.dialog('widget'));
handle = $(".ui-resizable-se", el.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove();
});
@ -251,77 +251,77 @@ test("resizeStop", function() {
asyncTest("close", function() {
expect(14);
var el = $('<div></div>').dialog({
var el = $("<div></div>").dialog({
close: function(ev, ui) {
ok(true, '.dialog("close") fires close callback');
ok(true, ".dialog('close') fires close callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogclose', 'event type in callback');
deepEqual(ui, {}, 'ui hash in callback');
equal(ev.type, "dialogclose", "event type in callback");
deepEqual(ui, {}, "ui hash in callback");
}
}).bind('dialogclose', function(ev, ui) {
ok(true, '.dialog("close") fires dialogclose event');
equal(this, el[0], 'context of event');
deepEqual(ui, {}, 'ui hash in event');
}).bind("dialogclose", function(ev, ui) {
ok(true, ".dialog('close') fires dialogclose event");
equal(this, el[0], "context of event");
deepEqual(ui, {}, "ui hash in event");
});
el.dialog('close');
el.dialog("close");
el.remove();
// Close event with an effect
el = $('<div></div>').dialog({
el = $("<div></div>").dialog({
hide: 10,
close: function(ev, ui) {
ok(true, '.dialog("close") fires close callback');
ok(true, ".dialog('close') fires close callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogclose', 'event type in callback');
deepEqual(ui, {}, 'ui hash in callback');
equal(ev.type, "dialogclose", "event type in callback");
deepEqual(ui, {}, "ui hash in callback");
start();
}
}).bind('dialogclose', function(ev, ui) {
ok(true, '.dialog("close") fires dialogclose event');
equal(this, el[0], 'context of event');
deepEqual(ui, {}, 'ui hash in event');
}).bind("dialogclose", function(ev, ui) {
ok(true, ".dialog('close') fires dialogclose event");
equal(this, el[0], "context of event");
deepEqual(ui, {}, "ui hash in event");
});
el.dialog('close');
el.dialog("close");
});
test("beforeClose", function() {
expect(14);
var el = $('<div></div>').dialog({
var el = $("<div></div>").dialog({
beforeClose: function(ev, ui) {
ok(true, '.dialog("close") fires beforeClose callback');
ok(true, ".dialog('close') fires beforeClose callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogbeforeclose', 'event type in callback');
deepEqual(ui, {}, 'ui hash in callback');
equal(ev.type, "dialogbeforeclose", "event type in callback");
deepEqual(ui, {}, "ui hash in callback");
return false;
}
});
el.dialog('close');
ok( el.dialog("widget").is(":visible"), 'beforeClose callback should prevent dialog from closing');
el.dialog("close");
ok( el.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
el.remove();
el = $('<div></div>').dialog();
el.dialog('option', 'beforeClose', function(ev, ui) {
ok(true, '.dialog("close") fires beforeClose callback');
el = $("<div></div>").dialog();
el.dialog("option", "beforeClose", function(ev, ui) {
ok(true, ".dialog('close') fires beforeClose callback");
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogbeforeclose', 'event type in callback');
deepEqual(ui, {}, 'ui hash in callback');
equal(ev.type, "dialogbeforeclose", "event type in callback");
deepEqual(ui, {}, "ui hash in callback");
return false;
});
el.dialog('close');
el.dialog("close");
ok( el.dialog("widget").is(":visible"), 'beforeClose callback should prevent dialog from closing');
ok( el.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
el.remove();
el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
ok(true, '.dialog("close") triggers dialogbeforeclose event');
el = $("<div></div>").dialog().bind("dialogbeforeclose", function(ev, ui) {
ok(true, ".dialog('close') triggers dialogbeforeclose event");
equal(this, el[0], "context of event");
deepEqual(ui, {}, 'ui hash in event');
deepEqual(ui, {}, "ui hash in event");
return false;
});
el.dialog('close');
ok( el.dialog("widget").is(":visible"), 'dialogbeforeclose event should prevent dialog from closing');
el.dialog("close");
ok( el.dialog("widget").is(":visible"), "dialogbeforeclose event should prevent dialog from closing");
el.remove();
});
@ -329,14 +329,14 @@ test("beforeClose", function() {
asyncTest("ensure dialog's container doesn't scroll on resize and focus", function() {
expect(2);
var el = $('#dialog1').dialog(),
var el = $("#dialog1").dialog(),
initialScroll = $(window).scrollTop();
el.dialog('option', 'height', 600);
el.dialog("option", "height", 600);
equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after height change");
setTimeout( function(){
$(".ui-dialog-titlebar-close").simulate('mousedown');
$(".ui-dialog-titlebar-close").simulate("mousedown");
equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog");
el.dialog('destroy');
el.dialog("destroy");
start();
}, 500);
});

View File

@ -12,25 +12,25 @@ module("dialog: methods", {
test("init", function() {
expect(6);
$("<div></div>").appendTo('body').dialog().remove();
ok(true, '.dialog() called on element');
$("<div></div>").appendTo("body").dialog().remove();
ok(true, ".dialog() called on element");
$([]).dialog().remove();
ok(true, '.dialog() called on empty collection');
ok(true, ".dialog() called on empty collection");
$('<div></div>').dialog().remove();
ok(true, '.dialog() called on disconnected DOMElement - never connected');
$("<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');
$("<div></div>").appendTo("body").remove().dialog().remove();
ok(true, ".dialog() called on disconnected DOMElement - removed");
var el = $('<div></div>').dialog();
var el = $("<div></div>").dialog();
el.dialog("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
ok(true, "arbitrary option getter after init");
$('<div></div>').dialog().dialog("option", "foo", "bar").remove();
ok(true, 'arbitrary option setter after init');
$("<div></div>").dialog().dialog("option", "foo", "bar").remove();
ok(true, "arbitrary option setter after init");
});
test("destroy", function() {
@ -61,12 +61,12 @@ test("destroy", function() {
test("#4980: Destroy should place element back in original DOM position", function(){
expect( 2 );
var container = $('<div id="container"><div id="modal">Content</div></div>'),
modal = container.find('#modal');
var container = $("<div id='container'><div id='modal'>Content</div></div>"),
modal = container.find("#modal");
modal.dialog();
ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element');
modal.dialog('destroy');
ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position');
ok(!$.contains(container[0], modal[0]), "dialog should move modal element to outside container element");
modal.dialog("destroy");
ok($.contains(container[0], modal[0]), "dialog(destroy) should place element back in original DOM position");
});
test( "enable/disable disabled", function() {
@ -81,29 +81,29 @@ test("close", function() {
expect( 3 );
var el,
expected = $('<div></div>').dialog(),
actual = expected.dialog('close');
equal(actual, expected, 'close is chainable');
expected = $("<div></div>").dialog(),
actual = expected.dialog("close");
equal(actual, expected, "close is chainable");
el = $('<div></div>').dialog();
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible before close method called');
el.dialog('close');
ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog hidden after close method called');
el = $("<div></div>").dialog();
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog visible before close method called");
el.dialog("close");
ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog hidden after close method called");
});
test("isOpen", function() {
expect(4);
var el = $('<div></div>').dialog();
equal(el.dialog('isOpen'), true, "dialog is open after init");
el.dialog('close');
equal(el.dialog('isOpen'), false, "dialog is closed");
var el = $("<div></div>").dialog();
equal(el.dialog("isOpen"), true, "dialog is open after init");
el.dialog("close");
equal(el.dialog("isOpen"), false, "dialog is closed");
el.remove();
el = $('<div></div>').dialog({autoOpen: false});
equal(el.dialog('isOpen'), false, "dialog is closed after init");
el.dialog('open');
equal(el.dialog('isOpen'), true, "dialog is open");
el = $("<div></div>").dialog({autoOpen: false});
equal(el.dialog("isOpen"), false, "dialog is closed after init");
el.dialog("open");
equal(el.dialog("isOpen"), true, "dialog is open");
el.remove();
});
@ -137,49 +137,49 @@ test("moveToTop", function() {
test("open", function() {
expect( 3 );
var el,
expected = $('<div></div>').dialog(),
actual = expected.dialog('open');
equal(actual, expected, 'open is chainable');
expected = $("<div></div>").dialog(),
actual = expected.dialog("open");
equal(actual, expected, "open is chainable");
el = $('<div></div>').dialog({ autoOpen: false });
ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog hidden before open method called');
el.dialog('open');
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called');
el = $("<div></div>").dialog({ autoOpen: false });
ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog hidden before open method called");
el.dialog("open");
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog visible after open method called");
});
test("#6137: dialog('open') causes form elements to reset on IE7", function() {
expect(2);
var d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' +
'<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false});
var d1 = $("<form><input type='radio' name='radio' id='a' value='a' checked='checked'></input>" +
"<input type='radio' name='radio' id='b' value='b'>b</input></form>").appendTo( "body" ).dialog({autoOpen: false});
d1.find('#b').prop( "checked", true );
equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
d1.find("#b").prop( "checked", true );
equal(d1.find("input:checked").val(), "b", "checkbox b is checked");
d1.dialog('open');
equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
d1.dialog("open");
equal(d1.find("input:checked").val(), "b", "checkbox b is checked");
d1.remove();
});
test("#5531: dialog width should be at least minWidth on creation", function () {
expect( 4 );
var el = $('<div></div>').dialog({
var el = $("<div></div>").dialog({
width: 200,
minWidth: 300
});
equal(el.dialog('option', 'width'), 300, "width is minWidth");
el.dialog('option', 'width', 200);
equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
el.dialog('option', 'width', 320);
equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
equal(el.dialog("option", "width"), 300, "width is minWidth");
el.dialog("option", "width", 200);
equal(el.dialog("option", "width"), 300, "width unchanged when set to < minWidth");
el.dialog("option", "width", 320);
equal(el.dialog("option", "width"), 320, "width changed if set to > minWidth");
el.remove();
el = $('<div></div>').dialog({
el = $("<div></div>").dialog({
minWidth: 300
});
ok(el.dialog('option', 'width') >= 300, "width is at least 300");
ok(el.dialog("option", "width") >= 300, "width is at least 300");
el.remove();
});

View File

@ -49,12 +49,12 @@ test( "appendTo", function() {
test("autoOpen", function() {
expect(2);
var el = $('<div></div>').dialog({ autoOpen: false });
ok( !el.dialog("widget").is(":visible"), '.dialog({ autoOpen: false })');
var el = $("<div></div>").dialog({ autoOpen: false });
ok( !el.dialog("widget").is(":visible"), ".dialog({ autoOpen: false })");
el.remove();
el = $('<div></div>').dialog({ autoOpen: true });
ok( el.dialog("widget").is(":visible"), '.dialog({ autoOpen: true })');
el = $("<div></div>").dialog({ autoOpen: true });
ok( el.dialog("widget").is(":visible"), ".dialog({ autoOpen: true })");
el.remove();
});
@ -74,7 +74,7 @@ test("buttons", function() {
equal(ev.target, btn[1], "event target");
}
},
el = $('<div></div>').dialog({ buttons: buttons });
el = $("<div></div>").dialog({ buttons: buttons });
btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
equal(btn.length, 2, "number of buttons");
@ -85,8 +85,8 @@ test("buttons", function() {
i++;
});
ok(btn.parent().hasClass('ui-dialog-buttonset'), "buttons in container");
ok(el.parent().hasClass('ui-dialog-buttons'), "dialog wrapper adds class about having buttons");
ok(btn.parent().hasClass("ui-dialog-buttonset"), "buttons in container");
ok(el.parent().hasClass("ui-dialog-buttons"), "dialog wrapper adds class about having buttons");
btn.trigger("click");
@ -98,13 +98,13 @@ test("buttons", function() {
}
};
deepEqual(el.dialog("option", "buttons"), buttons, '.dialog("option", "buttons") getter');
deepEqual(el.dialog("option", "buttons"), buttons, ".dialog('option', 'buttons') getter");
el.dialog("option", "buttons", newButtons);
deepEqual(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter');
deepEqual(el.dialog("option", "buttons"), newButtons, ".dialog('option', 'buttons', ...) setter");
btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
equal(btn.length, 1, "number of buttons after setter");
btn.trigger('click');
btn.trigger("click");
i = 0;
$.each(newButtons, function( key ) {
@ -116,7 +116,7 @@ test("buttons", function() {
btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
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");
equal(el.parent().hasClass("ui-dialog-buttons"), false, "dialog wrapper removes class about having buttons");
el.remove();
});
@ -156,77 +156,77 @@ test("buttons - advanced", function() {
test("closeOnEscape", function() {
expect( 6 );
var el = $('<div></div>').dialog({ closeOnEscape: false });
ok(true, 'closeOnEscape: false');
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').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(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open after ESC');
var el = $("<div></div>").dialog({ closeOnEscape: false });
ok(true, "closeOnEscape: false");
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").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(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open after ESC");
el.remove();
el = $('<div></div>').dialog({ closeOnEscape: true });
ok(true, 'closeOnEscape: true');
ok(el.dialog('widget').is(':visible') && !el.dialog('widget').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(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog is closed after ESC');
el = $("<div></div>").dialog({ closeOnEscape: true });
ok(true, "closeOnEscape: true");
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").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(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog is closed after ESC");
});
test("closeText", function() {
expect(3);
var el = $('<div></div>').dialog();
equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'close',
'default close text');
var el = $("<div></div>").dialog();
equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "close",
"default close text");
el.remove();
el = $('<div></div>').dialog({ closeText: "foo" });
equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'foo',
'closeText on init');
el = $("<div></div>").dialog({ closeText: "foo" });
equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "foo",
"closeText on init");
el.remove();
el = $('<div></div>').dialog().dialog('option', 'closeText', 'bar');
equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'bar',
'closeText via option method');
el = $("<div></div>").dialog().dialog("option", "closeText", "bar");
equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "bar",
"closeText via option method");
el.remove();
});
test("dialogClass", function() {
expect( 6 );
var el = $('<div></div>').dialog();
equal(el.dialog('widget').is(".foo"), false, 'dialogClass not specified. foo class added');
var el = $("<div></div>").dialog();
equal(el.dialog("widget").is(".foo"), false, "dialogClass not specified. foo class added");
el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo" });
equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init. foo class added');
el = $("<div></div>").dialog({ dialogClass: "foo" });
equal(el.dialog("widget").is(".foo"), true, "dialogClass in init. foo class added");
el.dialog( "option", "dialogClass", "foobar" );
equal( el.dialog('widget').is(".foo"), false, "dialogClass changed, previous one was removed" );
equal( el.dialog('widget').is(".foobar"), true, "dialogClass changed, new one was added" );
equal( el.dialog("widget").is(".foo"), false, "dialogClass changed, previous one was removed" );
equal( el.dialog("widget").is(".foobar"), true, "dialogClass changed, new one was added" );
el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo bar" });
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');
el = $("<div></div>").dialog({ dialogClass: "foo bar" });
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");
el.remove();
});
test("draggable", function() {
expect(4);
var el = $('<div></div>').dialog({ draggable: false });
var el = $("<div></div>").dialog({ draggable: false });
TestHelpers.dialog.testDrag(el, 50, -50, 0, 0);
el.dialog('option', 'draggable', true);
el.dialog("option", "draggable", true);
TestHelpers.dialog.testDrag(el, 50, -50, 50, -50);
el.remove();
el = $('<div></div>').dialog({ draggable: true });
el = $("<div></div>").dialog({ draggable: true });
TestHelpers.dialog.testDrag(el, 50, -50, 50, -50);
el.dialog('option', 'draggable', false);
el.dialog("option", "draggable", false);
TestHelpers.dialog.testDrag(el, 50, -50, 0, 0);
el.remove();
});
@ -234,22 +234,22 @@ test("draggable", function() {
test("height", function() {
expect(4);
var el = $('<div></div>').dialog();
equal(el.dialog('widget').outerHeight(), 150, "default height");
var el = $("<div></div>").dialog();
equal(el.dialog("widget").outerHeight(), 150, "default height");
el.remove();
el = $('<div></div>').dialog({ height: 237 });
equal(el.dialog('widget').outerHeight(), 237, "explicit height");
el = $("<div></div>").dialog({ height: 237 });
equal(el.dialog("widget").outerHeight(), 237, "explicit height");
el.remove();
el = $('<div></div>').dialog();
el.dialog('option', 'height', 238);
equal(el.dialog('widget').outerHeight(), 238, "explicit height set after init");
el = $("<div></div>").dialog();
el.dialog("option", "height", 238);
equal(el.dialog("widget").outerHeight(), 238, "explicit height set after init");
el.remove();
el = $('<div></div>').css("padding", "20px")
el = $("<div></div>").css("padding", "20px")
.dialog({ height: 240 });
equal(el.dialog('widget').outerHeight(), 240, "explicit height with padding");
equal(el.dialog("widget").outerHeight(), 240, "explicit height with padding");
el.remove();
});
@ -265,76 +265,76 @@ asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() {
test("maxHeight", function() {
expect(3);
var el = $('<div></div>').dialog({ maxHeight: 200 });
TestHelpers.dialog.drag(el, '.ui-resizable-s', 1000, 1000);
closeEnough(el.dialog('widget').height(), 200, 1, "maxHeight");
var el = $("<div></div>").dialog({ maxHeight: 200 });
TestHelpers.dialog.drag(el, ".ui-resizable-s", 1000, 1000);
closeEnough(el.dialog("widget").height(), 200, 1, "maxHeight");
el.remove();
el = $('<div></div>').dialog({ maxHeight: 200 });
TestHelpers.dialog.drag(el, '.ui-resizable-n', -1000, -1000);
closeEnough(el.dialog('widget').height(), 200, 1, "maxHeight");
el = $("<div></div>").dialog({ maxHeight: 200 });
TestHelpers.dialog.drag(el, ".ui-resizable-n", -1000, -1000);
closeEnough(el.dialog("widget").height(), 200, 1, "maxHeight");
el.remove();
el = $('<div></div>').dialog({ maxHeight: 200 }).dialog('option', 'maxHeight', 300);
TestHelpers.dialog.drag(el, '.ui-resizable-s', 1000, 1000);
closeEnough(el.dialog('widget').height(), 300, 1, "maxHeight");
el = $("<div></div>").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300);
TestHelpers.dialog.drag(el, ".ui-resizable-s", 1000, 1000);
closeEnough(el.dialog("widget").height(), 300, 1, "maxHeight");
el.remove();
});
test("maxWidth", function() {
expect(3);
var el = $('<div></div>').dialog({ maxWidth: 200 });
TestHelpers.dialog.drag(el, '.ui-resizable-e', 1000, 1000);
closeEnough(el.dialog('widget').width(), 200, 1, "maxWidth");
var el = $("<div></div>").dialog({ maxWidth: 200 });
TestHelpers.dialog.drag(el, ".ui-resizable-e", 1000, 1000);
closeEnough(el.dialog("widget").width(), 200, 1, "maxWidth");
el.remove();
el = $('<div></div>').dialog({ maxWidth: 200 });
TestHelpers.dialog.drag(el, '.ui-resizable-w', -1000, -1000);
closeEnough(el.dialog('widget').width(), 200, 1, "maxWidth");
el = $("<div></div>").dialog({ maxWidth: 200 });
TestHelpers.dialog.drag(el, ".ui-resizable-w", -1000, -1000);
closeEnough(el.dialog("widget").width(), 200, 1, "maxWidth");
el.remove();
el = $('<div></div>').dialog({ maxWidth: 200 }).dialog('option', 'maxWidth', 300);
TestHelpers.dialog.drag(el, '.ui-resizable-w', -1000, -1000);
closeEnough(el.dialog('widget').width(), 300, 1, "maxWidth");
el = $("<div></div>").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300);
TestHelpers.dialog.drag(el, ".ui-resizable-w", -1000, -1000);
closeEnough(el.dialog("widget").width(), 300, 1, "maxWidth");
el.remove();
});
test("minHeight", function() {
expect(3);
var el = $('<div></div>').dialog({ minHeight: 10 });
TestHelpers.dialog.drag(el, '.ui-resizable-s', -1000, -1000);
closeEnough(el.dialog('widget').height(), 10, 1, "minHeight");
var el = $("<div></div>").dialog({ minHeight: 10 });
TestHelpers.dialog.drag(el, ".ui-resizable-s", -1000, -1000);
closeEnough(el.dialog("widget").height(), 10, 1, "minHeight");
el.remove();
el = $('<div></div>').dialog({ minHeight: 10 });
TestHelpers.dialog.drag(el, '.ui-resizable-n', 1000, 1000);
closeEnough(el.dialog('widget').height(), 10, 1, "minHeight");
el = $("<div></div>").dialog({ minHeight: 10 });
TestHelpers.dialog.drag(el, ".ui-resizable-n", 1000, 1000);
closeEnough(el.dialog("widget").height(), 10, 1, "minHeight");
el.remove();
el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30);
TestHelpers.dialog.drag(el, '.ui-resizable-n', 1000, 1000);
closeEnough(el.dialog('widget').height(), 30, 1, "minHeight");
el = $("<div></div>").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30);
TestHelpers.dialog.drag(el, ".ui-resizable-n", 1000, 1000);
closeEnough(el.dialog("widget").height(), 30, 1, "minHeight");
el.remove();
});
test("minWidth", function() {
expect(3);
var el = $('<div></div>').dialog({ minWidth: 10 });
TestHelpers.dialog.drag(el, '.ui-resizable-e', -1000, -1000);
closeEnough(el.dialog('widget').width(), 10, 1, "minWidth");
var el = $("<div></div>").dialog({ minWidth: 10 });
TestHelpers.dialog.drag(el, ".ui-resizable-e", -1000, -1000);
closeEnough(el.dialog("widget").width(), 10, 1, "minWidth");
el.remove();
el = $('<div></div>').dialog({ minWidth: 10 });
TestHelpers.dialog.drag(el, '.ui-resizable-w', 1000, 1000);
closeEnough(el.dialog('widget').width(), 10, 1, "minWidth");
el = $("<div></div>").dialog({ minWidth: 10 });
TestHelpers.dialog.drag(el, ".ui-resizable-w", 1000, 1000);
closeEnough(el.dialog("widget").width(), 10, 1, "minWidth");
el.remove();
el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30);
TestHelpers.dialog.drag(el, '.ui-resizable-w', 1000, 1000);
closeEnough(el.dialog('widget').width(), 30, 1, "minWidth");
el = $("<div></div>").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30);
TestHelpers.dialog.drag(el, ".ui-resizable-w", 1000, 1000);
closeEnough(el.dialog("widget").width(), 30, 1, "minWidth");
el.remove();
});
@ -378,8 +378,8 @@ test( "position, right bottom at right bottom via ui.position args", function()
test( "position, at another element", function() {
expect( 4 );
var parent = $('<div></div>').css({
position: 'absolute',
var parent = $("<div></div>").css({
position: "absolute",
top: 400,
left: 600,
height: 10,
@ -420,16 +420,16 @@ test( "position, at another element", function() {
test("resizable", function() {
expect(4);
var el = $('<div></div>').dialog();
var el = $("<div></div>").dialog();
TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
el.dialog('option', 'resizable', false);
TestHelpers.dialog.shouldResize(el, 0, 0, 'disabled after init');
el.dialog("option", "resizable", false);
TestHelpers.dialog.shouldResize(el, 0, 0, "disabled after init");
el.remove();
el = $('<div></div>').dialog({ resizable: false });
el = $("<div></div>").dialog({ resizable: false });
TestHelpers.dialog.shouldResize(el, 0, 0, "disabled in init options");
el.dialog('option', 'resizable', true);
TestHelpers.dialog.shouldResize(el, 50, 50, 'enabled after init');
el.dialog("option", "resizable", true);
TestHelpers.dialog.shouldResize(el, 50, 50, "enabled after init");
el.remove();
});
@ -437,37 +437,37 @@ test( "title", function() {
expect( 11 );
function titleText() {
return el.dialog('widget').find( ".ui-dialog-title" ).html();
return el.dialog("widget").find( ".ui-dialog-title" ).html();
}
var el = $( '<div></div>' ).dialog();
var el = $( "<div></div>" ).dialog();
// some browsers return a non-breaking space and some return "&nbsp;"
// so we generate a non-breaking space for comparison
equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" );
equal( el.dialog( "option", "title" ), null, "option not changed" );
el.remove();
el = $( '<div title="foo">' ).dialog();
el = $( "<div title='foo'>" ).dialog();
equal( titleText(), "foo", "title in element attribute" );
equal( el.dialog( "option", "title"), "foo", "option updated from attribute" );
el.remove();
el = $( '<div></div>' ).dialog({ title: 'foo' });
el = $( "<div></div>" ).dialog({ title: "foo" });
equal( titleText(), "foo", "title in init options" );
equal( el.dialog("option", "title"), "foo", "opiton set from options hash" );
el.remove();
el = $( '<div title="foo">' ).dialog({ title: 'bar' });
el = $( "<div title='foo'>" ).dialog({ title: "bar" });
equal( titleText(), "bar", "title in init options should override title in element attribute" );
equal( el.dialog("option", "title"), "bar", "opiton set from options hash" );
el.remove();
el = $( '<div></div>' ).dialog().dialog( 'option', 'title', 'foo' );
equal( titleText(), 'foo', 'title after init' );
el = $( "<div></div>" ).dialog().dialog( "option", "title", "foo" );
equal( titleText(), "foo", "title after init" );
el.remove();
// make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement
el = $( '<form><input name="title"></form>' ).dialog();
el = $( "<form><input name='title'></form>" ).dialog();
// some browsers return a non-breaking space and some return "&nbsp;"
// so we get the text to normalize to the actual non-breaking space
equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" );
@ -478,34 +478,34 @@ test( "title", function() {
test("width", function() {
expect(3);
var el = $('<div></div>').dialog();
closeEnough(el.dialog('widget').width(), 300, 1, "default width");
var el = $("<div></div>").dialog();
closeEnough(el.dialog("widget").width(), 300, 1, "default width");
el.remove();
el = $('<div></div>').dialog({width: 437 });
closeEnough(el.dialog('widget').width(), 437, 1, "explicit width");
el.dialog('option', 'width', 438);
closeEnough(el.dialog('widget').width(), 438, 1, 'explicit width after init');
el = $("<div></div>").dialog({width: 437 });
closeEnough(el.dialog("widget").width(), 437, 1, "explicit width");
el.dialog("option", "width", 438);
closeEnough(el.dialog("widget").width(), 438, 1, "explicit width after init");
el.remove();
});
test("#4826: setting resizable false toggles resizable on dialog", function() {
expect(6);
var i,
el = $('<div></div>').dialog({ resizable: false });
el = $("<div></div>").dialog({ resizable: false });
TestHelpers.dialog.shouldResize(el, 0, 0, "[default]");
for (i=0; i<2; i++) {
el.dialog('close').dialog('open');
TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')');
el.dialog("close").dialog("open");
TestHelpers.dialog.shouldResize(el, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")");
}
el.remove();
el = $('<div></div>').dialog({ resizable: true });
el = $("<div></div>").dialog({ resizable: true });
TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
for (i=0; i<2; i++) {
el.dialog('close').dialog('option', 'resizable', false).dialog('open');
TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')');
el.dialog("close").dialog("option", "resizable", false).dialog("open");
TestHelpers.dialog.shouldResize(el, 0, 0, "set option resizable false toggle ("+ (i+1) +")");
}
el.remove();

View File

@ -1,6 +1,6 @@
TestHelpers.dialog = {
drag: function(el, handle, dx, dy) {
var d = el.dialog('widget');
var d = el.dialog("widget");
//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").simulate( "drag", {
@ -10,7 +10,7 @@ TestHelpers.dialog = {
},
testDrag: function(el, dx, dy, expectedDX, expectedDY, msg) {
var actualDX, actualDY, offsetAfter,
d = el.dialog('widget'),
d = el.dialog("widget"),
handle = $(".ui-dialog-titlebar", d),
offsetBefore = d.offset();
@ -22,11 +22,11 @@ TestHelpers.dialog = {
actualDX = offsetAfter.left - offsetBefore.left;
actualDY = offsetAfter.top - offsetBefore.top;
ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, 'dragged[' + expectedDX + ', ' + expectedDY + '] ' + msg);
ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg);
},
shouldResize: function(el, dw, dh, msg) {
var heightAfter, widthAfter, actual, expected,
d = el.dialog('widget'),
d = el.dialog("widget"),
handle = $(".ui-resizable-se", d),
heightBefore = d.height(),
widthBefore = d.width();
@ -39,6 +39,6 @@ TestHelpers.dialog = {
msg = msg ? msg + "." : "";
actual = { width: widthAfter, height: heightAfter },
expected = { width: widthBefore + dw, height: heightBefore + dh };
deepEqual(actual, expected, 'resized[' + 50 + ', ' + 50 + '] ' + msg);
deepEqual(actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg);
}
};

View File

@ -7,20 +7,20 @@
module("draggable: core");
test("element types", function() {
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
',acronym,code,samp,kbd,var,img,hr' +
',input,button,label,select,iframe').split(',');
var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" +
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
",acronym,code,samp,kbd,var,img,hr" +
",input,button,label,select,iframe").split(",");
expect( typeNames.length * 2 );
$.each(typeNames, function(i) {
var offsetBefore, offsetAfter,
typeName = typeNames[i],
el = $(document.createElement(typeName)).appendTo('#qunit-fixture');
el = $(document.createElement(typeName)).appendTo("#qunit-fixture");
(typeName === 'table' && el.append("<tr><td>content</td></tr>"));
el.draggable({ cancel: '' });
(typeName === "table" && el.append("<tr><td>content</td></tr>"));
el.draggable({ cancel: "" });
offsetBefore = el.offset();
el.simulate( "drag", {
dx: 50,
@ -50,16 +50,16 @@ test("No options, absolute", function() {
test("resizable handle with complex markup (#8756 / #8757)", function() {
expect( 2 );
$('#draggable1')
$("#draggable1")
.append(
$('<div>')
$("<div>")
.addClass("ui-resizable-handle")
.addClass("ui-resizable-w")
.append($('<div>'))
.append($("<div>"))
);
var handle = $('.ui-resizable-w div'),
target = $('#draggable1').draggable().resizable({ handles: 'all' });
var handle = $(".ui-resizable-w div"),
target = $("#draggable1").draggable().resizable({ handles: "all" });
// todo: fix resizable so it doesn't require a mouseover
handle.simulate("mouseover").simulate( "drag", { dx: -50 } );

View File

@ -82,7 +82,7 @@ test("stopping the stop callback", function() {
expect(1);
var el = $("#draggable2").draggable({
helper: 'clone',
helper: "clone",
stop: function() { return false; }
});
@ -91,7 +91,7 @@ test("stopping the stop callback", function() {
dy: 10
});
ok($("#draggable2").data('ui-draggable').helper, "the clone should not be deleted if the stop callback is stopped");
ok($("#draggable2").data("ui-draggable").helper, "the clone should not be deleted if the stop callback is stopped");
});

View File

@ -8,36 +8,36 @@ module("draggable: methods");
test("init", function() {
expect(5);
$("<div></div>").appendTo('body').draggable().remove();
ok(true, '.draggable() called on element');
$("<div></div>").appendTo("body").draggable().remove();
ok(true, ".draggable() called on element");
$([]).draggable();
ok(true, '.draggable() called on empty collection');
ok(true, ".draggable() called on empty collection");
$("<div></div>").draggable();
ok(true, '.draggable() called on disconnected DOMElement');
ok(true, ".draggable() called on disconnected DOMElement");
$("<div></div>").draggable().draggable("option", "foo");
ok(true, 'arbitrary option getter after init');
ok(true, "arbitrary option getter after init");
$("<div></div>").draggable().draggable("option", "foo", "bar");
ok(true, 'arbitrary option setter after init');
ok(true, "arbitrary option setter after init");
});
test("destroy", function() {
expect(4);
$("<div></div>").appendTo('body').draggable().draggable("destroy").remove();
ok(true, '.draggable("destroy") called on element');
$("<div></div>").appendTo("body").draggable().draggable("destroy").remove();
ok(true, ".draggable('destroy') called on element");
$([]).draggable().draggable("destroy");
ok(true, '.draggable("destroy") called on empty collection');
ok(true, ".draggable('destroy') called on empty collection");
$("<div></div>").draggable().draggable("destroy");
ok(true, '.draggable("destroy") called on disconnected DOMElement');
ok(true, ".draggable('destroy') called on disconnected DOMElement");
var expected = $('<div></div>').draggable(),
actual = expected.draggable('destroy');
equal(actual, expected, 'destroy is chainable');
var expected = $("<div></div>").draggable(),
actual = expected.draggable("destroy");
equal(actual, expected, "destroy is chainable");
});
test("enable", function() {
@ -46,23 +46,23 @@ test("enable", function() {
var expected, actual, el;
el = $("#draggable2").draggable({ disabled: true });
TestHelpers.draggable.shouldNotMove(el, '.draggable({ disabled: true })');
TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })");
el.draggable("enable");
TestHelpers.draggable.shouldMove(el, '.draggable("enable")');
TestHelpers.draggable.shouldMove(el, ".draggable('enable')");
equal(el.draggable("option", "disabled"), false, "disabled option getter");
el.draggable("destroy");
el.draggable({ disabled: true });
TestHelpers.draggable.shouldNotMove(el, '.draggable({ disabled: true })');
TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })");
el.draggable("option", "disabled", false);
equal(el.draggable("option", "disabled"), false, "disabled option setter");
TestHelpers.draggable.shouldMove(el, '.draggable("option", "disabled", false)');
TestHelpers.draggable.shouldMove(el, ".draggable('option', 'disabled', false)");
expected = $('<div></div>').draggable(),
actual = expected.draggable('enable');
equal(actual, expected, 'enable is chainable');
expected = $("<div></div>").draggable(),
actual = expected.draggable("enable");
equal(actual, expected, "enable is chainable");
});
test("disable", function() {
@ -71,24 +71,24 @@ test("disable", function() {
var expected, actual, el;
el = $("#draggable2").draggable({ disabled: false });
TestHelpers.draggable.shouldMove(el, '.draggable({ disabled: false })');
TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })");
el.draggable("disable");
TestHelpers.draggable.shouldNotMove(el, '.draggable("disable")');
TestHelpers.draggable.shouldNotMove(el, ".draggable('disable')");
equal(el.draggable("option", "disabled"), true, "disabled option getter");
el.draggable("destroy");
el.draggable({ disabled: false });
TestHelpers.draggable.shouldMove(el, '.draggable({ disabled: false })');
TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })");
el.draggable("option", "disabled", true);
equal(el.draggable("option", "disabled"), true, "disabled option setter");
TestHelpers.draggable.shouldNotMove(el, '.draggable("option", "disabled", true)');
TestHelpers.draggable.shouldNotMove(el, ".draggable('option', 'disabled', true)");
expected = $('<div></div>').draggable(),
actual = expected.draggable('disable');
equal(actual, expected, 'disable is chainable');
expected = $("<div></div>").draggable(),
actual = expected.draggable("disable");
equal(actual, expected, "disable is chainable");
});
})(jQuery);

View File

@ -7,10 +7,10 @@ module("draggable: options");
test("{ appendTo: 'parent' }, default", function() {
expect( 2 );
var el = $("#draggable2").draggable({ appendTo: 'parent' });
var el = $("#draggable2").draggable({ appendTo: "parent" });
TestHelpers.draggable.shouldMove(el);
el = $("#draggable1").draggable({ appendTo: 'parent' });
el = $("#draggable1").draggable({ appendTo: "parent" });
TestHelpers.draggable.shouldMove(el);
});
@ -74,7 +74,7 @@ test("{ axis: ? }, unexpected", function() {
test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
expect( 2 );
$('<div id="draggable-option-cancel-default"><input type="text"></div>').appendTo('#main');
$("<div id='draggable-option-cancel-default'><input type='text'></div>").appendTo("#main");
var el = $("#draggable-option-cancel-default").draggable({ cancel: "input,textarea,button,select,option" });
TestHelpers.draggable.shouldMove(el);
@ -94,7 +94,7 @@ test("{ cancel: 'span' }", function() {
el.draggable("destroy");
el = $("#draggable2").draggable({ cancel: 'span' });
el = $("#draggable2").draggable({ cancel: "span" });
TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 0, 0);
});
@ -122,13 +122,13 @@ test("{ cancel: ? }, unexpected", function() {
test("{ containment: false }, default", function() {
expect( 1 );
ok(false, 'missing test - untested code is broken code');
ok(false, "missing test - untested code is broken code");
});
test("{ containment: Element }", function() {
expect( 1 );
ok(false, 'missing test - untested code is broken code');
ok(false, "missing test - untested code is broken code");
});
*/
@ -136,12 +136,12 @@ test("{ containment: 'parent' }, relative", function() {
expect( 1 );
var offsetAfter,
el = $("#draggable1").draggable({ containment: 'parent' }),
el = $("#draggable1").draggable({ containment: "parent" }),
p = el.parent(),
po = p.offset(),
expected = {
left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'),
top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top')
left: po.left + TestHelpers.draggable.border(p, "left") + TestHelpers.draggable.margin(el, "left"),
top: po.top + TestHelpers.draggable.border(p, "top") + TestHelpers.draggable.margin(el, "top")
};
el.simulate( "drag", {
@ -149,19 +149,19 @@ test("{ containment: 'parent' }, relative", function() {
dy: -100
});
offsetAfter = el.offset();
deepEqual(offsetAfter, expected, 'compare offset to parent');
deepEqual(offsetAfter, expected, "compare offset to parent");
});
test("{ containment: 'parent' }, absolute", function() {
expect( 1 );
var offsetAfter,
el = $("#draggable2").draggable({ containment: 'parent' }),
el = $("#draggable2").draggable({ containment: "parent" }),
p = el.parent(),
po = p.offset(),
expected = {
left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'),
top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top')
left: po.left + TestHelpers.draggable.border(p, "left") + TestHelpers.draggable.margin(el, "left"),
top: po.top + TestHelpers.draggable.border(p, "top") + TestHelpers.draggable.margin(el, "top")
};
el.simulate( "drag", {
@ -169,32 +169,32 @@ test("{ containment: 'parent' }, absolute", function() {
dy: -100
});
offsetAfter = el.offset();
deepEqual(offsetAfter, expected, 'compare offset to parent');
deepEqual(offsetAfter, expected, "compare offset to parent");
});
/*
test("{ containment: 'document' }", function() {
expect( 1 );
ok(false, 'missing test - untested code is broken code');
ok(false, "missing test - untested code is broken code");
});
test("{ containment: 'window' }", function() {
expect( 1 );
ok(false, 'missing test - untested code is broken code');
ok(false, "missing test - untested code is broken code");
});
test("{ containment: Selector }", function() {
expect( 1 );
ok(false, 'missing test - untested code is broken code');
ok(false, "missing test - untested code is broken code");
});
test("{ containment: [x1, y1, x2, y2] }", function() {
expect( 1 );
ok(false, 'missing test - untested code is broken code');
ok(false, "missing test - untested code is broken code");
});
*/
@ -251,20 +251,13 @@ test("{ cursor: 'move' }", function() {
});
/*
test("{ cursorAt: false}, default", function() {
expect( 1 );
ok(false, 'missing test - untested code is broken code');
});
*/
test( "{ cursorAt: left, top }", function() {
expect( 20 );
test( "cursorAt", function() {
expect( 24 );
var deltaX = -3,
deltaY = -3,
tests = {
"false": { cursorAt : false },
"{ left: -5, top: -5 }": { x: -5, y: -5, cursorAt : { left: -5, top: -5 } },
"[ 10, 20 ]": { x: 10, y: 20, cursorAt : [ 10, 20 ] },
"'10 20'": { x: 10, y: 20, cursorAt : "10 20" },
@ -277,9 +270,12 @@ test( "{ cursorAt: left, top }", function() {
var el = $( "#draggable" + ( i + 1 ) ).draggable({
cursorAt: testData.cursorAt,
drag: function( event, ui ) {
if( testData.cursorAt.right ) {
equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y + TestHelpers.draggable.unreliableOffset, testName + position + " top" );
if( !testData.cursorAt ) {
equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
} else if( testData.cursorAt.right ) {
equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + " " +position + " top" );
} else {
equal( event.clientX - ui.offset.left, testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
equal( event.clientY - ui.offset.top, testData.y + TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" );
@ -315,7 +311,7 @@ test("{ grid: [50, 50] }, absolute", function() {
test("{ handle: 'span' }", function() {
expect( 2 );
var el = $("#draggable2").draggable({ handle: 'span' });
var el = $("#draggable2").draggable({ handle: "span" });
TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50, "drag span");
TestHelpers.draggable.shouldNotMove(el, "drag element");
@ -341,13 +337,13 @@ test("{ helper: 'original' }, relative, with scroll offset on parent", function(
var el = $("#draggable1").draggable({ helper: "original" });
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll();
@ -358,16 +354,16 @@ test("{ helper: 'original' }, relative, with scroll offset on root", function()
var el = $("#draggable1").draggable({ helper: "original" });
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll('root');
TestHelpers.draggable.restoreScroll("root");
});
@ -378,19 +374,19 @@ test("{ helper: 'original' }, relative, with scroll offset on root and parent",
var el = $("#draggable1").draggable({ helper: "original" });
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll();
TestHelpers.draggable.restoreScroll('root');
TestHelpers.draggable.restoreScroll("root");
});
@ -398,16 +394,16 @@ test("{ helper: 'original' }, absolute, with scroll offset on parent", function(
expect(3);
var el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll();
@ -417,18 +413,18 @@ test("{ helper: 'original' }, absolute, with scroll offset on root", function()
expect(3);
var el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll('root');
TestHelpers.draggable.restoreScroll("root");
});
@ -436,22 +432,22 @@ test("{ helper: 'original' }, absolute, with scroll offset on root and parent",
expect(3);
var el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
var el = $("#draggable1").css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll();
TestHelpers.draggable.restoreScroll('root');
TestHelpers.draggable.restoreScroll("root");
});
@ -459,16 +455,16 @@ test("{ helper: 'original' }, fixed, with scroll offset on parent", function() {
expect(3);
var el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll();
@ -478,40 +474,40 @@ test("{ helper: 'original' }, fixed, with scroll offset on root", function() {
expect(3);
var el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll('root');
TestHelpers.draggable.restoreScroll("root");
});
test("{ helper: 'original' }, fixed, with scroll offset on root and parent", function() {
expect(3);
var el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
var el = $("#draggable1").css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'relative');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "relative");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'static');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "static");
TestHelpers.draggable.setScroll();
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.testScroll(el, 'absolute');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.testScroll(el, "absolute");
TestHelpers.draggable.restoreScroll();
TestHelpers.draggable.restoreScroll('root');
TestHelpers.draggable.restoreScroll("root");
});
@ -529,7 +525,7 @@ test("{ helper: 'clone' }, absolute", function() {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
});
@ -544,29 +540,29 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
helperOffset = ui.helper.offset();
} });
$("#main").css('position', 'relative');
$("#main").css("position", "relative");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
$("#main").css('position', 'static');
$("#main").css("position", "static");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
$("#main").css('position', 'absolute');
$("#main").css("position", "absolute");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
TestHelpers.draggable.restoreScroll();
@ -576,38 +572,38 @@ test("{ helper: 'clone' }, absolute with scroll offset on root", function() {
expect(3);
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.setScroll("root");
var helperOffset = null,
origOffset = null,
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset();
} });
$("#main").css('position', 'relative');
$("#main").css("position", "relative");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
$("#main").css('position', 'static');
$("#main").css("position", "static");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
$("#main").css('position', 'absolute');
$("#main").css("position", "absolute");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
TestHelpers.draggable.restoreScroll('root');
TestHelpers.draggable.restoreScroll("root");
});
@ -615,7 +611,7 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func
expect(3);
TestHelpers.draggable.setScroll('root');
TestHelpers.draggable.setScroll("root");
TestHelpers.draggable.setScroll();
var helperOffset = null,
@ -624,31 +620,31 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func
helperOffset = ui.helper.offset();
} });
$("#main").css('position', 'relative');
$("#main").css("position", "relative");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
$("#main").css('position', 'static');
$("#main").css("position", "static");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
$("#main").css('position', 'absolute');
$("#main").css("position", "absolute");
origOffset = $("#draggable1").offset();
el.simulate( "drag", {
dx: 1,
dy: 1
});
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] ');
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, "dragged[1, 1] ");
TestHelpers.draggable.restoreScroll('root');
TestHelpers.draggable.restoreScroll("root");
TestHelpers.draggable.restoreScroll();
});

View File

@ -15,7 +15,7 @@ TestHelpers.draggable = {
expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
msg = msg ? msg + "." : "";
deepEqual(actual, expected, 'dragged[' + dx + ', ' + dy + '] ' + msg);
deepEqual(actual, expected, "dragged[" + dx + ", " + dy + "] " + msg);
},
shouldMove: function(el, why) {
TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50, why);
@ -24,10 +24,10 @@ TestHelpers.draggable = {
TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 0, why);
},
testScroll: function(el, position ) {
var oldPosition = $("#main").css('position');
$("#main").css('position', position);
TestHelpers.draggable.shouldMove(el, position+' parent');
$("#main").css('position', oldPosition);
var oldPosition = $("#main").css("position");
$("#main").css("position", position);
TestHelpers.draggable.shouldMove(el, position+" parent");
$("#main").css("position", oldPosition);
},
restoreScroll: function( what ) {
if( what ) {
@ -46,9 +46,9 @@ TestHelpers.draggable = {
}
},
border: function(el, side) {
return parseInt(el.css('border-' + side + '-width'), 10) || 0;
return parseInt(el.css("border-" + side + "-width"), 10) || 0;
},
margin: function(el, side) {
return parseInt(el.css('margin-' + side), 10) || 0;
return parseInt(el.css("margin-" + side), 10) || 0;
}
};

View File

@ -7,18 +7,18 @@
module("droppable: core");
test("element types", function() {
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
',acronym,code,samp,kbd,var,img,hr' +
',input,button,label,select,iframe').split(',');
var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" +
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
",acronym,code,samp,kbd,var,img,hr" +
",input,button,label,select,iframe").split(",");
expect( typeNames.length );
$.each(typeNames, function(i) {
var typeName = typeNames[i],
el = $(document.createElement(typeName)).appendTo('body');
el = $(document.createElement(typeName)).appendTo("body");
(typeName === 'table' && el.append("<tr><td>content</td></tr>"));
(typeName === "table" && el.append("<tr><td>content</td></tr>"));
el.droppable();
TestHelpers.droppable.shouldDrop();
el.droppable("destroy");

View File

@ -8,37 +8,37 @@ module("droppable: methods");
test("init", function() {
expect( 5 );
$("<div></div>").appendTo('body').droppable().remove();
ok(true, '.droppable() called on element');
$("<div></div>").appendTo("body").droppable().remove();
ok(true, ".droppable() called on element");
$([]).droppable();
ok(true, '.droppable() called on empty collection');
ok(true, ".droppable() called on empty collection");
$("<div></div>").droppable();
ok(true, '.droppable() called on disconnected DOMElement');
ok(true, ".droppable() called on disconnected DOMElement");
$("<div></div>").droppable().droppable("option", "foo");
ok(true, 'arbitrary option getter after init');
ok(true, "arbitrary option getter after init");
$("<div></div>").droppable().droppable("option", "foo", "bar");
ok(true, 'arbitrary option setter after init');
ok(true, "arbitrary option setter after init");
});
test("destroy", function() {
expect( 4 );
$("<div></div>").appendTo('body').droppable().droppable("destroy").remove();
ok(true, '.droppable("destroy") called on element');
$("<div></div>").appendTo("body").droppable().droppable("destroy").remove();
ok(true, ".droppable('destroy') called on element");
$([]).droppable().droppable("destroy");
ok(true, '.droppable("destroy") called on empty collection');
ok(true, ".droppable('destroy') called on empty collection");
$("<div></div>").droppable().droppable("destroy");
ok(true, '.droppable("destroy") called on disconnected DOMElement');
ok(true, ".droppable('destroy') called on disconnected DOMElement");
var expected = $('<div></div>').droppable(),
actual = expected.droppable('destroy');
equal(actual, expected, 'destroy is chainable');
var expected = $("<div></div>").droppable(),
actual = expected.droppable("destroy");
equal(actual, expected, "destroy is chainable");
});
test("enable", function() {
@ -58,9 +58,9 @@ test("enable", function() {
equal(el.droppable("option", "disabled"), false, "disabled option setter");
TestHelpers.droppable.shouldDrop();
expected = $('<div></div>').droppable(),
actual = expected.droppable('enable');
equal(actual, expected, 'enable is chainable');
expected = $("<div></div>").droppable(),
actual = expected.droppable("enable");
equal(actual, expected, "enable is chainable");
});
test("disable", function() {
@ -80,9 +80,9 @@ test("disable", function() {
equal(el.droppable("option", "disabled"), true, "disabled option setter");
TestHelpers.droppable.shouldNotDrop();
expected = $('<div></div>').droppable(),
actual = expected.droppable('disable');
equal(actual, expected, 'disable is chainable');
expected = $("<div></div>").droppable(),
actual = expected.droppable("disable");
equal(actual, expected, "disable is chainable");
});
})(jQuery);

View File

@ -1,10 +1,10 @@
TestHelpers.droppable = {
shouldDrop: function() {
// todo: actually implement this
ok(true, 'missing test - untested code is broken code');
ok(true, "missing test - untested code is broken code");
},
shouldNotDrop: function() {
// todo: actually implement this
ok(true, 'missing test - untested code is broken code');
ok(true, "missing test - untested code is broken code");
}
};

View File

@ -41,9 +41,12 @@ test( "{ disabled: false }", function() {
});
test( "{ icons: default }", function() {
expect( 1 );
expect( 2 );
var element = $( "#menu2" ).menu();
equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-carat-1-e" );
element.menu("option", "icons.submenu", "ui-icon-triangle-1-e");
equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-triangle-1-e" );
});
test( "{ icons: { submenu: 'custom' } }", function() {

View File

@ -96,7 +96,7 @@ QUnit.testDone(function() {
}
});
current.getElementsByTagName('a')[0].href = src;
current.getElementsByTagName("a")[0].href = src;
});
}( QUnit ) );

View File

@ -1,19 +1,19 @@
TestHelpers.commonWidgetTests('resizable', {
TestHelpers.commonWidgetTests("resizable", {
defaults: {
alsoResize: false,
animate: false,
animateDuration: 'slow',
animateEasing: 'swing',
animateDuration: "slow",
animateEasing: "swing",
aspectRatio: false,
autoHide: false,
cancel: 'input,textarea,button,select,option',
cancel: "input,textarea,button,select,option",
containment: false,
delay: 0,
disabled: false,
distance: 1,
ghost: false,
grid: false,
handles: 'e,s,se',
handles: "e,s,se",
helper: false,
maxHeight: null,
maxWidth: null,

View File

@ -8,17 +8,17 @@ module("resizable: core");
/*
test("element types", function() {
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
+ ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
+ ',acronym,code,samp,kbd,var,img,object,hr'
+ ',input,button,label,select,iframe').split(',');
var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form"
+ ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr"
+ ",acronym,code,samp,kbd,var,img,object,hr"
+ ",input,button,label,select,iframe").split(",");
$.each(typeNames, function(i) {
var typeName = typeNames[i];
el = $(document.createElement(typeName)).appendTo('body');
(typeName == 'table' && el.append("<tr><td>content</td></tr>"));
el = $(document.createElement(typeName)).appendTo("body");
(typeName == "table" && el.append("<tr><td>content</td></tr>"));
el.resizable();
ok(true, '$("&lt;' + typeName + '/&gt").resizable()');
ok(true, "$('&lt;" + typeName + "/&gt').resizable()");
el.resizable("destroy");
el.remove();
});
@ -28,7 +28,7 @@ test("element types", function() {
test("n", function() {
expect(4);
var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' });
var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, 0, -50);
equal( target.height(), 150, "compare height" );
@ -43,7 +43,7 @@ test("n", function() {
test("s", function() {
expect(5);
var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' });
var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, 0, 50);
equal( target.height(), 150, "compare height" );
@ -59,7 +59,7 @@ test("s", function() {
test("e", function() {
expect(5);
var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' });
var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, 50);
equal( target.width(), 150, "compare width");
@ -75,7 +75,7 @@ test("e", function() {
test("w", function() {
expect(4);
var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' });
var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50);
equal( target.width(), 150, "compare width" );
@ -90,7 +90,7 @@ test("w", function() {
test("ne", function() {
expect(5);
var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' });
var handle = ".ui-resizable-ne", target = $("#resizable1").css({ overflow: "hidden" }).resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50, -50);
equal( target.width(), 50, "compare width" );
@ -106,7 +106,7 @@ test("ne", function() {
test("se", function() {
expect(6);
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' });
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, 50, 50);
equal( target.width(), 150, "compare width" );
@ -123,7 +123,7 @@ test("se", function() {
test("sw", function() {
expect(5);
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' });
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50, -50);
equal( target.width(), 150, "compare width" );
@ -139,7 +139,7 @@ test("sw", function() {
test("nw", function() {
expect(4);
var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' });
var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50, -50);
equal( target.width(), 150, "compare width" );
@ -153,15 +153,15 @@ test("nw", function() {
test("handle with complex markup (#8756)", function() {
expect(2);
$('#resizable1')
$("#resizable1")
.append(
$('<div>')
$("<div>")
.addClass("ui-resizable-handle")
.addClass("ui-resizable-w")
.append($('<div>'))
.append($("<div>"))
);
var handle = '.ui-resizable-w div', target = $('#resizable1').resizable({ handles: 'all' });
var handle = ".ui-resizable-w div", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50);
equal( target.width(), 150, "compare width" );
@ -176,7 +176,7 @@ test("resizable accounts for scroll position correctly (#3815)", function() {
var position, top, left,
container = $("<div style='overflow:scroll;height:300px;width:300px;position:relative;'></div>").appendTo("#qunit-fixture"),
overflowed = $("<div style='width: 1000px; height: 1000px;'></div>").appendTo( container ),
el = $("<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>").appendTo( overflowed ).resizable({ handles: 'all' }),
el = $("<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>").appendTo( overflowed ).resizable({ handles: "all" }),
handle = ".ui-resizable-e";
container.scrollLeft( 100 ).scrollTop( 100 );

View File

@ -28,7 +28,7 @@ test( "alsoResize", function() {
test("aspectRatio: 'preserve' (e)", function() {
expect(4);
var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 80);
equal( target.width(), 130, "compare maxWidth");
@ -42,7 +42,7 @@ test("aspectRatio: 'preserve' (e)", function() {
test("aspectRatio: 'preserve' (w)", function() {
expect(4);
var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, -80);
equal( target.width(), 130, "compare maxWidth");
@ -56,7 +56,7 @@ test("aspectRatio: 'preserve' (w)", function() {
test("aspectRatio: 'preserve' (n)", function() {
expect(4);
var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 0, -80);
equal( target.width(), 130, "compare maxWidth");
@ -70,7 +70,7 @@ test("aspectRatio: 'preserve' (n)", function() {
test("aspectRatio: 'preserve' (s)", function() {
expect(4);
var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 0, 80);
equal( target.width(), 130, "compare maxWidth");
@ -84,7 +84,7 @@ test("aspectRatio: 'preserve' (s)", function() {
test("aspectRatio: 'preserve' (se)", function() {
expect(4);
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 80, 80);
equal( target.width(), 130, "compare maxWidth");
@ -98,7 +98,7 @@ test("aspectRatio: 'preserve' (se)", function() {
test("aspectRatio: 'preserve' (sw)", function() {
expect(4);
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, -80, 80);
equal( target.width(), 130, "compare maxWidth");
@ -112,7 +112,7 @@ test("aspectRatio: 'preserve' (sw)", function() {
test("aspectRatio: 'preserve' (ne)", function() {
expect(4);
var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 80, -80);
equal( target.width(), 130, "compare maxWidth");
@ -141,7 +141,7 @@ test( "containment", function() {
test("grid", function() {
expect(4);
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] });
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: [0, 20] });
TestHelpers.resizable.drag(handle, 3, 9);
equal( target.width(), 103, "compare width");
@ -169,7 +169,7 @@ test("grid (min/max dimensions)", function() {
test("grid (wrapped)", function() {
expect(4);
var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] });
var handle = ".ui-resizable-se", target = $("#resizable2").resizable({ handles: "all", grid: [0, 20] });
TestHelpers.resizable.drag(handle, 3, 9);
equal( target.width(), 103, "compare width");
@ -183,7 +183,7 @@ test("grid (wrapped)", function() {
test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4);
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
TestHelpers.resizable.drag(handle, -50, -50);
equal( target.width(), 60, "compare minWidth" );
@ -197,7 +197,7 @@ test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4);
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
TestHelpers.resizable.drag(handle, 50, -50);
equal( target.width(), 60, "compare minWidth" );
@ -211,7 +211,7 @@ test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4);
var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
TestHelpers.resizable.drag(handle, -50, 50);
equal( target.width(), 60, "compare minWidth" );
@ -225,7 +225,7 @@ test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4);
var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
TestHelpers.resizable.drag(handle, 70, 70);
equal( target.width(), 60, "compare minWidth" );
@ -239,9 +239,9 @@ test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
test("zIndex, applied to all handles", function() {
expect(8);
var target = $('<div></div>').resizable({ handles: 'all', zIndex: 100 });
target.children( '.ui-resizable-handle' ).each( function( index, handle ) {
equal( $( handle ).css( 'zIndex' ), 100, 'compare zIndex' );
var target = $("<div></div>").resizable({ handles: "all", zIndex: 100 });
target.children( ".ui-resizable-handle" ).each( function( index, handle ) {
equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" );
});
});

View File

@ -26,7 +26,6 @@
<script src="selectable_events.js"></script>
<script src="selectable_methods.js"></script>
<script src="selectable_options.js"></script>
<script src="selectable_test_helpers.js"></script>
<script src="../swarminject.js"></script>
</head>

View File

@ -1,13 +1,13 @@
TestHelpers.commonWidgetTests('selectable', {
TestHelpers.commonWidgetTests("selectable", {
defaults: {
appendTo: 'body',
appendTo: "body",
autoRefresh: true,
cancel: 'input,textarea,button,select,option',
cancel: "input,textarea,button,select,option",
create: null,
delay: 0,
disabled: false,
distance: 0,
filter: '*',
tolerance: 'touch'
filter: "*",
tolerance: "touch"
}
});

View File

@ -35,4 +35,32 @@ test( "stop", function() {
});
});
test( "mousedown: initial position of helper", function() {
expect( 2 );
var contentToForceScroll, helper,
element = $("#selectable1").selectable();
contentToForceScroll = $("<div>").css({
height: "10000px",
width: "10000px"
});
contentToForceScroll.appendTo("body");
$( window ).scrollTop( 1 ).scrollLeft( 1 );
element.simulate( "mousedown", {
clientX: 10,
clientY: 10
});
helper = $(".ui-selectable-helper");
equal( helper.css("top"), "11px", "Scroll top should be accounted for." );
equal( helper.css("left"), "11px", "Scroll left should be accounted for." );
// Cleanup
element.simulate("mouseup");
contentToForceScroll.remove();
$( window ).scrollTop( 0 ).scrollLeft( 0 );
});
})( jQuery );

View File

@ -8,39 +8,39 @@ module("selectable: methods");
test("init", function() {
expect( 5 );
$("<div></div>").appendTo('body').selectable().remove();
ok(true, '.selectable() called on element');
$("<div></div>").appendTo("body").selectable().remove();
ok(true, ".selectable() called on element");
$([]).selectable().remove();
ok(true, '.selectable() called on empty collection');
ok(true, ".selectable() called on empty collection");
$("<div></div>").selectable().remove();
ok(true, '.selectable() called on disconnected DOMElement');
ok(true, ".selectable() called on disconnected DOMElement");
var el = $("<div></div>").selectable();
el.selectable("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
ok(true, "arbitrary option getter after init");
$("<div></div>").selectable().selectable("option", "foo", "bar").remove();
ok(true, 'arbitrary option setter after init');
ok(true, "arbitrary option setter after init");
});
test("destroy", function() {
expect( 4 );
$("<div></div>").appendTo('body').selectable().selectable("destroy").remove();
ok(true, '.selectable("destroy") called on element');
$("<div></div>").appendTo("body").selectable().selectable("destroy").remove();
ok(true, ".selectable('destroy') called on element");
$([]).selectable().selectable("destroy").remove();
ok(true, '.selectable("destroy") called on empty collection');
ok(true, ".selectable('destroy') called on empty collection");
$("<div></div>").selectable().selectable("destroy").remove();
ok(true, '.selectable("destroy") called on disconnected DOMElement');
ok(true, ".selectable('destroy') called on disconnected DOMElement");
var expected = $('<div></div>').selectable(),
actual = expected.selectable('destroy');
equal(actual, expected, 'destroy is chainable');
var expected = $("<div></div>").selectable(),
actual = expected.selectable("destroy");
equal(actual, expected, "destroy is chainable");
});
test("enable", function() {
@ -66,9 +66,9 @@ test("enable", function() {
equal(fired, true, "start fired");
el.selectable("destroy");
expected = $('<div></div>').selectable();
actual = expected.selectable('enable');
equal(actual, expected, 'enable is chainable');
expected = $("<div></div>").selectable();
actual = expected.selectable("enable");
equal(actual, expected, "enable is chainable");
});
test("disable", function() {
@ -96,9 +96,9 @@ test("disable", function() {
equal(fired, false, "start fired");
el.selectable("destroy");
expected = $('<div></div>').selectable();
actual = expected.selectable('disable');
equal(actual, expected, 'disable is chainable');
expected = $("<div></div>").selectable();
actual = expected.selectable("disable");
equal(actual, expected, "disable is chainable");
});
})(jQuery);

View File

@ -52,7 +52,7 @@ test("filter", function() {
selected = function() { actual += 1; };
el = $("#selectable1").selectable({ filter: '.special', selected: selected });
el = $("#selectable1").selectable({ filter: ".special", selected: selected });
el.simulate( "drag", {
dx: 1000,
dy: 1000

View File

@ -1,13 +1,13 @@
TestHelpers.commonWidgetTests( "slider", {
defaults: {
animate: false,
cancel: 'input,textarea,button,select,option',
cancel: "input,textarea,button,select,option",
delay: 0,
disabled: false,
distance: 0,
max: 100,
min: 0,
orientation: 'horizontal',
orientation: "horizontal",
range: false,
step: 1,
value: 0,

View File

@ -17,11 +17,11 @@ module("slider: core");
test("keydown HOME on handle sets value to min", function() {
expect( 2 );
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'horizontal',
orientation: "horizontal",
step: 1
};
el.slider(options);
@ -31,13 +31,13 @@ test("keydown HOME on handle sets value to min", function() {
handle().simulate("keydown", { keyCode: $.ui.keyCode.HOME });
equal(el.slider("value"), options.min);
el.slider('destroy');
el.slider("destroy");
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'vertical',
orientation: "vertical",
step: 1
};
el.slider(options);
@ -47,16 +47,16 @@ test("keydown HOME on handle sets value to min", function() {
handle().simulate("keydown", { keyCode: $.ui.keyCode.HOME });
equal(el.slider("value"), options.min);
el.slider('destroy');
el.slider("destroy");
});
test("keydown END on handle sets value to max", function() {
expect( 2 );
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'horizontal',
orientation: "horizontal",
step: 1
};
el.slider(options);
@ -66,13 +66,13 @@ test("keydown END on handle sets value to max", function() {
handle().simulate("keydown", { keyCode: $.ui.keyCode.END });
equal(el.slider("value"), options.max);
el.slider('destroy');
el.slider("destroy");
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'vertical',
orientation: "vertical",
step: 1
};
el.slider(options);
@ -82,13 +82,13 @@ test("keydown END on handle sets value to max", function() {
handle().simulate("keydown", { keyCode: $.ui.keyCode.END });
equal(el.slider("value"), options.max);
el.slider('destroy');
el.slider("destroy");
});
test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() {
expect( 4 );
$.each(['horizontal', 'vertical'], function(i, orientation) {
el = $('<div></div>');
$.each(["horizontal", "vertical"], function(i, orientation) {
el = $("<div></div>");
options = {
max: 100,
min: 0,
@ -111,8 +111,8 @@ test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than m
test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() {
expect( 4 );
$.each(['horizontal', 'vertical'], function(i, orientation) {
el = $('<div></div>');
$.each(["horizontal", "vertical"], function(i, orientation) {
el = $("<div></div>");
options = {
max: 100,
min: 0,
@ -135,11 +135,11 @@ test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than mi
test("keydown UP on handle increases value by step, not greater than max", function() {
expect( 4 );
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'horizontal',
orientation: "horizontal",
step: 1
};
el.slider(options);
@ -154,11 +154,11 @@ test("keydown UP on handle increases value by step, not greater than max", funct
el.slider("destroy");
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'vertical',
orientation: "vertical",
step: 1
};
el.slider(options);
@ -176,11 +176,11 @@ test("keydown UP on handle increases value by step, not greater than max", funct
test("keydown RIGHT on handle increases value by step, not greater than max", function() {
expect( 4 );
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'horizontal',
orientation: "horizontal",
step: 1
};
el.slider(options);
@ -195,11 +195,11 @@ test("keydown RIGHT on handle increases value by step, not greater than max", fu
el.slider("destroy");
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'vertical',
orientation: "vertical",
step: 1
};
el.slider(options);
@ -217,11 +217,11 @@ test("keydown RIGHT on handle increases value by step, not greater than max", fu
test("keydown DOWN on handle decreases value by step, not less than min", function() {
expect( 4 );
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'horizontal',
orientation: "horizontal",
step: 1
};
el.slider(options);
@ -236,11 +236,11 @@ test("keydown DOWN on handle decreases value by step, not less than min", functi
el.slider("destroy");
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'vertical',
orientation: "vertical",
step: 1
};
el.slider(options);
@ -258,11 +258,11 @@ test("keydown DOWN on handle decreases value by step, not less than min", functi
test("keydown LEFT on handle decreases value by step, not less than min", function() {
expect( 4 );
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'horizontal',
orientation: "horizontal",
step: 1
};
el.slider(options);
@ -277,11 +277,11 @@ test("keydown LEFT on handle decreases value by step, not less than min", functi
el.slider("destroy");
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 5,
min: -5,
orientation: 'vertical',
orientation: "vertical",
step: 1
};
el.slider(options);

View File

@ -8,22 +8,22 @@ module("slider: methods");
test("init", function() {
expect(5);
$("<div></div>").appendTo('body').slider().remove();
ok(true, '.slider() called on element');
$("<div></div>").appendTo("body").slider().remove();
ok(true, ".slider() called on element");
$([]).slider().remove();
ok(true, '.slider() called on empty collection');
ok(true, ".slider() called on empty collection");
$('<div></div>').slider().remove();
ok(true, '.slider() called on disconnected DOMElement');
$("<div></div>").slider().remove();
ok(true, ".slider() called on disconnected DOMElement");
var el = $('<div></div>').slider();
var el = $("<div></div>").slider();
el.slider("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
ok(true, "arbitrary option getter after init");
$('<div></div>').slider().slider("option", "foo", "bar").remove();
ok(true, 'arbitrary option setter after init');
$("<div></div>").slider().slider("option", "foo", "bar").remove();
ok(true, "arbitrary option setter after init");
});
test("destroy", function() {
@ -36,60 +36,60 @@ test("destroy", function() {
test("enable", function() {
expect( 5 );
var el,
expected = $('<div></div>').slider(),
actual = expected.slider('enable');
equal(actual, expected, 'enable is chainable');
expected = $("<div></div>").slider(),
actual = expected.slider("enable");
equal(actual, expected, "enable is chainable");
el = $('<div></div>').slider({ disabled: true });
ok(el.hasClass('ui-state-disabled'), 'slider has ui-state-disabled class before enable method call');
ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class before enable method call');
el.slider('enable');
ok(!el.hasClass('ui-state-disabled'), 'slider does not have ui-state-disabled class after enable method call');
ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class after enable method call');
el = $("<div></div>").slider({ disabled: true });
ok(el.hasClass("ui-state-disabled"), "slider has ui-state-disabled class before enable method call");
ok(el.hasClass("ui-slider-disabled"), "slider has ui-slider-disabled class before enable method call");
el.slider("enable");
ok(!el.hasClass("ui-state-disabled"), "slider does not have ui-state-disabled class after enable method call");
ok(!el.hasClass("ui-slider-disabled"), "slider does not have ui-slider-disabled class after enable method call");
});
test("disable", function() {
expect( 5 );
var el,
expected = $('<div></div>').slider(),
actual = expected.slider('disable');
equal(actual, expected, 'disable is chainable');
expected = $("<div></div>").slider(),
actual = expected.slider("disable");
equal(actual, expected, "disable is chainable");
el = $('<div></div>').slider({ disabled: false });
ok(!el.hasClass('ui-state-disabled'), 'slider does not have ui-state-disabled class before disabled method call');
ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class before disable method call');
el.slider('disable');
ok(el.hasClass('ui-state-disabled'), 'slider has ui-state-disabled class after disable method call');
ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class after disable method call');
el = $("<div></div>").slider({ disabled: false });
ok(!el.hasClass("ui-state-disabled"), "slider does not have ui-state-disabled class before disabled method call");
ok(!el.hasClass("ui-slider-disabled"), "slider does not have ui-slider-disabled class before disable method call");
el.slider("disable");
ok(el.hasClass("ui-state-disabled"), "slider has ui-state-disabled class after disable method call");
ok(el.hasClass("ui-slider-disabled"), "slider has ui-slider-disabled class after disable method call");
});
test("value", function() {
expect( 17 );
$([false, 'min', 'max']).each(function() {
var el = $('<div></div>').slider({
$([false, "min", "max"]).each(function() {
var el = $("<div></div>").slider({
range: this,
value: 5
});
equal(el.slider('value'), 5, 'range: ' + this + ' slider method get');
equal(el.slider('value', 10), el, 'value method is chainable');
equal(el.slider('value'), 10, 'range: ' + this + ' slider method set');
equal(el.slider("value"), 5, "range: " + this + " slider method get");
equal(el.slider("value", 10), el, "value method is chainable");
equal(el.slider("value"), 10, "range: " + this + " slider method set");
el.remove();
});
var el = $('<div></div>').slider({
var el = $("<div></div>").slider({
min: -1, value: 0, max: 1
});
// min with value option vs value method
el.slider('option', 'value', -2);
equal(el.slider('option', 'value'), -2, 'value option does not respect min');
equal(el.slider('value'), -1, 'value method get respects min');
equal(el.slider('value', -2), el, 'value method is chainable');
equal(el.slider('option', 'value'), -1, 'value method set respects min');
el.slider("option", "value", -2);
equal(el.slider("option", "value"), -2, "value option does not respect min");
equal(el.slider("value"), -1, "value method get respects min");
equal(el.slider("value", -2), el, "value method is chainable");
equal(el.slider("option", "value"), -1, "value method set respects min");
// max with value option vs value method
el.slider('option', 'value', 2);
equal(el.slider('option', 'value'), 2, 'value option does not respect max');
equal(el.slider('value'), 1, 'value method get respects max');
equal(el.slider('value', 2), el, 'value method is chainable');
equal(el.slider('option', 'value'), 1, 'value method set respects max');
el.slider("option", "value", 2);
equal(el.slider("option", "value"), 2, "value option does not respect max");
equal(el.slider("value"), 1, "value method get respects max");
equal(el.slider("value", 2), el, "value method is chainable");
equal(el.slider("option", "value"), 1, "value method set respects max");
});
//test("values", function() {

View File

@ -13,12 +13,12 @@ module("slider: options");
test("max", function() {
expect( 2 );
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 37,
min: 6,
orientation: 'horizontal',
orientation: "horizontal",
step: 1,
value: 50
};
@ -26,18 +26,18 @@ test("max", function() {
el.slider(options);
ok(el.slider("option", "value") === options.value, "value option is not contained by max");
ok(el.slider("value") === options.max, "value method is contained by max");
el.slider('destroy');
el.slider("destroy");
});
test("min", function() {
expect( 2 );
el = $('<div></div>');
el = $("<div></div>");
options = {
max: 37,
min: 6,
orientation: 'vertical',
orientation: "vertical",
step: 1,
value: 2
};
@ -45,45 +45,45 @@ test("min", function() {
el.slider(options);
ok(el.slider("option", "value") === options.value, "value option is not contained by min");
ok(el.slider("value") === options.min, "value method is contained by min");
el.slider('destroy');
el.slider("destroy");
});
test("orientation", function() {
expect( 6 );
el = $('#slider1');
el = $("#slider1");
options = {
max: 2,
min: -2,
orientation: 'vertical',
orientation: "vertical",
value: 1
};
var percentVal = (options.value - options.min) / (options.max - options.min) * 100;
el.slider(options).slider("option", "orientation", "horizontal");
ok(el.is('.ui-slider-horizontal'), "horizontal slider has class .ui-slider-horizontal");
ok(!el.is('.ui-slider-vertical'), "horizontal slider does not have class .ui-slider-vertical");
equal(handle()[0].style.left, percentVal + '%', "horizontal slider handle is positioned with left: %");
ok(el.is(".ui-slider-horizontal"), "horizontal slider has class .ui-slider-horizontal");
ok(!el.is(".ui-slider-vertical"), "horizontal slider does not have class .ui-slider-vertical");
equal(handle()[0].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %");
el.slider('destroy');
el.slider("destroy");
options = {
max: 2,
min: -2,
orientation: 'horizontal',
orientation: "horizontal",
value: -1
};
percentVal = (options.value - options.min) / (options.max - options.min) * 100;
el.slider(options).slider("option", "orientation", "vertical");
ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical");
ok(!el.is('.ui-slider-horizontal'), "vertical slider does not have class .ui-slider-horizontal");
equal(handle()[0].style.bottom, percentVal + '%', "vertical slider handle is positioned with bottom: %");
ok(el.is(".ui-slider-vertical"), "vertical slider has class .ui-slider-vertical");
ok(!el.is(".ui-slider-horizontal"), "vertical slider does not have class .ui-slider-horizontal");
equal(handle()[0].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %");
el.slider('destroy');
el.slider("destroy");
});
@ -96,7 +96,7 @@ test("orientation", function() {
// What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple)
test("step", function() {
expect( 9 );
var el = $('<div></div>').slider({
var el = $("<div></div>").slider({
min: 0,
value: 0,
step: 10,
@ -116,7 +116,7 @@ test("step", function() {
el.slider("value", 19);
equal( el.slider("value"), 20 );
el = $('<div></div>').slider({
el = $("<div></div>").slider({
min: 0,
value: 0,
step: 20,
@ -136,7 +136,7 @@ test("step", function() {
el.slider("option", "value", 19);
equal( el.slider("value"), 20 );
el.slider('destroy');
el.slider("destroy");
});
//test("value", function() {

View File

@ -17,15 +17,15 @@ test("start", function() {
dy: 10
});
ok(hash, 'start event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
ok(hash, "start event triggered");
ok(hash.helper, "UI hash includes: helper");
ok(hash.placeholder, "UI hash includes: placeholder");
ok(hash.item, "UI hash includes: item");
ok(!hash.sender, "UI hash does not include: sender");
// todo: see if these events should actually have sane values in them
ok('position' in hash, 'UI hash includes: position');
ok('offset' in hash, 'UI hash includes: offset');
ok("position" in hash, "UI hash includes: position");
ok("offset" in hash, "UI hash includes: offset");
});
@ -42,13 +42,13 @@ test("sort", function() {
dy: 10
});
ok(hash, 'sort event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
ok(hash, "sort event triggered");
ok(hash.helper, "UI hash includes: helper");
ok(hash.placeholder, "UI hash includes: placeholder");
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
ok(hash.item, "UI hash includes: item");
ok(!hash.sender, "UI hash does not include: sender");
});
@ -65,7 +65,7 @@ test("change", function() {
dy: 1
});
ok(!hash, '1px drag, change event should not be triggered');
ok(!hash, "1px drag, change event should not be triggered");
$("#sortable").sortable({
change: function( e, ui ) {
@ -75,13 +75,13 @@ test("change", function() {
dy: 22
});
ok(hash, 'change event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
ok(hash, "change event triggered");
ok(hash.helper, "UI hash includes: helper");
ok(hash.placeholder, "UI hash includes: placeholder");
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
ok(hash.item, "UI hash includes: item");
ok(!hash.sender, "UI hash does not include: sender");
});
@ -97,13 +97,13 @@ test("beforeStop", function() {
dy: 20
});
ok(hash, 'beforeStop event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
ok(hash, "beforeStop event triggered");
ok(hash.helper, "UI hash includes: helper");
ok(hash.placeholder, "UI hash includes: placeholder");
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
ok(hash.item, "UI hash includes: item");
ok(!hash.sender, "UI hash does not include: sender");
});
@ -119,13 +119,13 @@ test("stop", function() {
dy: 20
});
ok(hash, 'stop event triggered');
ok(!hash.helper, 'UI should not include: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
ok(hash, "stop event triggered");
ok(!hash.helper, "UI should not include: helper");
ok(hash.placeholder, "UI hash includes: placeholder");
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
ok(hash.item, "UI hash includes: item");
ok(!hash.sender, "UI hash does not include: sender");
});
@ -142,7 +142,7 @@ test("update", function() {
dy: 1
});
ok(!hash, '1px drag, update event should not be triggered');
ok(!hash, "1px drag, update event should not be triggered");
$("#sortable").sortable({
update: function( e, ui ) {
@ -152,13 +152,13 @@ test("update", function() {
dy: 22
});
ok(hash, 'update event triggered');
ok(!hash.helper, 'UI hash should not include: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && ('top' in hash.position && 'left' in hash.position), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
ok(hash, "update event triggered");
ok(!hash.helper, "UI hash should not include: helper");
ok(hash.placeholder, "UI hash includes: placeholder");
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
ok(hash.item, "UI hash includes: item");
ok(!hash.sender, "UI hash does not include: sender");
});
@ -172,21 +172,21 @@ test("#3019: Stop fires too early", function() {
}
});
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable');
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable");
equal(helper, null, "helper should be false");
});
test('#4752: link event firing on sortable with connect list', function () {
test("#4752: link event firing on sortable with connect list", function () {
expect( 10 );
var fired = {},
hasFired = function (type) { return (type in fired) && (true === fired[type]); };
$('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable');
$("#sortable").clone().attr("id", "sortable2").insertAfter("#sortable");
$('#qunit-fixture ul').sortable({
connectWith: '#qunit-fixture ul',
$("#qunit-fixture ul").sortable({
connectWith: "#qunit-fixture ul",
change: function () {
fired.change = true;
},
@ -198,29 +198,29 @@ test('#4752: link event firing on sortable with connect list', function () {
}
});
$('#qunit-fixture ul').bind('click.ui-sortable-test', function () {
$("#qunit-fixture ul").bind("click.ui-sortable-test", function () {
fired.click = true;
});
$('#sortable li:eq(0)').simulate('click');
ok(!hasFired('change'), 'Click only, change event should not have fired');
ok(hasFired('click'), 'Click event should have fired');
$("#sortable li:eq(0)").simulate("click");
ok(!hasFired("change"), "Click only, change event should not have fired");
ok(hasFired("click"), "Click event should have fired");
// Drag an item within the first list
fired = {};
$('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 });
ok(hasFired('change'), '40px drag, change event should have fired');
ok(!hasFired('receive'), 'Receive event should not have fired');
ok(!hasFired('remove'), 'Remove event should not have fired');
ok(!hasFired('click'), 'Click event should not have fired');
$("#sortable li:eq(0)").simulate("drag", { dx: 0, dy: 40 });
ok(hasFired("change"), "40px drag, change event should have fired");
ok(!hasFired("receive"), "Receive event should not have fired");
ok(!hasFired("remove"), "Remove event should not have fired");
ok(!hasFired("click"), "Click event should not have fired");
// Drag an item from the first list to the second, connected list
fired = {};
$('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 });
ok(hasFired('change'), '150px drag, change event should have fired');
ok(hasFired('receive'), 'Receive event should have fired');
ok(hasFired('remove'), 'Remove event should have fired');
ok(!hasFired('click'), 'Click event should not have fired');
$("#sortable li:eq(0)").simulate("drag", { dx: 0, dy: 150 });
ok(hasFired("change"), "150px drag, change event should have fired");
ok(hasFired("receive"), "Receive event should have fired");
ok(hasFired("remove"), "Remove event should have fired");
ok(!hasFired("click"), "Click event should not have fired");
});
/*

View File

@ -8,36 +8,36 @@ module("sortable: methods");
test("init", function() {
expect(5);
$("<div></div>").appendTo('body').sortable().remove();
ok(true, '.sortable() called on element');
$("<div></div>").appendTo("body").sortable().remove();
ok(true, ".sortable() called on element");
$([]).sortable();
ok(true, '.sortable() called on empty collection');
ok(true, ".sortable() called on empty collection");
$("<div></div>").sortable();
ok(true, '.sortable() called on disconnected DOMElement');
ok(true, ".sortable() called on disconnected DOMElement");
$("<div></div>").sortable().sortable("option", "foo");
ok(true, 'arbitrary option getter after init');
ok(true, "arbitrary option getter after init");
$("<div></div>").sortable().sortable("option", "foo", "bar");
ok(true, 'arbitrary option setter after init');
ok(true, "arbitrary option setter after init");
});
test("destroy", function() {
expect(4);
$("<div></div>").appendTo('body').sortable().sortable("destroy").remove();
ok(true, '.sortable("destroy") called on element');
$("<div></div>").appendTo("body").sortable().sortable("destroy").remove();
ok(true, ".sortable('destroy') called on element");
$([]).sortable().sortable("destroy");
ok(true, '.sortable("destroy") called on empty collection');
ok(true, ".sortable('destroy') called on empty collection");
$("<div></div>").sortable().sortable("destroy");
ok(true, '.sortable("destroy") called on disconnected DOMElement');
ok(true, ".sortable('destroy') called on disconnected DOMElement");
var expected = $('<div></div>').sortable(),
actual = expected.sortable('destroy');
equal(actual, expected, 'destroy is chainable');
var expected = $("<div></div>").sortable(),
actual = expected.sortable("destroy");
equal(actual, expected, "destroy is chainable");
});
test("enable", function() {
@ -47,7 +47,7 @@ test("enable", function() {
el = $("#sortable").sortable({ disabled: true });
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, '.sortable({ disabled: true })');
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })");
el.sortable("enable");
equal(el.sortable("option", "disabled"), false, "disabled option getter");
@ -57,11 +57,11 @@ test("enable", function() {
el.sortable("option", "disabled", false);
equal(el.sortable("option", "disabled"), false, "disabled option setter");
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable("option", "disabled", false)');
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)");
expected = $('<div></div>').sortable(),
actual = expected.sortable('enable');
equal(actual, expected, 'enable is chainable');
expected = $("<div></div>").sortable(),
actual = expected.sortable("enable");
equal(actual, expected, "enable is chainable");
});
test("disable", function() {
@ -70,23 +70,23 @@ test("disable", function() {
var el, actual, expected;
el = $("#sortable").sortable({ disabled: false });
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable({ disabled: false })');
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })");
el.sortable("disable");
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, 'disabled.sortable getter');
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, "disabled.sortable getter");
el.sortable("destroy");
el.sortable({ disabled: false });
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, '.sortable({ disabled: false })');
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })");
el.sortable("option", "disabled", true);
equal(el.sortable("option", "disabled"), true, "disabled option setter");
ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction");
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, '.sortable("option", "disabled", true)');
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable('option', 'disabled', true)");
expected = $('<div></div>').sortable(),
actual = expected.sortable('disable');
equal(actual, expected, 'disable is chainable');
expected = $("<div></div>").sortable(),
actual = expected.sortable("disable");
equal(actual, expected, "disable is chainable");
});
})(jQuery);

View File

@ -5,7 +5,7 @@ var simulateKeyDownUp = TestHelpers.spinner.simulateKeyDownUp;
module( "spinner: events" );
test( "start", function() {
expect( 6 );
expect( 10 );
var element = $( "#spin" ).spinner();
function shouldStart( expectation, msg ) {
@ -29,14 +29,14 @@ test( "start", function() {
shouldStart( true, "button down" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
shouldStart( false, "stepUp" );
shouldStart( true, "stepUp" );
element.spinner( "stepUp" );
shouldStart( false, "stepDown" );
shouldStart( true, "stepDown" );
element.spinner( "stepDown" );
shouldStart( false, "pageUp" );
shouldStart( true, "pageUp" );
element.spinner( "pageUp" );
shouldStart( false, "pageDown" );
shouldStart( true, "pageDown" );
element.spinner( "pageDown" );
shouldStart( false, "value" );
@ -44,7 +44,7 @@ test( "start", function() {
});
test( "spin", function() {
expect( 6 );
expect( 10 );
var element = $( "#spin" ).spinner();
function shouldSpin( expectation, msg ) {
@ -68,14 +68,14 @@ test( "spin", function() {
shouldSpin( true, "button down" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
shouldSpin( false, "stepUp" );
shouldSpin( true, "stepUp" );
element.spinner( "stepUp" );
shouldSpin( false, "stepDown" );
shouldSpin( true, "stepDown" );
element.spinner( "stepDown" );
shouldSpin( false, "pageUp" );
shouldSpin( true, "pageUp" );
element.spinner( "pageUp" );
shouldSpin( false, "pageDown" );
shouldSpin( true, "pageDown" );
element.spinner( "pageDown" );
shouldSpin( false, "value" );
@ -83,7 +83,7 @@ test( "spin", function() {
});
test( "stop", function() {
expect( 6 );
expect( 10 );
var element = $( "#spin" ).spinner();
function shouldStop( expectation, msg ) {
@ -107,14 +107,14 @@ test( "stop", function() {
shouldStop( true, "button down" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
shouldStop( false, "stepUp" );
shouldStop( true, "stepUp" );
element.spinner( "stepUp" );
shouldStop( false, "stepDown" );
shouldStop( true, "stepDown" );
element.spinner( "stepDown" );
shouldStop( false, "pageUp" );
shouldStop( true, "pageUp" );
element.spinner( "pageUp" );
shouldStop( false, "pageDown" );
shouldStop( true, "pageDown" );
element.spinner( "pageDown" );
shouldStop( false, "value" );

View File

@ -5,10 +5,17 @@ module( "spinner: options" );
// culture is tested after numberFormat, since it depends on numberFormat
test( "icons: default ", function() {
expect( 2 );
var element = $( "#spin" ).val( 0 ).spinner().spinner( "widget" );
equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" );
equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" );
expect( 4 );
var element = $( "#spin" ).val( 0 ).spinner();
equal( element.spinner( "widget" ).find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" );
equal( element.spinner( "widget" ).find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" );
element.spinner( "option", "icons", {
up: "ui-icon-carat-1-n",
down: "ui-icon-carat-1-s"
});
equal( element.spinner( "widget" ).find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-carat-1-n" );
equal( element.spinner( "widget" ).find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-carat-1-s" );
});
test( "icons: custom ", function() {

View File

@ -393,14 +393,14 @@
/* Overlays */
.ui-widget-overlay {
background: #aaaaaa/*{bgColorOverlay}*/ url(images/ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlOverlay}*/ 50%/*{bgOverlayXPos}*/ 50%/*{bgOverlayYPos}*/ repeat-x/*{bgOverlayRepeat}*/;
/* no space between ".3;" and "filter" because themeRoller looks back to the first space for replacement */
opacity: .3;filter:Alpha(Opacity=30)/*{opacityOverlay}*/;
opacity: .3/*{opacityOverlay}*/;
filter: Alpha(Opacity=30)/*{opacityFilterOverlay}*/;
}
.ui-widget-shadow {
margin: -8px/*{offsetTopShadow}*/ 0 0 -8px/*{offsetLeftShadow}*/;
padding: 8px/*{thicknessShadow}*/;
background: #aaaaaa/*{bgColorShadow}*/ url(images/ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlShadow}*/ 50%/*{bgShadowXPos}*/ 50%/*{bgShadowYPos}*/ repeat-x/*{bgShadowRepeat}*/;
/* no space between ".3;" and "filter" because themeRoller looks back to the first space for replacement */
opacity: .3;filter:Alpha(Opacity=30)/*{opacityShadow}*/;
opacity: .3/*{opacityShadow}*/;
filter: Alpha(Opacity=30)/*{opacityFilterShadow}*/;
border-radius: 8px/*{cornerRadiusShadow}*/;
}

View File

@ -8,6 +8,7 @@
"latedef": true,
"noarg": true,
"onevar": true,
"quotmark": "double",
"trailing": true,
"undef": true,
"unused": true,

View File

@ -69,17 +69,17 @@ $.fn.extend({
scrollParent: function() {
var scrollParent;
if (($.ui.ie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
scrollParent = this.parents().filter(function() {
return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
}).eq(0);
} else {
scrollParent = this.parents().filter(function() {
return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
}).eq(0);
}
return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
},
zIndex: function( zIndex ) {

File diff suppressed because it is too large Load Diff

View File

@ -466,7 +466,7 @@ $.widget( "ui.dialog", {
// .ui-resizable has position: relative defined in the stylesheet
// but dialogs have to use absolute or fixed positioning
position = this.uiDialog.css("position"),
resizeHandles = typeof handles === 'string' ?
resizeHandles = typeof handles === "string" ?
handles :
"n,e,s,w,se,sw,ne,nw";

View File

@ -81,7 +81,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
this.dragDimensions = null;
// The actual dragging element, should always be a jQuery object
this.dragEl = ( this.options.helper === true || typeof this.options.helper === 'function' ) ?
this.dragEl = ( this.options.helper === true || typeof this.options.helper === "function" ) ?
this._createHelper( pointerPosition ) :
this.element;
@ -208,7 +208,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
// If user cancels stop, leave helper there
if ( this._trigger( "stop", event, this._fullHash( pointerPosition ) ) !== false ) {
if ( this.options.helper ) {
delete this.element.data( 'uiDraggable' ).helper;
delete this.element.data( "uiDraggable" ).helper;
this.dragEl.remove();
}
this._resetDomPosition();
@ -242,7 +242,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
helper.appendTo( this._appendToEl() || this.document[0].body );
}
this.element.data( 'uiDraggable' ).helper = helper;
this.element.data( "uiDraggable" ).helper = helper;
this._cacheDragDimensions( helper );
@ -536,7 +536,7 @@ if ( $.uiBackCompat !== false ) {
var el = this.options.appendTo;
if ( el === 'parent' ) {
if ( el === "parent" ) {
el = this.dragEl.parent();
}
@ -556,11 +556,11 @@ if ( $.uiBackCompat !== false ) {
this._super();
if ( this.options.helper === 'original' ) {
if ( this.options.helper === "original" ) {
this.options.helper = false;
}
if ( this.options.helper === 'clone' ) {
if ( this.options.helper === "clone" ) {
this.options.helper = true;
}
@ -580,15 +580,15 @@ if ( $.uiBackCompat !== false ) {
_setOption: function( key, value ) {
if ( key !== 'helper' ) {
if ( key !== "helper" ) {
return this._super( key, value );
}
if ( value === 'clone' ) {
if ( value === "clone" ) {
value = true;
}
if ( value === 'original' ) {
if ( value === "original" ) {
value = false;
}
@ -645,7 +645,7 @@ if ( $.uiBackCompat !== false ) {
_setOption: function( key, value ) {
if ( key !== 'cancel' ) {
if ( key !== "cancel" ) {
return this._super( key, value );
}
@ -831,10 +831,10 @@ if ( $.uiBackCompat !== false ) {
}
// Cache the original opacity of draggable element to reset later
originalOpacity = self.dragEl.css( 'opacity' );
originalOpacity = self.dragEl.css( "opacity" );
// Set draggable element to new opacity
self.dragEl.css( 'opacity', self.options.opacity );
self.dragEl.css( "opacity", self.options.opacity );
});
@ -846,7 +846,7 @@ if ( $.uiBackCompat !== false ) {
}
// Reset opacity
self.dragEl.css( 'opacity', originalOpacity );
self.dragEl.css( "opacity", originalOpacity );
});
@ -877,9 +877,9 @@ if ( $.uiBackCompat !== false ) {
}
// Cache the original css of draggable element to reset later
originalLeft = self.dragEl.css( 'left' );
originalTop = self.dragEl.css( 'top' );
originalPosition = self.dragEl.css( 'position' );
originalLeft = self.dragEl.css( "left" );
originalTop = self.dragEl.css( "top" );
originalPosition = self.dragEl.css( "position" );
});
@ -924,10 +924,10 @@ if ( $.uiBackCompat !== false ) {
}
// Cache the original zIndex of draggable element to reset later
originalZIndex = self.dragEl.css( 'z-index' );
originalZIndex = self.dragEl.css( "z-index" );
// Set draggable element to new zIndex
self.dragEl.css( 'z-index', self.options.zIndex );
self.dragEl.css( "z-index", self.options.zIndex );
});
@ -939,7 +939,7 @@ if ( $.uiBackCompat !== false ) {
}
// Reset zIndex
self.dragEl.css( 'z-index', originalZIndex );
self.dragEl.css( "z-index", originalZIndex );
});
@ -1055,7 +1055,7 @@ if ( $.uiBackCompat !== false ) {
$.widget( "ui.draggable", $.ui.draggable, {
options: {
snap: false,
snapMode: 'both',
snapMode: "both",
snapTolerance: 20
},
@ -1066,7 +1066,7 @@ if ( $.uiBackCompat !== false ) {
this._super();
this.element.on( 'dragstart', function() {
this.element.on( "dragstart", function() {
// Nothing to do
if ( !inst.options.snap ) {
@ -1077,7 +1077,7 @@ if ( $.uiBackCompat !== false ) {
snapElements = [];
// Select either all draggable elements, or the selector that was passed in
$( inst.options.snap === true ? ':data(ui-draggable)' : inst.options.snap ).each(function() {
$( inst.options.snap === true ? ":data(ui-draggable)" : inst.options.snap ).each(function() {
var el = $(this),
offset = el.offset();
@ -1107,7 +1107,7 @@ if ( $.uiBackCompat !== false ) {
});
this.element.on( 'drag', function( event, ui ) {
this.element.on( "drag", function( event, ui ) {
// Nothing to do
if ( !inst.options.snap ) {
@ -1136,7 +1136,7 @@ if ( $.uiBackCompat !== false ) {
continue;
}
if(o.snapMode !== 'inner') {
if(o.snapMode !== "inner") {
ts = Math.abs(t - y2) <= d;
bs = Math.abs(b - y1) <= d;
ls = Math.abs(l - x2) <= d;
@ -1157,7 +1157,7 @@ if ( $.uiBackCompat !== false ) {
first = (ts || bs || ls || rs);
if(o.snapMode !== 'outer') {
if(o.snapMode !== "outer") {
ts = Math.abs(t - y1) <= d;
bs = Math.abs(b - y2) <= d;
ls = Math.abs(l - x1) <= d;
@ -1195,7 +1195,7 @@ if ( $.uiBackCompat !== false ) {
var mod = d === "absolute" ? 1 : -1,
offset = {},
scroll = this.cssPosition === 'absolute' && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
$.extend(offset, {
parent: this._getParentOffset(),
@ -1207,13 +1207,13 @@ if ( $.uiBackCompat !== false ) {
pos.top + // The absolute mouse position
offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
( ( this.cssPosition === 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
),
left: (
pos.left + // The absolute mouse position
offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
( ( this.cssPosition === 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
)
};
@ -1229,7 +1229,7 @@ if ( $.uiBackCompat !== false ) {
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
if(this.cssPosition === 'absolute' && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
@ -1237,7 +1237,7 @@ if ( $.uiBackCompat !== false ) {
//This needs to be actually done for all browsers, since pageX/pageY includes this information
//Ugly IE fix
if((this.offsetParent[0] === document.body) ||
(this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === 'html' && $.ui.ie)) {
(this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
po = { top: 0, left: 0 };
}
@ -1278,7 +1278,7 @@ if ( $.uiBackCompat !== false ) {
this._super();
this.element.on( "dragstart", function() {
drops = $(':data(ui-sortable)');
drops = $(":data(ui-sortable)");
});
// On drag, make sure top does not change so axis is locked
@ -1289,7 +1289,7 @@ if ( $.uiBackCompat !== false ) {
}
drops.each( function() {
$(this).sortable('refreshPositions');
$(this).sortable("refreshPositions");
});

View File

@ -28,7 +28,7 @@ $.effects.effect.transfer = function( o, done ) {
width: target.innerWidth()
},
startPosition = elem.offset(),
transfer = $( '<div class="ui-effects-transfer"></div>' )
transfer = $( "<div class='ui-effects-transfer'></div>" )
.appendTo( document.body )
.addClass( o.className )
.css({

View File

@ -818,7 +818,7 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
$.each( arguments, function() {
var el = this.el;
$.each( this.diff, function(key) {
el.css( key, '' );
el.css( key, "" );
});
});

20
ui/jquery.ui.menu.js vendored
View File

@ -15,8 +15,6 @@
*/
(function( $, undefined ) {
var mouseHandled = false;
$.widget( "ui.menu", {
version: "@VERSION",
defaultElement: "<ul>",
@ -40,6 +38,9 @@ $.widget( "ui.menu", {
_create: function() {
this.activeMenu = this.element;
// flag used to prevent firing of the click handler
// as the event bubbles up through nested menus
this.mouseHandled = false;
this.element
.uniqueId()
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
@ -73,8 +74,8 @@ $.widget( "ui.menu", {
},
"click .ui-menu-item:has(a)": function( event ) {
var target = $( event.target ).closest( ".ui-menu-item" );
if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) {
mouseHandled = true;
if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
this.mouseHandled = true;
this.select( event );
// Open submenu on click
@ -130,7 +131,7 @@ $.widget( "ui.menu", {
}
// Reset the mouseHandled flag
mouseHandled = false;
this.mouseHandled = false;
}
});
},
@ -343,6 +344,15 @@ $.widget( "ui.menu", {
}[ this.options.role ];
},
_setOption: function( key, value ) {
if ( key === "icons" ) {
this.element.find( ".ui-menu-icon" )
.removeClass( this.options.icons.submenu )
.addClass( value.submenu );
}
this._super( key, value );
},
focus: function( event, item ) {
var nested, focused;
this.blur( event, event && event.type === "focus" );

30
ui/jquery.ui.mouse.js vendored
View File

@ -21,7 +21,7 @@ $( document ).mouseup( function() {
$.widget("ui.mouse", {
version: "@VERSION",
options: {
cancel: 'input,textarea,button,select,option',
cancel: "input,textarea,button,select,option",
distance: 1,
delay: 0
},
@ -29,12 +29,12 @@ $.widget("ui.mouse", {
var that = this;
this.element
.bind('mousedown.'+this.widgetName, function(event) {
.bind("mousedown."+this.widgetName, function(event) {
return that._mouseDown(event);
})
.bind('click.'+this.widgetName, function(event) {
if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
$.removeData(event.target, that.widgetName + '.preventClickEvent');
.bind("click."+this.widgetName, function(event) {
if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
$.removeData(event.target, that.widgetName + ".preventClickEvent");
event.stopImmediatePropagation();
return false;
}
@ -46,11 +46,11 @@ $.widget("ui.mouse", {
// TODO: make sure destroying one instance of mouse doesn't mess with
// other instances of mouse
_mouseDestroy: function() {
this.element.unbind('.'+this.widgetName);
this.element.unbind("."+this.widgetName);
if ( this._mouseMoveDelegate ) {
$(document)
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
.unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
.unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
}
},
@ -88,8 +88,8 @@ $.widget("ui.mouse", {
}
// Click event may never have fired (Gecko & Opera)
if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
$.removeData(event.target, this.widgetName + '.preventClickEvent');
if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
$.removeData(event.target, this.widgetName + ".preventClickEvent");
}
// these delegates are required to keep context
@ -100,8 +100,8 @@ $.widget("ui.mouse", {
return that._mouseUp(event);
};
$(document)
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
.bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
.bind("mouseup."+this.widgetName, this._mouseUpDelegate);
event.preventDefault();
@ -131,14 +131,14 @@ $.widget("ui.mouse", {
_mouseUp: function(event) {
$(document)
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
.unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
.unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
if (this._mouseStarted) {
this._mouseStarted = false;
if (event.target === this._mouseDownEvent.target) {
$.data(event.target, this.widgetName + '.preventClickEvent', true);
$.data(event.target, this.widgetName + ".preventClickEvent", true);
}
this._mouseStop(event);

View File

@ -57,7 +57,7 @@ $.widget("ui.resizable", $.ui.mouse, {
aspectRatio: o.aspectRatio,
originalElement: this.element,
_proportionallyResizeElements: [],
_helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
_helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
});
//Wrap the element if it cannot hold child nodes
@ -65,18 +65,18 @@ $.widget("ui.resizable", $.ui.mouse, {
//Create a wrapper element and set the wrapper to the new current internal element
this.element.wrap(
$('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
position: this.element.css('position'),
$("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
position: this.element.css("position"),
width: this.element.outerWidth(),
height: this.element.outerHeight(),
top: this.element.css('top'),
left: this.element.css('left')
top: this.element.css("top"),
left: this.element.css("left")
})
);
//Overwrite the original this.element
this.element = this.element.parent().data(
"ui-resizable", this.element.data('ui-resizable')
"ui-resizable", this.element.data("ui-resizable")
);
this.elementIsWrapper = true;
@ -86,25 +86,25 @@ $.widget("ui.resizable", $.ui.mouse, {
this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
//Prevent Safari textarea resize
this.originalResizeStyle = this.originalElement.css('resize');
this.originalElement.css('resize', 'none');
this.originalResizeStyle = this.originalElement.css("resize");
this.originalElement.css("resize", "none");
//Push the actual element to our proportionallyResize internal array
this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
// avoid IE jump (hard set the margin)
this.originalElement.css({ margin: this.originalElement.css('margin') });
this.originalElement.css({ margin: this.originalElement.css("margin") });
// fix handlers offset
this._proportionallyResize();
}
this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' });
this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" });
if(this.handles.constructor === String) {
if ( this.handles === 'all') {
this.handles = 'n,e,s,w,se,sw,ne,nw';
if ( this.handles === "all") {
this.handles = "n,e,s,w,se,sw,ne,nw";
}
n = this.handles.split(",");
@ -113,19 +113,19 @@ $.widget("ui.resizable", $.ui.mouse, {
for(i = 0; i < n.length; i++) {
handle = $.trim(n[i]);
hname = 'ui-resizable-'+handle;
axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
hname = "ui-resizable-"+handle;
axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
// Apply zIndex to all handles - see #7960
axis.css({ zIndex: o.zIndex });
//TODO : What's going on here?
if ('se' === handle) {
axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
if ("se" === handle) {
axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
}
//Insert into internal handles object and append to element
this.handles[handle] = '.ui-resizable-'+handle;
this.handles[handle] = ".ui-resizable-"+handle;
this.element.append(axis);
}
@ -152,10 +152,10 @@ $.widget("ui.resizable", $.ui.mouse, {
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
//The padding type i have to apply...
padPos = [ 'padding',
/ne|nw|n/.test(i) ? 'Top' :
/se|sw|s/.test(i) ? 'Bottom' :
/^e$/.test(i) ? 'Right' : 'Left' ].join("");
padPos = [ "padding",
/ne|nw|n/.test(i) ? "Top" :
/se|sw|s/.test(i) ? "Bottom" :
/^e$/.test(i) ? "Right" : "Left" ].join("");
target.css(padPos, padWrapper);
@ -173,7 +173,7 @@ $.widget("ui.resizable", $.ui.mouse, {
//TODO: make renderAxis a prototype function
this._renderAxis(this.element);
this._handles = $('.ui-resizable-handle', this.element)
this._handles = $(".ui-resizable-handle", this.element)
.disableSelection();
//Matching axis name
@ -183,7 +183,7 @@ $.widget("ui.resizable", $.ui.mouse, {
axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
}
//Axis, default = se
that.axis = axis && axis[1] ? axis[1] : 'se';
that.axis = axis && axis[1] ? axis[1] : "se";
}
});
@ -222,7 +222,7 @@ $.widget("ui.resizable", $.ui.mouse, {
var wrapper,
_destroy = function(exp) {
$(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
.removeData("resizable").removeData("ui-resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
.removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
};
//TODO: Unwrap at same DOM position
@ -230,16 +230,16 @@ $.widget("ui.resizable", $.ui.mouse, {
_destroy(this.element);
wrapper = this.element;
this.originalElement.css({
position: wrapper.css('position'),
position: wrapper.css("position"),
width: wrapper.outerWidth(),
height: wrapper.outerHeight(),
top: wrapper.css('top'),
left: wrapper.css('left')
top: wrapper.css("top"),
left: wrapper.css("left")
}).insertAfter( wrapper );
wrapper.remove();
}
this.originalElement.css('resize', this.originalResizeStyle);
this.originalElement.css("resize", this.originalResizeStyle);
_destroy(this.originalElement);
return this;
@ -269,16 +269,16 @@ $.widget("ui.resizable", $.ui.mouse, {
this.resizing = true;
// bugfix for http://dev.jquery.com/ticket/1749
if ( (/absolute/).test( el.css('position') ) ) {
el.css({ position: 'absolute', top: el.css('top'), left: el.css('left') });
} else if (el.is('.ui-draggable')) {
el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
if ( (/absolute/).test( el.css("position") ) ) {
el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
} else if (el.is(".ui-draggable")) {
el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
}
this._renderProxy();
curleft = num(this.helper.css('left'));
curtop = num(this.helper.css('top'));
curleft = num(this.helper.css("left"));
curtop = num(this.helper.css("top"));
if (o.containment) {
curleft += $(o.containment).scrollLeft() || 0;
@ -295,10 +295,10 @@ $.widget("ui.resizable", $.ui.mouse, {
this.originalMousePosition = { left: event.pageX, top: event.pageY };
//Aspect Ratio
this.aspectRatio = (typeof o.aspectRatio === 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
cursor = $('.ui-resizable-' + this.axis).css('cursor');
$('body').css('cursor', cursor === 'auto' ? this.axis + '-resize' : cursor);
cursor = $(".ui-resizable-" + this.axis).css("cursor");
$("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
el.addClass("ui-resizable-resizing");
this._propagate("start", event);
@ -360,7 +360,7 @@ $.widget("ui.resizable", $.ui.mouse, {
// Call the user callback if the element was resized
if ( ! $.isEmptyObject(props) ) {
this._trigger('resize', event, this.ui());
this._trigger("resize", event, this.ui());
}
return false;
@ -376,12 +376,12 @@ $.widget("ui.resizable", $.ui.mouse, {
pr = this._proportionallyResizeElements;
ista = pr.length && (/textarea/i).test(pr[0].nodeName);
soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height;
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
soffsetw = ista ? 0 : that.sizeDiff.width;
s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null;
top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
if (!o.animate) {
this.element.css($.extend(s, { top: top, left: left }));
@ -395,7 +395,7 @@ $.widget("ui.resizable", $.ui.mouse, {
}
}
$('body').css('cursor', 'auto');
$("body").css("cursor", "auto");
this.element.removeClass("ui-resizable-resizing");
@ -472,11 +472,11 @@ $.widget("ui.resizable", $.ui.mouse, {
data.height = (data.width / this.aspectRatio);
}
if (a === 'sw') {
if (a === "sw") {
data.left = cpos.left + (csize.width - data.width);
data.top = null;
}
if (a === 'nw') {
if (a === "nw") {
data.top = cpos.top + (csize.height - data.height);
data.left = cpos.left + (csize.width - data.width);
}
@ -544,8 +544,8 @@ $.widget("ui.resizable", $.ui.mouse, {
if (!this.borderDif) {
this.borderDif = [];
borders = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')];
paddings = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
for ( j = 0; j < borders.length; j++ ) {
this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
@ -568,14 +568,14 @@ $.widget("ui.resizable", $.ui.mouse, {
if(this._helper) {
this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
this.helper.addClass(this._helper).css({
width: this.element.outerWidth() - 1,
height: this.element.outerHeight() - 1,
position: 'absolute',
left: this.elementOffset.left +'px',
top: this.elementOffset.top +'px',
position: "absolute",
left: this.elementOffset.left +"px",
top: this.elementOffset.top +"px",
zIndex: ++o.zIndex //TODO: Don't modify option
});
@ -650,11 +650,11 @@ $.ui.plugin.add("resizable", "animate", {
o = that.options,
pr = that._proportionallyResizeElements,
ista = pr.length && (/textarea/i).test(pr[0].nodeName),
soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
soffsetw = ista ? 0 : that.sizeDiff.width,
style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
that.element.animate(
$.extend(style, top && left ? { top: top, left: left } : {}), {
@ -663,10 +663,10 @@ $.ui.plugin.add("resizable", "animate", {
step: function() {
var data = {
width: parseInt(that.element.css('width'), 10),
height: parseInt(that.element.css('height'), 10),
top: parseInt(that.element.css('top'), 10),
left: parseInt(that.element.css('left'), 10)
width: parseInt(that.element.css("width"), 10),
height: parseInt(that.element.css("height"), 10),
top: parseInt(that.element.css("top"), 10),
left: parseInt(that.element.css("left"), 10)
};
if (pr && pr.length) {
@ -740,7 +740,7 @@ $.ui.plugin.add("resizable", "containment", {
pRatio = that._aspectRatio || event.shiftKey,
cop = { top:0, left:0 }, ce = that.containerElement;
if (ce[0] !== document && (/static/).test(ce.css('position'))) {
if (ce[0] !== document && (/static/).test(ce.css("position"))) {
cop = co;
}
@ -767,7 +767,7 @@ $.ui.plugin.add("resizable", "containment", {
hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
isParent = that.containerElement.get(0) === that.element.parent().get(0);
isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
if(isParent && isOffsetRelative) {
woset -= that.parentData.left;
@ -799,11 +799,11 @@ $.ui.plugin.add("resizable", "containment", {
w = helper.outerWidth() - that.sizeDiff.width,
h = helper.outerHeight() - that.sizeDiff.height;
if (that._helper && !o.animate && (/relative/).test(ce.css('position'))) {
if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
}
if (that._helper && !o.animate && (/static/).test(ce.css('position'))) {
if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
}
@ -820,12 +820,12 @@ $.ui.plugin.add("resizable", "alsoResize", {
var el = $(this);
el.data("ui-resizable-alsoresize", {
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
});
});
};
if (typeof(o.alsoResize) === 'object' && !o.alsoResize.parentNode) {
if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
}else{
@ -846,7 +846,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
_alsoResize = function (exp, c) {
$(exp).each(function() {
var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
$.each(css, function (i, prop) {
var sum = (start[prop]||0) + (delta[prop]||0);
@ -859,7 +859,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
});
};
if (typeof(o.alsoResize) === 'object' && !o.alsoResize.nodeType) {
if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
$.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
}else{
_alsoResize(o.alsoResize);
@ -879,9 +879,9 @@ $.ui.plugin.add("resizable", "ghost", {
that.ghost = that.originalElement.clone();
that.ghost
.css({ opacity: 0.25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
.addClass('ui-resizable-ghost')
.addClass(typeof o.ghost === 'string' ? o.ghost : '');
.css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
.addClass("ui-resizable-ghost")
.addClass(typeof o.ghost === "string" ? o.ghost : "");
that.ghost.appendTo(that.helper);
@ -890,7 +890,7 @@ $.ui.plugin.add("resizable", "ghost", {
resize: function(){
var that = $(this).data("ui-resizable");
if (that.ghost) {
that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
}
},

View File

@ -18,11 +18,11 @@
$.widget("ui.selectable", $.ui.mouse, {
version: "@VERSION",
options: {
appendTo: 'body',
appendTo: "body",
autoRefresh: true,
distance: 0,
filter: '*',
tolerance: 'touch'
filter: "*",
tolerance: "touch"
},
_create: function() {
var selectees,
@ -47,9 +47,9 @@ $.widget("ui.selectable", $.ui.mouse, {
right: pos.left + $this.outerWidth(),
bottom: pos.top + $this.outerHeight(),
startselected: false,
selected: $this.hasClass('ui-selected'),
selecting: $this.hasClass('ui-selecting'),
unselecting: $this.hasClass('ui-unselecting')
selected: $this.hasClass("ui-selected"),
selecting: $this.hasClass("ui-selecting"),
unselecting: $this.hasClass("ui-unselecting")
});
});
};
@ -88,8 +88,8 @@ $.widget("ui.selectable", $.ui.mouse, {
$(options.appendTo).append(this.helper);
// position helper (lasso)
this.helper.css({
"left": event.clientX,
"top": event.clientY,
"left": event.pageX,
"top": event.pageY,
"width": 0,
"height": 0
});
@ -98,13 +98,13 @@ $.widget("ui.selectable", $.ui.mouse, {
this.refresh();
}
this.selectees.filter('.ui-selected').each(function() {
this.selectees.filter(".ui-selected").each(function() {
var selectee = $.data(this, "selectable-item");
selectee.startselected = true;
if (!event.metaKey && !event.ctrlKey) {
selectee.$element.removeClass('ui-selected');
selectee.$element.removeClass("ui-selected");
selectee.selected = false;
selectee.$element.addClass('ui-unselecting');
selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
// selectable UNSELECTING callback
that._trigger("unselecting", event, {
@ -117,7 +117,7 @@ $.widget("ui.selectable", $.ui.mouse, {
var doSelect,
selectee = $.data(this, "selectable-item");
if (selectee) {
doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
selectee.$element
.removeClass(doSelect ? "ui-unselecting" : "ui-selected")
.addClass(doSelect ? "ui-selecting" : "ui-unselecting");
@ -169,24 +169,24 @@ $.widget("ui.selectable", $.ui.mouse, {
return;
}
if (options.tolerance === 'touch') {
if (options.tolerance === "touch") {
hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
} else if (options.tolerance === 'fit') {
} else if (options.tolerance === "fit") {
hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
}
if (hit) {
// SELECT
if (selectee.selected) {
selectee.$element.removeClass('ui-selected');
selectee.$element.removeClass("ui-selected");
selectee.selected = false;
}
if (selectee.unselecting) {
selectee.$element.removeClass('ui-unselecting');
selectee.$element.removeClass("ui-unselecting");
selectee.unselecting = false;
}
if (!selectee.selecting) {
selectee.$element.addClass('ui-selecting');
selectee.$element.addClass("ui-selecting");
selectee.selecting = true;
// selectable SELECTING callback
that._trigger("selecting", event, {
@ -197,15 +197,15 @@ $.widget("ui.selectable", $.ui.mouse, {
// UNSELECT
if (selectee.selecting) {
if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
selectee.$element.removeClass('ui-selecting');
selectee.$element.removeClass("ui-selecting");
selectee.selecting = false;
selectee.$element.addClass('ui-selected');
selectee.$element.addClass("ui-selected");
selectee.selected = true;
} else {
selectee.$element.removeClass('ui-selecting');
selectee.$element.removeClass("ui-selecting");
selectee.selecting = false;
if (selectee.startselected) {
selectee.$element.addClass('ui-unselecting');
selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
}
// selectable UNSELECTING callback
@ -216,10 +216,10 @@ $.widget("ui.selectable", $.ui.mouse, {
}
if (selectee.selected) {
if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
selectee.$element.removeClass('ui-selected');
selectee.$element.removeClass("ui-selected");
selectee.selected = false;
selectee.$element.addClass('ui-unselecting');
selectee.$element.addClass("ui-unselecting");
selectee.unselecting = true;
// selectable UNSELECTING callback
that._trigger("unselecting", event, {
@ -238,18 +238,18 @@ $.widget("ui.selectable", $.ui.mouse, {
this.dragged = false;
$('.ui-unselecting', this.element[0]).each(function() {
$(".ui-unselecting", this.element[0]).each(function() {
var selectee = $.data(this, "selectable-item");
selectee.$element.removeClass('ui-unselecting');
selectee.$element.removeClass("ui-unselecting");
selectee.unselecting = false;
selectee.startselected = false;
that._trigger("unselected", event, {
unselected: selectee.element
});
});
$('.ui-selecting', this.element[0]).each(function() {
$(".ui-selecting", this.element[0]).each(function() {
var selectee = $.data(this, "selectable-item");
selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
selectee.selecting = false;
selectee.selected = true;
selectee.startselected = true;

View File

@ -28,7 +28,7 @@ function copy( obj ) {
$.widget( "ui.sortable", $.ui.interaction, {
version: "@VERSION",
widgetEventPrefix: "sort",
items: 'li', // TODO: move to options when API is ready
items: "li", // TODO: move to options when API is ready
// dragEl: element being dragged (original or helper)
// position: final CSS position of dragEl
@ -100,14 +100,14 @@ $.widget( "ui.sortable", $.ui.interaction, {
// Create placeholder for while element is dragging
// TODO: what do we do about IDs?
// TODO: possibly use CSS for visibility portion
this.placeholder = this.dragEl.clone().removeAttr('id').css({
visibility : 'hidden',
position : this.originalCssPosition || ''
this.placeholder = this.dragEl.clone().removeAttr("id").css({
visibility : "hidden",
position : this.originalCssPosition || ""
});
this.dragEl.after( this.placeholder );
this.dragEl.css( 'position', 'absolute' );
this.dragEl.css( "position", "absolute" );
// // _createHelper() ensures that helpers are in the correct position
// // in the DOM, but we need to handle appendTo when there is no helper
@ -247,16 +247,16 @@ $.widget( "ui.sortable", $.ui.interaction, {
// If there were inline styles before drag, set them back
if ( this.originalCssPosition ) {
this.dragEl.css( 'position', this.originalCssPosition );
this.dragEl.css( "position", this.originalCssPosition );
}
// If there were no inline styles, let CSS take over again by removing inline absolute
else {
this.dragEl.css( 'position', '' );
this.dragEl.css( "position", "" );
}
// TODO: should same thing be done here as is done for position or is there better way altogether
this.dragEl.css( 'left', '' );
this.dragEl.css( 'top', '' );
this.dragEl.css( "left", "" );
this.dragEl.css( "top", "" );
this.placeholder.remove();

View File

@ -368,6 +368,14 @@ $.widget( "ui.spinner", {
value = this._parse( value );
}
}
if ( key === "icons" ) {
this.buttons.first().find( ".ui-icon" )
.removeClass( this.options.icons.up )
.addClass( value.up );
this.buttons.last().find( ".ui-icon" )
.removeClass( this.options.icons.down )
.addClass( value.down );
}
this._super( key, value );
@ -445,14 +453,20 @@ $.widget( "ui.spinner", {
this._stepUp( steps );
}),
_stepUp: function( steps ) {
this._spin( (steps || 1) * this.options.step );
if ( this._start() ) {
this._spin( (steps || 1) * this.options.step );
this._stop();
}
},
stepDown: modifier(function( steps ) {
this._stepDown( steps );
}),
_stepDown: function( steps ) {
this._spin( (steps || 1) * -this.options.step );
if ( this._start() ) {
this._spin( (steps || 1) * -this.options.step );
this._stop();
}
},
pageUp: modifier(function( pages ) {