transit 0.0.1 → 0.0.2

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