activeadmin-rb 1.4.0

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