jquery-ui-middleman 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +2 -0
  5. data/Gemfile +3 -0
  6. data/History.md +115 -0
  7. data/License.txt +2 -0
  8. data/README.md +226 -0
  9. data/Rakefile +221 -0
  10. data/VERSIONS.md +27 -0
  11. data/app/assets/images/jquery-ui/animated-overlay.gif +0 -0
  12. data/app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  13. data/app/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  14. data/app/assets/images/jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  15. data/app/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  16. data/app/assets/images/jquery-ui/ui-bg_glass_75_dadada_1x400.png +0 -0
  17. data/app/assets/images/jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  18. data/app/assets/images/jquery-ui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  19. data/app/assets/images/jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  20. data/app/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
  21. data/app/assets/images/jquery-ui/ui-icons_2e83ff_256x240.png +0 -0
  22. data/app/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
  23. data/app/assets/images/jquery-ui/ui-icons_888888_256x240.png +0 -0
  24. data/app/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  25. data/app/assets/javascripts/jquery.ui.accordion.js +575 -0
  26. data/app/assets/javascripts/jquery.ui.all.js +34 -0
  27. data/app/assets/javascripts/jquery.ui.autocomplete.js +615 -0
  28. data/app/assets/javascripts/jquery.ui.button.js +422 -0
  29. data/app/assets/javascripts/jquery.ui.core.js +320 -0
  30. data/app/assets/javascripts/jquery.ui.datepicker-af.js +23 -0
  31. data/app/assets/javascripts/jquery.ui.datepicker-ar-DZ.js +23 -0
  32. data/app/assets/javascripts/jquery.ui.datepicker-ar.js +23 -0
  33. data/app/assets/javascripts/jquery.ui.datepicker-az.js +23 -0
  34. data/app/assets/javascripts/jquery.ui.datepicker-be.js +23 -0
  35. data/app/assets/javascripts/jquery.ui.datepicker-bg.js +24 -0
  36. data/app/assets/javascripts/jquery.ui.datepicker-bs.js +23 -0
  37. data/app/assets/javascripts/jquery.ui.datepicker-ca.js +23 -0
  38. data/app/assets/javascripts/jquery.ui.datepicker-cs.js +23 -0
  39. data/app/assets/javascripts/jquery.ui.datepicker-cy-GB.js +23 -0
  40. data/app/assets/javascripts/jquery.ui.datepicker-da.js +23 -0
  41. data/app/assets/javascripts/jquery.ui.datepicker-de.js +23 -0
  42. data/app/assets/javascripts/jquery.ui.datepicker-el.js +23 -0
  43. data/app/assets/javascripts/jquery.ui.datepicker-en-AU.js +23 -0
  44. data/app/assets/javascripts/jquery.ui.datepicker-en-GB.js +23 -0
  45. data/app/assets/javascripts/jquery.ui.datepicker-en-NZ.js +23 -0
  46. data/app/assets/javascripts/jquery.ui.datepicker-eo.js +23 -0
  47. data/app/assets/javascripts/jquery.ui.datepicker-es.js +23 -0
  48. data/app/assets/javascripts/jquery.ui.datepicker-et.js +23 -0
  49. data/app/assets/javascripts/jquery.ui.datepicker-eu.js +23 -0
  50. data/app/assets/javascripts/jquery.ui.datepicker-fa.js +59 -0
  51. data/app/assets/javascripts/jquery.ui.datepicker-fi.js +23 -0
  52. data/app/assets/javascripts/jquery.ui.datepicker-fo.js +23 -0
  53. data/app/assets/javascripts/jquery.ui.datepicker-fr-CA.js +23 -0
  54. data/app/assets/javascripts/jquery.ui.datepicker-fr-CH.js +23 -0
  55. data/app/assets/javascripts/jquery.ui.datepicker-fr.js +25 -0
  56. data/app/assets/javascripts/jquery.ui.datepicker-gl.js +23 -0
  57. data/app/assets/javascripts/jquery.ui.datepicker-he.js +23 -0
  58. data/app/assets/javascripts/jquery.ui.datepicker-hi.js +23 -0
  59. data/app/assets/javascripts/jquery.ui.datepicker-hr.js +23 -0
  60. data/app/assets/javascripts/jquery.ui.datepicker-hu.js +23 -0
  61. data/app/assets/javascripts/jquery.ui.datepicker-hy.js +23 -0
  62. data/app/assets/javascripts/jquery.ui.datepicker-id.js +23 -0
  63. data/app/assets/javascripts/jquery.ui.datepicker-is.js +23 -0
  64. data/app/assets/javascripts/jquery.ui.datepicker-it.js +23 -0
  65. data/app/assets/javascripts/jquery.ui.datepicker-ja.js +23 -0
  66. data/app/assets/javascripts/jquery.ui.datepicker-ka.js +21 -0
  67. data/app/assets/javascripts/jquery.ui.datepicker-kk.js +23 -0
  68. data/app/assets/javascripts/jquery.ui.datepicker-km.js +23 -0
  69. data/app/assets/javascripts/jquery.ui.datepicker-ko.js +23 -0
  70. data/app/assets/javascripts/jquery.ui.datepicker-ky.js +24 -0
  71. data/app/assets/javascripts/jquery.ui.datepicker-lb.js +23 -0
  72. data/app/assets/javascripts/jquery.ui.datepicker-lt.js +23 -0
  73. data/app/assets/javascripts/jquery.ui.datepicker-lv.js +23 -0
  74. data/app/assets/javascripts/jquery.ui.datepicker-mk.js +23 -0
  75. data/app/assets/javascripts/jquery.ui.datepicker-ml.js +23 -0
  76. data/app/assets/javascripts/jquery.ui.datepicker-ms.js +23 -0
  77. data/app/assets/javascripts/jquery.ui.datepicker-nb.js +22 -0
  78. data/app/assets/javascripts/jquery.ui.datepicker-nl-BE.js +23 -0
  79. data/app/assets/javascripts/jquery.ui.datepicker-nl.js +23 -0
  80. data/app/assets/javascripts/jquery.ui.datepicker-nn.js +22 -0
  81. data/app/assets/javascripts/jquery.ui.datepicker-no.js +23 -0
  82. data/app/assets/javascripts/jquery.ui.datepicker-pl.js +23 -0
  83. data/app/assets/javascripts/jquery.ui.datepicker-pt-BR.js +23 -0
  84. data/app/assets/javascripts/jquery.ui.datepicker-pt.js +22 -0
  85. data/app/assets/javascripts/jquery.ui.datepicker-rm.js +21 -0
  86. data/app/assets/javascripts/jquery.ui.datepicker-ro.js +26 -0
  87. data/app/assets/javascripts/jquery.ui.datepicker-ru.js +23 -0
  88. data/app/assets/javascripts/jquery.ui.datepicker-sk.js +23 -0
  89. data/app/assets/javascripts/jquery.ui.datepicker-sl.js +24 -0
  90. data/app/assets/javascripts/jquery.ui.datepicker-sq.js +23 -0
  91. data/app/assets/javascripts/jquery.ui.datepicker-sr-SR.js +23 -0
  92. data/app/assets/javascripts/jquery.ui.datepicker-sr.js +23 -0
  93. data/app/assets/javascripts/jquery.ui.datepicker-sv.js +23 -0
  94. data/app/assets/javascripts/jquery.ui.datepicker-ta.js +23 -0
  95. data/app/assets/javascripts/jquery.ui.datepicker-th.js +23 -0
  96. data/app/assets/javascripts/jquery.ui.datepicker-tj.js +23 -0
  97. data/app/assets/javascripts/jquery.ui.datepicker-tr.js +23 -0
  98. data/app/assets/javascripts/jquery.ui.datepicker-uk.js +24 -0
  99. data/app/assets/javascripts/jquery.ui.datepicker-vi.js +23 -0
  100. data/app/assets/javascripts/jquery.ui.datepicker-zh-CN.js +23 -0
  101. data/app/assets/javascripts/jquery.ui.datepicker-zh-HK.js +23 -0
  102. data/app/assets/javascripts/jquery.ui.datepicker-zh-TW.js +23 -0
  103. data/app/assets/javascripts/jquery.ui.datepicker.js +2040 -0
  104. data/app/assets/javascripts/jquery.ui.dialog.js +815 -0
  105. data/app/assets/javascripts/jquery.ui.draggable.js +962 -0
  106. data/app/assets/javascripts/jquery.ui.droppable.js +377 -0
  107. data/app/assets/javascripts/jquery.ui.effect-blind.js +84 -0
  108. data/app/assets/javascripts/jquery.ui.effect-bounce.js +115 -0
  109. data/app/assets/javascripts/jquery.ui.effect-clip.js +69 -0
  110. data/app/assets/javascripts/jquery.ui.effect-drop.js +67 -0
  111. data/app/assets/javascripts/jquery.ui.effect-explode.js +99 -0
  112. data/app/assets/javascripts/jquery.ui.effect-fade.js +32 -0
  113. data/app/assets/javascripts/jquery.ui.effect-fold.js +78 -0
  114. data/app/assets/javascripts/jquery.ui.effect-highlight.js +52 -0
  115. data/app/assets/javascripts/jquery.ui.effect-pulsate.js +65 -0
  116. data/app/assets/javascripts/jquery.ui.effect-scale.js +320 -0
  117. data/app/assets/javascripts/jquery.ui.effect-shake.js +76 -0
  118. data/app/assets/javascripts/jquery.ui.effect-slide.js +66 -0
  119. data/app/assets/javascripts/jquery.ui.effect-transfer.js +49 -0
  120. data/app/assets/javascripts/jquery.ui.effect.all.js +14 -0
  121. data/app/assets/javascripts/jquery.ui.effect.js +1289 -0
  122. data/app/assets/javascripts/jquery.ui.menu.js +625 -0
  123. data/app/assets/javascripts/jquery.ui.mouse.js +172 -0
  124. data/app/assets/javascripts/jquery.ui.position.js +497 -0
  125. data/app/assets/javascripts/jquery.ui.progressbar.js +148 -0
  126. data/app/assets/javascripts/jquery.ui.resizable.js +972 -0
  127. data/app/assets/javascripts/jquery.ui.selectable.js +281 -0
  128. data/app/assets/javascripts/jquery.ui.slider.js +676 -0
  129. data/app/assets/javascripts/jquery.ui.sortable.js +1289 -0
  130. data/app/assets/javascripts/jquery.ui.spinner.js +497 -0
  131. data/app/assets/javascripts/jquery.ui.tabs.js +849 -0
  132. data/app/assets/javascripts/jquery.ui.tooltip.js +406 -0
  133. data/app/assets/javascripts/jquery.ui.widget.js +521 -0
  134. data/app/assets/stylesheets/jquery.ui.accordion.css.erb +42 -0
  135. data/app/assets/stylesheets/jquery.ui.all.css.erb +14 -0
  136. data/app/assets/stylesheets/jquery.ui.autocomplete.css.erb +21 -0
  137. data/app/assets/stylesheets/jquery.ui.base.css.erb +27 -0
  138. data/app/assets/stylesheets/jquery.ui.button.css.erb +118 -0
  139. data/app/assets/stylesheets/jquery.ui.core.css.erb +93 -0
  140. data/app/assets/stylesheets/jquery.ui.datepicker.css.erb +182 -0
  141. data/app/assets/stylesheets/jquery.ui.dialog.css.erb +75 -0
  142. data/app/assets/stylesheets/jquery.ui.menu.css.erb +83 -0
  143. data/app/assets/stylesheets/jquery.ui.progressbar.css.erb +32 -0
  144. data/app/assets/stylesheets/jquery.ui.resizable.css.erb +82 -0
  145. data/app/assets/stylesheets/jquery.ui.selectable.css.erb +19 -0
  146. data/app/assets/stylesheets/jquery.ui.slider.css.erb +77 -0
  147. data/app/assets/stylesheets/jquery.ui.spinner.css.erb +70 -0
  148. data/app/assets/stylesheets/jquery.ui.tabs.css.erb +56 -0
  149. data/app/assets/stylesheets/jquery.ui.theme.css.erb +409 -0
  150. data/app/assets/stylesheets/jquery.ui.tooltip.css.erb +23 -0
  151. data/lib/jquery-ui-middleman.rb +1 -0
  152. data/lib/jquery/ui/version.rb +6 -0
  153. metadata +209 -0
