pakunok 0.0.1

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