@@ -8,33 +8,33 @@ module( "button: options" );
test( "disabled, explicit value", function( assert ) {
expect( 7 );

var element = $( "#radio01" ).button({ disabled: false });
var element = $( "#radio01" ).button( { disabled: false } );
deepEqual( element.button( "option", "disabled" ), false, "disabled option set to false" );
deepEqual( element.prop( "disabled" ), false, "element is disabled" );

assert.lacksClasses( element.button( "widget" ), "ui-state-disabled ui-button-disabled" );

element = $( "#radio02" ).button({ disabled: true });
element = $( "#radio02" ).button( { disabled: true } );

ok( !element.button( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
assert.hasClasses( element.button( "widget" ), "ui-button-disabled ui-state-disabled" );

deepEqual( element.button( "option", "disabled" ), true, "disabled option set to true" );
deepEqual( element.prop( "disabled" ), true, "element is not disabled" );
});
} );

test("disabled, null", function() {
test( "disabled, null", function() {
expect( 4 );
$("#radio01").button({ disabled: null });
deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
deepEqual(false, $("#radio01").prop("disabled"), "element is disabled");

$("#radio02").prop("disabled", true).button({ disabled: null });
deepEqual(true, $("#radio02").button("option", "disabled"),
"disabled option set to true");
deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled");
});
$( "#radio01" ).button( { disabled: null } );
deepEqual( false, $( "#radio01" ).button( "option", "disabled" ),
"disabled option set to false" );
deepEqual( false, $( "#radio01" ).prop( "disabled" ), "element is disabled" );

$( "#radio02" ).prop( "disabled", true ).button( { disabled: null } );
deepEqual( true, $( "#radio02" ).button( "option", "disabled" ),
"disabled option set to true" );
deepEqual( true, $( "#radio02" ).prop( "disabled" ), "element is not disabled" );
} );

test( "disabled, ui-state-active is removed unless checkbox or radio", function( assert ) {
expect( 12 );
@@ -68,90 +68,90 @@ test( "disabled, ui-state-active is removed unless checkbox or radio", function(
assert.lacksClasses( buttonElement, "ui-state-active",
"Disabled [" + elementType + "] does not have ui-state-active class." );
}
});
});
} );
} );

test("text false without icon", function() {
test( "text false without icon", function() {
expect( 1 );
$("#button").button({
$( "#button" ).button( {
text: false
});
ok( $("#button").is(".ui-button-text-only:not(.ui-button-icon-only)") );
} );
ok( $( "#button" ).is( ".ui-button-text-only:not(.ui-button-icon-only)" ) );

$("#button").button("destroy");
});
$( "#button" ).button( "destroy" );
} );

test("text false with icon", function() {
test( "text false with icon", function() {
expect( 1 );
$("#button").button({
$( "#button" ).button( {
text: false,
icons: {
primary: "iconclass"
}
});
ok( $("#button").is(".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)") );
} );
ok( $( "#button" ).is( ".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)" ) );

$("#button").button("destroy");
});
$( "#button" ).button( "destroy" );
} );

test("label, default", function() {
test( "label, default", function() {
expect( 2 );
$("#button").button();
deepEqual( $("#button").text(), "Label" );
deepEqual( $( "#button").button( "option", "label" ), "Label" );
$( "#button" ).button();
deepEqual( $( "#button" ).text(), "Label" );
deepEqual( $( "#button" ).button( "option", "label" ), "Label" );

$("#button").button("destroy");
});
$( "#button" ).button( "destroy" );
} );

test("label", function() {
test( "label", function() {
expect( 2 );
$("#button").button({
$( "#button" ).button( {
label: "xxx"
});
deepEqual( $("#button").text(), "xxx" );
deepEqual( $("#button").button( "option", "label" ), "xxx" );
} );
deepEqual( $( "#button" ).text(), "xxx" );
deepEqual( $( "#button" ).button( "option", "label" ), "xxx" );

$("#button").button("destroy");
});
$( "#button" ).button( "destroy" );
} );

test("label default with input type submit", function() {
test( "label default with input type submit", function() {
expect( 2 );
deepEqual( $("#submit").button().val(), "Label" );
deepEqual( $("#submit").button( "option", "label" ), "Label" );
});
deepEqual( $( "#submit" ).button().val(), "Label" );
deepEqual( $( "#submit" ).button( "option", "label" ), "Label" );
} );

test("label with input type submit", function() {
test( "label with input type submit", function() {
expect( 2 );
var label = $("#submit").button({
var label = $( "#submit" ).button( {
label: "xxx"
}).val();
} ).val();
deepEqual( label, "xxx" );
deepEqual( $("#submit").button( "option", "label" ), "xxx" );
});
deepEqual( $( "#submit" ).button( "option", "label" ), "xxx" );
} );

test("icons", function() {
test( "icons", function() {
expect( 1 );
$("#button").button({
$( "#button" ).button( {
text: false,
icons: {
primary: "iconclass",
secondary: "iconclass2"
}
});
ok( $("#button").is(":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)") );
} );
ok( $( "#button" ).is( ":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)" ) );

$("#button").button("destroy");
});
$( "#button" ).button( "destroy" );
} );

test( "#5295 - button does not remove hoverstate if disabled" , function( assert ) {
test( "#5295 - button does not remove hoverstate if disabled", function( assert ) {
expect( 1 );
var btn = $("#button").button();
var btn = $( "#button" ).button();
btn.on( "hover", function() {
btn.button( "disable" );
});
} );
btn.trigger( "mouseenter" );
btn.trigger( "mouseleave" );
assert.lacksClasses( btn, "ui-state-hover" );
});
} );

} );
@@ -6,7 +6,7 @@

<script src="../../../external/requirejs/require.js"></script>
<script src="../../lib/css.js" data-modules="core calendar"></script>
<script src="../../lib/bootstrap.js" data-widget="datepicker"></script>
<script src="../../lib/bootstrap.js" data-widget="calendar"></script>
</head>
<body>

@@ -28,6 +28,6 @@ common.testWidget( "calendar", {
create: null,
select: null
}
});
} );

} );
@@ -51,7 +51,7 @@ test( "base structure", function() {
element.calendar( "option", "buttons", {
"test": function() {},
"test button": function() {}
});
} );

equal( dp.children().length, 3, "Structure buttons - child count (header, calendar, buttonpane)" );

@@ -65,6 +65,7 @@ test( "base structure", function() {
}

function step3() {

// Multi-month 2
element = $( "#calendar" ).calendar( { numberOfMonths: 2 } );
dp = element.calendar( "widget" );
@@ -79,7 +80,7 @@ test( "base structure", function() {
}

step1();
});
} );

test( "Localization", function() {
expect( 10 );
@@ -130,20 +131,20 @@ test( "Localization", function() {
.calendar( "option", optionsDe )
.calendar( "refresh" );
testLocalization( "After init: " );
});
} );

asyncTest( "keyboard handling", function() {
expect( 10 );

var element = $( "#calendar" );

function step1() {
element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );

testHelper
.focusGrid( element )
.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -156,7 +157,7 @@ asyncTest( "keyboard handling", function() {
}

function step2() {
element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );

testHelper.focusGrid( element )
.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } )
@@ -171,10 +172,10 @@ asyncTest( "keyboard handling", function() {
}

function step3() {
element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );

testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -187,10 +188,10 @@ asyncTest( "keyboard handling", function() {
}

function step4() {
element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );

testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -203,10 +204,10 @@ asyncTest( "keyboard handling", function() {
}

function step5() {
element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );

testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -219,11 +220,11 @@ asyncTest( "keyboard handling", function() {
}

function step6() {
element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );

testHelper.focusGrid( element )
.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP, altKey: true } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -236,10 +237,10 @@ asyncTest( "keyboard handling", function() {
}

function step7() {
element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );

testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -252,11 +253,11 @@ asyncTest( "keyboard handling", function() {
}

function step8() {
element.calendar({ value: new Date( 2014, 1 - 1, 1 ) });
element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } );

testHelper.focusGrid( element )
.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN, altKey: true } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -270,10 +271,10 @@ asyncTest( "keyboard handling", function() {

// Check for moving to short months
function step9() {
element.calendar({ value: new Date( 2014, 3 - 1, 31 ) });
element.calendar( { value: new Date( 2014, 3 - 1, 31 ) } );

testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -286,10 +287,10 @@ asyncTest( "keyboard handling", function() {
}

function step10() {
element.calendar({ value: new Date( 2016, 1 - 1, 30 ) });
element.calendar( { value: new Date( 2016, 1 - 1, 30 ) } );

testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -302,7 +303,7 @@ asyncTest( "keyboard handling", function() {
}

step1();
});
} );

asyncTest( "mouse", function() {
expect( 6 );
@@ -319,7 +320,7 @@ asyncTest( "mouse", function() {
"Mouse click"
);

element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) );
element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) );
$( ".ui-calendar-calendar tbody button:contains(12)", element ).simulate( "mousedown" );
testHelper.equalsDate(
element.calendar( "valueAsDate" ),
@@ -328,7 +329,7 @@ asyncTest( "mouse", function() {
);

// Previous/next
element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) );
element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) );
$( ".ui-calendar-prev", element ).simulate( "click" );
$( ".ui-calendar-calendar tbody button:contains(16)", element ).simulate( "mousedown" );
testHelper.equalsDate(
@@ -337,7 +338,7 @@ asyncTest( "mouse", function() {
"Mouse click - previous"
);

element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) );
element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) );
$( ".ui-calendar-next", element ).simulate( "click" );
$( ".ui-calendar-calendar tbody button:contains(18)", element ).simulate( "mousedown" );
testHelper.equalsDate(
@@ -352,11 +353,11 @@ asyncTest( "mouse", function() {
// Previous/next with minimum/maximum
function step2() {
element.calendar( "destroy" );
element.calendar({
value: new Date( 2008, 3 - 1, 4),
element.calendar( {
value: new Date( 2008, 3 - 1, 4 ),
min: new Date( 2008, 2 - 1, 2 ),
max: new Date( 2008, 2 - 1, 26 )
});
} );

$( ".ui-calendar-prev", element ).simulate( "click" );
$( "tbody button:contains(16)", element ).simulate( "mousedown" );
@@ -370,11 +371,11 @@ asyncTest( "mouse", function() {

function step3() {
element.calendar( "destroy" );
element.calendar({
value: new Date( 2008, 1 - 1, 4),
element.calendar( {
value: new Date( 2008, 1 - 1, 4 ),
min: new Date( 2008, 2 - 1, 2 ),
max: new Date( 2008, 2 - 1, 26 )
});
} );

$( ".ui-calendar-next", element ).simulate( "click" );
$( "tbody button:contains(18)", element ).simulate( "mousedown" );
@@ -387,6 +388,6 @@ asyncTest( "mouse", function() {
}

step1();
});
} );

} );
@@ -11,8 +11,8 @@ test( "destroy", function( assert ) {

assert.domEqual( "#calendar", function() {
$( "#calendar" ).calendar().calendar( "destroy" );
});
});
} );
} );

