changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
18:be944660c56a | 19:3d72ae0968f4 |
---|---|
1 // jscs:disable maximumLineLength |
1 /* eslint-disable max-len, camelcase */ |
2 /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */ |
|
3 /*! |
2 /*! |
4 * jQuery UI Datepicker 1.12.1 |
3 * jQuery UI Datepicker 1.13.1 |
5 * http://jqueryui.com |
4 * http://jqueryui.com |
6 * |
5 * |
7 * Copyright jQuery Foundation and other contributors |
6 * Copyright jQuery Foundation and other contributors |
8 * Released under the MIT license. |
7 * Released under the MIT license. |
9 * http://jquery.org/license |
8 * http://jquery.org/license |
17 //>>css.structure: ../../themes/base/core.css |
16 //>>css.structure: ../../themes/base/core.css |
18 //>>css.structure: ../../themes/base/datepicker.css |
17 //>>css.structure: ../../themes/base/datepicker.css |
19 //>>css.theme: ../../themes/base/theme.css |
18 //>>css.theme: ../../themes/base/theme.css |
20 |
19 |
21 ( function( factory ) { |
20 ( function( factory ) { |
21 "use strict"; |
|
22 |
|
22 if ( typeof define === "function" && define.amd ) { |
23 if ( typeof define === "function" && define.amd ) { |
23 |
24 |
24 // AMD. Register as an anonymous module. |
25 // AMD. Register as an anonymous module. |
25 define( [ |
26 define( [ |
26 "jquery", |
27 "jquery", |
29 } else { |
30 } else { |
30 |
31 |
31 // Browser globals |
32 // Browser globals |
32 factory( jQuery ); |
33 factory( jQuery ); |
33 } |
34 } |
34 }( function( $ ) { |
35 } )( function( $ ) { |
35 |
36 "use strict"; |
36 $.extend( $.ui, { datepicker: { version: "1.12.1" } } ); |
37 |
38 $.extend( $.ui, { datepicker: { version: "1.13.1" } } ); |
|
37 |
39 |
38 var datepicker_instActive; |
40 var datepicker_instActive; |
39 |
41 |
40 function datepicker_getZindex( elem ) { |
42 function datepicker_getZindex( elem ) { |
41 var position, value; |
43 var position, value; |
59 elem = elem.parent(); |
61 elem = elem.parent(); |
60 } |
62 } |
61 |
63 |
62 return 0; |
64 return 0; |
63 } |
65 } |
66 |
|
64 /* Date picker manager. |
67 /* Date picker manager. |
65 Use the singleton instance of this class, $.datepicker, to interact with the date picker. |
68 Use the singleton instance of this class, $.datepicker, to interact with the date picker. |
66 Settings for (groups of) date pickers are maintained in an instance object, |
69 Settings for (groups of) date pickers are maintained in an instance object, |
67 allowing multiple different settings on the same page. */ |
70 allowing multiple different settings on the same page. */ |
68 |
71 |
85 this.regional[ "" ] = { // Default regional settings |
88 this.regional[ "" ] = { // Default regional settings |
86 closeText: "Done", // Display text for close link |
89 closeText: "Done", // Display text for close link |
87 prevText: "Prev", // Display text for previous month link |
90 prevText: "Prev", // Display text for previous month link |
88 nextText: "Next", // Display text for next month link |
91 nextText: "Next", // Display text for next month link |
89 currentText: "Today", // Display text for current month link |
92 currentText: "Today", // Display text for current month link |
90 monthNames: [ "January","February","March","April","May","June", |
93 monthNames: [ "January", "February", "March", "April", "May", "June", |
91 "July","August","September","October","November","December" ], // Names of months for drop-down and formatting |
94 "July", "August", "September", "October", "November", "December" ], // Names of months for drop-down and formatting |
92 monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting |
95 monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting |
93 dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting |
96 dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting |
94 dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting |
97 dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting |
95 dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday |
98 dayNamesMin: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ], // Column headings for days starting at Sunday |
96 weekHeader: "Wk", // Column header for week of the year |
99 weekHeader: "Wk", // Column header for week of the year |
97 dateFormat: "mm/dd/yy", // See format options on parseDate |
100 dateFormat: "mm/dd/yy", // See format options on parseDate |
98 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... |
101 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... |
99 isRTL: false, // True if right-to-left language, false if left-to-right |
102 isRTL: false, // True if right-to-left language, false if left-to-right |
100 showMonthAfterYear: false, // True if the year select precedes month, false for month then year |
103 showMonthAfterYear: false, // True if the year select precedes month, false for month then year |
101 yearSuffix: "" // Additional text to append to the year in the month headers |
104 yearSuffix: "", // Additional text to append to the year in the month headers, |
105 selectMonthLabel: "Select month", // Invisible label for month selector |
|
106 selectYearLabel: "Select year" // Invisible label for year selector |
|
102 }; |
107 }; |
103 this._defaults = { // Global defaults for all the date picker instances |
108 this._defaults = { // Global defaults for all the date picker instances |
104 showOn: "focus", // "focus" for popup on focus, |
109 showOn: "focus", // "focus" for popup on focus, |
105 // "button" for trigger button, or "both" for either |
110 // "button" for trigger button, or "both" for either |
106 showAnim: "fadeIn", // Name of jQuery animation for popup |
111 showAnim: "fadeIn", // Name of jQuery animation for popup |
107 showOptions: {}, // Options for enhanced animations |
112 showOptions: {}, // Options for enhanced animations |
108 defaultDate: null, // Used when field is blank: actual date, |
113 defaultDate: null, // Used when field is blank: actual date, |
109 // +/-number for offset from today, null for today |
114 // +/-number for offset from today, null for today |
110 appendText: "", // Display text following the input box, e.g. showing the format |
115 appendText: "", // Display text following the input box, e.g. showing the format |
111 buttonText: "...", // Text for trigger button |
116 buttonText: "...", // Text for trigger button |
112 buttonImage: "", // URL for trigger button image |
117 buttonImage: "", // URL for trigger button image |
113 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button |
118 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button |
114 hideIfNoPrevNext: false, // True to hide next/previous month links |
119 hideIfNoPrevNext: false, // True to hide next/previous month links |
115 // if not applicable, false to just disable them |
120 // if not applicable, false to just disable them |
116 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links |
121 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links |
117 gotoCurrent: false, // True if today link goes back to current selection instead |
122 gotoCurrent: false, // True if today link goes back to current selection instead |
118 changeMonth: false, // True if month can be selected directly, false if only prev/next |
123 changeMonth: false, // True if month can be selected directly, false if only prev/next |
119 changeYear: false, // True if year can be selected directly, false if only prev/next |
124 changeYear: false, // True if year can be selected directly, false if only prev/next |
120 yearRange: "c-10:c+10", // Range of years to display in drop-down, |
125 yearRange: "c-10:c+10", // Range of years to display in drop-down, |
121 // either relative to today's year (-nn:+nn), relative to currently displayed year |
126 // either relative to today's year (-nn:+nn), relative to currently displayed year |
122 // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) |
127 // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) |
123 showOtherMonths: false, // True to show dates in other months, false to leave blank |
128 showOtherMonths: false, // True to show dates in other months, false to leave blank |
124 selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable |
129 selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable |
125 showWeek: false, // True to show week of the year, false to not show it |
130 showWeek: false, // True to show week of the year, false to not show it |
126 calculateWeek: this.iso8601Week, // How to calculate the week of the year, |
131 calculateWeek: this.iso8601Week, // How to calculate the week of the year, |
127 // takes a Date and returns the number of the week for it |
132 // takes a Date and returns the number of the week for it |
128 shortYearCutoff: "+10", // Short year values < this are in the current century, |
133 shortYearCutoff: "+10", // Short year values < this are in the current century, |
129 // > this are in the previous century, |
134 // > this are in the previous century, |
130 // string value starting with "+" for current year + value |
135 // string value starting with "+" for current year + value |
131 minDate: null, // The earliest selectable date, or null for no limit |
136 minDate: null, // The earliest selectable date, or null for no limit |
132 maxDate: null, // The latest selectable date, or null for no limit |
137 maxDate: null, // The latest selectable date, or null for no limit |
133 duration: "fast", // Duration of display/closure |
138 duration: "fast", // Duration of display/closure |
134 beforeShowDay: null, // Function that takes a date and returns an array with |
139 beforeShowDay: null, // Function that takes a date and returns an array with |
135 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "", |
140 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "", |
136 // [2] = cell title (optional), e.g. $.datepicker.noWeekends |
141 // [2] = cell title (optional), e.g. $.datepicker.noWeekends |
137 beforeShow: null, // Function that takes an input field and |
142 beforeShow: null, // Function that takes an input field and |
138 // returns a set of custom settings for the date picker |
143 // returns a set of custom settings for the date picker |
139 onSelect: null, // Define a callback function when a date is selected |
144 onSelect: null, // Define a callback function when a date is selected |
140 onChangeMonthYear: null, // Define a callback function when the month or year is changed |
145 onChangeMonthYear: null, // Define a callback function when the month or year is changed |
141 onClose: null, // Define a callback function when the datepicker is closed |
146 onClose: null, // Define a callback function when the datepicker is closed |
147 onUpdateDatepicker: null, // Define a callback function when the datepicker is updated |
|
142 numberOfMonths: 1, // Number of months to show at a time |
148 numberOfMonths: 1, // Number of months to show at a time |
143 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) |
149 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) |
144 stepMonths: 1, // Number of months to step back/forward |
150 stepMonths: 1, // Number of months to step back/forward |
145 stepBigMonths: 12, // Number of months to step back/forward for the big links |
151 stepBigMonths: 12, // Number of months to step back/forward for the big links |
146 altField: "", // Selector for an alternate field to store selected dates into |
152 altField: "", // Selector for an alternate field to store selected dates into |
155 this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en ); |
161 this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en ); |
156 this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ); |
162 this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ); |
157 } |
163 } |
158 |
164 |
159 $.extend( Datepicker.prototype, { |
165 $.extend( Datepicker.prototype, { |
166 |
|
160 /* Class name added to elements to indicate already configured with a date picker. */ |
167 /* Class name added to elements to indicate already configured with a date picker. */ |
161 markerClassName: "hasDatepicker", |
168 markerClassName: "hasDatepicker", |
162 |
169 |
163 //Keep track of the maximum number of rows displayed (see #7043) |
170 //Keep track of the maximum number of rows displayed (see #7043) |
164 maxRows: 4, |
171 maxRows: 4, |
204 return { id: id, input: target, // associated target |
211 return { id: id, input: target, // associated target |
205 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection |
212 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection |
206 drawMonth: 0, drawYear: 0, // month being drawn |
213 drawMonth: 0, drawYear: 0, // month being drawn |
207 inline: inline, // is datepicker inline or not |
214 inline: inline, // is datepicker inline or not |
208 dpDiv: ( !inline ? this.dpDiv : // presentation div |
215 dpDiv: ( !inline ? this.dpDiv : // presentation div |
209 datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) }; |
216 datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) }; |
210 }, |
217 }, |
211 |
218 |
212 /* Attach the date picker to an input field. */ |
219 /* Attach the date picker to an input field. */ |
213 _connectDatepicker: function( target, inst ) { |
220 _connectDatepicker: function( target, inst ) { |
214 var input = $( target ); |
221 var input = $( target ); |
217 if ( input.hasClass( this.markerClassName ) ) { |
224 if ( input.hasClass( this.markerClassName ) ) { |
218 return; |
225 return; |
219 } |
226 } |
220 this._attachments( input, inst ); |
227 this._attachments( input, inst ); |
221 input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ). |
228 input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ). |
222 on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp ); |
229 on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp ); |
223 this._autoSize( inst ); |
230 this._autoSize( inst ); |
224 $.data( target, "datepicker", inst ); |
231 $.data( target, "datepicker", inst ); |
225 |
232 |
226 //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) |
233 //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) |
227 if ( inst.settings.disabled ) { |
234 if ( inst.settings.disabled ) { |
237 |
244 |
238 if ( inst.append ) { |
245 if ( inst.append ) { |
239 inst.append.remove(); |
246 inst.append.remove(); |
240 } |
247 } |
241 if ( appendText ) { |
248 if ( appendText ) { |
242 inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" ); |
249 inst.append = $( "<span>" ) |
250 .addClass( this._appendClass ) |
|
251 .text( appendText ); |
|
243 input[ isRTL ? "before" : "after" ]( inst.append ); |
252 input[ isRTL ? "before" : "after" ]( inst.append ); |
244 } |
253 } |
245 |
254 |
246 input.off( "focus", this._showDatepicker ); |
255 input.off( "focus", this._showDatepicker ); |
247 |
256 |
254 input.on( "focus", this._showDatepicker ); |
263 input.on( "focus", this._showDatepicker ); |
255 } |
264 } |
256 if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked |
265 if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked |
257 buttonText = this._get( inst, "buttonText" ); |
266 buttonText = this._get( inst, "buttonText" ); |
258 buttonImage = this._get( inst, "buttonImage" ); |
267 buttonImage = this._get( inst, "buttonImage" ); |
259 inst.trigger = $( this._get( inst, "buttonImageOnly" ) ? |
268 |
260 $( "<img/>" ).addClass( this._triggerClass ). |
269 if ( this._get( inst, "buttonImageOnly" ) ) { |
261 attr( { src: buttonImage, alt: buttonText, title: buttonText } ) : |
270 inst.trigger = $( "<img>" ) |
262 $( "<button type='button'></button>" ).addClass( this._triggerClass ). |
271 .addClass( this._triggerClass ) |
263 html( !buttonImage ? buttonText : $( "<img/>" ).attr( |
272 .attr( { |
264 { src:buttonImage, alt:buttonText, title:buttonText } ) ) ); |
273 src: buttonImage, |
274 alt: buttonText, |
|
275 title: buttonText |
|
276 } ); |
|
277 } else { |
|
278 inst.trigger = $( "<button type='button'>" ) |
|
279 .addClass( this._triggerClass ); |
|
280 if ( buttonImage ) { |
|
281 inst.trigger.html( |
|
282 $( "<img>" ) |
|
283 .attr( { |
|
284 src: buttonImage, |
|
285 alt: buttonText, |
|
286 title: buttonText |
|
287 } ) |
|
288 ); |
|
289 } else { |
|
290 inst.trigger.text( buttonText ); |
|
291 } |
|
292 } |
|
293 |
|
265 input[ isRTL ? "before" : "after" ]( inst.trigger ); |
294 input[ isRTL ? "before" : "after" ]( inst.trigger ); |
266 inst.trigger.on( "click", function() { |
295 inst.trigger.on( "click", function() { |
267 if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) { |
296 if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) { |
268 $.datepicker._hideDatepicker(); |
297 $.datepicker._hideDatepicker(); |
269 } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) { |
298 } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) { |
395 $.removeData( target, "datepicker" ); |
424 $.removeData( target, "datepicker" ); |
396 if ( nodeName === "input" ) { |
425 if ( nodeName === "input" ) { |
397 inst.append.remove(); |
426 inst.append.remove(); |
398 inst.trigger.remove(); |
427 inst.trigger.remove(); |
399 $target.removeClass( this.markerClassName ). |
428 $target.removeClass( this.markerClassName ). |
400 off( "focus", this._showDatepicker ). |
429 off( "focus", this._showDatepicker ). |
401 off( "keydown", this._doKeyDown ). |
430 off( "keydown", this._doKeyDown ). |
402 off( "keypress", this._doKeyPress ). |
431 off( "keypress", this._doKeyPress ). |
403 off( "keyup", this._doKeyUp ); |
432 off( "keyup", this._doKeyUp ); |
404 } else if ( nodeName === "div" || nodeName === "span" ) { |
433 } else if ( nodeName === "div" || nodeName === "span" ) { |
405 $target.removeClass( this.markerClassName ).empty(); |
434 $target.removeClass( this.markerClassName ).empty(); |
406 } |
435 } |
407 |
436 |
408 if ( datepicker_instActive === inst ) { |
437 if ( datepicker_instActive === inst ) { |
409 datepicker_instActive = null; |
438 datepicker_instActive = null; |
439 this._curInst = null; |
|
410 } |
440 } |
411 }, |
441 }, |
412 |
442 |
413 /* Enable the date picker to a jQuery selection. |
443 /* Enable the date picker to a jQuery selection. |
414 * @param target element - the target input field or division or span |
444 * @param target element - the target input field or division or span |
424 |
454 |
425 nodeName = target.nodeName.toLowerCase(); |
455 nodeName = target.nodeName.toLowerCase(); |
426 if ( nodeName === "input" ) { |
456 if ( nodeName === "input" ) { |
427 target.disabled = false; |
457 target.disabled = false; |
428 inst.trigger.filter( "button" ). |
458 inst.trigger.filter( "button" ). |
429 each( function() { this.disabled = false; } ).end(). |
459 each( function() { |
430 filter( "img" ).css( { opacity: "1.0", cursor: "" } ); |
460 this.disabled = false; |
461 } ).end(). |
|
462 filter( "img" ).css( { opacity: "1.0", cursor: "" } ); |
|
431 } else if ( nodeName === "div" || nodeName === "span" ) { |
463 } else if ( nodeName === "div" || nodeName === "span" ) { |
432 inline = $target.children( "." + this._inlineClass ); |
464 inline = $target.children( "." + this._inlineClass ); |
433 inline.children().removeClass( "ui-state-disabled" ); |
465 inline.children().removeClass( "ui-state-disabled" ); |
434 inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ). |
466 inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ). |
435 prop( "disabled", false ); |
467 prop( "disabled", false ); |
436 } |
468 } |
437 this._disabledInputs = $.map( this._disabledInputs, |
469 this._disabledInputs = $.map( this._disabledInputs, |
438 function( value ) { return ( value === target ? null : value ); } ); // delete entry |
470 |
471 // Delete entry |
|
472 function( value ) { |
|
473 return ( value === target ? null : value ); |
|
474 } ); |
|
439 }, |
475 }, |
440 |
476 |
441 /* Disable the date picker to a jQuery selection. |
477 /* Disable the date picker to a jQuery selection. |
442 * @param target element - the target input field or division or span |
478 * @param target element - the target input field or division or span |
443 */ |
479 */ |
452 |
488 |
453 nodeName = target.nodeName.toLowerCase(); |
489 nodeName = target.nodeName.toLowerCase(); |
454 if ( nodeName === "input" ) { |
490 if ( nodeName === "input" ) { |
455 target.disabled = true; |
491 target.disabled = true; |
456 inst.trigger.filter( "button" ). |
492 inst.trigger.filter( "button" ). |
457 each( function() { this.disabled = true; } ).end(). |
493 each( function() { |
458 filter( "img" ).css( { opacity: "0.5", cursor: "default" } ); |
494 this.disabled = true; |
495 } ).end(). |
|
496 filter( "img" ).css( { opacity: "0.5", cursor: "default" } ); |
|
459 } else if ( nodeName === "div" || nodeName === "span" ) { |
497 } else if ( nodeName === "div" || nodeName === "span" ) { |
460 inline = $target.children( "." + this._inlineClass ); |
498 inline = $target.children( "." + this._inlineClass ); |
461 inline.children().addClass( "ui-state-disabled" ); |
499 inline.children().addClass( "ui-state-disabled" ); |
462 inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ). |
500 inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ). |
463 prop( "disabled", true ); |
501 prop( "disabled", true ); |
464 } |
502 } |
465 this._disabledInputs = $.map( this._disabledInputs, |
503 this._disabledInputs = $.map( this._disabledInputs, |
466 function( value ) { return ( value === target ? null : value ); } ); // delete entry |
504 |
505 // Delete entry |
|
506 function( value ) { |
|
507 return ( value === target ? null : value ); |
|
508 } ); |
|
467 this._disabledInputs[ this._disabledInputs.length ] = target; |
509 this._disabledInputs[ this._disabledInputs.length ] = target; |
468 }, |
510 }, |
469 |
511 |
470 /* Is the first field in a jQuery collection disabled as a datepicker? |
512 /* Is the first field in a jQuery collection disabled as a datepicker? |
471 * @param target element - the target input field or division or span |
513 * @param target element - the target input field or division or span |
489 * @throws error if a jQuery problem getting data |
531 * @throws error if a jQuery problem getting data |
490 */ |
532 */ |
491 _getInst: function( target ) { |
533 _getInst: function( target ) { |
492 try { |
534 try { |
493 return $.data( target, "datepicker" ); |
535 return $.data( target, "datepicker" ); |
494 } |
536 } catch ( err ) { |
495 catch ( err ) { |
|
496 throw "Missing instance data for this datepicker"; |
537 throw "Missing instance data for this datepicker"; |
497 } |
538 } |
498 }, |
539 }, |
499 |
540 |
500 /* Update or retrieve the settings for a date picker attached to an input field or division. |
541 /* Update or retrieve the settings for a date picker attached to an input field or division. |
511 inst = this._getInst( target ); |
552 inst = this._getInst( target ); |
512 |
553 |
513 if ( arguments.length === 2 && typeof name === "string" ) { |
554 if ( arguments.length === 2 && typeof name === "string" ) { |
514 return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) : |
555 return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) : |
515 ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) : |
556 ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) : |
516 this._get( inst, name ) ) : null ) ); |
557 this._get( inst, name ) ) : null ) ); |
517 } |
558 } |
518 |
559 |
519 settings = name || {}; |
560 settings = name || {}; |
520 if ( typeof name === "string" ) { |
561 if ( typeof name === "string" ) { |
521 settings = {}; |
562 settings = {}; |
604 |
645 |
605 inst._keyEvent = true; |
646 inst._keyEvent = true; |
606 if ( $.datepicker._datepickerShowing ) { |
647 if ( $.datepicker._datepickerShowing ) { |
607 switch ( event.keyCode ) { |
648 switch ( event.keyCode ) { |
608 case 9: $.datepicker._hideDatepicker(); |
649 case 9: $.datepicker._hideDatepicker(); |
609 handled = false; |
650 handled = false; |
610 break; // hide on tab out |
651 break; // hide on tab out |
611 case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." + |
652 case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." + |
612 $.datepicker._currentClass + ")", inst.dpDiv ); |
653 $.datepicker._currentClass + ")", inst.dpDiv ); |
613 if ( sel[ 0 ] ) { |
654 if ( sel[ 0 ] ) { |
614 $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] ); |
655 $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] ); |
615 } |
656 } |
616 |
657 |
617 onSelect = $.datepicker._get( inst, "onSelect" ); |
658 onSelect = $.datepicker._get( inst, "onSelect" ); |
618 if ( onSelect ) { |
659 if ( onSelect ) { |
619 dateStr = $.datepicker._formatDate( inst ); |
660 dateStr = $.datepicker._formatDate( inst ); |
620 |
661 |
621 // Trigger custom callback |
662 // Trigger custom callback |
622 onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); |
663 onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); |
623 } else { |
664 } else { |
624 $.datepicker._hideDatepicker(); |
665 $.datepicker._hideDatepicker(); |
625 } |
666 } |
626 |
667 |
627 return false; // don't submit the form |
668 return false; // don't submit the form |
628 case 27: $.datepicker._hideDatepicker(); |
669 case 27: $.datepicker._hideDatepicker(); |
629 break; // hide on escape |
670 break; // hide on escape |
630 case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ? |
671 case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ? |
672 -$.datepicker._get( inst, "stepBigMonths" ) : |
|
673 -$.datepicker._get( inst, "stepMonths" ) ), "M" ); |
|
674 break; // previous month/year on page up/+ ctrl |
|
675 case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ? |
|
676 +$.datepicker._get( inst, "stepBigMonths" ) : |
|
677 +$.datepicker._get( inst, "stepMonths" ) ), "M" ); |
|
678 break; // next month/year on page down/+ ctrl |
|
679 case 35: if ( event.ctrlKey || event.metaKey ) { |
|
680 $.datepicker._clearDate( event.target ); |
|
681 } |
|
682 handled = event.ctrlKey || event.metaKey; |
|
683 break; // clear on ctrl or command +end |
|
684 case 36: if ( event.ctrlKey || event.metaKey ) { |
|
685 $.datepicker._gotoToday( event.target ); |
|
686 } |
|
687 handled = event.ctrlKey || event.metaKey; |
|
688 break; // current on ctrl or command +home |
|
689 case 37: if ( event.ctrlKey || event.metaKey ) { |
|
690 $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" ); |
|
691 } |
|
692 handled = event.ctrlKey || event.metaKey; |
|
693 |
|
694 // -1 day on ctrl or command +left |
|
695 if ( event.originalEvent.altKey ) { |
|
696 $.datepicker._adjustDate( event.target, ( event.ctrlKey ? |
|
631 -$.datepicker._get( inst, "stepBigMonths" ) : |
697 -$.datepicker._get( inst, "stepBigMonths" ) : |
632 -$.datepicker._get( inst, "stepMonths" ) ), "M" ); |
698 -$.datepicker._get( inst, "stepMonths" ) ), "M" ); |
633 break; // previous month/year on page up/+ ctrl |
699 } |
634 case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ? |
700 |
701 // next month/year on alt +left on Mac |
|
702 break; |
|
703 case 38: if ( event.ctrlKey || event.metaKey ) { |
|
704 $.datepicker._adjustDate( event.target, -7, "D" ); |
|
705 } |
|
706 handled = event.ctrlKey || event.metaKey; |
|
707 break; // -1 week on ctrl or command +up |
|
708 case 39: if ( event.ctrlKey || event.metaKey ) { |
|
709 $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" ); |
|
710 } |
|
711 handled = event.ctrlKey || event.metaKey; |
|
712 |
|
713 // +1 day on ctrl or command +right |
|
714 if ( event.originalEvent.altKey ) { |
|
715 $.datepicker._adjustDate( event.target, ( event.ctrlKey ? |
|
635 +$.datepicker._get( inst, "stepBigMonths" ) : |
716 +$.datepicker._get( inst, "stepBigMonths" ) : |
636 +$.datepicker._get( inst, "stepMonths" ) ), "M" ); |
717 +$.datepicker._get( inst, "stepMonths" ) ), "M" ); |
637 break; // next month/year on page down/+ ctrl |
718 } |
638 case 35: if ( event.ctrlKey || event.metaKey ) { |
719 |
639 $.datepicker._clearDate( event.target ); |
720 // next month/year on alt +right |
640 } |
721 break; |
641 handled = event.ctrlKey || event.metaKey; |
|
642 break; // clear on ctrl or command +end |
|
643 case 36: if ( event.ctrlKey || event.metaKey ) { |
|
644 $.datepicker._gotoToday( event.target ); |
|
645 } |
|
646 handled = event.ctrlKey || event.metaKey; |
|
647 break; // current on ctrl or command +home |
|
648 case 37: if ( event.ctrlKey || event.metaKey ) { |
|
649 $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" ); |
|
650 } |
|
651 handled = event.ctrlKey || event.metaKey; |
|
652 |
|
653 // -1 day on ctrl or command +left |
|
654 if ( event.originalEvent.altKey ) { |
|
655 $.datepicker._adjustDate( event.target, ( event.ctrlKey ? |
|
656 -$.datepicker._get( inst, "stepBigMonths" ) : |
|
657 -$.datepicker._get( inst, "stepMonths" ) ), "M" ); |
|
658 } |
|
659 |
|
660 // next month/year on alt +left on Mac |
|
661 break; |
|
662 case 38: if ( event.ctrlKey || event.metaKey ) { |
|
663 $.datepicker._adjustDate( event.target, -7, "D" ); |
|
664 } |
|
665 handled = event.ctrlKey || event.metaKey; |
|
666 break; // -1 week on ctrl or command +up |
|
667 case 39: if ( event.ctrlKey || event.metaKey ) { |
|
668 $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" ); |
|
669 } |
|
670 handled = event.ctrlKey || event.metaKey; |
|
671 |
|
672 // +1 day on ctrl or command +right |
|
673 if ( event.originalEvent.altKey ) { |
|
674 $.datepicker._adjustDate( event.target, ( event.ctrlKey ? |
|
675 +$.datepicker._get( inst, "stepBigMonths" ) : |
|
676 +$.datepicker._get( inst, "stepMonths" ) ), "M" ); |
|
677 } |
|
678 |
|
679 // next month/year on alt +right |
|
680 break; |
|
681 case 40: if ( event.ctrlKey || event.metaKey ) { |
722 case 40: if ( event.ctrlKey || event.metaKey ) { |
682 $.datepicker._adjustDate( event.target, +7, "D" ); |
723 $.datepicker._adjustDate( event.target, +7, "D" ); |
683 } |
724 } |
684 handled = event.ctrlKey || event.metaKey; |
725 handled = event.ctrlKey || event.metaKey; |
685 break; // +1 week on ctrl or command +down |
726 break; // +1 week on ctrl or command +down |
686 default: handled = false; |
727 default: handled = false; |
687 } |
728 } |
688 } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home |
729 } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home |
689 $.datepicker._showDatepicker( this ); |
730 $.datepicker._showDatepicker( this ); |
690 } else { |
731 } else { |
723 if ( date ) { // only if valid |
764 if ( date ) { // only if valid |
724 $.datepicker._setDateFromField( inst ); |
765 $.datepicker._setDateFromField( inst ); |
725 $.datepicker._updateAlternate( inst ); |
766 $.datepicker._updateAlternate( inst ); |
726 $.datepicker._updateDatepicker( inst ); |
767 $.datepicker._updateDatepicker( inst ); |
727 } |
768 } |
728 } |
769 } catch ( err ) { |
729 catch ( err ) { |
|
730 } |
770 } |
731 } |
771 } |
732 return true; |
772 return true; |
733 }, |
773 }, |
734 |
774 |
795 |
835 |
796 // fix width for dynamic number of date pickers |
836 // fix width for dynamic number of date pickers |
797 // and adjust position before showing |
837 // and adjust position before showing |
798 offset = $.datepicker._checkOffset( inst, offset, isFixed ); |
838 offset = $.datepicker._checkOffset( inst, offset, isFixed ); |
799 inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ? |
839 inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ? |
800 "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none", |
840 "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none", |
801 left: offset.left + "px", top: offset.top + "px" } ); |
841 left: offset.left + "px", top: offset.top + "px" } ); |
802 |
842 |
803 if ( !inst.inline ) { |
843 if ( !inst.inline ) { |
804 showAnim = $.datepicker._get( inst, "showAnim" ); |
844 showAnim = $.datepicker._get( inst, "showAnim" ); |
805 duration = $.datepicker._get( inst, "duration" ); |
845 duration = $.datepicker._get( inst, "duration" ); |
829 |
869 |
830 var origyearshtml, |
870 var origyearshtml, |
831 numMonths = this._getNumberOfMonths( inst ), |
871 numMonths = this._getNumberOfMonths( inst ), |
832 cols = numMonths[ 1 ], |
872 cols = numMonths[ 1 ], |
833 width = 17, |
873 width = 17, |
834 activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ); |
874 activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ), |
875 onUpdateDatepicker = $.datepicker._get( inst, "onUpdateDatepicker" ); |
|
835 |
876 |
836 if ( activeCell.length > 0 ) { |
877 if ( activeCell.length > 0 ) { |
837 datepicker_handleMouseover.apply( activeCell.get( 0 ) ); |
878 datepicker_handleMouseover.apply( activeCell.get( 0 ) ); |
838 } |
879 } |
839 |
880 |
840 inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" ); |
881 inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" ); |
841 if ( cols > 1 ) { |
882 if ( cols > 1 ) { |
842 inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" ); |
883 inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" ); |
843 } |
884 } |
844 inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) + |
885 inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) + |
845 "Class" ]( "ui-datepicker-multi" ); |
886 "Class" ]( "ui-datepicker-multi" ); |
846 inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) + |
887 inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) + |
847 "Class" ]( "ui-datepicker-rtl" ); |
888 "Class" ]( "ui-datepicker-rtl" ); |
848 |
889 |
849 if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { |
890 if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { |
850 inst.input.trigger( "focus" ); |
891 inst.input.trigger( "focus" ); |
851 } |
892 } |
852 |
893 |
855 origyearshtml = inst.yearshtml; |
896 origyearshtml = inst.yearshtml; |
856 setTimeout( function() { |
897 setTimeout( function() { |
857 |
898 |
858 //assure that inst.yearshtml didn't change. |
899 //assure that inst.yearshtml didn't change. |
859 if ( origyearshtml === inst.yearshtml && inst.yearshtml ) { |
900 if ( origyearshtml === inst.yearshtml && inst.yearshtml ) { |
860 inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml ); |
901 inst.dpDiv.find( "select.ui-datepicker-year" ).first().replaceWith( inst.yearshtml ); |
861 } |
902 } |
862 origyearshtml = inst.yearshtml = null; |
903 origyearshtml = inst.yearshtml = null; |
863 }, 0 ); |
904 }, 0 ); |
905 } |
|
906 |
|
907 if ( onUpdateDatepicker ) { |
|
908 onUpdateDatepicker.apply( ( inst.input ? inst.input[ 0 ] : null ), [ inst ] ); |
|
864 } |
909 } |
865 }, |
910 }, |
866 |
911 |
867 // #6694 - don't focus the input if it's already focused |
912 // #6694 - don't focus the input if it's already focused |
868 // this breaks the change event in IE |
913 // this breaks the change event in IE |
897 _findPos: function( obj ) { |
942 _findPos: function( obj ) { |
898 var position, |
943 var position, |
899 inst = this._getInst( obj ), |
944 inst = this._getInst( obj ), |
900 isRTL = this._get( inst, "isRTL" ); |
945 isRTL = this._get( inst, "isRTL" ); |
901 |
946 |
902 while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) { |
947 while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.pseudos.hidden( obj ) ) ) { |
903 obj = obj[ isRTL ? "previousSibling" : "nextSibling" ]; |
948 obj = obj[ isRTL ? "previousSibling" : "nextSibling" ]; |
904 } |
949 } |
905 |
950 |
906 position = $( obj ).offset(); |
951 position = $( obj ).offset(); |
907 return [ position.left, position.top ]; |
952 return [ position.left, position.top ]; |
973 $target.parents( "#" + $.datepicker._mainDivId ).length === 0 && |
1018 $target.parents( "#" + $.datepicker._mainDivId ).length === 0 && |
974 !$target.hasClass( $.datepicker.markerClassName ) && |
1019 !$target.hasClass( $.datepicker.markerClassName ) && |
975 !$target.closest( "." + $.datepicker._triggerClass ).length && |
1020 !$target.closest( "." + $.datepicker._triggerClass ).length && |
976 $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) || |
1021 $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) || |
977 ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) { |
1022 ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) { |
978 $.datepicker._hideDatepicker(); |
1023 $.datepicker._hideDatepicker(); |
979 } |
1024 } |
980 }, |
1025 }, |
981 |
1026 |
982 /* Adjust one of the date sub-fields. */ |
1027 /* Adjust one of the date sub-fields. */ |
983 _adjustDate: function( id, offset, period ) { |
1028 _adjustDate: function( id, offset, period ) { |
985 inst = this._getInst( target[ 0 ] ); |
1030 inst = this._getInst( target[ 0 ] ); |
986 |
1031 |
987 if ( this._isDisabledDatepicker( target[ 0 ] ) ) { |
1032 if ( this._isDisabledDatepicker( target[ 0 ] ) ) { |
988 return; |
1033 return; |
989 } |
1034 } |
990 this._adjustInstDate( inst, offset + |
1035 this._adjustInstDate( inst, offset, period ); |
991 ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning |
|
992 period ); |
|
993 this._updateDatepicker( inst ); |
1036 this._updateDatepicker( inst ); |
994 }, |
1037 }, |
995 |
1038 |
996 /* Action for current link. */ |
1039 /* Action for current link. */ |
997 _gotoToday: function( id ) { |
1040 _gotoToday: function( id ) { |
1017 _selectMonthYear: function( id, select, period ) { |
1060 _selectMonthYear: function( id, select, period ) { |
1018 var target = $( id ), |
1061 var target = $( id ), |
1019 inst = this._getInst( target[ 0 ] ); |
1062 inst = this._getInst( target[ 0 ] ); |
1020 |
1063 |
1021 inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] = |
1064 inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] = |
1022 inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] = |
1065 inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] = |
1023 parseInt( select.options[ select.selectedIndex ].value, 10 ); |
1066 parseInt( select.options[ select.selectedIndex ].value, 10 ); |
1024 |
1067 |
1025 this._notifyChange( inst ); |
1068 this._notifyChange( inst ); |
1026 this._adjustDate( target ); |
1069 this._adjustDate( target ); |
1027 }, |
1070 }, |
1028 |
1071 |
1034 if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) { |
1077 if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) { |
1035 return; |
1078 return; |
1036 } |
1079 } |
1037 |
1080 |
1038 inst = this._getInst( target[ 0 ] ); |
1081 inst = this._getInst( target[ 0 ] ); |
1039 inst.selectedDay = inst.currentDay = $( "a", td ).html(); |
1082 inst.selectedDay = inst.currentDay = parseInt( $( "a", td ).attr( "data-date" ) ); |
1040 inst.selectedMonth = inst.currentMonth = month; |
1083 inst.selectedMonth = inst.currentMonth = month; |
1041 inst.selectedYear = inst.currentYear = year; |
1084 inst.selectedYear = inst.currentYear = year; |
1042 this._selectDate( id, this._formatDate( inst, |
1085 this._selectDate( id, this._formatDate( inst, |
1043 inst.currentDay, inst.currentMonth, inst.currentYear ) ); |
1086 inst.currentDay, inst.currentMonth, inst.currentYear ) ); |
1044 }, |
1087 }, |
1087 |
1130 |
1088 if ( altField ) { // update alternate field too |
1131 if ( altField ) { // update alternate field too |
1089 altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" ); |
1132 altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" ); |
1090 date = this._getDate( inst ); |
1133 date = this._getDate( inst ); |
1091 dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) ); |
1134 dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) ); |
1092 $( altField ).val( dateStr ); |
1135 $( document ).find( altField ).val( dateStr ); |
1093 } |
1136 } |
1094 }, |
1137 }, |
1095 |
1138 |
1096 /* Set as beforeShowDay function to prevent selection of weekends. |
1139 /* Set as beforeShowDay function to prevent selection of weekends. |
1097 * @param date Date - the date to customise |
1140 * @param date Date - the date to customise |
1169 |
1212 |
1170 // Extract a number from the string value |
1213 // Extract a number from the string value |
1171 getNumber = function( match ) { |
1214 getNumber = function( match ) { |
1172 var isDoubled = lookAhead( match ), |
1215 var isDoubled = lookAhead( match ), |
1173 size = ( match === "@" ? 14 : ( match === "!" ? 20 : |
1216 size = ( match === "@" ? 14 : ( match === "!" ? 20 : |
1174 ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ), |
1217 ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ), |
1175 minSize = ( match === "y" ? size : 1 ), |
1218 minSize = ( match === "y" ? size : 1 ), |
1176 digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ), |
1219 digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ), |
1177 num = value.substring( iValue ).match( digits ); |
1220 num = value.substring( iValue ).match( digits ); |
1178 if ( !num ) { |
1221 if ( !num ) { |
1179 throw "Missing number at position " + iValue; |
1222 throw "Missing number at position " + iValue; |
1526 }, |
1569 }, |
1527 offsetString = function( offset ) { |
1570 offsetString = function( offset ) { |
1528 try { |
1571 try { |
1529 return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ), |
1572 return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ), |
1530 offset, $.datepicker._getFormatConfig( inst ) ); |
1573 offset, $.datepicker._getFormatConfig( inst ) ); |
1531 } |
1574 } catch ( e ) { |
1532 catch ( e ) { |
|
1533 |
1575 |
1534 // Ignore |
1576 // Ignore |
1535 } |
1577 } |
1536 |
1578 |
1537 var date = ( offset.toLowerCase().match( /^c/ ) ? |
1579 var date = ( offset.toLowerCase().match( /^c/ ) ? |
1538 $.datepicker._getDate( inst ) : null ) || new Date(), |
1580 $.datepicker._getDate( inst ) : null ) || new Date(), |
1539 year = date.getFullYear(), |
1581 year = date.getFullYear(), |
1540 month = date.getMonth(), |
1582 month = date.getMonth(), |
1541 day = date.getDate(), |
1583 day = date.getDate(), |
1542 pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, |
1584 pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, |
1543 matches = pattern.exec( offset ); |
1585 matches = pattern.exec( offset ); |
1610 |
1652 |
1611 /* Retrieve the date(s) directly. */ |
1653 /* Retrieve the date(s) directly. */ |
1612 _getDate: function( inst ) { |
1654 _getDate: function( inst ) { |
1613 var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null : |
1655 var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null : |
1614 this._daylightSavingAdjust( new Date( |
1656 this._daylightSavingAdjust( new Date( |
1615 inst.currentYear, inst.currentMonth, inst.currentDay ) ) ); |
1657 inst.currentYear, inst.currentMonth, inst.currentDay ) ) ); |
1616 return startDate; |
1658 return startDate; |
1617 }, |
1659 }, |
1618 |
1660 |
1619 /* Attach the onxxx handlers. These are declared statically so |
1661 /* Attach the onxxx handlers. These are declared statically so |
1620 * they work with static code transformers like Caja. |
1662 * they work with static code transformers like Caja. |
1621 */ |
1663 */ |
1701 prevText = this._get( inst, "prevText" ); |
1743 prevText = this._get( inst, "prevText" ); |
1702 prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText, |
1744 prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText, |
1703 this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ), |
1745 this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ), |
1704 this._getFormatConfig( inst ) ) ); |
1746 this._getFormatConfig( inst ) ) ); |
1705 |
1747 |
1706 prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ? |
1748 if ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ) { |
1707 "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" + |
1749 prev = $( "<a>" ) |
1708 " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" : |
1750 .attr( { |
1709 ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" ) ); |
1751 "class": "ui-datepicker-prev ui-corner-all", |
1752 "data-handler": "prev", |
|
1753 "data-event": "click", |
|
1754 title: prevText |
|
1755 } ) |
|
1756 .append( |
|
1757 $( "<span>" ) |
|
1758 .addClass( "ui-icon ui-icon-circle-triangle-" + |
|
1759 ( isRTL ? "e" : "w" ) ) |
|
1760 .text( prevText ) |
|
1761 )[ 0 ].outerHTML; |
|
1762 } else if ( hideIfNoPrevNext ) { |
|
1763 prev = ""; |
|
1764 } else { |
|
1765 prev = $( "<a>" ) |
|
1766 .attr( { |
|
1767 "class": "ui-datepicker-prev ui-corner-all ui-state-disabled", |
|
1768 title: prevText |
|
1769 } ) |
|
1770 .append( |
|
1771 $( "<span>" ) |
|
1772 .addClass( "ui-icon ui-icon-circle-triangle-" + |
|
1773 ( isRTL ? "e" : "w" ) ) |
|
1774 .text( prevText ) |
|
1775 )[ 0 ].outerHTML; |
|
1776 } |
|
1710 |
1777 |
1711 nextText = this._get( inst, "nextText" ); |
1778 nextText = this._get( inst, "nextText" ); |
1712 nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText, |
1779 nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText, |
1713 this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ), |
1780 this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ), |
1714 this._getFormatConfig( inst ) ) ); |
1781 this._getFormatConfig( inst ) ) ); |
1715 |
1782 |
1716 next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ? |
1783 if ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ) { |
1717 "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" + |
1784 next = $( "<a>" ) |
1718 " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" : |
1785 .attr( { |
1719 ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" ) ); |
1786 "class": "ui-datepicker-next ui-corner-all", |
1787 "data-handler": "next", |
|
1788 "data-event": "click", |
|
1789 title: nextText |
|
1790 } ) |
|
1791 .append( |
|
1792 $( "<span>" ) |
|
1793 .addClass( "ui-icon ui-icon-circle-triangle-" + |
|
1794 ( isRTL ? "w" : "e" ) ) |
|
1795 .text( nextText ) |
|
1796 )[ 0 ].outerHTML; |
|
1797 } else if ( hideIfNoPrevNext ) { |
|
1798 next = ""; |
|
1799 } else { |
|
1800 next = $( "<a>" ) |
|
1801 .attr( { |
|
1802 "class": "ui-datepicker-next ui-corner-all ui-state-disabled", |
|
1803 title: nextText |
|
1804 } ) |
|
1805 .append( |
|
1806 $( "<span>" ) |
|
1807 .attr( "class", "ui-icon ui-icon-circle-triangle-" + |
|
1808 ( isRTL ? "w" : "e" ) ) |
|
1809 .text( nextText ) |
|
1810 )[ 0 ].outerHTML; |
|
1811 } |
|
1720 |
1812 |
1721 currentText = this._get( inst, "currentText" ); |
1813 currentText = this._get( inst, "currentText" ); |
1722 gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today ); |
1814 gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today ); |
1723 currentText = ( !navigationAsDateFormat ? currentText : |
1815 currentText = ( !navigationAsDateFormat ? currentText : |
1724 this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) ); |
1816 this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) ); |
1725 |
1817 |
1726 controls = ( !inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" + |
1818 controls = ""; |
1727 this._get( inst, "closeText" ) + "</button>" : "" ); |
1819 if ( !inst.inline ) { |
1728 |
1820 controls = $( "<button>" ) |
1729 buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) + |
1821 .attr( { |
1730 ( this._isInRange( inst, gotoDate ) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" + |
1822 type: "button", |
1731 ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : ""; |
1823 "class": "ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all", |
1824 "data-handler": "hide", |
|
1825 "data-event": "click" |
|
1826 } ) |
|
1827 .text( this._get( inst, "closeText" ) )[ 0 ].outerHTML; |
|
1828 } |
|
1829 |
|
1830 buttonPanel = ""; |
|
1831 if ( showButtonPanel ) { |
|
1832 buttonPanel = $( "<div class='ui-datepicker-buttonpane ui-widget-content'>" ) |
|
1833 .append( isRTL ? controls : "" ) |
|
1834 .append( this._isInRange( inst, gotoDate ) ? |
|
1835 $( "<button>" ) |
|
1836 .attr( { |
|
1837 type: "button", |
|
1838 "class": "ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all", |
|
1839 "data-handler": "today", |
|
1840 "data-event": "click" |
|
1841 } ) |
|
1842 .text( currentText ) : |
|
1843 "" ) |
|
1844 .append( isRTL ? "" : controls )[ 0 ].outerHTML; |
|
1845 } |
|
1732 |
1846 |
1733 firstDay = parseInt( this._get( inst, "firstDay" ), 10 ); |
1847 firstDay = parseInt( this._get( inst, "firstDay" ), 10 ); |
1734 firstDay = ( isNaN( firstDay ) ? 0 : firstDay ); |
1848 firstDay = ( isNaN( firstDay ) ? 0 : firstDay ); |
1735 |
1849 |
1736 showWeek = this._get( inst, "showWeek" ); |
1850 showWeek = this._get( inst, "showWeek" ); |
1766 } |
1880 } |
1767 calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" + |
1881 calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" + |
1768 ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) + |
1882 ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) + |
1769 ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) + |
1883 ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) + |
1770 this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate, |
1884 this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate, |
1771 row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers |
1885 row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers |
1772 "</div><table class='ui-datepicker-calendar'><thead>" + |
1886 "</div><table class='ui-datepicker-calendar'><thead>" + |
1773 "<tr>"; |
1887 "<tr>"; |
1774 thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" ); |
1888 thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" ); |
1775 for ( dow = 0; dow < 7; dow++ ) { // days of the week |
1889 for ( dow = 0; dow < 7; dow++ ) { // days of the week |
1776 day = ( dow + firstDay ) % 7; |
1890 day = ( dow + firstDay ) % 7; |
1801 ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends |
1915 ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends |
1802 ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months |
1916 ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months |
1803 ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key |
1917 ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key |
1804 ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ? |
1918 ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ? |
1805 |
1919 |
1806 // or defaultDate is current printedDate and defaultDate is selectedDate |
1920 // or defaultDate is current printedDate and defaultDate is selectedDate |
1807 " " + this._dayOverClass : "" ) + // highlight selected day |
1921 " " + this._dayOverClass : "" ) + // highlight selected day |
1808 ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days |
1922 ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days |
1809 ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates |
1923 ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates |
1810 ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day |
1924 ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day |
1811 ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different) |
1925 ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different) |
1812 ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "'" ) + "'" : "" ) + // cell title |
1926 ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "'" ) + "'" : "" ) + // cell title |
1813 ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions |
1927 ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions |
1814 ( otherMonth && !showOtherMonths ? " " : // display for other months |
1928 ( otherMonth && !showOtherMonths ? " " : // display for other months |
1815 ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + |
1929 ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + |
1816 ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) + |
1930 ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) + |
1817 ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day |
1931 ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day |
1818 ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months |
1932 ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months |
1819 "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date |
1933 "' href='#' aria-current='" + ( printDate.getTime() === currentDate.getTime() ? "true" : "false" ) + // mark date as selected for screen reader |
1934 "' data-date='" + printDate.getDate() + // store date as data |
|
1935 "'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date |
|
1820 printDate.setDate( printDate.getDate() + 1 ); |
1936 printDate.setDate( printDate.getDate() + 1 ); |
1821 printDate = this._daylightSavingAdjust( printDate ); |
1937 printDate = this._daylightSavingAdjust( printDate ); |
1822 } |
1938 } |
1823 calender += tbody + "</tr>"; |
1939 calender += tbody + "</tr>"; |
1824 } |
1940 } |
1826 if ( drawMonth > 11 ) { |
1942 if ( drawMonth > 11 ) { |
1827 drawMonth = 0; |
1943 drawMonth = 0; |
1828 drawYear++; |
1944 drawYear++; |
1829 } |
1945 } |
1830 calender += "</tbody></table>" + ( isMultiMonth ? "</div>" + |
1946 calender += "</tbody></table>" + ( isMultiMonth ? "</div>" + |
1831 ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" ); |
1947 ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" ); |
1832 group += calender; |
1948 group += calender; |
1833 } |
1949 } |
1834 html += group; |
1950 html += group; |
1835 } |
1951 } |
1836 html += buttonPanel; |
1952 html += buttonPanel; |
1838 return html; |
1954 return html; |
1839 }, |
1955 }, |
1840 |
1956 |
1841 /* Generate the month and year header. */ |
1957 /* Generate the month and year header. */ |
1842 _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate, |
1958 _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate, |
1843 secondary, monthNames, monthNamesShort ) { |
1959 secondary, monthNames, monthNamesShort ) { |
1844 |
1960 |
1845 var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear, |
1961 var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear, |
1846 changeMonth = this._get( inst, "changeMonth" ), |
1962 changeMonth = this._get( inst, "changeMonth" ), |
1847 changeYear = this._get( inst, "changeYear" ), |
1963 changeYear = this._get( inst, "changeYear" ), |
1848 showMonthAfterYear = this._get( inst, "showMonthAfterYear" ), |
1964 showMonthAfterYear = this._get( inst, "showMonthAfterYear" ), |
1965 selectMonthLabel = this._get( inst, "selectMonthLabel" ), |
|
1966 selectYearLabel = this._get( inst, "selectYearLabel" ), |
|
1849 html = "<div class='ui-datepicker-title'>", |
1967 html = "<div class='ui-datepicker-title'>", |
1850 monthHtml = ""; |
1968 monthHtml = ""; |
1851 |
1969 |
1852 // Month selection |
1970 // Month selection |
1853 if ( secondary || !changeMonth ) { |
1971 if ( secondary || !changeMonth ) { |
1854 monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>"; |
1972 monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>"; |
1855 } else { |
1973 } else { |
1856 inMinYear = ( minDate && minDate.getFullYear() === drawYear ); |
1974 inMinYear = ( minDate && minDate.getFullYear() === drawYear ); |
1857 inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear ); |
1975 inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear ); |
1858 monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>"; |
1976 monthHtml += "<select class='ui-datepicker-month' aria-label='" + selectMonthLabel + "' data-handler='selectMonth' data-event='change'>"; |
1859 for ( month = 0; month < 12; month++ ) { |
1977 for ( month = 0; month < 12; month++ ) { |
1860 if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) { |
1978 if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) { |
1861 monthHtml += "<option value='" + month + "'" + |
1979 monthHtml += "<option value='" + month + "'" + |
1862 ( month === drawMonth ? " selected='selected'" : "" ) + |
1980 ( month === drawMonth ? " selected='selected'" : "" ) + |
1863 ">" + monthNamesShort[ month ] + "</option>"; |
1981 ">" + monthNamesShort[ month ] + "</option>"; |
1881 years = this._get( inst, "yearRange" ).split( ":" ); |
1999 years = this._get( inst, "yearRange" ).split( ":" ); |
1882 thisYear = new Date().getFullYear(); |
2000 thisYear = new Date().getFullYear(); |
1883 determineYear = function( value ) { |
2001 determineYear = function( value ) { |
1884 var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) : |
2002 var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) : |
1885 ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) : |
2003 ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) : |
1886 parseInt( value, 10 ) ) ); |
2004 parseInt( value, 10 ) ) ); |
1887 return ( isNaN( year ) ? thisYear : year ); |
2005 return ( isNaN( year ) ? thisYear : year ); |
1888 }; |
2006 }; |
1889 year = determineYear( years[ 0 ] ); |
2007 year = determineYear( years[ 0 ] ); |
1890 endYear = Math.max( year, determineYear( years[ 1 ] || "" ) ); |
2008 endYear = Math.max( year, determineYear( years[ 1 ] || "" ) ); |
1891 year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year ); |
2009 year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year ); |
1892 endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear ); |
2010 endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear ); |
1893 inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>"; |
2011 inst.yearshtml += "<select class='ui-datepicker-year' aria-label='" + selectYearLabel + "' data-handler='selectYear' data-event='change'>"; |
1894 for ( ; year <= endYear; year++ ) { |
2012 for ( ; year <= endYear; year++ ) { |
1895 inst.yearshtml += "<option value='" + year + "'" + |
2013 inst.yearshtml += "<option value='" + year + "'" + |
1896 ( year === drawYear ? " selected='selected'" : "" ) + |
2014 ( year === drawYear ? " selected='selected'" : "" ) + |
1897 ">" + year + "</option>"; |
2015 ">" + year + "</option>"; |
1898 } |
2016 } |
1966 |
2084 |
1967 /* Determines if we should allow a "next/prev" month display change. */ |
2085 /* Determines if we should allow a "next/prev" month display change. */ |
1968 _canAdjustMonth: function( inst, offset, curYear, curMonth ) { |
2086 _canAdjustMonth: function( inst, offset, curYear, curMonth ) { |
1969 var numMonths = this._getNumberOfMonths( inst ), |
2087 var numMonths = this._getNumberOfMonths( inst ), |
1970 date = this._daylightSavingAdjust( new Date( curYear, |
2088 date = this._daylightSavingAdjust( new Date( curYear, |
1971 curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) ); |
2089 curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) ); |
1972 |
2090 |
1973 if ( offset < 0 ) { |
2091 if ( offset < 0 ) { |
1974 date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) ); |
2092 date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) ); |
1975 } |
2093 } |
1976 return this._isInRange( inst, date ); |
2094 return this._isInRange( inst, date ); |
1982 minDate = this._getMinMaxDate( inst, "min" ), |
2100 minDate = this._getMinMaxDate( inst, "min" ), |
1983 maxDate = this._getMinMaxDate( inst, "max" ), |
2101 maxDate = this._getMinMaxDate( inst, "max" ), |
1984 minYear = null, |
2102 minYear = null, |
1985 maxYear = null, |
2103 maxYear = null, |
1986 years = this._get( inst, "yearRange" ); |
2104 years = this._get( inst, "yearRange" ); |
1987 if ( years ) { |
2105 if ( years ) { |
1988 yearSplit = years.split( ":" ); |
2106 yearSplit = years.split( ":" ); |
1989 currentYear = new Date().getFullYear(); |
2107 currentYear = new Date().getFullYear(); |
1990 minYear = parseInt( yearSplit[ 0 ], 10 ); |
2108 minYear = parseInt( yearSplit[ 0 ], 10 ); |
1991 maxYear = parseInt( yearSplit[ 1 ], 10 ); |
2109 maxYear = parseInt( yearSplit[ 1 ], 10 ); |
1992 if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) { |
2110 if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) { |
1993 minYear += currentYear; |
2111 minYear += currentYear; |
1994 } |
2112 } |
1995 if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) { |
2113 if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) { |
1996 maxYear += currentYear; |
2114 maxYear += currentYear; |
1997 } |
2115 } |
1998 } |
2116 } |
1999 |
2117 |
2000 return ( ( !minDate || date.getTime() >= minDate.getTime() ) && |
2118 return ( ( !minDate || date.getTime() >= minDate.getTime() ) && |
2001 ( !maxDate || date.getTime() <= maxDate.getTime() ) && |
2119 ( !maxDate || date.getTime() <= maxDate.getTime() ) && |
2002 ( !minYear || date.getFullYear() >= minYear ) && |
2120 ( !minYear || date.getFullYear() >= minYear ) && |
2003 ( !maxYear || date.getFullYear() <= maxYear ) ); |
2121 ( !maxYear || date.getFullYear() <= maxYear ) ); |
2019 inst.currentDay = inst.selectedDay; |
2137 inst.currentDay = inst.selectedDay; |
2020 inst.currentMonth = inst.selectedMonth; |
2138 inst.currentMonth = inst.selectedMonth; |
2021 inst.currentYear = inst.selectedYear; |
2139 inst.currentYear = inst.selectedYear; |
2022 } |
2140 } |
2023 var date = ( day ? ( typeof day === "object" ? day : |
2141 var date = ( day ? ( typeof day === "object" ? day : |
2024 this._daylightSavingAdjust( new Date( year, month, day ) ) ) : |
2142 this._daylightSavingAdjust( new Date( year, month, day ) ) ) : |
2025 this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ); |
2143 this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ); |
2026 return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) ); |
2144 return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) ); |
2027 } |
2145 } |
2028 } ); |
2146 } ); |
2029 |
2147 |
2033 * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. |
2151 * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. |
2034 */ |
2152 */ |
2035 function datepicker_bindHover( dpDiv ) { |
2153 function datepicker_bindHover( dpDiv ) { |
2036 var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"; |
2154 var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a"; |
2037 return dpDiv.on( "mouseout", selector, function() { |
2155 return dpDiv.on( "mouseout", selector, function() { |
2038 $( this ).removeClass( "ui-state-hover" ); |
2156 $( this ).removeClass( "ui-state-hover" ); |
2039 if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) { |
2157 if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) { |
2040 $( this ).removeClass( "ui-datepicker-prev-hover" ); |
2158 $( this ).removeClass( "ui-datepicker-prev-hover" ); |
2041 } |
2159 } |
2042 if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) { |
2160 if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) { |
2043 $( this ).removeClass( "ui-datepicker-next-hover" ); |
2161 $( this ).removeClass( "ui-datepicker-next-hover" ); |
2044 } |
2162 } |
2045 } ) |
2163 } ) |
2046 .on( "mouseover", selector, datepicker_handleMouseover ); |
2164 .on( "mouseover", selector, datepicker_handleMouseover ); |
2047 } |
2165 } |
2048 |
2166 |
2049 function datepicker_handleMouseover() { |
2167 function datepicker_handleMouseover() { |
2050 if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) { |
2168 if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) { |
2093 } |
2211 } |
2094 |
2212 |
2095 var otherArgs = Array.prototype.slice.call( arguments, 1 ); |
2213 var otherArgs = Array.prototype.slice.call( arguments, 1 ); |
2096 if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) { |
2214 if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) { |
2097 return $.datepicker[ "_" + options + "Datepicker" ]. |
2215 return $.datepicker[ "_" + options + "Datepicker" ]. |
2098 apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) ); |
2216 apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) ); |
2099 } |
2217 } |
2100 if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) { |
2218 if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) { |
2101 return $.datepicker[ "_" + options + "Datepicker" ]. |
2219 return $.datepicker[ "_" + options + "Datepicker" ]. |
2102 apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) ); |
2220 apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) ); |
2103 } |
2221 } |
2104 return this.each( function() { |
2222 return this.each( function() { |
2105 typeof options === "string" ? |
2223 if ( typeof options === "string" ) { |
2106 $.datepicker[ "_" + options + "Datepicker" ]. |
2224 $.datepicker[ "_" + options + "Datepicker" ] |
2107 apply( $.datepicker, [ this ].concat( otherArgs ) ) : |
2225 .apply( $.datepicker, [ this ].concat( otherArgs ) ); |
2226 } else { |
|
2108 $.datepicker._attachDatepicker( this, options ); |
2227 $.datepicker._attachDatepicker( this, options ); |
2228 } |
|
2109 } ); |
2229 } ); |
2110 }; |
2230 }; |
2111 |
2231 |
2112 $.datepicker = new Datepicker(); // singleton instance |
2232 $.datepicker = new Datepicker(); // singleton instance |
2113 $.datepicker.initialized = false; |
2233 $.datepicker.initialized = false; |
2114 $.datepicker.uuid = new Date().getTime(); |
2234 $.datepicker.uuid = new Date().getTime(); |
2115 $.datepicker.version = "1.12.1"; |
2235 $.datepicker.version = "1.13.1"; |
2116 |
2236 |
2117 return $.datepicker; |
2237 return $.datepicker; |
2118 |
2238 |
2119 } ) ); |
2239 } ); |