activeadmin 3.2.2 → 4.0.0.beta1

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

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

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