test( "enable / disable", function() {
expect( 8 );
@@ -30,7 +30,7 @@ test( "enable / disable", function() {
ok( !element.hasClass( "ui-calendar-disabled" ), "no longer has disabled widget class name" );
ok( !element.hasClass( "ui-state-disabled" ), "no longer has disabled state class name" );
equal( element.attr( "aria-disabled" ), "false", "no longer has ARIA disabled" );
});
} );

test( "widget", function() {
expect( 1 );
@@ -39,7 +39,7 @@ test( "widget", function() {
widget = element.calendar( "widget" );

strictEqual( widget[ 0 ], element[ 0 ] );
});
} );

test( "value", function() {
expect( 3 );
@@ -54,7 +54,7 @@ test( "value", function() {

element.calendar( "value", "abc" );
equal( element.calendar( "value" ), "1/1/14", "Setting invalid values should be ignored." );
});
} );

test( "valueAsDate", function() {
expect( 11 );
@@ -77,7 +77,7 @@ test( "valueAsDate", function() {
equal( element.calendar( "valueAsDate" ), null, "Set date - default" );

element.calendar( "valueAsDate", date1 );
testHelper.equalsDate(element.calendar( "valueAsDate" ), date1, "Set date - 2008-06-04" );
testHelper.equalsDate( element.calendar( "valueAsDate" ), date1, "Set date - 2008-06-04" );

// With minimum/maximum
element = $( "#calendar" ).calendar();
@@ -140,6 +140,6 @@ test( "valueAsDate", function() {
dateAndTimeClone.getTime(),
"Date object passed should not be changed by valueAsDate"
);
});
} );

} );
@@ -6,13 +6,13 @@ define( [

module( "calendar: options" );

test("buttons", function() {
test( "buttons", function() {
expect( 21 );

var button, i, newButtons,
buttons = {
"Ok": function( event ) {
ok(true, "button click fires callback" );
ok( true, "button click fires callback" );
equal( this, element[ 0 ], "context of callback" );
equal( event.target, button[ 0 ], "event target" );
},
@@ -22,7 +22,7 @@ test("buttons", function() {
equal( event.target, button[ 1 ], "event target" );
}
},
element = $( "#calendar" ).calendar({ buttons: buttons });
element = $( "#calendar" ).calendar( { buttons: buttons } );

button = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" );
equal( button.length, 2, "number of buttons" );
@@ -31,7 +31,7 @@ test("buttons", function() {
$.each( buttons, function( key ) {
equal( button.eq( i ).text(), key, "text of button " + ( i + 1 ) );
i++;
});
} );

ok( button.parent().hasClass( "ui-calendar-buttonset" ), "buttons in container" );
ok(
@@ -69,7 +69,7 @@ test("buttons", function() {
$.each( newButtons, function( key ) {
equal( button.eq( i ).text(), key, "text of button " + ( i + 1 ) );
i += 1;
});
} );

element.calendar( "option", "buttons", null );
button = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" );
@@ -78,14 +78,14 @@ test("buttons", function() {
equal( element.hasClass( "ui-calendar-buttons" ), false, "calendar element removes class about having buttons" );

element.remove();
});
} );

test( "buttons - advanced", function() {
expect( 7 );

var buttons,
element = $( "#calendar" ).calendar({
buttons: [{
element = $( "#calendar" ).calendar( {
buttons: [ {
text: "a button",
"class": "additional-class",
id: "my-button-id",
@@ -96,8 +96,8 @@ test( "buttons - advanced", function() {
primary: "ui-icon-cancel"
},
showText: false
}]
});
} ]
} );

buttons = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" );
equal( buttons.length, 1, "correct number of buttons" );
@@ -109,7 +109,7 @@ test( "buttons - advanced", function() {
buttons.click();

element.remove();
});
} );

test( "dateFormat", function() {
expect( 2 );
@@ -122,7 +122,7 @@ test( "dateFormat", function() {

element.calendar( "option", "dateFormat", { date: "full" } );
equal( element.calendar( "value" ), "Wednesday, January 1, 2014", "updated formatting" );
});
} );

test( "eachDay", function() {
expect( 5 );
@@ -140,7 +140,7 @@ test( "eachDay", function() {
if ( day.date === 1 ) {
day.render = false;
}
});
} );
firstCell = picker.find( "td[id]:first" );
timestamp = parseInt( firstCell.find( "button" ).attr( "data-timestamp" ), 10 );
equal( new Date( timestamp ).getDate(), 2, "first available day is the 2nd" );
@@ -150,19 +150,19 @@ test( "eachDay", function() {
if ( day.date === 1 ) {
day.selectable = false;
}
});
} );
firstCell = picker.find( "td[id]:first" );
ok( firstCell.find( "button" ).prop( "disabled" ), "the 1st is not selectable" );

input.calendar( "option", "eachDay", function( day ) {
if ( day.date === 1 ) {
day.extraClasses = "ui-custom";
}
});
} );
ok( picker.find( "td[id]:first button" ).hasClass( "ui-custom" ), "extraClasses applied" );

input.calendar( "destroy" );
});
} );

