ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared');\r
ok(!$.data(inp[0], PROP_NAME), 'Both - instance absent');\r
ok(inp.next().is('#alt'), 'Both - button and append text absent');\r
+ // Inline\r
+ var inl = init('#inl');\r
+ ok(inl.is('.hasDatepicker'), 'Inline - marker class set');\r
+ ok(inl.html() != '', 'Inline - datepicker present');\r
+ ok($.data(inl[0], PROP_NAME), 'Inline - instance present');\r
+ ok(inl.next().length == 0 || inl.next().is('p'), 'Inline - button absent');\r
+ inl.datepicker('destroy');\r
+ inl = $('#inl');\r
+ ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared');\r
+ ok(inl.html() == '', 'Inline - datepicker absent');\r
+ ok(!$.data(inl[0], PROP_NAME), 'Inline - instance absent');\r
+ ok(inl.next().length == 0 || inl.next().is('p'), 'Inline - button absent');\r
});\r
\r
test('change', function() {\r
ok(month.is('div.ui-datepicker-one-month') && !month.is('div.ui-datepicker-new-row'),\r
'Structure multi - fourth month division');\r
inp.datepicker('hide').datepicker('destroy');\r
+ // Inline\r
+ var inl = init('#inl');\r
+ dp = inl.children();\r
+ ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');\r
+ ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');\r
+ ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month');\r
+ equals(dp.children().length, 3, 'Structure inline - child count');\r
+ var links = dp.children(':first');\r
+ ok(links.is('div.ui-datepicker-links'), 'Structure inline - links division');\r
+ equals(links.children().length, 3, 'Structure inline - links child count');\r
+ var month = dp.children(':eq(1)');\r
+ ok(month.is('div.ui-datepicker-one-month') && month.is('div.ui-datepicker-new-row'),\r
+ 'Structure inline - month division');\r
+ var header = month.children(':first');\r
+ ok(header.is('div.ui-datepicker-header'), 'Structure inline - month header division');\r
+ equals(header.children().length, 2, 'Structure inline - month header child count');\r
+ var table = month.children(':eq(1)');\r
+ ok(table.is('table.ui-datepicker'), 'Structure inline - month table');\r
+ ok(table.children(':first').is('thead'), 'Structure inline - month table thead');\r
+ ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body');\r
+ ok(dp.children('.ui-datepicker-status').length == 0, 'Structure inline - status');\r
+ inl.datepicker('destroy');\r
+ // Inline multi-month\r
+ inl = init('#inl', {numberOfMonths: 2});\r
+ dp = inl.children();\r
+ ok(dp.is('.ui-datepicker-inline'), 'Structure inline multi - main div');\r
+ ok(dp.is('.ui-datepicker-multi'), 'Structure inline multi - not multi-month');\r
+ equals(dp.children().length, 4, 'Structure inline multi - child count');\r
+ var links = dp.children(':first');\r
+ ok(links.is('div.ui-datepicker-links'), 'Structure inline multi - links division');\r
+ equals(links.children().length, 3, 'Structure inline multi - links child count');\r
+ var month = dp.children(':eq(1)');\r
+ ok(month.is('div.ui-datepicker-one-month') && month.is('div.ui-datepicker-new-row'),\r
+ 'Structure inline multi - first month division');\r
+ month = dp.children(':eq(2)');\r
+ ok(month.is('div.ui-datepicker-one-month') && !month.is('div.ui-datepicker-new-row'),\r
+ 'Structure inline multi - second month division');\r
+ inl.datepicker('destroy');\r
});\r
\r
test('customStructure', function() {\r
ok(dp.children(':last').prev().is('div.ui-datepicker-status'),\r
'Structure show status - status division');\r
inp.datepicker('hide').datepicker('destroy');\r
+ // Inline\r
+ var inl = init('#inl', {showStatus: true, hideIfNoPrevNext: true,\r
+ minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});\r
+ dp = inl.children();\r
+ ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');\r
+ ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');\r
+ ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month');\r
+ equals(dp.children().length, 5, 'Structure inline - child count');\r
+ var links = dp.children(':first');\r
+ ok(links.is('div.ui-datepicker-links'), 'Structure inline - links division');\r
+ equals(links.children().children().length, 0, 'Structure inline - links child count');\r
+ var month = dp.children(':eq(1)');\r
+ ok(month.is('div.ui-datepicker-one-month') && month.is('div.ui-datepicker-new-row'),\r
+ 'Structure inline - month division');\r
+ ok(dp.children(':last').prev().is('div.ui-datepicker-status'),\r
+ 'Structure inline - status');\r
+ inl.datepicker('destroy');\r
});\r
\r
test('enableDisable', function() {\r
$('.ui-datepicker tr:eq(2) td:first', dp).simulate('mouseover', {});\r
ok($('.ui-datepicker tr:eq(2)', dp).is('.ui-datepicker-week-over'),\r
'Mouse over - week highlight');\r
+ // Inline\r
+ var inl = init('#inl');\r
+ var dp = $('.ui-datepicker-inline', inl);\r
+ var date = new Date();\r
+ inl.datepicker('setDate', date);\r
+ $('.ui-datepicker tbody a:contains(10)', dp).simulate('click', {});\r
+ date.setDate(10);\r
+ equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline');\r
+ inl.datepicker('setDate', new Date(2008, 2 - 1, 4));\r
+ $('.ui-datepicker tbody a:contains(12)', dp).simulate('click', {});\r
+ equalsDate(inl.datepicker('getDate'), new Date(2008, 2 - 1, 12),\r
+ 'Mouse click inline - preset');\r
+ $('.ui-datepicker-current a', dp).simulate('click', {});\r
+ $('.ui-datepicker tbody a:contains(14)', dp).simulate('click', {});\r
+ date.setDate(14);\r
+ equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline - current');\r
+ inl.datepicker('setDate', new Date(2008, 2 - 1, 4));\r
+ $('.ui-datepicker-prev a', dp).simulate('click', {});\r
+ $('.ui-datepicker tbody a:contains(16)', dp).simulate('click', {});\r
+ equalsDate(inl.datepicker('getDate'), new Date(2008, 1 - 1, 16),\r
+ 'Mouse click inline - previous');\r
+ inl.datepicker('setDate', new Date(2008, 2 - 1, 4));\r
+ $('.ui-datepicker-next a', dp).simulate('click', {});\r
+ $('.ui-datepicker tbody a:contains(18)', dp).simulate('click', {});\r
+ equalsDate(inl.datepicker('getDate'), new Date(2008, 3 - 1, 18),\r
+ 'Mouse click inline - next');\r
});\r
\r
test('defaultDate', function() {\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), maxDate,\r
'Min/max - null, 12/07/2008 - ctrl+pgdn');\r
- // relative dates\r
+ // Relative dates\r
var date = new Date();\r
date.setDate(date.getDate() - 7);\r
inp.datepicker('change', {minDate: '-1w', maxDate: '+1 M +10 D '}).\r
var inp = init('#inp');\r
var date1 = new Date(2008, 6 - 1, 4);\r
var date2 = new Date();\r
+ ok(inp.datepicker('getDate') == null, 'Set date - default');\r
inp.datepicker('setDate', date1);\r
equalsDate(inp.datepicker('getDate'), date1, 'Set date - 2008-06-04');\r
date1 = new Date();\r
'Set date range - -2w');\r
inp.datepicker('setDate');\r
isObj(inp.datepicker('getDate'), [null, null], 'Set date range - null');\r
+ // Inline\r
+ var inl = init('#inl');\r
+ var date1 = new Date(2008, 6 - 1, 4);\r
+ var date2 = new Date();\r
+ equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - default');\r
+ inl.datepicker('setDate', date1);\r
+ equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - 2008-06-04');\r
+ date1 = new Date();\r
+ date1.setDate(date1.getDate() + 7);\r
+ inl.datepicker('setDate', +7);\r
+ equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - +7');\r
+ date2.setFullYear(date2.getFullYear() + 2);\r
+ inl.datepicker('setDate', '+2y');\r
+ equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - +2y');\r
+ inl.datepicker('setDate', date1, date2);\r
+ equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - two dates');\r
+ inl.datepicker('setDate');\r
+ ok(inl.datepicker('getDate') == null, 'Set date inline - null');\r
});\r
\r
test('ranges', function() {\r
equalsDateArray(inp.datepicker('getDate'),\r
[new Date(2008, 5 - 1, 28), new Date(2008, 6 - 1, 11)],\r
'Range min/max - ctrl+up/enter/ctrl+down/ctrl+down/enter');\r
+ // Inline\r
+ var inl = init('#inl', {rangeSelect: true});\r
+ var dp = $('.ui-datepicker-inline', inl);\r
+ date1 = new Date();\r
+ date1.setDate(12);\r
+ date2 = new Date();\r
+ date2.setDate(19);\r
+ $('.ui-datepicker tbody a:contains(12)', dp).simulate('click', {});\r
+ $('.ui-datepicker tbody a:contains(12)', dp).simulate('click', {});\r
+ equalsDateArray(inl.datepicker('getDate'), [date1, date1],\r
+ 'Range inline - same day');\r
+ $('.ui-datepicker tbody a:contains(12)', dp).simulate('click', {});\r
+ $('.ui-datepicker tbody a:contains(10)', dp).simulate('click', {}); // Doesn't select\r
+ equalsDateArray(inl.datepicker('getDate'), [date1, date1],\r
+ 'Range inline - prev');\r
+ $('.ui-datepicker tbody a:contains(12)', dp).simulate('click', {}); // Selects\r
+ inl.datepicker('setDate', date1);\r
+ $('.ui-datepicker tbody a:contains(12)', dp).simulate('click', {});\r
+ $('.ui-datepicker tbody a:contains(19)', dp).simulate('click', {});\r
+ equalsDateArray(inl.datepicker('getDate'), [date1, date2],\r
+ 'Range inline - next');\r
});\r
\r
test('altField', function() {\r