Tests: Convert single quotes to double quotes.

This commit is contained in:
Mike Sherov 2012-12-26 08:08:48 -05:00
parent 74d7eac2da
commit 0d4022bceb
35 changed files with 2078 additions and 2077 deletions

View File

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

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");
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

@ -23,10 +23,10 @@ test("{ addClasses: false }", function() {
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);
});
@ -90,7 +90,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);
@ -110,7 +110,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);
});
@ -123,7 +123,7 @@ test("{ cancel: ? }, unexpected", function() {
"[]": [],
"null": null,
"undefined": undefined,
"function() {return '';}": function() {return '';},
"function() {return '';}": function() {return "";},
"function() {return true;}": function() {return true;},
"function() {return false;}": function() {return false;}
};
@ -141,13 +141,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");
});
*/
@ -155,12 +155,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", {
@ -168,19 +168,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", {
@ -188,32 +188,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");
});
*/
@ -274,7 +274,7 @@ test("{ cursor: 'move' }", function() {
test("{ cursorAt: false}, default", function() {
expect( 1 );
ok(false, 'missing test - untested code is broken code');
ok(false, "missing test - untested code is broken code");
});
*/
@ -318,11 +318,11 @@ test("{ distance: 10 }", function() {
expect( 3 );
var el = $("#draggable2").draggable({ distance: 10 });
TestHelpers.draggable.testDrag(el, el, -9, -9, 0, 0, 'distance not met');
TestHelpers.draggable.testDrag(el, el, -9, -9, 0, 0, "distance not met");
TestHelpers.draggable.testDrag(el, el, -10, -10, -10, -10, 'distance met');
TestHelpers.draggable.testDrag(el, el, -10, -10, -10, -10, "distance met");
TestHelpers.draggable.testDrag(el, el, 9, 9, 0, 0, 'distance not met');
TestHelpers.draggable.testDrag(el, el, 9, 9, 0, 0, "distance not met");
});
@ -345,7 +345,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");
@ -371,13 +371,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();
@ -388,16 +388,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");
});
@ -408,19 +408,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");
});
@ -428,16 +428,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();
@ -447,18 +447,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");
});
@ -466,22 +466,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");
});
@ -489,16 +489,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();
@ -508,40 +508,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");
});
@ -559,7 +559,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] ");
});
@ -574,29 +574,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();
@ -606,38 +606,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");
});
@ -645,7 +645,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,
@ -654,31 +654,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

@ -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

@ -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

@ -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);