test( "showWeek", function() {
expect( 7 );
@@ -174,7 +174,7 @@ test( "showWeek", function() {
"no week column cells present" );
input.calendar( "destroy" );

input = $( "#calendar" ).calendar({ showWeek: true });
input = $( "#calendar" ).calendar( { showWeek: true } );
container = input.calendar( "widget" );
equal( container.find( "thead th" ).length, 8, "7 days + a column cell" );
ok( container.find( "thead th:first" ).is( ".ui-calendar-week-col" ),
@@ -188,13 +188,16 @@ test( "showWeek", function() {
equal( container.find( "thead th" ).length, 7, "no week column" );
input.calendar( "option", "showWeek", true );
equal( container.find( "thead th" ).length, 8, "supports changing option after init" );
});
} );

test( "min / max", function() {
expect( 7 );
expect( 17 );

// With existing date
var element = $( "#calendar" ).calendar(),
container = element.calendar( "widget" ),
prevButton = container.find( ".ui-calendar-prev" ),
nextButton = container.find( ".ui-calendar-next" ),
minDate = new Date( 2008, 2 - 1, 29 ),
maxDate = new Date( 2008, 12 - 1, 7 );

@@ -232,7 +235,82 @@ test( "min / max", function() {
element
.calendar( "option", { min: minDate, max: maxDate } )
.calendar( "value", "1/4/09" );
testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value > max" );});
testHelper.equalsDate( element.calendar( "valueAsDate" ), new Date( 2008, 6 - 1, 4 ), "Min/max - value > max" );

element
.calendar( "option", { min: minDate, max: maxDate } )
.calendar( "value", "3/4/08" );
ok( !prevButton.hasClass( "ui-state-disabled" ), "Prev button enabled" );
prevButton.simulate( "click" );
ok( prevButton.hasClass( "ui-state-disabled" ), "Prev button disabled" );

element.calendar( "value", "11/4/08" );
ok( !nextButton.hasClass( "ui-state-disabled" ), "Next button enabled" );
nextButton.simulate( "click" );
ok( nextButton.hasClass( "ui-state-disabled" ), "Next button disabled" );

element
.calendar( "option", { max: null } )
.calendar( "value", "1/4/09" )
.calendar( "option", { min: minDate, max: maxDate } );
ok( nextButton.hasClass( "ui-state-disabled" ), "Other year above max: Next button disabled" );
prevButton.simulate( "click" );
ok( nextButton.hasClass( "ui-state-disabled" ), "Other year above max: Next button disabled after click" );
prevButton.simulate( "click" );
ok( !nextButton.hasClass( "ui-state-disabled" ), "Other year above max: Next button enabled after click" );

element
.calendar( "option", { min: null } )
.calendar( "value", "1/4/08" )
.calendar( "option", { min: minDate, max: maxDate } );
ok( prevButton.hasClass( "ui-state-disabled" ), "Other year below min: Prev button disabled" );
nextButton.simulate( "click" );
ok( prevButton.hasClass( "ui-state-disabled" ), "Other year below min: Prev button disabled after click" );
nextButton.simulate( "click" );
ok( !prevButton.hasClass( "ui-state-disabled" ), "Other year below min: Prev button enabled after click" );
} );

test( "numberOfMonths", function() {
expect( 6 );
var date = new Date( 2015, 8 - 1, 1 ),
input = $( "#calendar" ).calendar( {
numberOfMonths: 3,
value: date
} ),
container = input.calendar( "widget" );

equal( container.find( ".ui-calendar-group" ).length, 3, "3 calendar grids" );
equal(
container.find( "tbody:first td[id]:first" ).attr( "id" ),
"calendar-2015-7-1",
"Correct id set for first day of first grid"
);
equal(
container.find( "tbody:last td[id]:last" ).attr( "id" ),
"calendar-2015-9-31",
"Correct id set for last day of third grid"
);

// Test for jumping in weekday rendering after click on last day of last grid
container.find( "tbody:last td[id]:last button" ).trigger( "mousedown" );
equal( container.find( "thead:last th:last" ).text(), "Sa",
"After mousedown last month: Last day is Saturday"
);

// Test if using cursor to go to the next / prev month advances three month
// Focus doesn't work here so we use an additional mouse down event
container.find( "tbody:first td[id]:first button" ).trigger( "mousedown" );
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( container.find( ".ui-calendar-month:first" ).text(), "May",
"After move to previous month: First month is May"
);

container.find( "tbody:last td[id]:last button" ).trigger( "mousedown" );
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( container.find( ".ui-calendar-month:last" ).text(), "October",
"After move to next month: Last month is October"
);
} );

/*
// TODO: Move this to $.date, Globalize or calendar widget
@@ -80,6 +80,21 @@
<div id="visibilityHiddenAncestor" style="visibility: hidden;">
<input id="visibilityHiddenAncestor-input">
<span tabindex="1" id="visibilityHiddenAncestor-span">.</span>

<span id="nestedVisibilityOverrideAncestor" style="visibility: visible;">
<input id="nestedVisibilityOverrideAncestor-input">
<span tabindex="1" id="nestedVisibilityOverrideAncestor-span">.</span>
</span>

<span tabIndex="1" id="nestedVisibilityInheritWithHiddenAncestor"
style="visibility: inherit;">.</span>
<input id="nestedVisibilityInheritWithHiddenAncestor-input" style="visibility: inherit;">
</div>

<div id="visibilityVisibleAncestor" style="visibility: visible;">
<span tabIndex="1" id="nestedVisibilityInheritWithVisibleAncestor"
style="visibility: inherit;">.</span>
<input id="nestedVisibilityInheritWithVisibleAncestor-input" style="visibility: inherit;">
</div>

<span tabindex="1" id="displayNone-span" style="display: none;">.</span>
@@ -17,7 +17,7 @@ test( "innerWidth - getter", function() {
equal( el.innerWidth(), 122, "getter passthru" );
el.hide();
equal( el.innerWidth(), 122, "getter passthru when hidden" );
});
} );

test( "innerWidth - setter", function() {
expect( 2 );
@@ -28,7 +28,7 @@ test( "innerWidth - setter", function() {
el.hide();
el.innerWidth( 100 );
equal( el.width(), 78, "width set properly when hidden" );
});
} );

test( "innerHeight - getter", function() {
expect( 2 );
@@ -37,7 +37,7 @@ test( "innerHeight - getter", function() {
equal( el.innerHeight(), 70, "getter passthru" );
el.hide();
equal( el.innerHeight(), 70, "getter passthru when hidden" );
});
} );

test( "innerHeight - setter", function() {
expect( 2 );
@@ -48,7 +48,7 @@ test( "innerHeight - setter", function() {
el.hide();
el.innerHeight( 50 );
equal( el.height(), 30, "height set properly when hidden" );
});
} );

test( "outerWidth - getter", function() {
expect( 2 );
@@ -57,7 +57,7 @@ test( "outerWidth - getter", function() {
equal( el.outerWidth(), 140, "getter passthru" );
el.hide();
equal( el.outerWidth(), 140, "getter passthru when hidden" );
});
} );

test( "outerWidth - setter", function() {
expect( 2 );
@@ -68,16 +68,16 @@ test( "outerWidth - setter", function() {
el.hide();
el.outerWidth( 120 );
equal( el.width(), 80, "width set properly when hidden" );
});
} );

test( "outerWidth(true) - getter", function() {
expect( 2 );
var el = $( "#dimensions" );

equal( el.outerWidth(true), 154, "getter passthru w/ margin" );
equal( el.outerWidth( true ), 154, "getter passthru w/ margin" );
el.hide();
equal( el.outerWidth(true), 154, "getter passthru w/ margin when hidden" );
});
equal( el.outerWidth( true ), 154, "getter passthru w/ margin when hidden" );
} );

test( "outerWidth(true) - setter", function() {
expect( 2 );
@@ -88,7 +88,7 @@ test( "outerWidth(true) - setter", function() {
el.hide();
el.outerWidth( 120, true );
equal( el.width(), 66, "width set properly when hidden" );
});
} );

test( "outerHeight - getter", function() {
expect( 2 );
@@ -97,7 +97,7 @@ test( "outerHeight - getter", function() {
equal( el.outerHeight(), 86, "getter passthru" );
el.hide();
equal( el.outerHeight(), 86, "getter passthru when hidden" );
});
} );

test( "outerHeight - setter", function() {
expect( 2 );
@@ -108,16 +108,16 @@ test( "outerHeight - setter", function() {
el.hide();
el.outerHeight( 70 );
equal( el.height(), 34, "height set properly when hidden" );
});
} );

test( "outerHeight(true) - getter", function() {
expect( 2 );
var el = $( "#dimensions" );

equal( el.outerHeight(true), 98, "getter passthru w/ margin" );
equal( el.outerHeight( true ), 98, "getter passthru w/ margin" );
el.hide();
equal( el.outerHeight(true), 98, "getter passthru w/ margin when hidden" );
});
equal( el.outerHeight( true ), 98, "getter passthru w/ margin when hidden" );
} );

test( "outerHeight(true) - setter", function() {
expect( 2 );
@@ -128,7 +128,7 @@ test( "outerHeight(true) - setter", function() {
el.hide();
el.outerHeight( 80, true );
equal( el.height(), 32, "height set properly when hidden" );
});
} );

test( "uniqueId / removeUniqueId", function() {
expect( 3 );
@@ -138,7 +138,7 @@ test( "uniqueId / removeUniqueId", function() {
ok( /ui-id-\d+$/.test( el.attr( "id" ) ), "element has generated id" );
el.removeUniqueId();
equal( el.attr( "id" ), null, "unique id has been removed from element" );
});
} );

test( "Labels", function() {
expect( 2 );
@@ -14,7 +14,7 @@ function isFocusable( selector, msg ) {
}

function isNotFocusable( selector, msg ) {
QUnit.push( $( selector ).length && !$( selector ).is(":focusable"), null, null,
QUnit.push( $( selector ).length && !$( selector ).is( ":focusable" ), null, null,
msg + " - selector " + selector + " is not focusable" );
}

@@ -85,10 +85,10 @@ test( "data", function() {

element = $( "<div>" ).data( "test", function() {} );
shouldHaveData( "data set to function" );
});
} );

test( "focusable - visible, enabled elements", function() {
expect( 18 );
expect( 20 );

isNotFocusable( "#formNoTabindex", "form" );
isFocusable( "#formTabindex", "form with tabindex" );
@@ -108,7 +108,11 @@ test( "focusable - visible, enabled elements", function() {
isNotFocusable( "#visibleAncestor-div", "div" );
isFocusable( "#visibleAncestor-spanWithTabindex", "span with tabindex" );
isFocusable( "#visibleAncestor-divWithNegativeTabindex", "div with tabindex" );
});
isFocusable( "#nestedVisibilityInheritWithVisibleAncestor",
"span, visibility: inherit inside visibility: visible parent" );
isFocusable( "#nestedVisibilityInheritWithVisibleAncestor-input",
"input, visibility: inherit inside visibility: visible parent" );
} );

test( "focusable - disabled elements", function() {
expect( 9 );
@@ -122,23 +126,29 @@ test( "focusable - disabled elements", function() {
isNotFocusable( "#disabledElement-button", "button" );
isNotFocusable( "#disabledElement-select", "select" );
isNotFocusable( "#disabledElement-textarea", "textarea" );
});
} );

test( "focusable - hidden styles", function() {
expect( 8 );
expect( 12 );

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

isFocusable( "#nestedVisibilityOverrideAncestor-input", "input, visibility: visible parent but visibility: hidden grandparent" );
isFocusable( "#nestedVisibilityOverrideAncestor-span", "span with tabindex, visibility: visible parent but visibility: hidden grandparent " );

isNotFocusable( "#nestedVisibilityInheritWithHiddenAncestor", "span, visibility: inherit inside visibility: hidden parent" );
isNotFocusable( "#nestedVisibilityInheritWithHiddenAncestor-input", "input, visibility: inherit inside visibility: hidden parent" );

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

test( "focusable - natively focusable with various tabindex", function() {
expect( 4 );
@@ -147,7 +157,7 @@ test( "focusable - natively focusable with various tabindex", function() {
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 );
@@ -156,21 +166,21 @@ test( "focusable - not natively focusable with various tabindex", function() {
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" );
});
} );

test( "focusable - dimensionless parent with overflow", function() {
expect( 1 );

isFocusable( "#dimensionlessParent", "input" );
});
} );

test( "tabbable - visible, enabled elements", function() {
expect( 18 );
@@ -193,7 +203,7 @@ test( "tabbable - visible, enabled elements", function() {
isNotTabbable( "#visibleAncestor-div", "div" );
isTabbable( "#visibleAncestor-spanWithTabindex", "span with tabindex" );
isNotTabbable( "#visibleAncestor-divWithNegativeTabindex", "div with tabindex" );
});
} );

test( "tabbable - disabled elements", function() {
expect( 9 );
@@ -207,23 +217,26 @@ test( "tabbable - disabled elements", function() {
isNotTabbable( "#disabledElement-button", "button" );
isNotTabbable( "#disabledElement-select", "select" );
isNotTabbable( "#disabledElement-textarea", "textarea" );
});
} );

test( "tabbable - hidden styles", function() {
expect( 8 );
expect( 10 );

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

isTabbable( "#nestedVisibilityOverrideAncestor-input", "input, visibility: visible parent but visibility: hidden grandparent" );
isTabbable( "#nestedVisibilityOverrideAncestor-span", "span with tabindex, visibility: visible parent but visibility: hidden grandparent " );

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

test( "tabbable - natively tabbable with various tabindex", function() {
expect( 4 );
@@ -232,7 +245,7 @@ test( "tabbable - natively tabbable with various tabindex", function() {
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 );
@@ -241,21 +254,21 @@ test( "tabbable - not natively tabbable with various tabindex", function() {
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" );
});
} );

test( "tabbable - dimensionless parent with overflow", function() {
expect( 1 );

isTabbable( "#dimensionlessParent", "input" );
});
} );

test( "escapeSelector", function() {
expect( 1 );
@@ -1,29 +1,31 @@
define( [
"jquery",
"globalize",
"date"
], function( $, Globalize ) {
"./helper",
"ui/date"
], function( $, testHelper ) {

module( "date: core" );

var attributes = testHelper.getAttributes( "en" );

test( "Instantiation", function() {
expect( 2 );
ok( new $.date() instanceof $.date, "constructor function" );
ok( $.date() instanceof $.date, "instantiation without new" );
});

test( "Check Sets and Gets", 6, function() {
var date = $.date();
equal( date.setYear( 2012 ).year(), 2012, "Set year and retrieve" );
equal( date.setMonth( 9 ).month(), 9, "Set month and retrieve" );
ok( new $.ui.date( null, attributes ) instanceof $.ui.date, "constructor function" );
ok( $.ui.date( null, attributes ) instanceof $.ui.date, "instantiation without new" );
} );

test( "Check Sets and Gets", 4, function() {
var date = $.ui.date( null, attributes );
equal( date.setDay( 15 ).day(), 15, "Set day and retrieve" );
equal( date.setFullDate( 2012, 9, 15 ).year(), 2012, "Set full date and retrieve year" );
equal( date.month(), 9, "Set full date and retrieve month" );
equal( date.day(), 15, "Set full date and retrieve day" );
});

// TODO Add setTime test
} );

test( "Date Adjustments - Normal Use Cases", 10, function() {
var date = $.date();
var date = $.ui.date( null, attributes );

// Use October 15, 2012
date.setFullDate( 2012, 9, 15 );
@@ -45,30 +47,30 @@ test( "Date Adjustments - Normal Use Cases", 10, function() {
equal( date.adjust( "D", 1 ).year(), 2013, "Add 1 day to change year from 2012 to 2013" );
equal( date.adjust( "D", -1 ).year(), 2012,
"Subtract 1 day to change month from 2013 to 2012" );
});
} );

test( "Date Adjustments - Month Overflow Edge Cases", 2, function() {
var date = $.date();
var date = $.ui.date( null, attributes );

// Use May 31 2012
date.setFullDate( 2012, 4, 31 );
equal( date.adjust( "M", 1 ).day(), 30,
"Add 1 month from May to June sets days to 30, last day in June (prevent Overflow)" );
equal( date.adjust( "M", -1 ).day(), 30,
"Subtract 1 month from June to May sets days to 30 in May" );
});
} );

test( "Date Adjustments - Leap Year Edge Cases", 1, function() {
var date = $.date();
var date = $.ui.date( null, attributes );

// Use February 29 2012 a Leap year
date.setFullDate( 2012, 1, 29 );
equal( date.adjust( "Y", 1 ).day(), 28,
"Feb 29 2012, add a year to convert to Feb 28, 2013" );
});
} );

test( "List days of Week", 2, function() {
var date = $.date(),
var date = $.ui.date( null, attributes ),
offset0 = [
{ "fullname": "Sunday", "shortname": "Su" },
{ "fullname": "Monday", "shortname": "Mo" },
@@ -89,51 +91,36 @@ test( "List days of Week", 2, function() {
];

deepEqual( date.weekdays(), offset0, "Get weekdays with start of day on 0 (English)" );
Globalize.locale( "de" );
date = $.ui.date( null, testHelper.getAttributes( "de" ) );
deepEqual( date.weekdays(), offset1, "Get weekdays with start of day on 1 (Germany)" );

// Revert Globalize changes back to English
Globalize.locale( "en" );
});

test( "Leap Year Check", 8, function() {
var date = $.date();
ok( date.setYear( 2008 ).isLeapYear(), "2008 is a Leap Year" );
ok( !date.setYear( 2009 ).isLeapYear(), "2009 is not a Leap Year" );
ok( !date.setYear( 2010 ).isLeapYear(), "2010 is not a Leap Year" );
ok( !date.setYear( 2011 ).isLeapYear(), "2011 is not a Leap Year" );
ok( date.isLeapYear( 2012 ), "2012 is a Leap Year" );
ok( !date.isLeapYear( 2013 ), "2013 is not a Leap Year" );
ok( !date.isLeapYear( 2014 ), "2014 is not a Leap year" );
ok( !date.isLeapYear( 2015 ), "2015 is not a Leap year" );
});
} );

test( "Days in Month", 3, function() {
var date = $.date();
var date = $.ui.date( null, attributes );
date.setFullDate( 2012, 1, 1 );
equal( date.daysInMonth(), 29, "Leap Year implicit check for 29 days" );
equal( date.daysInMonth( 2012, 1 ), 29, "Leap Year explicit check for 29 days" );
equal( date.daysInMonth( 2011, 3 ), 30, "April has 30 days" );
});
} );

test( "Month Name", 2, function() {
var date = $.date();
equal( date.setMonth( 3 ).monthName(), "April", "Month name return April (English)" );
Globalize.locale( "de" );
equal( date.setMonth( 2 ).monthName(), "März", "Month name return March (German)" );
Globalize.locale( "en" );
});
var date = $.ui.date( null, attributes );
equal( date.setFullDate( 2012, 3, 1 ).monthName(), "April", "Month name return April (English)" );
date = $.ui.date( null, testHelper.getAttributes( "de" ) );
equal( date.setFullDate( 2012, 2, 1 ).monthName(), "März", "Month name return March (German)" );
} );

test( "Clone", 2, function() {
var date = $.date(),
var date = $.ui.date( null, attributes ),
date2 = date.clone();
ok( date2, "Created cloned object" );
notEqual( date.adjust( "Y", 1 ).year(), date2.year(), "Object manipulated independently" );
});
} );

test( "Days", 1, function() {
//TODO needs work
var date = $.date();

// TODO Needs work
var date = $.ui.date( null, attributes );
date.eachDay = function( day ) {
if ( day.lead && day.date > 20 ) {
day.selectable = false;
@@ -154,11 +141,11 @@ test( "Days", 1, function() {
day.title = "A good day!";
}
};
ok( date.days(), "Date days() returns");
});
ok( date.days(), "Date days() returns" );
} );

test( "Months", 5, function(){
var date = $.date(),
test( "Months", 5, function() {
var date = $.ui.date( null, attributes ),
firstMonth = date.months( 1 )[ 0 ],
lastMonth = date.months( 1 )[ 1 ];

@@ -168,30 +155,20 @@ test( "Months", 5, function(){
ok( !lastMonth.first );

ok( firstMonth.month() === lastMonth.month() - 1 );
});
} );

test( "Equal", 4, function() {
var date = $.date();
var date = $.ui.date( null, attributes );
date.setFullDate( 2012, 9, 16 );
ok( date.equal( new Date( 2012, 9, 16 ) ), "Does date equal provide date" );
ok( !date.equal( new Date( 2011, 9, 16 ) ), "Does date year not equal provide date" );
ok( !date.equal( new Date( 2012, 8, 16 ) ), "Does date month not equal provide date" );
ok( !date.equal( new Date( 2012, 9, 15 ) ), "Does date day not equal provide date" );
});
} );

test( "Date", 1, function() {
var date = $.date();
var date = $.ui.date( null, attributes );
ok( date.date() instanceof Date, "Date returned" );
});

test( "Format", 4, function() {
var date = $.date();
date.setFullDate( 2012, 9, 16 );
equal( date.format({ date: "short" }), "10/16/12", "Checking default US format" );
equal( date.format({ pattern: "yyyy/MM/dd" }), "2012/10/16", "Checking yyyy/MM/dd format" );
equal( date.format({ pattern: "yy/dd/MM" }), "12/16/10", "Checking yy/dd/MM format" );
equal( date.format({ pattern: "MMMM dd, yyyy" }), "October 16, 2012",
"Checking MMMM dd, yyyy format" );
});
} );

} );
@@ -11,9 +11,6 @@
<body>

<div id="qunit"></div>
<div id="qunit-fixture">
<div><input type="text" id="inp"><input type="text" id="alt"><div id="inl"></div></div>
<p><input type="text" id="inp2"></p>
</div>
<div id="qunit-fixture"></div>
</body>
</html>
@@ -0,0 +1,30 @@
define( [
"jquery",
"globalize",
"lib/helper",
"globalize/date"
], function( $, Globalize, helper ) {

return $.extend( helper, {
getAttributes: function( locale ) {
var globalize = new Globalize( locale ),
weekdayShortFormatter = globalize.dateFormatter( { raw: "EEEEEE" } ),
weekdayNarrowFormatter = globalize.dateFormatter( { raw: "EEEEE" } );

return {
firstDay: globalize.cldr.supplemental.weekData.firstDay(),
formatWeekdayShort: function( date ) {

// Return the short weekday if its length is < 3. Otherwise, its narrow form.
var shortWeekday = weekdayShortFormatter( date );

return shortWeekday.length > 3 ? weekdayNarrowFormatter( date ) : shortWeekday;
},
formatWeekdayFull: globalize.dateFormatter( { raw: "EEEE" } ),
formatMonth: globalize.dateFormatter( { raw: "MMMM" } ),
formatWeekOfYear: globalize.dateFormatter( { raw: "w" } )
};
}
} );

} );
@@ -37,6 +37,6 @@ common.testWidget( "datepicker", {
open: null,
select: null
}
});
} );

} );
@@ -19,7 +19,7 @@ test( "input's value determines starting date", function() {
equal( picker.find( ".ui-state-active" ).html(), "1", "correct day highlighted" );

input.val( "" ).datepicker( "destroy" );
});
} );

asyncTest( "base structure", function() {
expect( 5 );
@@ -29,7 +29,7 @@ asyncTest( "base structure", function() {

input.focus();

setTimeout(function() {
setTimeout( function() {
ok( widget.is( ":visible" ), "Datepicker visible" );
equal( widget.children().length, 2, "Child count" );
ok( widget.is( ".ui-calendar" ), "Class ui-calendar" );
@@ -39,7 +39,7 @@ asyncTest( "base structure", function() {
input.datepicker( "close" );
start();
}, 50 );
});
} );

asyncTest( "Keyboard handling: input", function() {
expect( 10 );
@@ -53,7 +53,7 @@ asyncTest( "Keyboard handling: input", function() {
ok( !picker.is( ":visible" ), "datepicker closed" );

input.val( "" ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
setTimeout(function() {
setTimeout( function() {
ok( picker.is( ":visible" ), "Keystroke down opens datepicker" );
input.datepicker( "destroy" );
step2();
@@ -67,7 +67,7 @@ asyncTest( "Keyboard handling: input", function() {
ok( !picker.is( ":visible" ), "datepicker closed" );

input.val( "" ).simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
setTimeout(function() {
setTimeout( function() {
ok( picker.is( ":visible" ), "Keystroke up opens datepicker" );
input.datepicker( "destroy" );
step3();
@@ -121,12 +121,12 @@ asyncTest( "Keyboard handling: input", function() {
}

step1();
});
} );

// TODO: implement
test( "ARIA", function() {
expect( 0 );
});
} );

asyncTest( "mouse", function() {
expect( 4 );
@@ -136,7 +136,7 @@ asyncTest( "mouse", function() {

input.datepicker( "open" );

setTimeout(function() {
setTimeout( function() {
input.val( "4/4/08" ).datepicker( "refresh" ).datepicker( "open" );
$( ".ui-calendar-calendar tbody button:contains(12)", picker ).simulate( "mousedown", {} );
testHelper.equalsDate(
@@ -168,6 +168,6 @@ asyncTest( "mouse", function() {

start();
}, 100 );
});
} );

} );
@@ -17,7 +17,7 @@ test( "beforeOpen", function() {
open: function() {
ok( input.datepicker( "widget" ).is( ":visible" ), "calendar open on open" );
}
});
} );

input
.datepicker( "open" )
@@ -29,9 +29,9 @@ test( "beforeOpen", function() {
open: function() {
ok( false, "calendar should not open when openBefore is canceled" );
}
})
} )
.datepicker( "open" );
});
} );

test( "close", function() {
expect( 4 );
@@ -41,7 +41,7 @@ test( "close", function() {
close: function() {
ok( shouldFire, "close event fired" );
}
});
} );

shouldFire = false;
input.datepicker( "open" );
@@ -62,7 +62,7 @@ test( "close", function() {
input.datepicker( "open" );
shouldFire = true;
input.datepicker( "widget" ).find( "tbody tr:first button:first" ).simulate( "mousedown" );
});
} );

test( "open", function() {
expect( 2 );
@@ -72,11 +72,11 @@ test( "open", function() {
ok( true, "open event fired on open" );
ok( widget.is( ":visible" ), "calendar open on open" );
}
}),
} ),
widget = input.datepicker( "widget" );

input.datepicker( "open" );
});
} );

asyncTest( "select", function() {
expect( 4 );
@@ -90,7 +90,7 @@ asyncTest( "select", function() {
"select originalEvent " + message
);
}
}),
} ),
widget = input.datepicker( "widget" ),
message = "";

@@ -99,7 +99,7 @@ asyncTest( "select", function() {
input
.simulate( "focus" )
.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
setTimeout(function() {
setTimeout( function() {
widget.find( "tbody tr:first button:first" ).simulate( "mousedown" );
input.datepicker( "close" );
step2();
@@ -111,7 +111,7 @@ asyncTest( "select", function() {
input
.simulate( "focus" )
.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement )
.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } )
.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
@@ -125,14 +125,14 @@ asyncTest( "select", function() {
input
.simulate( "focus" )
.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
setTimeout(function() {
setTimeout( function() {
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
input.datepicker( "close" );
start();
}, 100 );
}

step1();
});
} );

} );
@@ -15,8 +15,8 @@ test( "destroy", function( assert ) {
ok( input.attr( "aria-owns" ), "aria-owns attribute added" );
ok( input.attr( "aria-haspopup" ), "aria-haspopup attribute added" );
input.datepicker( "destroy" );
});
});
} );
} );

test( "enable / disable", function() {
expect( 10 );
@@ -37,20 +37,20 @@ test( "enable / disable", function() {
ok( !input.hasClass( "ui-state-disabled" ), "no longer has disabled state class name" );
equal( input.attr( "aria-disabled" ), "false", "no longer has ARIA disabled" );
equal( input.attr( "disabled" ), undefined, "input no longer disabled" );
});
} );

test( "widget", function() {
expect( 1 );

var actual = $( "#datepicker" ).datepicker().datepicker( "widget" );
deepEqual( $( "body > .ui-front" )[ 0 ], actual[ 0 ] );
actual.remove();
});
} );

test( "open / close", function() {
expect( 7 );

var input = testHelper.initNewInput({ show: false, hide: false }),
var input = testHelper.initNewInput( { show: false, hide: false } ),
calendar = input.datepicker( "widget" );

ok( calendar.is( ":hidden" ), "calendar hidden on init" );
@@ -64,7 +64,7 @@ test( "open / close", function() {
ok( !calendar.is( ":visible" ), "close: calendar hidden" );
equal( calendar.attr( "aria-hidden" ), "true", "close: calendar aria-hidden" );
equal( calendar.attr( "aria-expanded" ), "false", "close: calendar aria-expanded" );
});
} );

test( "value", function() {
expect( 4 );
@@ -84,7 +84,7 @@ test( "value", function() {

input.val( "abc" );
strictEqual( input.datepicker( "value" ), null, "Invalid values should return null." );
});
} );

test( "valueAsDate", function() {
expect( 6 );
@@ -110,7 +110,7 @@ test( "valueAsDate", function() {
strictEqual( input.datepicker( "valueAsDate" ), null, "Set date - default" );
input.datepicker( "valueAsDate", date1 );
testHelper.equalsDate( input.datepicker( "valueAsDate" ), date1, "Set date - 2008-06-04" );
});
} );

test( "isValid", function() {
expect( 2 );
@@ -123,6 +123,6 @@ test( "isValid", function() {
ok( !input.datepicker( "isValid" ) );

input.datepicker( "destroy" );
});
} );

} );
@@ -17,12 +17,12 @@ test( "appendTo", function() {
equal( container, document.body, "defaults to body" );
input.datepicker( "destroy" );

input.datepicker({ appendTo: "#qunit-fixture" });
input.datepicker( { appendTo: "#qunit-fixture" } );
container = input.datepicker( "widget" ).parent()[ 0 ];
equal( container, $( "#qunit-fixture" )[ 0 ], "child of specified element" );
input.datepicker( "destroy" );

input.datepicker({ appendTo: "#does-not-exist" });
input.datepicker( { appendTo: "#does-not-exist" } );
container = input.datepicker( "widget" ).parent()[ 0 ];
equal( container, document.body, "set to body if element does not exist" );
input.datepicker( "destroy" );
@@ -33,16 +33,16 @@ test( "appendTo", function() {
equal( container, $( "#qunit-fixture" )[ 0 ], "modified after init" );
input.datepicker( "destroy" );

input.datepicker({ appendTo: detached });
input.datepicker( { appendTo: detached } );
container = input.datepicker( "widget" ).parent()[ 0 ];
equal( container, detached[ 0 ], "detached jQuery object" );
input.datepicker( "destroy" );

input.datepicker({ appendTo: detached[ 0 ] });
input.datepicker( { appendTo: detached[ 0 ] } );
container = input.datepicker( "widget" ).parent()[ 0 ];
equal( container, detached[ 0 ], "detached DOM element" );
input.datepicker( "destroy" );
});
} );

test( "Pass-through options", function() {
expect( 11 );
@@ -77,20 +77,20 @@ test( "Pass-through options", function() {
if ( key === "locale" ) {
equal( input.val(), "Mittwoch, 1. Januar 2014", "option " + key + ": updated locale" );
}
});
});
} );
} );

asyncTest( "position", function(assert) {
asyncTest( "position", function( assert ) {
expect( 3 );
var input = $( "<input>" ).datepicker().appendTo( "body" ).css({
var input = $( "<input>" ).datepicker().appendTo( "body" ).css( {
position: "absolute",
top: 0,
left: 0
}),
} ),
container = input.datepicker( "widget" );

input.datepicker( "open" );
setTimeout(function() {
setTimeout( function() {
assert.close( input.offset().left, container.offset().left, 1, "left sides line up by default" );
assert.close( container.offset().top, input.offset().top + input.outerHeight(), 1,
"datepicker directly under input by default" );
@@ -99,21 +99,21 @@ asyncTest( "position", function(assert) {
input.datepicker( "option", "position", {
my: "left top",
at: "right bottom"
});
} );
assert.close( container.offset().left, input.offset().left + input.outerWidth(), 1,
"datepicker on right hand side of input after position change" );

input.remove();
start();
});
});
} );
} );

test( "Stop datepicker from appearing with beforeOpen event handler", function() {
expect( 3 );

var input = testHelper.init( "#datepicker", {
beforeOpen: function() {}
});
} );

input.datepicker( "open" );
ok( input.datepicker( "widget" ).is( ":visible" ), "beforeOpen returns nothing" );
@@ -123,7 +123,7 @@ test( "Stop datepicker from appearing with beforeOpen event handler", function()
beforeOpen: function() {
return true;
}
});
} );
input.datepicker( "open" );
ok( input.datepicker( "widget" ).is( ":visible" ), "beforeOpen returns true" );
input.datepicker( "close" ).datepicker( "destroy" );
@@ -132,10 +132,10 @@ test( "Stop datepicker from appearing with beforeOpen event handler", function()
beforeOpen: function() {
return false;
}
});
} );
input.datepicker( "open" );
ok( !input.datepicker( "widget" ).is( ":visible" ), "beforeOpen returns false" );
input.datepicker( "destroy" );
});
} );

} );
@@ -36,7 +36,7 @@ common.testWidget( "dialog", {
title: null,
width: 300,

// callbacks
// Callbacks
beforeClose: null,
close: null,
create: null,
@@ -49,6 +49,6 @@ common.testWidget( "dialog", {
resizeStart: null,
resizeStop: null
}
});
} );

} );
@@ -35,7 +35,7 @@ common.testWidget( "dialog", {
title: null,
width: 300,

// callbacks
// Callbacks
beforeClose: null,
close: null,
create: null,
@@ -48,6 +48,6 @@ common.testWidget( "dialog", {
resizeStart: null,
resizeStop: null
}
});
} );

} );
@@ -4,17 +4,17 @@ define( [
], function( $ ) {

// TODO add teardown callback to remove dialogs
module("dialog: core");
module( "dialog: core" );

test( "markup structure", function( assert ) {
expect( 11 );

var element = $( "<div>" ).dialog({
var element = $( "<div>" ).dialog( {
buttons: [ {
text: "Ok",
click: $.noop
} ]
}),
} ),
widget = element.dialog( "widget" ),
titlebar = widget.find( ".ui-dialog-titlebar" ),
title = titlebar.find( ".ui-dialog-title" ),
@@ -35,7 +35,7 @@ test( "markup structure", function( assert ) {
equal( buttonset.length, 1, "Buttonpane has exactly one buttonset" );
equal( buttons.length, 1, "Buttonset contains exactly 1 button when created with 1" );

});
} );

test( "markup structure - no buttons", function( assert ) {
expect( 7 );
@@ -53,18 +53,18 @@ test( "markup structure - no buttons", function( assert ) {
equal( close.length, 1, "Titlebar has exactly one close button" );
equal( title.length, 1, "Titlebar has exactly one title" );
assert.hasClasses( element, "ui-dialog-content ui-widget-content" );
});
} );

test("title id", function() {
expect(1);
test( "title id", function() {
expect( 1 );

var titleId,
element = $("<div>").dialog();
element = $( "<div>" ).dialog();

titleId = element.dialog("widget").find(".ui-dialog-title").attr("id");
ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id");
titleId = element.dialog( "widget" ).find( ".ui-dialog-title" ).attr( "id" );
ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id" );
element.remove();
});
} );

test( "ARIA", function() {
expect( 4 );
@@ -76,26 +76,26 @@ test( "ARIA", function() {
equal( wrapper.attr( "aria-describedby" ), element.attr( "id" ), "aria-describedby added" );
element.remove();

element = $("<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>").dialog();
element = $( "<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>" ).dialog();
equal( element.dialog( "widget" ).attr( "aria-describedby" ), null, "no aria-describedby added, as already present in markup" );
element.remove();
});
} );

test("widget method", function() {
test( "widget method", function() {
expect( 1 );
var dialog = $("<div>").appendTo("#qunit-fixture").dialog();
deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]);
var dialog = $( "<div>" ).appendTo( "#qunit-fixture" ).dialog();
deepEqual( dialog.parent()[ 0 ], dialog.dialog( "widget" )[ 0 ] );
dialog.remove();
});
} );

asyncTest( "focus tabbable", function() {
expect( 8 );
var element,
options = {
buttons: [{
buttons: [ {
text: "Ok",
click: $.noop
}]
} ]
};

function checkFocus( markup, options, testFn, next ) {
@@ -106,23 +106,23 @@ asyncTest( "focus tabbable", function() {
$( "body" ).trigger( "focus" );

element = $( markup ).dialog( options );
setTimeout(function() {
testFn(function done() {
setTimeout( function() {
testFn( function done() {
element.remove();
setTimeout( next );
});
});
} );
} );
}

function step1() {
checkFocus( "<div><input><input></div>", options, function( done ) {
var input = element.find( "input:last" ).trigger( "focus" ).trigger( "blur" );
element.dialog( "instance" )._focusTabbable();
setTimeout(function() {
setTimeout( function() {
equal( document.activeElement, input[ 0 ],
"1. an element that was focused previously." );
done();
});
} );
}, step2 );
}

@@ -164,10 +164,10 @@ asyncTest( "focus tabbable", function() {
checkFocus( "<div>text</div>", { autoOpen: false }, function( done ) {
element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
element.dialog( "open" );
setTimeout(function() {
setTimeout( function() {
equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" );
done();
});
} );
}, step7 );
}

@@ -177,17 +177,17 @@ asyncTest( "focus tabbable", function() {
{
open: function() {
var inputs = $( this ).find( "input" );
inputs.last().on( "keydown",function( event ) {
inputs.last().on( "keydown", function( event ) {
event.preventDefault();
inputs.first().trigger( "focus" );
});
} );
}
},
function( done ) {
var inputs = element.find( "input" );
equal( document.activeElement, inputs[ 1 ], "Focus starts on second input" );
inputs.last().simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
setTimeout(function() {
inputs.last().simulate( "keydown", { keyCode: $.ui.keyCode.TAB } );
setTimeout( function() {
equal( document.activeElement, inputs[ 0 ],
"Honor preventDefault, allowing custom focus management" );
done();
@@ -198,19 +198,19 @@ asyncTest( "focus tabbable", function() {
}

step1();
});
} );

test( "#7960: resizable handles below modal overlays", function() {
expect( 1 );

var resizable = $( "<div>" ).resizable(),
dialog = $( "<div>" ).dialog({ modal: true }),
dialog = $( "<div>" ).dialog( { modal: true } ),
resizableZindex = parseInt( resizable.find( ".ui-resizable-handle" ).css( "zIndex" ), 10 ),
overlayZindex = parseInt( $( ".ui-widget-overlay" ).css( "zIndex" ), 10 );

ok( resizableZindex < overlayZindex, "Resizable handles have lower z-index than modal overlay" );
dialog.dialog( "destroy" );
});
} );

asyncTest( "Prevent tabbing out of dialogs", function() {
expect( 3 );
@@ -219,13 +219,13 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
inputs = element.find( "input" );

// Remove close button to test focus on just the two buttons
element.dialog( "widget" ).find( ".ui-button").remove();
element.dialog( "widget" ).find( ".ui-button" ).remove();

function checkTab() {
equal( document.activeElement, inputs[ 0 ], "Tab key event moved focus within the modal" );

// check shift tab
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
// Check shift tab
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true } );
setTimeout( checkShiftTab );
}

@@ -237,39 +237,39 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
}

inputs[ 1 ].focus();
setTimeout(function() {
setTimeout( function() {
equal( document.activeElement, inputs[ 1 ], "Focus set on second input" );
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB } );

setTimeout( checkTab );
});
});
} );
} );

asyncTest( "#9048: multiple modal dialogs opened and closed in different order", function() {
expect( 1 );
$( "#dialog1, #dialog2" ).dialog({ autoOpen: false, modal:true });
$( "#dialog1, #dialog2" ).dialog( { autoOpen: false, modal:true } );
$( "#dialog1" ).dialog( "open" );
$( "#dialog2" ).dialog( "open" );
$( "#dialog1" ).dialog( "close" );
setTimeout(function() {
setTimeout( function() {
$( "#dialog2" ).dialog( "close" );
$( "#favorite-animal" ).trigger( "focus" );
ok( true, "event handlers cleaned up (no errors thrown)" );
start();
});
});
} );
} );

asyncTest( "interaction between overlay and other dialogs", function() {
$.widget( "ui.testWidget", $.ui.dialog, {
options: {
modal: true,
autoOpen: false
}
});
} );
expect( 2 );
var first = $( "<div><input id='input-1'></div>" ).dialog({
var first = $( "<div><input id='input-1'></div>" ).dialog( {
modal: true
}),
} ),
firstInput = first.find( "input" ),
second = $( "<div><input id='input-2'></div>" ).testWidget(),
secondInput = second.find( "input" );
@@ -280,18 +280,18 @@ asyncTest( "interaction between overlay and other dialogs", function() {
$( "body" ).trigger( "focus" );

// Wait for the modal to init
setTimeout(function() {
setTimeout( function() {
second.testWidget( "open" );

// Simulate user tabbing from address bar to an element outside the dialog
$( "#favorite-animal" ).trigger( "focus" );
setTimeout(function() {
setTimeout( function() {
equal( document.activeElement, secondInput[ 0 ] );

// Last active dialog must receive focus
firstInput.trigger( "focus" );
$( "#favorite-animal" ).trigger( "focus" );
setTimeout(function() {
setTimeout( function() {
equal( document.activeElement, firstInput[ 0 ] );

// Cleanup
@@ -300,9 +300,9 @@ asyncTest( "interaction between overlay and other dialogs", function() {
delete $.ui.testWidget;
delete $.fn.testWidget;
start();
});
});
});
});
} );
} );
} );
} );

} );
@@ -13,18 +13,18 @@ test( "dialogClass", function( assert ) {
assert.lacksClasses( widget, "foo", "dialogClass not specified. class not added" );
element.remove();

element = $( "<div>" ).dialog({ dialogClass: "foo" });
element = $( "<div>" ).dialog( { dialogClass: "foo" } );
widget = element.dialog( "widget" );
assert.hasClasses( widget, "foo", "dialogClass in init, foo class added" );
element.dialog( "option", "dialogClass", "foobar" );
assert.lacksClasses( widget, "foo", "dialogClass changed, previous one was removed" );
assert.hasClasses( widget, "foobar", "dialogClass changed, new one was added" );
element.remove();

element = $( "<div>" ).dialog({ dialogClass: "foo bar" });
element = $( "<div>" ).dialog( { dialogClass: "foo bar" } );
widget = element.dialog( "widget" );
assert.hasClasses( widget, "foo bar", "dialogClass in init, two classes." );
element.remove();
});
} );

} );

Large diffs are not rendered by default.

@@ -5,50 +5,52 @@ define( [
], function( $, helper ) {

return $.extend( helper, {
drag: function(element, handle, dx, dy) {
var d = element.dialog("widget");
drag: function( element, handle, dx, dy ) {
var d = element.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", {
$( handle, d ).simulate( "mouseover" ).simulate( "drag", {
dx: dx,
dy: dy
});
} );
},
testDrag: function(element, dx, dy, expectedDX, expectedDY, msg) {
testDrag: function( element, dx, dy, expectedDX, expectedDY, msg ) {
var actualDX, actualDY, offsetAfter,
d = element.dialog("widget"),
handle = $(".ui-dialog-titlebar", d),
d = element.dialog( "widget" ),
handle = $( ".ui-dialog-titlebar", d ),
offsetBefore = d.offset();

this.drag(element, handle, dx, dy);
this.drag( element, handle, dx, dy );

offsetAfter = d.offset();

msg = msg ? msg + "." : "";

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 );
},

// TODO switch back to checking the size of the .ui-dialog element (var d)
// once we switch to using box-sizing: border-box (#9845) that should work fine
// using the element's dimensions to avoid subpixel errors
shouldResize: function(element, dw, dh, msg) {
shouldResize: function( element, dw, dh, msg ) {
var heightAfter, widthAfter, actual, expected,
d = element.dialog("widget"),
handle = $(".ui-resizable-se", d),
d = element.dialog( "widget" ),
handle = $( ".ui-resizable-se", d ),
heightBefore = element.height(),
widthBefore = element.width();

this.drag(element, handle, 50, 50);
this.drag( element, handle, 50, 50 );

heightAfter = element.height();
widthAfter = element.width();

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

@@ -3,37 +3,37 @@ define( [
"ui/widgets/dialog"
], function( $ ) {

module("dialog: methods", {
module( "dialog: methods", {
teardown: function() {
$("body>.ui-dialog").remove();
$( "body>.ui-dialog" ).remove();
}
});
} );

test("init", function() {
expect(6);
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");
$( [] ).dialog().remove();
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 element = $("<div></div>").dialog();
element.dialog("option", "foo");
var element = $( "<div></div>" ).dialog();
element.dialog( "option", "foo" );
element.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( assert ) {
test( "destroy", function( assert ) {
expect( 17 );

var element, element2;
@@ -43,30 +43,30 @@ test("destroy", function( assert ) {
var dialog = $( "#dialog1" ).dialog().dialog( "destroy" );
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
equal( dialog.index(), 0 );
});
} );
assert.domEqual( "#form-dialog", function() {
var dialog = $( "#form-dialog" ).dialog().dialog( "destroy" );
equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] );
equal( dialog.index(), 2 );
});
} );

// Ensure dimensions are restored (#8119)
$( "#dialog1" ).show().css({
$( "#dialog1" ).show().css( {
width: "400px",
minHeight: "100px",
height: "200px"
});
} );
assert.domEqual( "#dialog1", function() {
$( "#dialog1" ).dialog().dialog( "destroy" );
});
} );

// Don't throw errors when destroying a never opened modal dialog (#9004)
$( "#dialog1" ).dialog({ autoOpen: false, modal: true }).dialog( "destroy" );
$( "#dialog1" ).dialog( { autoOpen: false, modal: true } ).dialog( "destroy" );
equal( $( ".ui-widget-overlay" ).length, 0, "overlay does not exist" );
equal( $( document ).data( "ui-dialog-overlays" ), undefined, "ui-dialog-overlays equals the number of open overlays");
equal( $( document ).data( "ui-dialog-overlays" ), undefined, "ui-dialog-overlays equals the number of open overlays" );

element = $( "#dialog1" ).dialog({ modal: true }),
element2 = $( "#dialog2" ).dialog({ modal: true });
element = $( "#dialog1" ).dialog( { modal: true } ),
element2 = $( "#dialog2" ).dialog( { modal: true } );
equal( $( ".ui-widget-overlay" ).length, 2, "overlays created when dialogs are open" );
equal( $( document ).data( "ui-dialog-overlays" ), 2, "ui-dialog-overlays equals the number of open overlays" );
element.dialog( "close" );
@@ -78,190 +78,192 @@ test("destroy", function( assert ) {
element2.dialog( "destroy" );
equal( $( ".ui-widget-overlay" ).length, 0, "overlays removed when all dialogs are destoryed" );
equal( $( document ).data( "ui-dialog-overlays" ), undefined, "ui-dialog-overlays equals the number of open overlays" );
});
} );

asyncTest("#9000: Dialog leaves broken event handler after close/destroy in certain cases", function() {
asyncTest( "#9000: Dialog leaves broken event handler after close/destroy in certain cases", function() {
expect( 1 );
$( "#dialog1" ).dialog({ modal:true }).dialog( "close" ).dialog( "destroy" );
setTimeout(function() {
$( "#dialog1" ).dialog( { modal:true } ).dialog( "close" ).dialog( "destroy" );
setTimeout( function() {
$( "#favorite-animal" ).trigger( "focus" );
ok( true, "close and destroy modal dialog before its really opened" );
start();
});
});
} );
} );

test("#4980: Destroy should place element back in original DOM position", 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( assert ) {
expect( 3 );
var element = $( "<div></div>" ).dialog();
element.dialog( "disable" );
equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" );
equal( element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" );
assert.lacksClasses( element, "ui-dialog-disabled ui-state-disabled", "disable method doesn't add classes" );
ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" );
});
} );

test("close", function() {
test( "close", function() {
expect( 3 );

var element,
expected = $("<div></div>").dialog(),
actual = expected.dialog("close");
equal(actual, expected, "close is chainable");

element = $("<div></div>").dialog();
ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog visible before close method called");
element.dialog("close");
ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog hidden after close method called");
});

test("isOpen", function() {
expect(4);

var element = $("<div></div>").dialog();
equal(element.dialog("isOpen"), true, "dialog is open after init");
element.dialog("close");
equal(element.dialog("isOpen"), false, "dialog is closed");
expected = $( "<div></div>" ).dialog(),
actual = expected.dialog( "close" );
equal( actual, expected, "close is chainable" );

element = $( "<div></div>" ).dialog();
ok( element.dialog( "widget" ).is( ":visible" ) && !element.dialog( "widget" ).is( ":hidden" ), "dialog visible before close method called" );
element.dialog( "close" );
ok( element.dialog( "widget" ).is( ":hidden" ) && !element.dialog( "widget" ).is( ":visible" ), "dialog hidden after close method called" );
} );

test( "isOpen", function() {
expect( 4 );

var element = $( "<div></div>" ).dialog();
equal( element.dialog( "isOpen" ), true, "dialog is open after init" );
element.dialog( "close" );
equal( element.dialog( "isOpen" ), false, "dialog is closed" );
element.remove();

element = $("<div></div>").dialog({autoOpen: false});
equal(element.dialog("isOpen"), false, "dialog is closed after init");
element.dialog("open");
equal(element.dialog("isOpen"), true, "dialog is open");
element = $( "<div></div>" ).dialog( { autoOpen: false } );
equal( element.dialog( "isOpen" ), false, "dialog is closed after init" );
element.dialog( "open" );
equal( element.dialog( "isOpen" ), true, "dialog is open" );
element.remove();
});
} );

test("moveToTop", function() {
test( "moveToTop", function() {
expect( 5 );
function order() {
var actual = $( ".ui-dialog" ).map(function() {
var actual = $( ".ui-dialog" ).map( function() {
return +$( this ).css( "z-index" );
}).get();
} ).get();
deepEqual( actual, $.makeArray( arguments ) );
}
var dialog1, dialog2,
focusOn = "dialog1";
dialog1 = $( "#dialog1" ).dialog({
dialog1 = $( "#dialog1" ).dialog( {
focus: function() {
equal( focusOn, "dialog1" );
}
});
} );
focusOn = "dialog2";
dialog2 = $( "#dialog2" ).dialog({
dialog2 = $( "#dialog2" ).dialog( {
focus: function() {
equal( focusOn, "dialog2" );
}
});
} );
order( 100, 101 );
focusOn = "dialog1";
dialog1.dialog( "moveToTop" );
order( 102, 101 );
});
} );

test( "moveToTop: content scroll stays intact", function() {
expect( 2 );
var otherDialog = $( "#dialog1" ).dialog(),
scrollDialog = $( "#form-dialog" ).dialog({
scrollDialog = $( "#form-dialog" ).dialog( {
height: 200
});
} );
scrollDialog.scrollTop( 50 );
equal( scrollDialog.scrollTop(), 50 );

otherDialog.dialog( "moveToTop" );
equal( scrollDialog.scrollTop(), 50 );
});
} );

test("open", function() {
test( "open", function() {
expect( 3 );
var element,
expected = $("<div></div>").dialog(),
actual = expected.dialog("open");
equal(actual, expected, "open is chainable");

element = $("<div></div>").dialog({ autoOpen: false });
ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog hidden before open method called");
element.dialog("open");
ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog visible after open method called");
});
expected = $( "<div></div>" ).dialog(),
actual = expected.dialog( "open" );
equal( actual, expected, "open is chainable" );

element = $( "<div></div>" ).dialog( { autoOpen: false } );
ok( element.dialog( "widget" ).is( ":hidden" ) && !element.dialog( "widget" ).is( ":visible" ), "dialog hidden before open method called" );
element.dialog( "open" );
ok( element.dialog( "widget" ).is( ":visible" ) && !element.dialog( "widget" ).is( ":hidden" ), "dialog visible after open method called" );
} );

// http://bugs.jqueryui.com/ticket/6137
test("Ensure form elements don't reset when opening a dialog", function() {
expect(2);
test( "Ensure form elements don't reset when opening a dialog", 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();
});
} );

asyncTest( "#8958: dialog can be opened while opening", function() {
expect( 1 );

var element = $( "<div>" ).dialog({
var element = $( "<div>" ).dialog( {
autoOpen: false,
modal: true,
open: function() {
equal( $( ".ui-widget-overlay" ).length, 1 );
start();
}
});
} );

// Support: IE8
// For some reason the #favorite-color input doesn't get focus if we don't
// focus the body first, causing the test to hang.
$( "body" ).trigger( "focus" );

$( "#favorite-animal" )

// We focus the input to start the test. Once it receives focus, the
// dialog will open. Opening the dialog, will cause an element inside
// the dialog to gain focus, thus blurring the input.
.on( "focus", function() {
element.dialog( "open" );
})
} )

// When the input blurs, the dialog is in the process of opening. We
// try to open the dialog again, to make sure that dialogs properly
// handle a call to the open() method during the process of the dialog
// being opened.
.on( "blur", function() {
element.dialog( "open" );
})
} )
.trigger( "focus" );
});
} );

test("#5531: dialog width should be at least minWidth on creation", function () {
test( "#5531: dialog width should be at least minWidth on creation", function() {
expect( 4 );
var element = $("<div></div>").dialog({
var element = $( "<div></div>" ).dialog( {
width: 200,
minWidth: 300
});
} );

equal(element.dialog("option", "width"), 300, "width is minWidth");
element.dialog("option", "width", 200);
equal(element.dialog("option", "width"), 300, "width unchanged when set to < minWidth");
element.dialog("option", "width", 320);
equal(element.dialog("option", "width"), 320, "width changed if set to > minWidth");
equal( element.dialog( "option", "width" ), 300, "width is minWidth" );
element.dialog( "option", "width", 200 );
equal( element.dialog( "option", "width" ), 300, "width unchanged when set to < minWidth" );
element.dialog( "option", "width", 320 );
equal( element.dialog( "option", "width" ), 320, "width changed if set to > minWidth" );
element.remove();

element = $("<div></div>").dialog({
element = $( "<div></div>" ).dialog( {
minWidth: 300
});
ok(element.dialog("option", "width") >= 300, "width is at least 300");
} );
ok( element.dialog( "option", "width" ) >= 300, "width is at least 300" );
element.remove();

});
} );

} );

Large diffs are not rendered by default.

@@ -37,12 +37,12 @@ common.testWidget( "draggable", {
distance: 1,
iframeFix: false,

// callbacks
// Callbacks
create: null,
drag: null,
start: null,
stop: null
}
});
} );

} );
@@ -14,84 +14,84 @@ test( "element types", function( assert ) {
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
",acronym,code,samp,kbd,var,img,hr" +
",input,button,label,select,iframe"
).split(",");
).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" );

if ( typeName === "table" ) {
el.append("<tr><td>content</td></tr>");
el.append( "<tr><td>content</td></tr>" );
}

el.draggable({ cancel: "" });
el.draggable( { cancel: "" } );
offsetBefore = el.offset();
el.simulate( "drag", {
dx: 50,
dy: 50
});
} );
offsetAfter = el.offset();

// Support: FF, Chrome, and IE9,
// there are some rounding errors in so we can't say equal, we have to settle for close enough
assert.close( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + "> left" );
assert.close( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + "> top" );
el.draggable("destroy");
el.draggable( "destroy" );
el.remove();
});
});
} );
} );

test( "No options, relative", function() {
expect( 2 );
testHelper.shouldMove( $( "#draggable1" ).draggable(), "no options, relative" );
});
} );

test( "No options, absolute", function() {
expect( 2 );
testHelper.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" );
});
} );

test( "resizable handle with complex markup (#8756 / #8757)", function() {
expect( 2 );

$( "#draggable1" )
.append(
$("<div>")
.addClass("ui-resizable-handle ui-resizable-w")
.append( $("<div>") )
$( "<div>" )
.addClass( "ui-resizable-handle ui-resizable-w" )
.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 } );
// Todo: fix resizable so it doesn't require a mouseover
handle.simulate( "mouseover" ).simulate( "drag", { dx: -50 } );
equal( target.width(), 250, "compare width" );

// todo: fix resizable so it doesn't require a mouseover
handle.simulate("mouseover").simulate( "drag", { dx: 50 } );
// Todo: fix resizable so it doesn't require a mouseover
handle.simulate( "mouseover" ).simulate( "drag", { dx: 50 } );
equal( target.width(), 200, "compare width" );
});
} );

test( "#8269: Removing draggable element on drop", function() {
expect( 2 );

var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable({
var element = $( "#draggable1" ).wrap( "<div id='wrapper' />" ).draggable( {
stop: function() {
ok( true, "stop still called despite element being removed from DOM on drop" );
}
}),
} ),
dropOffset = $( "#droppable" ).offset();

$( "#droppable" ).droppable({
$( "#droppable" ).droppable( {
drop: function() {
$( "#wrapper" ).remove();
ok( true, "element removed from DOM on drop" );
}
});
} );

// Support: Opera 12.10, Safari 5.1, jQuery <1.8
if ( testHelper.unreliableContains ) {
@@ -102,31 +102,31 @@ test( "#8269: Removing draggable element on drop", function() {
handle: "corner",
x: dropOffset.left,
y: dropOffset.top
});
} );
}
});
} );

// http://bugs.jqueryui.com/ticket/7778
// drag element breaks in IE8 when its content is replaced onmousedown
test( "Stray mousemove after mousedown still drags", function() {
expect( 2 );

var element = $( "#draggable1" ).draggable({ scroll: false });
var element = $( "#draggable1" ).draggable( { scroll: false } );

// In IE8, when content is placed under the mouse (e.g. when draggable content is replaced
// on mousedown), mousemove is triggered on those elements even though the mouse hasn't moved.
// Support: IE <9
element.on( "mousedown", function() {
$( document ).simulate( "mousemove", { button: -1 });
});
$( document ).simulate( "mousemove", { button: -1 } );
} );

testHelper.shouldMove( element, "element is draggable" );
});
} );

test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() {
expect( 2 );

var element = $( "#draggable1" ).draggable({
var element = $( "#draggable1" ).draggable( {
stop: function( event, ui ) {
equal( ui.position.left, 1, "left position is correct despite overflow on HTML" );
equal( ui.position.top, 1, "top position is correct despite overflow on HTML" );
@@ -136,7 +136,7 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
.scrollTop( 0 )
.scrollLeft( 0 );
}
}),
} ),
oldOverflowY = $( "html" ).css( "overflow-y" ),
oldOverflowX = $( "html" ).css( "overflow-x" );

@@ -152,19 +152,19 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
dx: 1,
dy: 1,
moves: 1
});
});
} );
} );

test( "#9315: jumps down with offset of scrollbar", function() {
expect( 2 );

var element = $( "#draggable2" ).draggable({
var element = $( "#draggable2" ).draggable( {
stop: function( event, ui ) {
equal( ui.position.left, 11, "left position is correct when position is absolute" );
equal( ui.position.top, 11, "top position is correct when position is absolute" );
$( "html" ).scrollTop( 0 ).scrollLeft( 0 );
}
});
} );

testHelper.forceScrollableWindow();

@@ -174,21 +174,23 @@ test( "#9315: jumps down with offset of scrollbar", function() {
dx: 1,
dy: 1,
moves: 1
});
});
} );
} );

test( "scroll offset with fixed ancestors", function() {
expect( 2 );

var startValue = 300,
element = $( "#draggable1" )

// http://bugs.jqueryui.com/ticket/5009
// scroll not working with parent's position fixed
.wrap( "<div id='wrapper' />" )

// http://bugs.jqueryui.com/ticket/9612
// abspos elements inside of fixed elements moving away from the mouse when scrolling
.wrap( "<div id='wrapper2' />" )
.draggable({
.draggable( {
drag: function() {
startValue += 100;
$( document ).scrollTop( startValue ).scrollLeft( startValue );
@@ -198,7 +200,7 @@ test( "scroll offset with fixed ancestors", function() {
equal( ui.position.top, 10, "top position is correct when parent position is fixed" );
$( document ).scrollTop( 0 ).scrollLeft( 0 );
}
});
} );

testHelper.forceScrollableWindow();

@@ -209,30 +211,30 @@ test( "scroll offset with fixed ancestors", function() {
dx: 10,
dy: 10,
moves: 3
});
});
} );
} );

$( [ "hidden", "auto", "scroll" ] ).each(function() {
$( [ "hidden", "auto", "scroll" ] ).each( function() {
var overflow = this;

// http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div
// Http://bugs.jqueryui.com/ticket/9379 - position bug in scrollable div
// http://bugs.jqueryui.com/ticket/10147 - Wrong position in a parent with "overflow: hidden"
test( "position in scrollable parent with overflow: " + overflow, function() {
expect( 2 );

$( "#qunit-fixture" ).html( "<div id='outer'><div id='inner'></div><div id='dragged'>a</div></div>" );
$( "#inner" ).css({ position: "absolute", width: "500px", height: "500px" });
$( "#outer" ).css({ position: "absolute", width: "300px", height: "300px" });
$( "#dragged" ).css({ width: "10px", height: "10px" });
$( "#inner" ).css( { position: "absolute", width: "500px", height: "500px" } );
$( "#outer" ).css( { position: "absolute", width: "300px", height: "300px" } );
$( "#dragged" ).css( { width: "10px", height: "10px" } );

var moves = 3,
startValue = 0,
dragDelta = 20,
delta = 100,

// we scroll after each drag event, so subtract 1 from number of moves for expected
// We scroll after each drag event, so subtract 1 from number of moves for expected
expected = delta + ( ( moves - 1 ) * dragDelta ),
element = $( "#dragged" ).draggable({
element = $( "#dragged" ).draggable( {
drag: function() {
startValue += dragDelta;
$( "#outer" ).scrollTop( startValue ).scrollLeft( startValue );
@@ -241,17 +243,17 @@ $( [ "hidden", "auto", "scroll" ] ).each(function() {
equal( ui.position.left, expected, "left position is correct when grandparent is scrolled" );
equal( ui.position.top, expected, "top position is correct when grandparent is scrolled" );
}
});
} );

$( "#outer" ).css( "overflow", overflow );

element.simulate( "drag", {
dy: delta,
dx: delta,
moves: moves
});
});
});
} );
} );
} );

test( "#5727: draggable from iframe", function() {
expect( 1 );
@@ -273,7 +275,7 @@ test( "#5727: draggable from iframe", function() {
// TODO: fix draggable within an IFRAME to fire events on the element properly
// and these testHelper.shouldMove relies on events for testing
//testHelper.shouldMove( draggable1, "draggable from an iframe" );
});
} );

test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function() {
expect( 2 );
@@ -282,12 +284,12 @@ test( "#8399: A draggable should become the active element after you are finishe

$( document ).one( "mousemove", function() {
notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" );
});
} );

testHelper.move( element, 50, 50 );

strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" );
});
} );

asyncTest( "blur behavior", function() {
expect( 3 );
@@ -300,18 +302,18 @@ asyncTest( "blur behavior", function() {

testHelper.move( focusElement, 1, 1 );

// http://bugs.jqueryui.com/ticket/10527
// Http://bugs.jqueryui.com/ticket/10527
// Draggable: Can't select option in modal dialog (IE8)
strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused after mousing down on itself" );

testHelper.move( element, 50, 50 );

// http://bugs.jqueryui.com/ticket/4261
// Http://bugs.jqueryui.com/ticket/4261
// active element should blur when mousing down on a draggable
notStrictEqual( document.activeElement, focusElement.get( 0 ), "test element is no longer focused after mousing down on a draggable" );
start();
});
});
} );
} );

test( "ui-draggable-handle assigned to appropriate element", function( assert ) {
expect( 5 );
@@ -328,7 +330,7 @@ test( "ui-draggable-handle assigned to appropriate element", function( assert )

element.draggable( "destroy" );
assert.lacksClasses( element.find( "p" ), "ui-draggable-handle" );
});
} );

test( "ui-draggable-handle managed correctly in nested draggables", function( assert ) {
expect( 4 );
@@ -341,6 +343,6 @@ test( "ui-draggable-handle managed correctly in nested draggables", function( as
parent.draggable( "destroy" );
assert.lacksClasses( parent, "ui-draggable-handle", "parent loses class name on destroy" );
assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" );
});
} );

} );
@@ -7,12 +7,12 @@ var element;

module( "draggable: events", {
setup: function() {
element = $("<div>").appendTo("#qunit-fixture");
element = $( "<div>" ).appendTo( "#qunit-fixture" );
},
teardown: function() {
element.draggable("destroy");
element.draggable( "destroy" );
}
});
} );

test( "callbacks occurrence count", function() {
expect( 3 );
@@ -21,7 +21,7 @@ test( "callbacks occurrence count", function() {
stop = 0,
dragc = 0;

element.draggable({
element.draggable( {
start: function() {
start++;
},
@@ -31,17 +31,17 @@ test( "callbacks occurrence count", function() {
stop: function() {
stop++;
}
});
} );

element.simulate( "drag", {
dx: 10,
dy: 10
});
} );

equal( start, 1, "start callback should happen exactly once" );
equal( dragc, 3, "drag callback should happen exactly once per mousemove" );
equal( stop, 1, "stop callback should happen exactly once" );
});
} );

test( "stopping the start callback", function() {
expect( 3 );
@@ -50,7 +50,7 @@ test( "stopping the start callback", function() {
stop = 0,
dragc = 0;

element.draggable({
element.draggable( {
start: function() {
start++;
return false;
@@ -61,17 +61,17 @@ test( "stopping the start callback", function() {
stop: function() {
stop++;
}
});
} );

element.simulate( "drag", {
dx: 10,
dy: 10
});
} );

equal( start, 1, "start callback should happen exactly once" );
equal( dragc, 0, "drag callback should not happen at all" );
equal( stop, 0, "stop callback should not happen if there wasnt even a start" );
});
} );

test( "stopping the drag callback", function() {
expect( 2 );
@@ -80,7 +80,7 @@ test( "stopping the drag callback", function() {
stop = 0,
dragc = 0;

element.draggable({
element.draggable( {
start: function() {
start++;
},
@@ -91,34 +91,34 @@ test( "stopping the drag callback", function() {
stop: function() {
stop++;
}
});
} );

element.simulate( "drag", {
dx: 10,
dy: 10
});
} );

equal( start, 1, "start callback should happen exactly once" );
equal( stop, 1, "stop callback should happen, as we need to actively stop the drag" );
});
} );

test( "stopping the stop callback", function() {
expect( 1 );

element.draggable({
element.draggable( {
helper: "clone",
stop: function() {
return false;
}
});
} );

element.simulate( "drag", {
dx: 10,
dy: 10
});
} );

ok( element.draggable( "instance" ).helper, "the clone should not be deleted if the stop callback is stopped" );
});
} );

// http://bugs.jqueryui.com/ticket/6884
// Draggable: ui.offset.left differs between the "start" and "drag" hooks
@@ -129,7 +129,7 @@ test( "position and offset in hash is consistent between start, drag, and stop",

element = $( "<div style='margin: 2px;'></div>" ).appendTo( "#qunit-fixture" );

element.draggable({
element.draggable( {
start: function( event, ui ) {
startPos = ui.position;
startOffset = ui.offset;
@@ -142,13 +142,13 @@ test( "position and offset in hash is consistent between start, drag, and stop",
stopPos = ui.position;
stopOffset = ui.offset;
}
});
} );

element.simulate( "drag", {
dx: 10,
dy: 10,
moves: 1
});
} );

startPos.left += 10;
startPos.top += 10;
@@ -159,6 +159,6 @@ test( "position and offset in hash is consistent between start, drag, and stop",
deepEqual( dragPos, stopPos, "drag position equals stop position" );
deepEqual( startOffset, dragOffset, "start offset equals drag offset plus distance" );
deepEqual( dragOffset, stopOffset, "drag offset equals stop offset" );
});
} );

} );