databaseformalizer 0.3.0

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