1 |
TestHelpers.datepicker = { |
2 |
addMonths: function(date, offset) { |
3 |
var maxDay = 32 - new Date(date.getFullYear(), date.getMonth() + offset, 32).getDate(); |
4 |
date.setDate(Math.min(date.getDate(), maxDay)); |
5 |
date.setMonth(date.getMonth() + offset); |
6 |
return date; |
7 |
}, |
8 |
equalsDate: function(d1, d2, message) { |
9 |
if (!d1 || !d2) { |
10 |
ok(false, message + " - missing date"); |
11 |
return; |
12 |
} |
13 |
d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate()); |
14 |
d2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate()); |
15 |
equal(d1.toString(), d2.toString(), message); |
16 |
}, |
17 |
init: function(id, options) { |
18 |
$.datepicker.setDefaults($.datepicker.regional[""]); |
19 |
return $(id).datepicker($.extend({showAnim: ""}, options || {})); |
20 |
}, |
21 |
onFocus: function( element, onFocus ) { |
22 |
var fn = function( event ){ |
23 |
if( !event.originalEvent ) { |
24 |
return; |
25 |
} |
26 |
element.unbind( "focus", fn ); |
27 |
onFocus(); |
28 |
}; |
29 |
|
30 |
element.bind( "focus", fn )[ 0 ].focus(); |
31 |
}, |
32 |
PROP_NAME: "datepicker" |
33 |
}; |