jquery-ui-rails 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jquery-ui-rails might be problematic. Click here for more details.

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