test('keystrokes', function() {\r
var inp = init('#inp');\r
var date = new Date();\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke enter');\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
'Keystroke enter - preset');\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_HOME}).\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_HOME}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+home');\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});\r
ok(inp.datepicker('getDate') == null, 'Keystroke ctrl+end');\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
ok(inp.datepicker('getDate') == null, 'Keystroke esc');\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
'Keystroke esc - preset');\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
'Keystroke esc - abandoned');\r
// Moving by day or week\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_LEFT}).\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_LEFT}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() - 1);\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+left');\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_LEFT}).\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_LEFT}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() + 1);\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke left');\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_RIGHT}).\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_RIGHT}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() + 1);\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+right');\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_RIGHT}).\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_RIGHT}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() - 1);\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke right');\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_UP}).\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_UP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() - 7);\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+up');\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_UP}).\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_UP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() + 7);\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke up');\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() + 7);\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+down');\r
- inp.val('').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_DOWN}).\r
+ inp.val('').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_DOWN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() - 7);\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke down');\r
// Moving by month or year\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 4),\r
'Keystroke pgup');\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 4),\r
'Keystroke pgdn');\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 4),\r
'Keystroke ctrl+pgup');\r
- inp.val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 4),\r
'Keystroke ctrl+pgdn');\r
// Check for moving to short months\r
- inp.val('03/31/2008').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
+ inp.val('03/31/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29),\r
'Keystroke pgup - Feb');\r
- inp.val('01/30/2008').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
+ inp.val('01/30/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29), \r
'Keystroke pgdn - Feb');\r
- inp.val('02/29/2008').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
+ inp.val('02/29/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 28),\r
'Keystroke ctrl+pgup - Feb');\r
- inp.val('02/29/2008').datepicker('show');\r
- inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
+ inp.val('02/29/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 28),\r
'Keystroke ctrl+pgdn - Feb');\r
// Goto current\r
- inp.datepicker('change', {gotoCurrent: true});\r
- inp.datepicker('hide').val('02/04/2008').datepicker('show');\r
- inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
+ inp.datepicker('change', {gotoCurrent: true}).\r
+ datepicker('hide').val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_HOME}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
'Keystroke ctrl+home');\r
+ // Change steps\r
+ inp.datepicker('change', {stepMonths: 2, stepBigMonths: 6, gotoCurrent: false}).\r
+ datepicker('hide').val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ equalsDate(inp.datepicker('getDate'), new Date(2007, 12 - 1, 4),\r
+ 'Keystroke pgup step 2');\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 4 - 1, 4),\r
+ 'Keystroke pgdn step 2');\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ equalsDate(inp.datepicker('getDate'), new Date(2007, 8 - 1, 4),\r
+ 'Keystroke ctrl+pgup step 6');\r
+ inp.val('02/04/2008').datepicker('show').\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 8 - 1, 4),\r
+ 'Keystroke ctrl+pgdn step 6');\r
});\r
\r
test('mouse', function() {\r
// Minimum/maximum\r
date1 = new Date(2008, 5 - 1, 20);\r
date2 = new Date(2008, 7 - 1, 2);\r
- inp.datepicker('change', {minDate: date1, maxDate: date2, onChangeMonthYear: null}).\r
+ inp.datepicker('change', {minDate: date1, maxDate: date2, onClose: null}).\r
datepicker('hide').val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN});\r
date.setFullYear(date.getFullYear() + 1);\r
equalsDate(selectedDate, date, 'Callback change month/year date - ctrl+pgdn');\r
+ inp.datepicker('setDate', new Date(2007, 1 - 1, 26));\r
+ equalsDate(selectedDate, new Date(2007, 1 - 1, 1),\r
+ 'Callback change month/year date - setDate');\r
+ selectedDate = null;\r
+ inp.datepicker('setDate', new Date(2007, 1 - 1, 12));\r
+ ok(selectedDate == null, 'Callback change month/year date - setDate no change');\r
// onChangeMonthYear step by 2\r
inp.datepicker('change', {stepMonths: 2}).\r
datepicker('hide').val('').datepicker('show');\r