2015-04-07 00:06:31 +00:00
|
|
|
define( [
|
2016-04-03 15:11:33 +00:00
|
|
|
"qunit",
|
2015-04-07 00:06:31 +00:00
|
|
|
"jquery",
|
|
|
|
"lib/common",
|
2020-05-16 07:16:24 +00:00
|
|
|
"lib/helper",
|
2015-04-07 14:55:52 +00:00
|
|
|
"./helper",
|
2015-07-15 01:58:04 +00:00
|
|
|
"ui/widgets/datepicker",
|
2015-04-07 00:06:31 +00:00
|
|
|
"ui/i18n/datepicker-he"
|
2020-05-16 07:16:24 +00:00
|
|
|
], function( QUnit, $, common, helper, testHelper ) {
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
QUnit.module( "datepicker: core", {
|
|
|
|
beforeEach: function() {
|
2015-05-14 01:54:56 +00:00
|
|
|
$( "body" ).trigger( "focus" );
|
2020-05-16 07:16:24 +00:00
|
|
|
},
|
|
|
|
afterEach: helper.moduleAfterEach
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2015-10-01 10:08:04 +00:00
|
|
|
common.testJshint( "widgets/datepicker" );
|
2012-12-06 16:56:56 +00:00
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
QUnit.test( "initialization - Reinitialization after body had been emptied.", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2015-08-24 13:00:11 +00:00
|
|
|
var bodyContent = $( "body" ).children(), inp = $( "#inp" );
|
|
|
|
$( "#inp" ).datepicker();
|
|
|
|
$( "body" ).empty().append( inp );
|
|
|
|
$( "#inp" ).datepicker();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( $( "#" + $.datepicker._mainDivId ).length === 1, "Datepicker container added" );
|
2015-08-24 13:00:11 +00:00
|
|
|
$( "body" ).empty().append( bodyContent ); // Returning to initial state for later tests
|
|
|
|
} );
|
2012-11-19 14:14:59 +00:00
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
QUnit.test( "widget method - empty collection", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
$( "#nonExist" ).datepicker(); // Should create nothing
|
|
|
|
assert.ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" );
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2011-02-15 18:15:46 +00:00
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
QUnit.test( "widget method", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2015-08-24 13:00:11 +00:00
|
|
|
var actual = $( "#inp" ).datepicker().datepicker( "widget" )[ 0 ];
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.deepEqual( $( "body > #ui-datepicker-div:last-child" )[ 0 ], actual );
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
QUnit.test( "baseStructure", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 58 );
|
2012-04-19 15:17:35 +00:00
|
|
|
var header, title, table, thead, week, panel, inl, child,
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.initNewInput(),
|
2013-04-14 21:07:24 +00:00
|
|
|
dp = $( "#ui-datepicker-div" );
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-12-11 15:06:13 +00:00
|
|
|
function step1() {
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( dp.is( ":visible" ), "Structure - datepicker visible" );
|
|
|
|
assert.ok( !dp.is( ".ui-datepicker-rtl" ), "Structure - not right-to-left" );
|
|
|
|
assert.ok( !dp.is( ".ui-datepicker-multi" ), "Structure - not multi-month" );
|
|
|
|
assert.equal( dp.children().length, 2, "Structure - child count" );
|
2012-12-11 15:06:13 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
header = dp.children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure - header division" );
|
|
|
|
assert.equal( header.children().length, 3, "Structure - header child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( header.children().first().is( "a.ui-datepicker-prev" ) && header.children().first().html() !== "", "Structure - prev link" );
|
|
|
|
assert.ok( header.children().eq( 1 ).is( "a.ui-datepicker-next" ) && header.children().eq ( 1 ).html() !== "", "Structure - next link" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
title = header.children().last();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( title.is( "div.ui-datepicker-title" ) && title.html() !== "", "Structure - title division" );
|
|
|
|
assert.equal( title.children().length, 2, "Structure - title child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( title.children().first().is( "span.ui-datepicker-month" ) && title.children().first().text() !== "", "Structure - month text" );
|
|
|
|
assert.ok( title.children().last().is( "span.ui-datepicker-year" ) && title.children().last().text() !== "", "Structure - year text" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
table = dp.children().eq( 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( table.is( "table.ui-datepicker-calendar" ), "Structure - month table" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( table.children().first().is( "thead" ), "Structure - month table thead" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
thead = table.children().first().children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( thead.is( "tr" ), "Structure - month table title row" );
|
|
|
|
assert.equal( thead.find( "th" ).length, 7, "Structure - month table title cells" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( table.children().eq( 1 ).is( "tbody" ), "Structure - month table body" );
|
|
|
|
assert.ok( table.children().eq( 1 ).children( "tr" ).length >= 4, "Structure - month table week count" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
week = table.children().eq( 1 ).children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( week.is( "tr" ), "Structure - month table week row" );
|
|
|
|
assert.equal( week.children().length, 7, "Structure - week child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( week.children().first().is( "td.ui-datepicker-week-end" ), "Structure - month table first day cell" );
|
|
|
|
assert.ok( week.children().last().is( "td.ui-datepicker-week-end" ), "Structure - month table second day cell" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
2012-12-11 15:06:13 +00:00
|
|
|
step2();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2012-12-11 15:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function step2() {
|
2015-08-24 13:00:11 +00:00
|
|
|
|
2012-12-11 15:06:13 +00:00
|
|
|
// Editable month/year and button panel
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.initNewInput( {
|
2013-04-14 21:07:24 +00:00
|
|
|
changeMonth: true,
|
|
|
|
changeYear: true,
|
|
|
|
showButtonPanel: true
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2013-04-14 21:07:24 +00:00
|
|
|
title = dp.find( "div.ui-datepicker-title" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( title.children().first().is( "select.ui-datepicker-month" ), "Structure - month selector" );
|
|
|
|
assert.ok( title.children().last().is( "select.ui-datepicker-year" ), "Structure - year selector" );
|
2012-12-11 15:06:13 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
panel = dp.children().last();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure - button panel division" );
|
|
|
|
assert.equal( panel.children().length, 2, "Structure - button panel child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( panel.children().first().is( "button.ui-datepicker-current" ), "Structure - today button" );
|
|
|
|
assert.ok( panel.children().last().is( "button.ui-datepicker-close" ), "Structure - close button" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
2012-12-11 15:06:13 +00:00
|
|
|
step3();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2012-12-11 15:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function step3() {
|
2015-08-24 13:00:11 +00:00
|
|
|
|
2012-12-11 15:06:13 +00:00
|
|
|
// Multi-month 2
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.initNewInput( { numberOfMonths: 2 } );
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( dp.is( ".ui-datepicker-multi" ), "Structure multi [2] - multi-month" );
|
|
|
|
assert.equal( dp.children().length, 3, "Structure multi [2] - child count" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2] - first month division" );
|
2012-12-11 15:06:13 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2] - second month division" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 2 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2] - row break" );
|
|
|
|
assert.ok( dp.is( ".ui-datepicker-multi-2" ), "Structure multi [2] - multi-2" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
2012-12-11 15:06:13 +00:00
|
|
|
step4();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2012-12-11 15:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function step4() {
|
2015-08-24 13:00:11 +00:00
|
|
|
|
2012-12-11 15:06:13 +00:00
|
|
|
// Multi-month 3
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.initNewInput( { numberOfMonths: 3 } );
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( dp.is( ".ui-datepicker-multi-3" ), "Structure multi [3] - multi-3" );
|
|
|
|
assert.ok( !dp.is( ".ui-datepicker-multi-2" ), "Structure multi [3] - Trac #6704" );
|
2012-12-11 15:06:13 +00:00
|
|
|
|
2013-04-14 21:07:24 +00:00
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
2012-12-11 15:06:13 +00:00
|
|
|
step5();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2012-12-11 15:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function step5() {
|
2015-08-24 13:00:11 +00:00
|
|
|
|
2012-12-11 15:06:13 +00:00
|
|
|
// Multi-month [2, 2]
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.initNewInput( { numberOfMonths: [ 2, 2 ] } );
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( dp.is( ".ui-datepicker-multi" ), "Structure multi - multi-month" );
|
|
|
|
assert.equal( dp.children().length, 6, "Structure multi [2,2] - child count" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - first month division" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - second month division" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 2 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 3 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure multi [2,2] - third month division" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 4 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure multi [2,2] - fourth month division" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 5 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure multi [2,2] - row break" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
2012-12-11 15:06:13 +00:00
|
|
|
|
|
|
|
// Inline
|
2015-04-07 14:30:07 +00:00
|
|
|
inl = testHelper.init( "#inl" );
|
2012-12-11 15:06:13 +00:00
|
|
|
dp = inl.children();
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( dp.is( ".ui-datepicker-inline" ), "Structure inline - main div" );
|
|
|
|
assert.ok( !dp.is( ".ui-datepicker-rtl" ), "Structure inline - not right-to-left" );
|
|
|
|
assert.ok( !dp.is( ".ui-datepicker-multi" ), "Structure inline - not multi-month" );
|
|
|
|
assert.equal( dp.children().length, 2, "Structure inline - child count" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
header = dp.children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure inline - header division" );
|
|
|
|
assert.equal( header.children().length, 3, "Structure inline - header child count" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
table = dp.children().eq( 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( table.is( "table.ui-datepicker-calendar" ), "Structure inline - month table" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( table.children().first().is( "thead" ), "Structure inline - month table thead" );
|
|
|
|
assert.ok( table.children().eq( 1 ).is( "tbody" ), "Structure inline - month table body" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inl.datepicker( "destroy" );
|
2012-12-11 15:06:13 +00:00
|
|
|
|
|
|
|
// Inline multi-month
|
2015-04-07 14:30:07 +00:00
|
|
|
inl = testHelper.init( "#inl", { numberOfMonths: 2 } );
|
2012-12-11 15:06:13 +00:00
|
|
|
dp = inl.children();
|
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( dp.is( ".ui-datepicker-inline" ) && dp.is( ".ui-datepicker-multi" ), "Structure inline multi - main div" );
|
|
|
|
assert.equal( dp.children().length, 3, "Structure inline multi - child count" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-first" ), "Structure inline multi - first month division" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-group" ) && child.is( "div.ui-datepicker-group-last" ), "Structure inline multi - second month division" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
child = dp.children().eq( 2 );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( child.is( "div.ui-datepicker-row-break" ), "Structure inline multi - row break" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inl.datepicker( "destroy" );
|
2016-04-03 15:11:33 +00:00
|
|
|
ready();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2012-12-11 15:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
step1();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2009-02-04 04:27:14 +00:00
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
QUnit.test( "customStructure", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 20 );
|
2012-10-26 19:59:29 +00:00
|
|
|
var header, panel, title, thead,
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.initNewInput( $.datepicker.regional.he ),
|
2013-04-14 21:07:24 +00:00
|
|
|
dp = $( "#ui-datepicker-div" );
|
|
|
|
|
|
|
|
function step1() {
|
|
|
|
inp.datepicker( "option", "showButtonPanel", true );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( dp.is( ".ui-datepicker-rtl" ), "Structure RTL - right-to-left" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
header = dp.children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure RTL - header division" );
|
|
|
|
assert.equal( header.children().length, 3, "Structure RTL - header child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( header.children().first().is( "a.ui-datepicker-next" ), "Structure RTL - prev link" );
|
|
|
|
assert.ok( header.children().eq( 1 ).is( "a.ui-datepicker-prev" ), "Structure RTL - next link" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
panel = dp.children().last();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( panel.is( "div.ui-datepicker-buttonpane" ), "Structure RTL - button division" );
|
|
|
|
assert.equal( panel.children().length, 2, "Structure RTL - button panel child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( panel.children().first().is( "button.ui-datepicker-close" ), "Structure RTL - close button" );
|
|
|
|
assert.ok( panel.children().last().is( "button.ui-datepicker-current" ), "Structure RTL - today button" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
|
|
|
step2();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2013-04-14 21:07:24 +00:00
|
|
|
}
|
2009-02-04 04:27:14 +00:00
|
|
|
|
|
|
|
// Hide prev/next
|
2013-04-14 21:07:24 +00:00
|
|
|
function step2() {
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.initNewInput( {
|
2013-04-14 21:07:24 +00:00
|
|
|
hideIfNoPrevNext: true,
|
|
|
|
minDate: new Date( 2008, 2 - 1, 4 ),
|
|
|
|
maxDate: new Date( 2008, 2 - 1, 14 )
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2013-04-14 21:07:24 +00:00
|
|
|
inp.val( "02/10/2008" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2020-01-22 15:44:34 +00:00
|
|
|
header = dp.children().first();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( header.is( "div.ui-datepicker-header" ), "Structure hide prev/next - header division" );
|
|
|
|
assert.equal( header.children().length, 1, "Structure hide prev/next - links child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( header.children().first().is( "div.ui-datepicker-title" ), "Structure hide prev/next - title division" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
|
|
|
step3();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2013-04-14 21:07:24 +00:00
|
|
|
}
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Changeable Month with read-only year
|
2013-04-14 21:07:24 +00:00
|
|
|
function step3() {
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.initNewInput( { changeMonth: true } );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2020-01-22 15:44:34 +00:00
|
|
|
title = dp.children().first().children().last();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.equal( title.children().length, 2, "Structure changeable month - title child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( title.children().first().is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" );
|
|
|
|
assert.ok( title.children().last().is( "span.ui-datepicker-year" ), "Structure changeable month - read-only year" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
|
|
|
step4();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2013-04-14 21:07:24 +00:00
|
|
|
}
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Changeable year with read-only month
|
2013-04-14 21:07:24 +00:00
|
|
|
function step4() {
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.initNewInput( { changeYear: true } );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2020-01-22 15:44:34 +00:00
|
|
|
title = dp.children().first().children().last();
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.equal( title.children().length, 2, "Structure changeable year - title child count" );
|
2020-01-22 15:44:34 +00:00
|
|
|
assert.ok( title.children().first().is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" );
|
|
|
|
assert.ok( title.children().last().is( "select.ui-datepicker-year" ), "Structure changeable year - year selector" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
|
|
|
step5();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2013-04-14 21:07:24 +00:00
|
|
|
}
|
2009-02-04 04:27:14 +00:00
|
|
|
|
|
|
|
// Read-only first day of week
|
2013-04-14 21:07:24 +00:00
|
|
|
function step5() {
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.initNewInput( { changeFirstDay: false } );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2013-04-14 21:07:24 +00:00
|
|
|
thead = dp.find( ".ui-datepicker-calendar thead tr" );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.equal( thead.children().length, 7, "Structure read-only first day - thead child count" );
|
|
|
|
assert.equal( thead.find( "a" ).length, 0, "Structure read-only first day - thead links count" );
|
2013-04-14 21:07:24 +00:00
|
|
|
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
2016-04-03 15:11:33 +00:00
|
|
|
ready();
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2013-04-14 21:07:24 +00:00
|
|
|
}
|
|
|
|
|
2013-04-14 22:47:29 +00:00
|
|
|
// TODO: figure out why this setTimeout is needed in IE,
|
|
|
|
// it only is necessary when the previous baseStructure tests runs first
|
|
|
|
// Support: IE
|
|
|
|
setTimeout( step1 );
|
2015-08-24 13:00:11 +00:00
|
|
|
} );
|
2009-02-04 04:27:14 +00:00
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
QUnit.test( "keystrokes", function( assert ) {
|
|
|
|
assert.expect( 26 );
|
2015-08-24 13:00:11 +00:00
|
|
|
var inp = testHelper.init( "#inp" ),
|
2012-04-19 15:17:35 +00:00
|
|
|
date = new Date();
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke enter" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke enter - preset" );
|
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.HOME } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+home" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.END } );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( inp.datepicker( "getDate" ) == null, "Keystroke ctrl+end" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( inp.datepicker( "getDate" ) == null, "Keystroke esc" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"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 } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke esc - abandoned" );
|
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Moving by day or week
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.LEFT } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
date.setDate( date.getDate() - 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+left" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
date.setDate( date.getDate() + 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke left" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.RIGHT } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
date.setDate( date.getDate() + 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+right" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
date.setDate( date.getDate() - 1 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke right" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.UP } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
date.setDate( date.getDate() - 7 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+up" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.UP } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
date.setDate( date.getDate() + 7 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke up" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.DOWN } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
date.setDate( date.getDate() + 7 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke ctrl+down" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
date.setDate( date.getDate() - 7 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Keystroke down" );
|
2015-08-24 13:00:11 +00:00
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Moving by month or year
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 1 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke pgup" );
|
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 3 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke pgdn" );
|
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2007, 2 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"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 } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2009, 2 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke ctrl+pgdn" );
|
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Check for moving to short months
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "03/31/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 29 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke pgup - Feb" );
|
|
|
|
inp.val( "01/30/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 29 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"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 } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2007, 2 - 1, 28 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"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 } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2009, 2 - 1, 28 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke ctrl+pgdn - Feb" );
|
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Goto current
|
2015-08-24 13:00:11 +00:00
|
|
|
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 } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke ctrl+home" );
|
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Change steps
|
2015-08-24 13:00:11 +00:00
|
|
|
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 } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2007, 12 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke pgup step 2" );
|
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ).
|
|
|
|
simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 4 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Keystroke pgdn step 2" );
|
|
|
|
} );
|
|
|
|
|
2016-04-03 15:11:33 +00:00
|
|
|
QUnit.test( "mouse", function( assert ) {
|
|
|
|
assert.expect( 15 );
|
2012-04-19 15:17:35 +00:00
|
|
|
var inl,
|
2015-08-24 13:00:11 +00:00
|
|
|
inp = testHelper.init( "#inp" ),
|
|
|
|
dp = $( "#ui-datepicker-div" ),
|
2012-04-19 15:17:35 +00:00
|
|
|
date = new Date();
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "" ).datepicker( "show" );
|
|
|
|
$( ".ui-datepicker-calendar tbody a:contains(10)", dp ).simulate( "click", {} );
|
|
|
|
date.setDate( 10 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Mouse click" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" );
|
|
|
|
$( ".ui-datepicker-calendar tbody a:contains(12)", dp ).simulate( "click", {} );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 12 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Mouse click - preset" );
|
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" );
|
|
|
|
inp.val( "" ).datepicker( "show" );
|
|
|
|
$( "button.ui-datepicker-close", dp ).simulate( "click", {} );
|
2016-04-03 15:11:33 +00:00
|
|
|
assert.ok( inp.datepicker( "getDate" ) == null, "Mouse click - close" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" );
|
|
|
|
$( "button.ui-datepicker-close", dp ).simulate( "click", {} );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"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", {} );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 4 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Mouse click - abandoned" );
|
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Current/previous/next
|
2015-08-24 13:00:11 +00:00
|
|
|
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 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), date, "Mouse click - current" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inp.val( "02/04/2008" ).datepicker( "show" );
|
|
|
|
$( ".ui-datepicker-prev", dp ).simulate( "click" );
|
|
|
|
$( ".ui-datepicker-calendar tbody a:contains(16)", dp ).simulate( "click" );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 1 - 1, 16 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"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" );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 3 - 1, 18 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Mouse click - next" );
|
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Previous/next with minimum/maximum
|
2015-08-24 13:00:11 +00:00
|
|
|
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" );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 16 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"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" );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inp.datepicker( "getDate" ), new Date( 2008, 2 - 1, 18 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Mouse click - next + min/max" );
|
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
// Inline
|
2015-08-24 13:00:11 +00:00
|
|
|
inl = testHelper.init( "#inl" );
|
|
|
|
dp = $( ".ui-datepicker-inline", inl );
|
2012-04-19 15:17:35 +00:00
|
|
|
date = new Date();
|
2015-08-24 13:00:11 +00:00
|
|
|
inl.datepicker( "setDate", date );
|
|
|
|
$( ".ui-datepicker-calendar tbody a:contains(10)", dp ).simulate( "click", {} );
|
|
|
|
date.setDate( 10 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date, "Mouse click inline" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inl.datepicker( "option", { showButtonPanel: true } ).datepicker( "setDate", new Date( 2008, 2 - 1, 4 ) );
|
|
|
|
$( ".ui-datepicker-calendar tbody a:contains(12)", dp ).simulate( "click", {} );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inl.datepicker( "getDate" ), new Date( 2008, 2 - 1, 12 ), "Mouse click inline - preset" );
|
2015-08-24 13:00:11 +00:00
|
|
|
inl.datepicker( "option", { showButtonPanel: true } );
|
|
|
|
$( ".ui-datepicker-current", dp ).simulate( "click", {} );
|
|
|
|
$( ".ui-datepicker-calendar tbody a:contains(14)", dp ).simulate( "click", {} );
|
|
|
|
date.setDate( 14 );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inl.datepicker( "getDate" ), date, "Mouse click inline - current" );
|
2015-08-24 13:00:11 +00:00
|
|
|
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" );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inl.datepicker( "getDate" ), new Date( 2008, 1 - 1, 16 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"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" );
|
2016-04-03 15:11:33 +00:00
|
|
|
testHelper.equalsDate( assert, inl.datepicker( "getDate" ), new Date( 2008, 3 - 1, 18 ),
|
2015-08-24 13:00:11 +00:00
|
|
|
"Mouse click inline - next" );
|
|
|
|
} );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2015-04-07 00:06:31 +00:00
|
|
|
} );
|