@@ -0,0 +1,2040 @@
1
+ //= require jquery.ui.core
2
+
3
+ /*!
4
+ * jQuery UI Datepicker 1.10.3
5
+ * http://jqueryui.com
6
+ *
7
+ * Copyright 2013 jQuery Foundation and other contributors
8
+ * Released under the MIT license.
9
+ * http://jquery.org/license
10
+ *
11
+ * http://api.jqueryui.com/datepicker/
12
+ *
13
+ * Depends:
14
+ * jquery.ui.core.js
15
+ */
16
+ (function( $, undefined ) {
17
+
18
+ $.extend($.ui, { datepicker: { version: "1.10.3" } });
19
+
20
+ var PROP_NAME = "datepicker",
21
+ instActive;
22
+
23
+ /* Date picker manager.
24
+ Use the singleton instance of this class, $.datepicker, to interact with the date picker.
25
+ Settings for (groups of) date pickers are maintained in an instance object,
26
+ allowing multiple different settings on the same page. */
27
+
28
+ function Datepicker() {
29
+ this._curInst = null; // The current instance in use
30
+ this._keyEvent = false; // If the last event was a key event
31
+ this._disabledInputs = []; // List of date picker inputs that have been disabled
32
+ this._datepickerShowing = false; // True if the popup picker is showing , false if not
33
+ this._inDialog = false; // True if showing within a "dialog", false if not
34
+ this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
35
+ this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
36
+ this._appendClass = "ui-datepicker-append"; // The name of the append marker class
37
+ this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
38
+ this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
39
+ this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
40
+ this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
41
+ this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
42
+ this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
43
+ this.regional = []; // Available regional settings, indexed by language code
44
+ this.regional[""] = { // Default regional settings
45
+ closeText: "Done", // Display text for close link
46
+ prevText: "Prev", // Display text for previous month link
47
+ nextText: "Next", // Display text for next month link
48
+ currentText: "Today", // Display text for current month link
49
+ monthNames: ["January","February","March","April","May","June",
50
+ "July","August","September","October","November","December"], // Names of months for drop-down and formatting
51
+ monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
52
+ dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
53
+ dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
54
+ dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
55
+ weekHeader: "Wk", // Column header for week of the year
56
+ dateFormat: "mm/dd/yy", // See format options on parseDate
57
+ firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
58
+ isRTL: false, // True if right-to-left language, false if left-to-right
59
+ showMonthAfterYear: false, // True if the year select precedes month, false for month then year
60
+ yearSuffix: "" // Additional text to append to the year in the month headers
61
+ };
62
+ this._defaults = { // Global defaults for all the date picker instances
63
+ showOn: "focus", // "focus" for popup on focus,
64
+ // "button" for trigger button, or "both" for either
65
+ showAnim: "fadeIn", // Name of jQuery animation for popup
66
+ showOptions: {}, // Options for enhanced animations
67
+ defaultDate: null, // Used when field is blank: actual date,
68
+ // +/-number for offset from today, null for today
69
+ appendText: "", // Display text following the input box, e.g. showing the format
70
+ buttonText: "...", // Text for trigger button
71
+ buttonImage: "", // URL for trigger button image
72
+ buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
73
+ hideIfNoPrevNext: false, // True to hide next/previous month links
74
+ // if not applicable, false to just disable them
75
+ navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
76
+ gotoCurrent: false, // True if today link goes back to current selection instead
77
+ changeMonth: false, // True if month can be selected directly, false if only prev/next
78
+ changeYear: false, // True if year can be selected directly, false if only prev/next
79
+ yearRange: "c-10:c+10", // Range of years to display in drop-down,
80
+ // either relative to today's year (-nn:+nn), relative to currently displayed year
81
+ // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
82
+ showOtherMonths: false, // True to show dates in other months, false to leave blank
83
+ selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
84
+ showWeek: false, // True to show week of the year, false to not show it
85
+ calculateWeek: this.iso8601Week, // How to calculate the week of the year,
86
+ // takes a Date and returns the number of the week for it
87
+ shortYearCutoff: "+10", // Short year values < this are in the current century,
88
+ // > this are in the previous century,
89
+ // string value starting with "+" for current year + value
90
+ minDate: null, // The earliest selectable date, or null for no limit
91
+ maxDate: null, // The latest selectable date, or null for no limit
92
+ duration: "fast", // Duration of display/closure
93
+ beforeShowDay: null, // Function that takes a date and returns an array with
94
+ // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
95
+ // [2] = cell title (optional), e.g. $.datepicker.noWeekends
96
+ beforeShow: null, // Function that takes an input field and
97
+ // returns a set of custom settings for the date picker
98
+ onSelect: null, // Define a callback function when a date is selected
99
+ onChangeMonthYear: null, // Define a callback function when the month or year is changed
100
+ onClose: null, // Define a callback function when the datepicker is closed
101
+ numberOfMonths: 1, // Number of months to show at a time
102
+ showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
103
+ stepMonths: 1, // Number of months to step back/forward
104
+ stepBigMonths: 12, // Number of months to step back/forward for the big links
105
+ altField: "", // Selector for an alternate field to store selected dates into
106
+ altFormat: "", // The date format to use for the alternate field
107
+ constrainInput: true, // The input is constrained by the current date format
108
+ showButtonPanel: false, // True to show button panel, false to not show it
109
+ autoSize: false, // True to size the input for the date format, false to leave as is
110
+ disabled: false // The initial disabled state
111
+ };
112
+ $.extend(this._defaults, this.regional[""]);
113
+ this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
114
+ }
115
+
116
+ $.extend(Datepicker.prototype, {
117
+ /* Class name added to elements to indicate already configured with a date picker. */
118
+ markerClassName: "hasDatepicker",
119
+
120
+ //Keep track of the maximum number of rows displayed (see #7043)
121
+ maxRows: 4,
122
+
123
+ // TODO rename to "widget" when switching to widget factory
124
+ _widgetDatepicker: function() {
125
+ return this.dpDiv;
126
+ },
127
+
128
+ /* Override the default settings for all instances of the date picker.
129
+ * @param settings object - the new settings to use as defaults (anonymous object)
130
+ * @return the manager object
131
+ */
132
+ setDefaults: function(settings) {
133
+ extendRemove(this._defaults, settings || {});
134
+ return this;
135
+ },
136
+
137
+ /* Attach the date picker to a jQuery selection.
138
+ * @param target element - the target input field or division or span
139
+ * @param settings object - the new settings to use for this date picker instance (anonymous)
140
+ */
141
+ _attachDatepicker: function(target, settings) {
142
+ var nodeName, inline, inst;
143
+ nodeName = target.nodeName.toLowerCase();
144
+ inline = (nodeName === "div" || nodeName === "span");
145
+ if (!target.id) {
146
+ this.uuid += 1;
147
+ target.id = "dp" + this.uuid;
148
+ }
149
+ inst = this._newInst($(target), inline);
150
+ inst.settings = $.extend({}, settings || {});
151
+ if (nodeName === "input") {
152
+ this._connectDatepicker(target, inst);
153
+ } else if (inline) {
154
+ this._inlineDatepicker(target, inst);
155
+ }
156
+ },
157
+
158
+ /* Create a new instance object. */
159
+ _newInst: function(target, inline) {
160
+ var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
161
+ return {id: id, input: target, // associated target
162
+ selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
163
+ drawMonth: 0, drawYear: 0, // month being drawn
164
+ inline: inline, // is datepicker inline or not
165
+ dpDiv: (!inline ? this.dpDiv : // presentation div
166
+ bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
167
+ },
168
+
169
+ /* Attach the date picker to an input field. */
170
+ _connectDatepicker: function(target, inst) {
171
+ var input = $(target);
172
+ inst.append = $([]);
173
+ inst.trigger = $([]);
174
+ if (input.hasClass(this.markerClassName)) {
175
+ return;
176
+ }
177
+ this._attachments(input, inst);
178
+ input.addClass(this.markerClassName).keydown(this._doKeyDown).
179
+ keypress(this._doKeyPress).keyup(this._doKeyUp);
180
+ this._autoSize(inst);
181
+ $.data(target, PROP_NAME, inst);
182
+ //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
183
+ if( inst.settings.disabled ) {
184
+ this._disableDatepicker( target );
185
+ }
186
+ },
187
+
188
+ /* Make attachments based on settings. */
189
+ _attachments: function(input, inst) {
190
+ var showOn, buttonText, buttonImage,
191
+ appendText = this._get(inst, "appendText"),
192
+ isRTL = this._get(inst, "isRTL");
193
+
194
+ if (inst.append) {
195
+ inst.append.remove();
196
+ }
197
+ if (appendText) {
198
+ inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
199
+ input[isRTL ? "before" : "after"](inst.append);
200
+ }
201
+
202
+ input.unbind("focus", this._showDatepicker);
203
+
204
+ if (inst.trigger) {
205
+ inst.trigger.remove();
206
+ }
207
+
208
+ showOn = this._get(inst, "showOn");
209
+ if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
210
+ input.focus(this._showDatepicker);
211
+ }
212
+ if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
213
+ buttonText = this._get(inst, "buttonText");
214
+ buttonImage = this._get(inst, "buttonImage");
215
+ inst.trigger = $(this._get(inst, "buttonImageOnly") ?
216
+ $("<img/>").addClass(this._triggerClass).
217
+ attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
218
+ $("<button type='button'></button>").addClass(this._triggerClass).
219
+ html(!buttonImage ? buttonText : $("<img/>").attr(
220
+ { src:buttonImage, alt:buttonText, title:buttonText })));
221
+ input[isRTL ? "before" : "after"](inst.trigger);
222
+ inst.trigger.click(function() {
223
+ if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
224
+ $.datepicker._hideDatepicker();
225
+ } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
226
+ $.datepicker._hideDatepicker();
227
+ $.datepicker._showDatepicker(input[0]);
228
+ } else {
229
+ $.datepicker._showDatepicker(input[0]);
230
+ }
231
+ return false;
232
+ });
233
+ }
234
+ },
235
+
236
+ /* Apply the maximum length for the date format. */
237
+ _autoSize: function(inst) {
238
+ if (this._get(inst, "autoSize") && !inst.inline) {
239
+ var findMax, max, maxI, i,
240
+ date = new Date(2009, 12 - 1, 20), // Ensure double digits
241
+ dateFormat = this._get(inst, "dateFormat");
242
+
243
+ if (dateFormat.match(/[DM]/)) {
244
+ findMax = function(names) {
245
+ max = 0;
246
+ maxI = 0;
247
+ for (i = 0; i < names.length; i++) {
248
+ if (names[i].length > max) {
249
+ max = names[i].length;
250
+ maxI = i;
251
+ }
252
+ }
253
+ return maxI;
254
+ };
255
+ date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
256
+ "monthNames" : "monthNamesShort"))));
257
+ date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
258
+ "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
259
+ }
260
+ inst.input.attr("size", this._formatDate(inst, date).length);
261
+ }
262
+ },
263
+
264
+ /* Attach an inline date picker to a div. */
265
+ _inlineDatepicker: function(target, inst) {
266
+ var divSpan = $(target);
267
+ if (divSpan.hasClass(this.markerClassName)) {
268
+ return;
269
+ }
270
+ divSpan.addClass(this.markerClassName).append(inst.dpDiv);
271
+ $.data(target, PROP_NAME, inst);
272
+ this._setDate(inst, this._getDefaultDate(inst), true);
273
+ this._updateDatepicker(inst);
274
+ this._updateAlternate(inst);
275
+ //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
276
+ if( inst.settings.disabled ) {
277
+ this._disableDatepicker( target );
278
+ }
279
+ // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
280
+ // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
281
+ inst.dpDiv.css( "display", "block" );
282
+ },
283
+
284
+ /* Pop-up the date picker in a "dialog" box.
285
+ * @param input element - ignored
286
+ * @param date string or Date - the initial date to display
287
+ * @param onSelect function - the function to call when a date is selected
288
+ * @param settings object - update the dialog date picker instance's settings (anonymous object)
289
+ * @param pos int[2] - coordinates for the dialog's position within the screen or
290
+ * event - with x/y coordinates or
291
+ * leave empty for default (screen centre)
292
+ * @return the manager object
293
+ */
294
+ _dialogDatepicker: function(input, date, onSelect, settings, pos) {
295
+ var id, browserWidth, browserHeight, scrollX, scrollY,
296
+ inst = this._dialogInst; // internal instance
297
+
298
+ if (!inst) {
299
+ this.uuid += 1;
300
+ id = "dp" + this.uuid;
301
+ this._dialogInput = $("<input type='text' id='" + id +
302
+ "' style='position: absolute; top: -100px; width: 0px;'/>");
303
+ this._dialogInput.keydown(this._doKeyDown);
304
+ $("body").append(this._dialogInput);
305
+ inst = this._dialogInst = this._newInst(this._dialogInput, false);
306
+ inst.settings = {};
307
+ $.data(this._dialogInput[0], PROP_NAME, inst);
308
+ }
309
+ extendRemove(inst.settings, settings || {});
310
+ date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
311
+ this._dialogInput.val(date);
312
+
313
+ this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
314
+ if (!this._pos) {
315
+ browserWidth = document.documentElement.clientWidth;
316
+ browserHeight = document.documentElement.clientHeight;
317
+ scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
318
+ scrollY = document.documentElement.scrollTop || document.body.scrollTop;
319
+ this._pos = // should use actual width/height below
320
+ [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
321
+ }
322
+
323
+ // move input on screen for focus, but hidden behind dialog
324
+ this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
325
+ inst.settings.onSelect = onSelect;
326
+ this._inDialog = true;
327
+ this.dpDiv.addClass(this._dialogClass);
328
+ this._showDatepicker(this._dialogInput[0]);
329
+ if ($.blockUI) {
330
+ $.blockUI(this.dpDiv);
331
+ }
332
+ $.data(this._dialogInput[0], PROP_NAME, inst);
333
+ return this;
334
+ },
335
+
336
+ /* Detach a datepicker from its control.
337
+ * @param target element - the target input field or division or span
338
+ */
339
+ _destroyDatepicker: function(target) {
340
+ var nodeName,
341
+ $target = $(target),
342
+ inst = $.data(target, PROP_NAME);
343
+
344
+ if (!$target.hasClass(this.markerClassName)) {
345
+ return;
346
+ }
347
+
348
+ nodeName = target.nodeName.toLowerCase();
349
+ $.removeData(target, PROP_NAME);
350
+ if (nodeName === "input") {
351
+ inst.append.remove();
352
+ inst.trigger.remove();
353
+ $target.removeClass(this.markerClassName).
354
+ unbind("focus", this._showDatepicker).
355
+ unbind("keydown", this._doKeyDown).
356
+ unbind("keypress", this._doKeyPress).
357
+ unbind("keyup", this._doKeyUp);
358
+ } else if (nodeName === "div" || nodeName === "span") {
359
+ $target.removeClass(this.markerClassName).empty();
360
+ }
361
+ },
362
+
363
+ /* Enable the date picker to a jQuery selection.
364
+ * @param target element - the target input field or division or span
365
+ */
366
+ _enableDatepicker: function(target) {
367
+ var nodeName, inline,
368
+ $target = $(target),
369
+ inst = $.data(target, PROP_NAME);
370
+
371
+ if (!$target.hasClass(this.markerClassName)) {
372
+ return;
373
+ }
374
+
375
+ nodeName = target.nodeName.toLowerCase();
376
+ if (nodeName === "input") {
377
+ target.disabled = false;
378
+ inst.trigger.filter("button").
379
+ each(function() { this.disabled = false; }).end().
380
+ filter("img").css({opacity: "1.0", cursor: ""});
381
+ } else if (nodeName === "div" || nodeName === "span") {
382
+ inline = $target.children("." + this._inlineClass);
383
+ inline.children().removeClass("ui-state-disabled");
384
+ inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
385
+ prop("disabled", false);
386
+ }
387
+ this._disabledInputs = $.map(this._disabledInputs,
388
+ function(value) { return (value === target ? null : value); }); // delete entry
389
+ },
390
+
391
+ /* Disable the date picker to a jQuery selection.
392
+ * @param target element - the target input field or division or span
393
+ */
394
+ _disableDatepicker: function(target) {
395
+ var nodeName, inline,
396
+ $target = $(target),
397
+ inst = $.data(target, PROP_NAME);
398
+
399
+ if (!$target.hasClass(this.markerClassName)) {
400
+ return;
401
+ }
402
+
403
+ nodeName = target.nodeName.toLowerCase();
404
+ if (nodeName === "input") {
405
+ target.disabled = true;
406
+ inst.trigger.filter("button").
407
+ each(function() { this.disabled = true; }).end().
408
+ filter("img").css({opacity: "0.5", cursor: "default"});
409
+ } else if (nodeName === "div" || nodeName === "span") {
410
+ inline = $target.children("." + this._inlineClass);
411
+ inline.children().addClass("ui-state-disabled");
412
+ inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
413
+ prop("disabled", true);
414
+ }
415
+ this._disabledInputs = $.map(this._disabledInputs,
416
+ function(value) { return (value === target ? null : value); }); // delete entry
417
+ this._disabledInputs[this._disabledInputs.length] = target;
418
+ },
419
+
420
+ /* Is the first field in a jQuery collection disabled as a datepicker?
421
+ * @param target element - the target input field or division or span
422
+ * @return boolean - true if disabled, false if enabled
423
+ */
424
+ _isDisabledDatepicker: function(target) {
425
+ if (!target) {
426
+ return false;
427
+ }
428
+ for (var i = 0; i < this._disabledInputs.length; i++) {
429
+ if (this._disabledInputs[i] === target) {
430
+ return true;
431
+ }
432
+ }
433
+ return false;
434
+ },
435
+
436
+ /* Retrieve the instance data for the target control.
437
+ * @param target element - the target input field or division or span
438
+ * @return object - the associated instance data
439
+ * @throws error if a jQuery problem getting data
440
+ */
441
+ _getInst: function(target) {
442
+ try {
443
+ return $.data(target, PROP_NAME);
444
+ }
445
+ catch (err) {
446
+ throw "Missing instance data for this datepicker";
447
+ }
448
+ },
449
+
450
+ /* Update or retrieve the settings for a date picker attached to an input field or division.
451
+ * @param target element - the target input field or division or span
452
+ * @param name object - the new settings to update or
453
+ * string - the name of the setting to change or retrieve,
454
+ * when retrieving also "all" for all instance settings or
455
+ * "defaults" for all global defaults
456
+ * @param value any - the new value for the setting
457
+ * (omit if above is an object or to retrieve a value)
458
+ */
459
+ _optionDatepicker: function(target, name, value) {
460
+ var settings, date, minDate, maxDate,
461
+ inst = this._getInst(target);
462
+
463
+ if (arguments.length === 2 && typeof name === "string") {
464
+ return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
465
+ (inst ? (name === "all" ? $.extend({}, inst.settings) :
466
+ this._get(inst, name)) : null));
467
+ }
468
+
469
+ settings = name || {};
470
+ if (typeof name === "string") {
471
+ settings = {};
472
+ settings[name] = value;
473
+ }
474
+
475
+ if (inst) {
476
+ if (this._curInst === inst) {
477
+ this._hideDatepicker();
478
+ }
479
+
480
+ date = this._getDateDatepicker(target, true);
481
+ minDate = this._getMinMaxDate(inst, "min");
482
+ maxDate = this._getMinMaxDate(inst, "max");
483
+ extendRemove(inst.settings, settings);
484
+ // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
485
+ if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
486
+ inst.settings.minDate = this._formatDate(inst, minDate);
487
+ }
488
+ if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
489
+ inst.settings.maxDate = this._formatDate(inst, maxDate);
490
+ }
491
+ if ( "disabled" in settings ) {
492
+ if ( settings.disabled ) {
493
+ this._disableDatepicker(target);
494
+ } else {
495
+ this._enableDatepicker(target);
496
+ }
497
+ }
498
+ this._attachments($(target), inst);
499
+ this._autoSize(inst);
500
+ this._setDate(inst, date);
501
+ this._updateAlternate(inst);
502
+ this._updateDatepicker(inst);
503
+ }
504
+ },
505
+
506
+ // change method deprecated
507
+ _changeDatepicker: function(target, name, value) {
508
+ this._optionDatepicker(target, name, value);
509
+ },
510
+
511
+ /* Redraw the date picker attached to an input field or division.
512
+ * @param target element - the target input field or division or span
513
+ */
514
+ _refreshDatepicker: function(target) {
515
+ var inst = this._getInst(target);
516
+ if (inst) {
517
+ this._updateDatepicker(inst);
518
+ }
519
+ },
520
+
521
+ /* Set the dates for a jQuery selection.
522
+ * @param target element - the target input field or division or span
523
+ * @param date Date - the new date
524
+ */
525
+ _setDateDatepicker: function(target, date) {
526
+ var inst = this._getInst(target);
527
+ if (inst) {
528
+ this._setDate(inst, date);
529
+ this._updateDatepicker(inst);
530
+ this._updateAlternate(inst);
531
+ }
532
+ },
533
+
534
+ /* Get the date(s) for the first entry in a jQuery selection.
535
+ * @param target element - the target input field or division or span
536
+ * @param noDefault boolean - true if no default date is to be used
537
+ * @return Date - the current date
538
+ */
539
+ _getDateDatepicker: function(target, noDefault) {
540
+ var inst = this._getInst(target);
541
+ if (inst && !inst.inline) {
542
+ this._setDateFromField(inst, noDefault);
543
+ }
544
+ return (inst ? this._getDate(inst) : null);
545
+ },
546
+
547
+ /* Handle keystrokes. */
548
+ _doKeyDown: function(event) {
549
+ var onSelect, dateStr, sel,
550
+ inst = $.datepicker._getInst(event.target),
551
+ handled = true,
552
+ isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
553
+
554
+ inst._keyEvent = true;
555
+ if ($.datepicker._datepickerShowing) {
556
+ switch (event.keyCode) {
557
+ case 9: $.datepicker._hideDatepicker();
558
+ handled = false;
559
+ break; // hide on tab out
560
+ case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
561
+ $.datepicker._currentClass + ")", inst.dpDiv);
562
+ if (sel[0]) {
563
+ $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
564
+ }
565
+
566
+ onSelect = $.datepicker._get(inst, "onSelect");
567
+ if (onSelect) {
568
+ dateStr = $.datepicker._formatDate(inst);
569
+
570
+ // trigger custom callback
571
+ onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
572
+ } else {
573
+ $.datepicker._hideDatepicker();
574
+ }
575
+
576
+ return false; // don't submit the form
577
+ case 27: $.datepicker._hideDatepicker();
578
+ break; // hide on escape
579
+ case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
580
+ -$.datepicker._get(inst, "stepBigMonths") :
581
+ -$.datepicker._get(inst, "stepMonths")), "M");
582
+ break; // previous month/year on page up/+ ctrl
583
+ case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
584
+ +$.datepicker._get(inst, "stepBigMonths") :
585
+ +$.datepicker._get(inst, "stepMonths")), "M");
586
+ break; // next month/year on page down/+ ctrl
587
+ case 35: if (event.ctrlKey || event.metaKey) {
588
+ $.datepicker._clearDate(event.target);
589
+ }
590
+ handled = event.ctrlKey || event.metaKey;
591
+ break; // clear on ctrl or command +end
592
+ case 36: if (event.ctrlKey || event.metaKey) {
593
+ $.datepicker._gotoToday(event.target);
594
+ }
595
+ handled = event.ctrlKey || event.metaKey;
596
+ break; // current on ctrl or command +home
597
+ case 37: if (event.ctrlKey || event.metaKey) {
598
+ $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
599
+ }
600
+ handled = event.ctrlKey || event.metaKey;
601
+ // -1 day on ctrl or command +left
602
+ if (event.originalEvent.altKey) {
603
+ $.datepicker._adjustDate(event.target, (event.ctrlKey ?
604
+ -$.datepicker._get(inst, "stepBigMonths") :
605
+ -$.datepicker._get(inst, "stepMonths")), "M");
606
+ }
607
+ // next month/year on alt +left on Mac
608
+ break;
609
+ case 38: if (event.ctrlKey || event.metaKey) {
610
+ $.datepicker._adjustDate(event.target, -7, "D");
611
+ }
612
+ handled = event.ctrlKey || event.metaKey;
613
+ break; // -1 week on ctrl or command +up
614
+ case 39: if (event.ctrlKey || event.metaKey) {
615
+ $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
616
+ }
617
+ handled = event.ctrlKey || event.metaKey;
618
+ // +1 day on ctrl or command +right
619
+ if (event.originalEvent.altKey) {
620
+ $.datepicker._adjustDate(event.target, (event.ctrlKey ?
621
+ +$.datepicker._get(inst, "stepBigMonths") :
622
+ +$.datepicker._get(inst, "stepMonths")), "M");
623
+ }
624
+ // next month/year on alt +right
625
+ break;
626
+ case 40: if (event.ctrlKey || event.metaKey) {
627
+ $.datepicker._adjustDate(event.target, +7, "D");
628
+ }
629
+ handled = event.ctrlKey || event.metaKey;
630
+ break; // +1 week on ctrl or command +down
631
+ default: handled = false;
632
+ }
633
+ } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
634
+ $.datepicker._showDatepicker(this);
635
+ } else {
636
+ handled = false;
637
+ }
638
+
639
+ if (handled) {
640
+ event.preventDefault();
641
+ event.stopPropagation();
642
+ }
643
+ },
644
+
645
+ /* Filter entered characters - based on date format. */
646
+ _doKeyPress: function(event) {
647
+ var chars, chr,
648
+ inst = $.datepicker._getInst(event.target);
649
+
650
+ if ($.datepicker._get(inst, "constrainInput")) {
651
+ chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
652
+ chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
653
+ return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
654
+ }
655
+ },
656
+
657
+ /* Synchronise manual entry and field/alternate field. */
658
+ _doKeyUp: function(event) {
659
+ var date,
660
+ inst = $.datepicker._getInst(event.target);
661
+
662
+ if (inst.input.val() !== inst.lastVal) {
663
+ try {
664
+ date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
665
+ (inst.input ? inst.input.val() : null),
666
+ $.datepicker._getFormatConfig(inst));
667
+
668
+ if (date) { // only if valid
669
+ $.datepicker._setDateFromField(inst);
670
+ $.datepicker._updateAlternate(inst);
671
+ $.datepicker._updateDatepicker(inst);
672
+ }
673
+ }
674
+ catch (err) {
675
+ }
676
+ }
677
+ return true;
678
+ },
679
+
680
+ /* Pop-up the date picker for a given input field.
681
+ * If false returned from beforeShow event handler do not show.
682
+ * @param input element - the input field attached to the date picker or
683
+ * event - if triggered by focus
684
+ */
685
+ _showDatepicker: function(input) {
686
+ input = input.target || input;
687
+ if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
688
+ input = $("input", input.parentNode)[0];
689
+ }
690
+
691
+ if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
692
+ return;
693
+ }
694
+
695
+ var inst, beforeShow, beforeShowSettings, isFixed,
696
+ offset, showAnim, duration;
697
+
698
+ inst = $.datepicker._getInst(input);
699
+ if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
700
+ $.datepicker._curInst.dpDiv.stop(true, true);
701
+ if ( inst && $.datepicker._datepickerShowing ) {
702
+ $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
703
+ }
704
+ }
705
+
706
+ beforeShow = $.datepicker._get(inst, "beforeShow");
707
+ beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
708
+ if(beforeShowSettings === false){
709
+ return;
710
+ }
711
+ extendRemove(inst.settings, beforeShowSettings);
712
+
713
+ inst.lastVal = null;
714
+ $.datepicker._lastInput = input;
715
+ $.datepicker._setDateFromField(inst);
716
+
717
+ if ($.datepicker._inDialog) { // hide cursor
718
+ input.value = "";
719
+ }
720
+ if (!$.datepicker._pos) { // position below input
721
+ $.datepicker._pos = $.datepicker._findPos(input);
722
+ $.datepicker._pos[1] += input.offsetHeight; // add the height
723
+ }
724
+
725
+ isFixed = false;
726
+ $(input).parents().each(function() {
727
+ isFixed |= $(this).css("position") === "fixed";
728
+ return !isFixed;
729
+ });
730
+
731
+ offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
732
+ $.datepicker._pos = null;
733
+ //to avoid flashes on Firefox
734
+ inst.dpDiv.empty();
735
+ // determine sizing offscreen
736
+ inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
737
+ $.datepicker._updateDatepicker(inst);
738
+ // fix width for dynamic number of date pickers
739
+ // and adjust position before showing
740
+ offset = $.datepicker._checkOffset(inst, offset, isFixed);
741
+ inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
742
+ "static" : (isFixed ? "fixed" : "absolute")), display: "none",
743
+ left: offset.left + "px", top: offset.top + "px"});
744
+
745
+ if (!inst.inline) {
746
+ showAnim = $.datepicker._get(inst, "showAnim");
747
+ duration = $.datepicker._get(inst, "duration");
748
+ inst.dpDiv.zIndex($(input).zIndex()+1);
749
+ $.datepicker._datepickerShowing = true;
750
+
751
+ if ( $.effects && $.effects.effect[ showAnim ] ) {
752
+ inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
753
+ } else {
754
+ inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
755
+ }
756
+
757
+ if ( $.datepicker._shouldFocusInput( inst ) ) {
758
+ inst.input.focus();
759
+ }
760
+
761
+ $.datepicker._curInst = inst;
762
+ }
763
+ },
764
+
765
+ /* Generate the date picker content. */
766
+ _updateDatepicker: function(inst) {
767
+ this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
768
+ instActive = inst; // for delegate hover events
769
+ inst.dpDiv.empty().append(this._generateHTML(inst));
770
+ this._attachHandlers(inst);
771
+ inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
772
+
773
+ var origyearshtml,
774
+ numMonths = this._getNumberOfMonths(inst),
775
+ cols = numMonths[1],
776
+ width = 17;
777
+
778
+ inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
779
+ if (cols > 1) {
780
+ inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
781
+ }
782
+ inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
783
+ "Class"]("ui-datepicker-multi");
784
+ inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
785
+ "Class"]("ui-datepicker-rtl");
786
+
787
+ if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
788
+ inst.input.focus();
789
+ }
790
+
791
+ // deffered render of the years select (to avoid flashes on Firefox)
792
+ if( inst.yearshtml ){
793
+ origyearshtml = inst.yearshtml;
794
+ setTimeout(function(){
795
+ //assure that inst.yearshtml didn't change.
796
+ if( origyearshtml === inst.yearshtml && inst.yearshtml ){
797
+ inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
798
+ }
799
+ origyearshtml = inst.yearshtml = null;
800
+ }, 0);
801
+ }
802
+ },
803
+
804
+ // #6694 - don't focus the input if it's already focused
805
+ // this breaks the change event in IE
806
+ // Support: IE and jQuery <1.9
807
+ _shouldFocusInput: function( inst ) {
808
+ return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
809
+ },
810
+
811
+ /* Check positioning to remain on screen. */
812
+ _checkOffset: function(inst, offset, isFixed) {
813
+ var dpWidth = inst.dpDiv.outerWidth(),
814
+ dpHeight = inst.dpDiv.outerHeight(),
815
+ inputWidth = inst.input ? inst.input.outerWidth() : 0,
816
+ inputHeight = inst.input ? inst.input.outerHeight() : 0,
817
+ viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
818
+ viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
819
+
820
+ offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
821
+ offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
822
+ offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
823
+
824
+ // now check if datepicker is showing outside window viewport - move to a better place if so.
825
+ offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
826
+ Math.abs(offset.left + dpWidth - viewWidth) : 0);
827
+ offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
828
+ Math.abs(dpHeight + inputHeight) : 0);
829
+
830
+ return offset;
831
+ },
832
+
833
+ /* Find an object's position on the screen. */
834
+ _findPos: function(obj) {
835
+ var position,
836
+ inst = this._getInst(obj),
837
+ isRTL = this._get(inst, "isRTL");
838
+
839
+ while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
840
+ obj = obj[isRTL ? "previousSibling" : "nextSibling"];
841
+ }
842
+
843
+ position = $(obj).offset();
844
+ return [position.left, position.top];
845
+ },
846
+
847
+ /* Hide the date picker from view.
848
+ * @param input element - the input field attached to the date picker
849
+ */
850
+ _hideDatepicker: function(input) {
851
+ var showAnim, duration, postProcess, onClose,
852
+ inst = this._curInst;
853
+
854
+ if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
855
+ return;
856
+ }
857
+
858
+ if (this._datepickerShowing) {
859
+ showAnim = this._get(inst, "showAnim");
860
+ duration = this._get(inst, "duration");
861
+ postProcess = function() {
862
+ $.datepicker._tidyDialog(inst);
863
+ };
864
+
865
+ // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
866
+ if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
867
+ inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
868
+ } else {
869
+ inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
870
+ (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
871
+ }
872
+
873
+ if (!showAnim) {
874
+ postProcess();
875
+ }
876
+ this._datepickerShowing = false;
877
+
878
+ onClose = this._get(inst, "onClose");
879
+ if (onClose) {
880
+ onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
881
+ }
882
+
883
+ this._lastInput = null;
884
+ if (this._inDialog) {
885
+ this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
886
+ if ($.blockUI) {
887
+ $.unblockUI();
888
+ $("body").append(this.dpDiv);
889
+ }
890
+ }
891
+ this._inDialog = false;
892
+ }
893
+ },
894
+
895
+ /* Tidy up after a dialog display. */
896
+ _tidyDialog: function(inst) {
897
+ inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
898
+ },
899
+
900
+ /* Close date picker if clicked elsewhere. */
901
+ _checkExternalClick: function(event) {
902
+ if (!$.datepicker._curInst) {
903
+ return;
904
+ }
905
+
906
+ var $target = $(event.target),
907
+ inst = $.datepicker._getInst($target[0]);
908
+
909
+ if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
910
+ $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
911
+ !$target.hasClass($.datepicker.markerClassName) &&
912
+ !$target.closest("." + $.datepicker._triggerClass).length &&
913
+ $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
914
+ ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
915
+ $.datepicker._hideDatepicker();
916
+ }
917
+ },
918
+
919
+ /* Adjust one of the date sub-fields. */
920
+ _adjustDate: function(id, offset, period) {
921
+ var target = $(id),
922
+ inst = this._getInst(target[0]);
923
+
924
+ if (this._isDisabledDatepicker(target[0])) {
925
+ return;
926
+ }
927
+ this._adjustInstDate(inst, offset +
928
+ (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
929
+ period);
930
+ this._updateDatepicker(inst);
931
+ },
932
+
933
+ /* Action for current link. */
934
+ _gotoToday: function(id) {
935
+ var date,
936
+ target = $(id),
937
+ inst = this._getInst(target[0]);
938
+
939
+ if (this._get(inst, "gotoCurrent") && inst.currentDay) {
940
+ inst.selectedDay = inst.currentDay;
941
+ inst.drawMonth = inst.selectedMonth = inst.currentMonth;
942
+ inst.drawYear = inst.selectedYear = inst.currentYear;
943
+ } else {
944
+ date = new Date();
945
+ inst.selectedDay = date.getDate();
946
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
947
+ inst.drawYear = inst.selectedYear = date.getFullYear();
948
+ }
949
+ this._notifyChange(inst);
950
+ this._adjustDate(target);
951
+ },
952
+
953
+ /* Action for selecting a new month/year. */
954
+ _selectMonthYear: function(id, select, period) {
955
+ var target = $(id),
956
+ inst = this._getInst(target[0]);
957
+
958
+ inst["selected" + (period === "M" ? "Month" : "Year")] =
959
+ inst["draw" + (period === "M" ? "Month" : "Year")] =
960
+ parseInt(select.options[select.selectedIndex].value,10);
961
+
962
+ this._notifyChange(inst);
963
+ this._adjustDate(target);
964
+ },
965
+
966
+ /* Action for selecting a day. */
967
+ _selectDay: function(id, month, year, td) {
968
+ var inst,
969
+ target = $(id);
970
+
971
+ if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
972
+ return;
973
+ }
974
+
975
+ inst = this._getInst(target[0]);
976
+ inst.selectedDay = inst.currentDay = $("a", td).html();
977
+ inst.selectedMonth = inst.currentMonth = month;
978
+ inst.selectedYear = inst.currentYear = year;
979
+ this._selectDate(id, this._formatDate(inst,
980
+ inst.currentDay, inst.currentMonth, inst.currentYear));
981
+ },
982
+
983
+ /* Erase the input field and hide the date picker. */
984
+ _clearDate: function(id) {
985
+ var target = $(id);
986
+ this._selectDate(target, "");
987
+ },
988
+
989
+ /* Update the input field with the selected date. */
990
+ _selectDate: function(id, dateStr) {
991
+ var onSelect,
992
+ target = $(id),
993
+ inst = this._getInst(target[0]);
994
+
995
+ dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
996
+ if (inst.input) {
997
+ inst.input.val(dateStr);
998
+ }
999
+ this._updateAlternate(inst);
1000
+
1001
+ onSelect = this._get(inst, "onSelect");
1002
+ if (onSelect) {
1003
+ onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
1004
+ } else if (inst.input) {
1005
+ inst.input.trigger("change"); // fire the change event
1006
+ }
1007
+
1008
+ if (inst.inline){
1009
+ this._updateDatepicker(inst);
1010
+ } else {
1011
+ this._hideDatepicker();
1012
+ this._lastInput = inst.input[0];
1013
+ if (typeof(inst.input[0]) !== "object") {
1014
+ inst.input.focus(); // restore focus
1015
+ }
1016
+ this._lastInput = null;
1017
+ }
1018
+ },
1019
+
1020
+ /* Update any alternate field to synchronise with the main field. */
1021
+ _updateAlternate: function(inst) {
1022
+ var altFormat, date, dateStr,
1023
+ altField = this._get(inst, "altField");
1024
+
1025
+ if (altField) { // update alternate field too
1026
+ altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
1027
+ date = this._getDate(inst);
1028
+ dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
1029
+ $(altField).each(function() { $(this).val(dateStr); });
1030
+ }
1031
+ },
1032
+
1033
+ /* Set as beforeShowDay function to prevent selection of weekends.
1034
+ * @param date Date - the date to customise
1035
+ * @return [boolean, string] - is this date selectable?, what is its CSS class?
1036
+ */
1037
+ noWeekends: function(date) {
1038
+ var day = date.getDay();
1039
+ return [(day > 0 && day < 6), ""];
1040
+ },
1041
+
1042
+ /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
1043
+ * @param date Date - the date to get the week for
1044
+ * @return number - the number of the week within the year that contains this date
1045
+ */
1046
+ iso8601Week: function(date) {
1047
+ var time,
1048
+ checkDate = new Date(date.getTime());
1049
+
1050
+ // Find Thursday of this week starting on Monday
1051
+ checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
1052
+
1053
+ time = checkDate.getTime();
1054
+ checkDate.setMonth(0); // Compare with Jan 1
1055
+ checkDate.setDate(1);
1056
+ return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
1057
+ },
1058
+
1059
+ /* Parse a string value into a date object.
1060
+ * See formatDate below for the possible formats.
1061
+ *
1062
+ * @param format string - the expected format of the date
1063
+ * @param value string - the date in the above format
1064
+ * @param settings Object - attributes include:
1065
+ * shortYearCutoff number - the cutoff year for determining the century (optional)
1066
+ * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
1067
+ * dayNames string[7] - names of the days from Sunday (optional)
1068
+ * monthNamesShort string[12] - abbreviated names of the months (optional)
1069
+ * monthNames string[12] - names of the months (optional)
1070
+ * @return Date - the extracted date value or null if value is blank
1071
+ */
1072
+ parseDate: function (format, value, settings) {
1073
+ if (format == null || value == null) {
1074
+ throw "Invalid arguments";
1075
+ }
1076
+
1077
+ value = (typeof value === "object" ? value.toString() : value + "");
1078
+ if (value === "") {
1079
+ return null;
1080
+ }
1081
+
1082
+ var iFormat, dim, extra,
1083
+ iValue = 0,
1084
+ shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
1085
+ shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
1086
+ new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
1087
+ dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
1088
+ dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
1089
+ monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
1090
+ monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
1091
+ year = -1,
1092
+ month = -1,
1093
+ day = -1,
1094
+ doy = -1,
1095
+ literal = false,
1096
+ date,
1097
+ // Check whether a format character is doubled
1098
+ lookAhead = function(match) {
1099
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
1100
+ if (matches) {
1101
+ iFormat++;
1102
+ }
1103
+ return matches;
1104
+ },
1105
+ // Extract a number from the string value
1106
+ getNumber = function(match) {
1107
+ var isDoubled = lookAhead(match),
1108
+ size = (match === "@" ? 14 : (match === "!" ? 20 :
1109
+ (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
1110
+ digits = new RegExp("^\\d{1," + size + "}"),
1111
+ num = value.substring(iValue).match(digits);
1112
+ if (!num) {
1113
+ throw "Missing number at position " + iValue;
1114
+ }
1115
+ iValue += num[0].length;
1116
+ return parseInt(num[0], 10);
1117
+ },
1118
+ // Extract a name from the string value and convert to an index
1119
+ getName = function(match, shortNames, longNames) {
1120
+ var index = -1,
1121
+ names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
1122
+ return [ [k, v] ];
1123
+ }).sort(function (a, b) {
1124
+ return -(a[1].length - b[1].length);
1125
+ });
1126
+
1127
+ $.each(names, function (i, pair) {
1128
+ var name = pair[1];
1129
+ if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
1130
+ index = pair[0];
1131
+ iValue += name.length;
1132
+ return false;
1133
+ }
1134
+ });
1135
+ if (index !== -1) {
1136
+ return index + 1;
1137
+ } else {
1138
+ throw "Unknown name at position " + iValue;
1139
+ }
1140
+ },
1141
+ // Confirm that a literal character matches the string value
1142
+ checkLiteral = function() {
1143
+ if (value.charAt(iValue) !== format.charAt(iFormat)) {
1144
+ throw "Unexpected literal at position " + iValue;
1145
+ }
1146
+ iValue++;
1147
+ };
1148
+
1149
+ for (iFormat = 0; iFormat < format.length; iFormat++) {
1150
+ if (literal) {
1151
+ if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
1152
+ literal = false;
1153
+ } else {
1154
+ checkLiteral();
1155
+ }
1156
+ } else {
1157
+ switch (format.charAt(iFormat)) {
1158
+ case "d":
1159
+ day = getNumber("d");
1160
+ break;
1161
+ case "D":
1162
+ getName("D", dayNamesShort, dayNames);
1163
+ break;
1164
+ case "o":
1165
+ doy = getNumber("o");
1166
+ break;
1167
+ case "m":
1168
+ month = getNumber("m");
1169
+ break;
1170
+ case "M":
1171
+ month = getName("M", monthNamesShort, monthNames);
1172
+ break;
1173
+ case "y":
1174
+ year = getNumber("y");
1175
+ break;
1176
+ case "@":
1177
+ date = new Date(getNumber("@"));
1178
+ year = date.getFullYear();
1179
+ month = date.getMonth() + 1;
1180
+ day = date.getDate();
1181
+ break;
1182
+ case "!":
1183
+ date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
1184
+ year = date.getFullYear();
1185
+ month = date.getMonth() + 1;
1186
+ day = date.getDate();
1187
+ break;
1188
+ case "'":
1189
+ if (lookAhead("'")){
1190
+ checkLiteral();
1191
+ } else {
1192
+ literal = true;
1193
+ }
1194
+ break;
1195
+ default:
1196
+ checkLiteral();
1197
+ }
1198
+ }
1199
+ }
1200
+
1201
+ if (iValue < value.length){
1202
+ extra = value.substr(iValue);
1203
+ if (!/^\s+/.test(extra)) {
1204
+ throw "Extra/unparsed characters found in date: " + extra;
1205
+ }
1206
+ }
1207
+
1208
+ if (year === -1) {
1209
+ year = new Date().getFullYear();
1210
+ } else if (year < 100) {
1211
+ year += new Date().getFullYear() - new Date().getFullYear() % 100 +
1212
+ (year <= shortYearCutoff ? 0 : -100);
1213
+ }
1214
+
1215
+ if (doy > -1) {
1216
+ month = 1;
1217
+ day = doy;
1218
+ do {
1219
+ dim = this._getDaysInMonth(year, month - 1);
1220
+ if (day <= dim) {
1221
+ break;
1222
+ }
1223
+ month++;
1224
+ day -= dim;
1225
+ } while (true);
1226
+ }
1227
+
1228
+ date = this._daylightSavingAdjust(new Date(year, month - 1, day));
1229
+ if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
1230
+ throw "Invalid date"; // E.g. 31/02/00
1231
+ }
1232
+ return date;
1233
+ },
1234
+
1235
+ /* Standard date formats. */
1236
+ ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
1237
+ COOKIE: "D, dd M yy",
1238
+ ISO_8601: "yy-mm-dd",
1239
+ RFC_822: "D, d M y",
1240
+ RFC_850: "DD, dd-M-y",
1241
+ RFC_1036: "D, d M y",
1242
+ RFC_1123: "D, d M yy",
1243
+ RFC_2822: "D, d M yy",
1244
+ RSS: "D, d M y", // RFC 822
1245
+ TICKS: "!",
1246
+ TIMESTAMP: "@",
1247
+ W3C: "yy-mm-dd", // ISO 8601
1248
+
1249
+ _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
1250
+ Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
1251
+
1252
+ /* Format a date object into a string value.
1253
+ * The format can be combinations of the following:
1254
+ * d - day of month (no leading zero)
1255
+ * dd - day of month (two digit)
1256
+ * o - day of year (no leading zeros)
1257
+ * oo - day of year (three digit)
1258
+ * D - day name short
1259
+ * DD - day name long
1260
+ * m - month of year (no leading zero)
1261
+ * mm - month of year (two digit)
1262
+ * M - month name short
1263
+ * MM - month name long
1264
+ * y - year (two digit)
1265
+ * yy - year (four digit)
1266
+ * @ - Unix timestamp (ms since 01/01/1970)
1267
+ * ! - Windows ticks (100ns since 01/01/0001)
1268
+ * "..." - literal text
1269
+ * '' - single quote
1270
+ *
1271
+ * @param format string - the desired format of the date
1272
+ * @param date Date - the date value to format
1273
+ * @param settings Object - attributes include:
1274
+ * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
1275
+ * dayNames string[7] - names of the days from Sunday (optional)
1276
+ * monthNamesShort string[12] - abbreviated names of the months (optional)
1277
+ * monthNames string[12] - names of the months (optional)
1278
+ * @return string - the date in the above format
1279
+ */
1280
+ formatDate: function (format, date, settings) {
1281
+ if (!date) {
1282
+ return "";
1283
+ }
1284
+
1285
+ var iFormat,
1286
+ dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
1287
+ dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
1288
+ monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
1289
+ monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
1290
+ // Check whether a format character is doubled
1291
+ lookAhead = function(match) {
1292
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
1293
+ if (matches) {
1294
+ iFormat++;
1295
+ }
1296
+ return matches;
1297
+ },
1298
+ // Format a number, with leading zero if necessary
1299
+ formatNumber = function(match, value, len) {
1300
+ var num = "" + value;
1301
+ if (lookAhead(match)) {
1302
+ while (num.length < len) {
1303
+ num = "0" + num;
1304
+ }
1305
+ }
1306
+ return num;
1307
+ },
1308
+ // Format a name, short or long as requested
1309
+ formatName = function(match, value, shortNames, longNames) {
1310
+ return (lookAhead(match) ? longNames[value] : shortNames[value]);
1311
+ },
1312
+ output = "",
1313
+ literal = false;
1314
+
1315
+ if (date) {
1316
+ for (iFormat = 0; iFormat < format.length; iFormat++) {
1317
+ if (literal) {
1318
+ if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
1319
+ literal = false;
1320
+ } else {
1321
+ output += format.charAt(iFormat);
1322
+ }
1323
+ } else {
1324
+ switch (format.charAt(iFormat)) {
1325
+ case "d":
1326
+ output += formatNumber("d", date.getDate(), 2);
1327
+ break;
1328
+ case "D":
1329
+ output += formatName("D", date.getDay(), dayNamesShort, dayNames);
1330
+ break;
1331
+ case "o":
1332
+ output += formatNumber("o",
1333
+ Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
1334
+ break;
1335
+ case "m":
1336
+ output += formatNumber("m", date.getMonth() + 1, 2);
1337
+ break;
1338
+ case "M":
1339
+ output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
1340
+ break;
1341
+ case "y":
1342
+ output += (lookAhead("y") ? date.getFullYear() :
1343
+ (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
1344
+ break;
1345
+ case "@":
1346
+ output += date.getTime();
1347
+ break;
1348
+ case "!":
1349
+ output += date.getTime() * 10000 + this._ticksTo1970;
1350
+ break;
1351
+ case "'":
1352
+ if (lookAhead("'")) {
1353
+ output += "'";
1354
+ } else {
1355
+ literal = true;
1356
+ }
1357
+ break;
1358
+ default:
1359
+ output += format.charAt(iFormat);
1360
+ }
1361
+ }
1362
+ }
1363
+ }
1364
+ return output;
1365
+ },
1366
+
1367
+ /* Extract all possible characters from the date format. */
1368
+ _possibleChars: function (format) {
1369
+ var iFormat,
1370
+ chars = "",
1371
+ literal = false,
1372
+ // Check whether a format character is doubled
1373
+ lookAhead = function(match) {
1374
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
1375
+ if (matches) {
1376
+ iFormat++;
1377
+ }
1378
+ return matches;
1379
+ };
1380
+
1381
+ for (iFormat = 0; iFormat < format.length; iFormat++) {
1382
+ if (literal) {
1383
+ if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
1384
+ literal = false;
1385
+ } else {
1386
+ chars += format.charAt(iFormat);
1387
+ }
1388
+ } else {
1389
+ switch (format.charAt(iFormat)) {
1390
+ case "d": case "m": case "y": case "@":
1391
+ chars += "0123456789";
1392
+ break;
1393
+ case "D": case "M":
1394
+ return null; // Accept anything
1395
+ case "'":
1396
+ if (lookAhead("'")) {
1397
+ chars += "'";
1398
+ } else {
1399
+ literal = true;
1400
+ }
1401
+ break;
1402
+ default:
1403
+ chars += format.charAt(iFormat);
1404
+ }
1405
+ }
1406
+ }
1407
+ return chars;
1408
+ },
1409
+
1410
+ /* Get a setting value, defaulting if necessary. */
1411
+ _get: function(inst, name) {
1412
+ return inst.settings[name] !== undefined ?
1413
+ inst.settings[name] : this._defaults[name];
1414
+ },
1415
+
1416
+ /* Parse existing date and initialise date picker. */
1417
+ _setDateFromField: function(inst, noDefault) {
1418
+ if (inst.input.val() === inst.lastVal) {
1419
+ return;
1420
+ }
1421
+
1422
+ var dateFormat = this._get(inst, "dateFormat"),
1423
+ dates = inst.lastVal = inst.input ? inst.input.val() : null,
1424
+ defaultDate = this._getDefaultDate(inst),
1425
+ date = defaultDate,
1426
+ settings = this._getFormatConfig(inst);
1427
+
1428
+ try {
1429
+ date = this.parseDate(dateFormat, dates, settings) || defaultDate;
1430
+ } catch (event) {
1431
+ dates = (noDefault ? "" : dates);
1432
+ }
1433
+ inst.selectedDay = date.getDate();
1434
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
1435
+ inst.drawYear = inst.selectedYear = date.getFullYear();
1436
+ inst.currentDay = (dates ? date.getDate() : 0);
1437
+ inst.currentMonth = (dates ? date.getMonth() : 0);
1438
+ inst.currentYear = (dates ? date.getFullYear() : 0);
1439
+ this._adjustInstDate(inst);
1440
+ },
1441
+
1442
+ /* Retrieve the default date shown on opening. */
1443
+ _getDefaultDate: function(inst) {
1444
+ return this._restrictMinMax(inst,
1445
+ this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
1446
+ },
1447
+
1448
+ /* A date may be specified as an exact value or a relative one. */
1449
+ _determineDate: function(inst, date, defaultDate) {
1450
+ var offsetNumeric = function(offset) {
1451
+ var date = new Date();
1452
+ date.setDate(date.getDate() + offset);
1453
+ return date;
1454
+ },
1455
+ offsetString = function(offset) {
1456
+ try {
1457
+ return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
1458
+ offset, $.datepicker._getFormatConfig(inst));
1459
+ }
1460
+ catch (e) {
1461
+ // Ignore
1462
+ }
1463
+
1464
+ var date = (offset.toLowerCase().match(/^c/) ?
1465
+ $.datepicker._getDate(inst) : null) || new Date(),
1466
+ year = date.getFullYear(),
1467
+ month = date.getMonth(),
1468
+ day = date.getDate(),
1469
+ pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
1470
+ matches = pattern.exec(offset);
1471
+
1472
+ while (matches) {
1473
+ switch (matches[2] || "d") {
1474
+ case "d" : case "D" :
1475
+ day += parseInt(matches[1],10); break;
1476
+ case "w" : case "W" :
1477
+ day += parseInt(matches[1],10) * 7; break;
1478
+ case "m" : case "M" :
1479
+ month += parseInt(matches[1],10);
1480
+ day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
1481
+ break;
1482
+ case "y": case "Y" :
1483
+ year += parseInt(matches[1],10);
1484
+ day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
1485
+ break;
1486
+ }
1487
+ matches = pattern.exec(offset);
1488
+ }
1489
+ return new Date(year, month, day);
1490
+ },
1491
+ newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
1492
+ (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
1493
+
1494
+ newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
1495
+ if (newDate) {
1496
+ newDate.setHours(0);
1497
+ newDate.setMinutes(0);
1498
+ newDate.setSeconds(0);
1499
+ newDate.setMilliseconds(0);
1500
+ }
1501
+ return this._daylightSavingAdjust(newDate);
1502
+ },
1503
+
1504
+ /* Handle switch to/from daylight saving.
1505
+ * Hours may be non-zero on daylight saving cut-over:
1506
+ * > 12 when midnight changeover, but then cannot generate
1507
+ * midnight datetime, so jump to 1AM, otherwise reset.
1508
+ * @param date (Date) the date to check
1509
+ * @return (Date) the corrected date
1510
+ */
1511
+ _daylightSavingAdjust: function(date) {
1512
+ if (!date) {
1513
+ return null;
1514
+ }
1515
+ date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
1516
+ return date;
1517
+ },
1518
+
1519
+ /* Set the date(s) directly. */
1520
+ _setDate: function(inst, date, noChange) {
1521
+ var clear = !date,
1522
+ origMonth = inst.selectedMonth,
1523
+ origYear = inst.selectedYear,
1524
+ newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
1525
+
1526
+ inst.selectedDay = inst.currentDay = newDate.getDate();
1527
+ inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
1528
+ inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
1529
+ if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
1530
+ this._notifyChange(inst);
1531
+ }
1532
+ this._adjustInstDate(inst);
1533
+ if (inst.input) {
1534
+ inst.input.val(clear ? "" : this._formatDate(inst));
1535
+ }
1536
+ },
1537
+
1538
+ /* Retrieve the date(s) directly. */
1539
+ _getDate: function(inst) {
1540
+ var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
1541
+ this._daylightSavingAdjust(new Date(
1542
+ inst.currentYear, inst.currentMonth, inst.currentDay)));
1543
+ return startDate;
1544
+ },
1545
+
1546
+ /* Attach the onxxx handlers. These are declared statically so
1547
+ * they work with static code transformers like Caja.
1548
+ */
1549
+ _attachHandlers: function(inst) {
1550
+ var stepMonths = this._get(inst, "stepMonths"),
1551
+ id = "#" + inst.id.replace( /\\\\/g, "\\" );
1552
+ inst.dpDiv.find("[data-handler]").map(function () {
1553
+ var handler = {
1554
+ prev: function () {
1555
+ $.datepicker._adjustDate(id, -stepMonths, "M");
1556
+ },
1557
+ next: function () {
1558
+ $.datepicker._adjustDate(id, +stepMonths, "M");
1559
+ },
1560
+ hide: function () {
1561
+ $.datepicker._hideDatepicker();
1562
+ },
1563
+ today: function () {
1564
+ $.datepicker._gotoToday(id);
1565
+ },
1566
+ selectDay: function () {
1567
+ $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
1568
+ return false;
1569
+ },
1570
+ selectMonth: function () {
1571
+ $.datepicker._selectMonthYear(id, this, "M");
1572
+ return false;
1573
+ },
1574
+ selectYear: function () {
1575
+ $.datepicker._selectMonthYear(id, this, "Y");
1576
+ return false;
1577
+ }
1578
+ };
1579
+ $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
1580
+ });
1581
+ },
1582
+
1583
+ /* Generate the HTML for the current state of the date picker. */
1584
+ _generateHTML: function(inst) {
1585
+ var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
1586
+ controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
1587
+ monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
1588
+ selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
1589
+ cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
1590
+ printDate, dRow, tbody, daySettings, otherMonth, unselectable,
1591
+ tempDate = new Date(),
1592
+ today = this._daylightSavingAdjust(
1593
+ new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
1594
+ isRTL = this._get(inst, "isRTL"),
1595
+ showButtonPanel = this._get(inst, "showButtonPanel"),
1596
+ hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
1597
+ navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
1598
+ numMonths = this._getNumberOfMonths(inst),
1599
+ showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
1600
+ stepMonths = this._get(inst, "stepMonths"),
1601
+ isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
1602
+ currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
1603
+ new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
1604
+ minDate = this._getMinMaxDate(inst, "min"),
1605
+ maxDate = this._getMinMaxDate(inst, "max"),
1606
+ drawMonth = inst.drawMonth - showCurrentAtPos,
1607
+ drawYear = inst.drawYear;
1608
+
1609
+ if (drawMonth < 0) {
1610
+ drawMonth += 12;
1611
+ drawYear--;
1612
+ }
1613
+ if (maxDate) {
1614
+ maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
1615
+ maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
1616
+ maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
1617
+ while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
1618
+ drawMonth--;
1619
+ if (drawMonth < 0) {
1620
+ drawMonth = 11;
1621
+ drawYear--;
1622
+ }
1623
+ }
1624
+ }
1625
+ inst.drawMonth = drawMonth;
1626
+ inst.drawYear = drawYear;
1627
+
1628
+ prevText = this._get(inst, "prevText");
1629
+ prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
1630
+ this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
1631
+ this._getFormatConfig(inst)));
1632
+
1633
+ prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
1634
+ "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
1635
+ " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
1636
+ (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>"));
1637
+
1638
+ nextText = this._get(inst, "nextText");
1639
+ nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
1640
+ this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
1641
+ this._getFormatConfig(inst)));
1642
+
1643
+ next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
1644
+ "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
1645
+ " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
1646
+ (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>"));
1647
+
1648
+ currentText = this._get(inst, "currentText");
1649
+ gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
1650
+ currentText = (!navigationAsDateFormat ? currentText :
1651
+ this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
1652
+
1653
+ 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'>" +
1654
+ this._get(inst, "closeText") + "</button>" : "");
1655
+
1656
+ buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
1657
+ (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'" +
1658
+ ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
1659
+
1660
+ firstDay = parseInt(this._get(inst, "firstDay"),10);
1661
+ firstDay = (isNaN(firstDay) ? 0 : firstDay);
1662
+
1663
+ showWeek = this._get(inst, "showWeek");
1664
+ dayNames = this._get(inst, "dayNames");
1665
+ dayNamesMin = this._get(inst, "dayNamesMin");
1666
+ monthNames = this._get(inst, "monthNames");
1667
+ monthNamesShort = this._get(inst, "monthNamesShort");
1668
+ beforeShowDay = this._get(inst, "beforeShowDay");
1669
+ showOtherMonths = this._get(inst, "showOtherMonths");
1670
+ selectOtherMonths = this._get(inst, "selectOtherMonths");
1671
+ defaultDate = this._getDefaultDate(inst);
1672
+ html = "";
1673
+ dow;
1674
+ for (row = 0; row < numMonths[0]; row++) {
1675
+ group = "";
1676
+ this.maxRows = 4;
1677
+ for (col = 0; col < numMonths[1]; col++) {
1678
+ selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
1679
+ cornerClass = " ui-corner-all";
1680
+ calender = "";
1681
+ if (isMultiMonth) {
1682
+ calender += "<div class='ui-datepicker-group";
1683
+ if (numMonths[1] > 1) {
1684
+ switch (col) {
1685
+ case 0: calender += " ui-datepicker-group-first";
1686
+ cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
1687
+ case numMonths[1]-1: calender += " ui-datepicker-group-last";
1688
+ cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
1689
+ default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
1690
+ }
1691
+ }
1692
+ calender += "'>";
1693
+ }
1694
+ calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
1695
+ (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
1696
+ (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
1697
+ this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
1698
+ row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
1699
+ "</div><table class='ui-datepicker-calendar'><thead>" +
1700
+ "<tr>";
1701
+ thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
1702
+ for (dow = 0; dow < 7; dow++) { // days of the week
1703
+ day = (dow + firstDay) % 7;
1704
+ thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
1705
+ "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
1706
+ }
1707
+ calender += thead + "</tr></thead><tbody>";
1708
+ daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
1709
+ if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
1710
+ inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
1711
+ }
1712
+ leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
1713
+ curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
1714
+ numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
1715
+ this.maxRows = numRows;
1716
+ printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
1717
+ for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
1718
+ calender += "<tr>";
1719
+ tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
1720
+ this._get(inst, "calculateWeek")(printDate) + "</td>");
1721
+ for (dow = 0; dow < 7; dow++) { // create date picker days
1722
+ daySettings = (beforeShowDay ?
1723
+ beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
1724
+ otherMonth = (printDate.getMonth() !== drawMonth);
1725
+ unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
1726
+ (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
1727
+ tbody += "<td class='" +
1728
+ ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
1729
+ (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
1730
+ ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
1731
+ (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
1732
+ // or defaultDate is current printedDate and defaultDate is selectedDate
1733
+ " " + this._dayOverClass : "") + // highlight selected day
1734
+ (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
1735
+ (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
1736
+ (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
1737
+ (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
1738
+ ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
1739
+ (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
1740
+ (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
1741
+ (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
1742
+ (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
1743
+ (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
1744
+ (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
1745
+ "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
1746
+ printDate.setDate(printDate.getDate() + 1);
1747
+ printDate = this._daylightSavingAdjust(printDate);
1748
+ }
1749
+ calender += tbody + "</tr>";
1750
+ }
1751
+ drawMonth++;
1752
+ if (drawMonth > 11) {
1753
+ drawMonth = 0;
1754
+ drawYear++;
1755
+ }
1756
+ calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
1757
+ ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
1758
+ group += calender;
1759
+ }
1760
+ html += group;
1761
+ }
1762
+ html += buttonPanel;
1763
+ inst._keyEvent = false;
1764
+ return html;
1765
+ },
1766
+
1767
+ /* Generate the month and year header. */
1768
+ _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
1769
+ secondary, monthNames, monthNamesShort) {
1770
+
1771
+ var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
1772
+ changeMonth = this._get(inst, "changeMonth"),
1773
+ changeYear = this._get(inst, "changeYear"),
1774
+ showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
1775
+ html = "<div class='ui-datepicker-title'>",
1776
+ monthHtml = "";
1777
+
1778
+ // month selection
1779
+ if (secondary || !changeMonth) {
1780
+ monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
1781
+ } else {
1782
+ inMinYear = (minDate && minDate.getFullYear() === drawYear);
1783
+ inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
1784
+ monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
1785
+ for ( month = 0; month < 12; month++) {
1786
+ if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
1787
+ monthHtml += "<option value='" + month + "'" +
1788
+ (month === drawMonth ? " selected='selected'" : "") +
1789
+ ">" + monthNamesShort[month] + "</option>";
1790
+ }
1791
+ }
1792
+ monthHtml += "</select>";
1793
+ }
1794
+
1795
+ if (!showMonthAfterYear) {
1796
+ html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
1797
+ }
1798
+
1799
+ // year selection
1800
+ if ( !inst.yearshtml ) {
1801
+ inst.yearshtml = "";
1802
+ if (secondary || !changeYear) {
1803
+ html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
1804
+ } else {
1805
+ // determine range of years to display
1806
+ years = this._get(inst, "yearRange").split(":");
1807
+ thisYear = new Date().getFullYear();
1808
+ determineYear = function(value) {
1809
+ var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
1810
+ (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
1811
+ parseInt(value, 10)));
1812
+ return (isNaN(year) ? thisYear : year);
1813
+ };
1814
+ year = determineYear(years[0]);
1815
+ endYear = Math.max(year, determineYear(years[1] || ""));
1816
+ year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
1817
+ endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
1818
+ inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
1819
+ for (; year <= endYear; year++) {
1820
+ inst.yearshtml += "<option value='" + year + "'" +
1821
+ (year === drawYear ? " selected='selected'" : "") +
1822
+ ">" + year + "</option>";
1823
+ }
1824
+ inst.yearshtml += "</select>";
1825
+
1826
+ html += inst.yearshtml;
1827
+ inst.yearshtml = null;
1828
+ }
1829
+ }
1830
+
1831
+ html += this._get(inst, "yearSuffix");
1832
+ if (showMonthAfterYear) {
1833
+ html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
1834
+ }
1835
+ html += "</div>"; // Close datepicker_header
1836
+ return html;
1837
+ },
1838
+
1839
+ /* Adjust one of the date sub-fields. */
1840
+ _adjustInstDate: function(inst, offset, period) {
1841
+ var year = inst.drawYear + (period === "Y" ? offset : 0),
1842
+ month = inst.drawMonth + (period === "M" ? offset : 0),
1843
+ day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
1844
+ date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
1845
+
1846
+ inst.selectedDay = date.getDate();
1847
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
1848
+ inst.drawYear = inst.selectedYear = date.getFullYear();
1849
+ if (period === "M" || period === "Y") {
1850
+ this._notifyChange(inst);
1851
+ }
1852
+ },
1853
+
1854
+ /* Ensure a date is within any min/max bounds. */
1855
+ _restrictMinMax: function(inst, date) {
1856
+ var minDate = this._getMinMaxDate(inst, "min"),
1857
+ maxDate = this._getMinMaxDate(inst, "max"),
1858
+ newDate = (minDate && date < minDate ? minDate : date);
1859
+ return (maxDate && newDate > maxDate ? maxDate : newDate);
1860
+ },
1861
+
1862
+ /* Notify change of month/year. */
1863
+ _notifyChange: function(inst) {
1864
+ var onChange = this._get(inst, "onChangeMonthYear");
1865
+ if (onChange) {
1866
+ onChange.apply((inst.input ? inst.input[0] : null),
1867
+ [inst.selectedYear, inst.selectedMonth + 1, inst]);
1868
+ }
1869
+ },
1870
+
1871
+ /* Determine the number of months to show. */
1872
+ _getNumberOfMonths: function(inst) {
1873
+ var numMonths = this._get(inst, "numberOfMonths");
1874
+ return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
1875
+ },
1876
+
1877
+ /* Determine the current maximum date - ensure no time components are set. */
1878
+ _getMinMaxDate: function(inst, minMax) {
1879
+ return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
1880
+ },
1881
+
1882
+ /* Find the number of days in a given month. */
1883
+ _getDaysInMonth: function(year, month) {
1884
+ return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
1885
+ },
1886
+
1887
+ /* Find the day of the week of the first of a month. */
1888
+ _getFirstDayOfMonth: function(year, month) {
1889
+ return new Date(year, month, 1).getDay();
1890
+ },
1891
+
1892
+ /* Determines if we should allow a "next/prev" month display change. */
1893
+ _canAdjustMonth: function(inst, offset, curYear, curMonth) {
1894
+ var numMonths = this._getNumberOfMonths(inst),
1895
+ date = this._daylightSavingAdjust(new Date(curYear,
1896
+ curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
1897
+
1898
+ if (offset < 0) {
1899
+ date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
1900
+ }
1901
+ return this._isInRange(inst, date);
1902
+ },
1903
+
1904
+ /* Is the given date in the accepted range? */
1905
+ _isInRange: function(inst, date) {
1906
+ var yearSplit, currentYear,
1907
+ minDate = this._getMinMaxDate(inst, "min"),
1908
+ maxDate = this._getMinMaxDate(inst, "max"),
1909
+ minYear = null,
1910
+ maxYear = null,
1911
+ years = this._get(inst, "yearRange");
1912
+ if (years){
1913
+ yearSplit = years.split(":");
1914
+ currentYear = new Date().getFullYear();
1915
+ minYear = parseInt(yearSplit[0], 10);
1916
+ maxYear = parseInt(yearSplit[1], 10);
1917
+ if ( yearSplit[0].match(/[+\-].*/) ) {
1918
+ minYear += currentYear;
1919
+ }
1920
+ if ( yearSplit[1].match(/[+\-].*/) ) {
1921
+ maxYear += currentYear;
1922
+ }
1923
+ }
1924
+
1925
+ return ((!minDate || date.getTime() >= minDate.getTime()) &&
1926
+ (!maxDate || date.getTime() <= maxDate.getTime()) &&
1927
+ (!minYear || date.getFullYear() >= minYear) &&
1928
+ (!maxYear || date.getFullYear() <= maxYear));
1929
+ },
1930
+
1931
+ /* Provide the configuration settings for formatting/parsing. */
1932
+ _getFormatConfig: function(inst) {
1933
+ var shortYearCutoff = this._get(inst, "shortYearCutoff");
1934
+ shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
1935
+ new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
1936
+ return {shortYearCutoff: shortYearCutoff,
1937
+ dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
1938
+ monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
1939
+ },
1940
+
1941
+ /* Format the given date for display. */
1942
+ _formatDate: function(inst, day, month, year) {
1943
+ if (!day) {
1944
+ inst.currentDay = inst.selectedDay;
1945
+ inst.currentMonth = inst.selectedMonth;
1946
+ inst.currentYear = inst.selectedYear;
1947
+ }
1948
+ var date = (day ? (typeof day === "object" ? day :
1949
+ this._daylightSavingAdjust(new Date(year, month, day))) :
1950
+ this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
1951
+ return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
1952
+ }
1953
+ });
1954
+
1955
+ /*
1956
+ * Bind hover events for datepicker elements.
1957
+ * Done via delegate so the binding only occurs once in the lifetime of the parent div.
1958
+ * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
1959
+ */
1960
+ function bindHover(dpDiv) {
1961
+ var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
1962
+ return dpDiv.delegate(selector, "mouseout", function() {
1963
+ $(this).removeClass("ui-state-hover");
1964
+ if (this.className.indexOf("ui-datepicker-prev") !== -1) {
1965
+ $(this).removeClass("ui-datepicker-prev-hover");
1966
+ }
1967
+ if (this.className.indexOf("ui-datepicker-next") !== -1) {
1968
+ $(this).removeClass("ui-datepicker-next-hover");
1969
+ }
1970
+ })
1971
+ .delegate(selector, "mouseover", function(){
1972
+ if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
1973
+ $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
1974
+ $(this).addClass("ui-state-hover");
1975
+ if (this.className.indexOf("ui-datepicker-prev") !== -1) {
1976
+ $(this).addClass("ui-datepicker-prev-hover");
1977
+ }
1978
+ if (this.className.indexOf("ui-datepicker-next") !== -1) {
1979
+ $(this).addClass("ui-datepicker-next-hover");
1980
+ }
1981
+ }
1982
+ });
1983
+ }
1984
+
1985
+ /* jQuery extend now ignores nulls! */
1986
+ function extendRemove(target, props) {
1987
+ $.extend(target, props);
1988
+ for (var name in props) {
1989
+ if (props[name] == null) {
1990
+ target[name] = props[name];
1991
+ }
1992
+ }
1993
+ return target;
1994
+ }
1995
+
1996
+ /* Invoke the datepicker functionality.
1997
+ @param options string - a command, optionally followed by additional parameters or
1998
+ Object - settings for attaching new datepicker functionality
1999
+ @return jQuery object */
2000
+ $.fn.datepicker = function(options){
2001
+
2002
+ /* Verify an empty collection wasn't passed - Fixes #6976 */
2003
+ if ( !this.length ) {
2004
+ return this;
2005
+ }
2006
+
2007
+ /* Initialise the date picker. */
2008
+ if (!$.datepicker.initialized) {
2009
+ $(document).mousedown($.datepicker._checkExternalClick);
2010
+ $.datepicker.initialized = true;
2011
+ }
2012
+
2013
+ /* Append datepicker main container to body if not exist. */
2014
+ if ($("#"+$.datepicker._mainDivId).length === 0) {
2015
+ $("body").append($.datepicker.dpDiv);
2016
+ }
2017
+
2018
+ var otherArgs = Array.prototype.slice.call(arguments, 1);
2019
+ if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
2020
+ return $.datepicker["_" + options + "Datepicker"].
2021
+ apply($.datepicker, [this[0]].concat(otherArgs));
2022
+ }
2023
+ if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
2024
+ return $.datepicker["_" + options + "Datepicker"].
2025
+ apply($.datepicker, [this[0]].concat(otherArgs));
2026
+ }
2027
+ return this.each(function() {
2028
+ typeof options === "string" ?
2029
+ $.datepicker["_" + options + "Datepicker"].
2030
+ apply($.datepicker, [this].concat(otherArgs)) :
2031
+ $.datepicker._attachDatepicker(this, options);
2032
+ });
2033
+ };
2034
+
2035
+ $.datepicker = new Datepicker(); // singleton instance
2036
+ $.datepicker.initialized = false;
2037
+ $.datepicker.uuid = new Date().getTime();
2038
+ $.datepicker.version = "1.10.3";
2039
+
2040
+ })(jQuery);