3 var debug = "[% debug | html %]";
4 var dformat = "[% dateformat | html %]";
6 if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
8 function Date_from_syspref(dstring) {
9 var dateX = dstring.split(/[-/.]/);
10 if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));}
11 if (dformat === "iso") {
12 return new Date(dateX[0], (dateX[1] - 1), dateX[2]); // YYYY-MM-DD to (YYYY,m(0-11),d)
13 } else if (dformat === "us") {
14 return new Date(dateX[2], (dateX[0] - 1), dateX[1]); // MM/DD/YYYY to (YYYY,m(0-11),d)
15 } else if (dformat === "metric") {
16 return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD/MM/YYYY to (YYYY,m(0-11),d)
17 } else if (dformat === "dmydot") {
18 return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD.MM.YYYY to (YYYY,m(0-11),d)
20 if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);}
25 /* Instead of including multiple localization files as you would normally see with
26 jQueryUI we expose the localization strings in the default configuration */
28 $.datepicker.regional[''] = {
32 currentText: _("Today"),
33 monthNames: [_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),
34 _("July"),_("August"),_("September"),_("October"),_("November"),_("December")],
35 monthNamesShort: [_("Jan"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"),
36 _("Jul"), _("Aug"), _("Sep"), _("Oct"), _("Nov"), _("Dec")],
37 dayNames: [_("Sunday"), _("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday")],
38 dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")],
39 dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
41 dateFormat: '[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSIF ( dateformat == "dmydot" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]',
42 firstDay: [% Koha.Preference('CalendarFirstDayOfWeek') | html %],
43 isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
44 showMonthAfterYear: false,
46 $.datepicker.setDefaults($.datepicker.regional['']);
49 $(document).ready(function(){
51 $.datepicker.setDefaults({
55 buttonImage: '[% interface | html %]/lib/famfamfam/calendar.png',
56 buttonImageOnly: true,
57 showButtonPanel: true,
58 showOtherMonths: true,
59 yearRange: "c-100:c+10"
62 $("#borrower_dateofbirth").datepicker({
66 $( ".datepicker" ).datepicker();
67 // http://jqueryui.com/demos/datepicker/#date-range
68 var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({
71 onSelect: function( selectedDate ) {
72 var option = this.id == "from" ? "minDate" : "maxDate",
73 instance = $( this ).data( "datepicker" );
74 date = $.datepicker.parseDate(
75 instance.settings.dateFormat ||
76 $.datepicker._defaults.dateFormat,
77 selectedDate, instance.settings );
78 dates.not( this ).datepicker( "option", option, date );
83 // jQuery Datepicker - a11y: Map arrow keys
84 var doKeyDown = $.datepicker._doKeyDown
85 $.extend($.datepicker, {
86 _doKeyDown: function(event) {
87 if (event.which === $.ui.keyCode.LEFT ||
88 event.which === $.ui.keyCode.RIGHT ||
89 event.which === $.ui.keyCode.UP ||
90 event.which === $.ui.keyCode.DOWN) {