2009-02-02 14:36:08 +00:00
|
|
|
|
/*
|
|
|
|
|
* datepicker_tickets.js
|
|
|
|
|
*/
|
|
|
|
|
(function($) {
|
|
|
|
|
|
2011-02-18 15:08:17 +00:00
|
|
|
|
module("datepicker: tickets");
|
2010-01-29 08:09:03 +00:00
|
|
|
|
|
|
|
|
|
// http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1
|
|
|
|
|
test('beforeShowDay-getDate', function() {
|
|
|
|
|
var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }});
|
|
|
|
|
var dp = $('#ui-datepicker-div');
|
|
|
|
|
inp.val('01/01/2010').datepicker('show');
|
2010-11-05 14:44:55 +00:00
|
|
|
|
// contains non-breaking space
|
|
|
|
|
equals($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month');
|
2010-01-29 08:09:03 +00:00
|
|
|
|
$('a.ui-datepicker-next', dp).click();
|
|
|
|
|
$('a.ui-datepicker-next', dp).click();
|
2010-11-05 14:44:55 +00:00
|
|
|
|
// contains non-breaking space
|
|
|
|
|
equals($('div.ui-datepicker-title').text(), 'March 2010', 'After next clicks');
|
2010-01-29 08:09:03 +00:00
|
|
|
|
inp.datepicker('hide').datepicker('show');
|
|
|
|
|
$('a.ui-datepicker-prev', dp).click();
|
|
|
|
|
$('a.ui-datepicker-prev', dp).click();
|
2010-11-05 14:44:55 +00:00
|
|
|
|
// contains non-breaking space
|
|
|
|
|
equals($('div.ui-datepicker-title').text(), 'November 2009', 'After prev clicks');
|
2010-01-29 08:09:03 +00:00
|
|
|
|
inp.datepicker('hide');
|
|
|
|
|
});
|
2009-02-02 14:36:08 +00:00
|
|
|
|
|
2011-08-09 13:55:50 +00:00
|
|
|
|
test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){
|
|
|
|
|
var inp = init('#inp',{
|
|
|
|
|
beforeShow: function(){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
var dp = $('#ui-datepicker-div');
|
|
|
|
|
inp.datepicker('show');
|
|
|
|
|
equals(dp.css('display'), 'none',"beforeShow returns false");
|
|
|
|
|
inp.datepicker('destroy');
|
|
|
|
|
|
|
|
|
|
inp = init('#inp',{
|
|
|
|
|
beforeShow: function(){
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dp = $('#ui-datepicker-div');
|
|
|
|
|
inp.datepicker('show');
|
|
|
|
|
equal(dp.css('display'), 'block',"beforeShow returns nothing");
|
|
|
|
|
inp.datepicker('hide');
|
|
|
|
|
inp.datepicker('destroy');
|
|
|
|
|
|
|
|
|
|
inp = init('#inp',{
|
|
|
|
|
beforeShow: function(){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dp = $('#ui-datepicker-div');
|
|
|
|
|
inp.datepicker('show');
|
|
|
|
|
equal(dp.css('display'), 'block',"beforeShow returns true");
|
|
|
|
|
inp.datepicker('hide');
|
|
|
|
|
inp.datepicker('destroy');
|
|
|
|
|
});
|
|
|
|
|
|
2011-05-14 22:20:06 +00:00
|
|
|
|
test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){
|
|
|
|
|
var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
|
|
|
|
|
equals(time, "089");
|
|
|
|
|
});
|
|
|
|
|
|
2011-05-18 15:30:26 +00:00
|
|
|
|
test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
|
2011-06-28 16:40:28 +00:00
|
|
|
|
var date;
|
2011-05-18 15:30:26 +00:00
|
|
|
|
try{
|
2011-06-28 16:40:28 +00:00
|
|
|
|
date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
|
|
|
|
|
ok(false, "Did not properly detect an invalid date");
|
2011-05-18 15:30:26 +00:00
|
|
|
|
}catch(e){
|
|
|
|
|
ok("invalid date detected");
|
|
|
|
|
}
|
2011-06-28 16:40:28 +00:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
date = $.datepicker.parseDate('dd/mm/yy', '18/04/1988 @ 2:43 pm');
|
|
|
|
|
equal(date.getDate(), 18);
|
|
|
|
|
equal(date.getMonth(), 3);
|
|
|
|
|
equal(date.getFullYear(), 1988);
|
|
|
|
|
} catch(e) {
|
|
|
|
|
ok(false, "Did not properly parse date with extra text separated by whitespace");
|
|
|
|
|
}
|
2011-05-18 15:30:26 +00:00
|
|
|
|
});
|
|
|
|
|
|
2009-02-02 14:36:08 +00:00
|
|
|
|
})(jQuery);
|