publify_core 9.0.0.pre1

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

Potentially problematic release.


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

Files changed (372) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +35 -0
  5. data/app/assets/fonts/open-sans-bold.woff +0 -0
  6. data/app/assets/fonts/open-sans.woff +0 -0
  7. data/app/assets/images/admin/loading.gif +0 -0
  8. data/app/assets/images/admin/typologo.gif +0 -0
  9. data/app/assets/images/calendar_date_select/calendar.gif +0 -0
  10. data/app/assets/images/close.gif +0 -0
  11. data/app/assets/images/closelabel.gif +0 -0
  12. data/app/assets/images/go.png +0 -0
  13. data/app/assets/images/loading.gif +0 -0
  14. data/app/assets/images/nextlabel.gif +0 -0
  15. data/app/assets/images/overlay.png +0 -0
  16. data/app/assets/images/powered.gif +0 -0
  17. data/app/assets/images/prevlabel.gif +0 -0
  18. data/app/assets/images/spinner-blue.gif +0 -0
  19. data/app/assets/images/spinner.gif +0 -0
  20. data/app/assets/images/thumb_blank.jpg +0 -0
  21. data/app/assets/javascripts/application.js +2 -0
  22. data/app/assets/javascripts/cookies.js +60 -0
  23. data/app/assets/javascripts/datetimepicker.js +1470 -0
  24. data/app/assets/javascripts/lang/da_DK.js +17 -0
  25. data/app/assets/javascripts/lang/default.js +21 -0
  26. data/app/assets/javascripts/lang/en_US.js +21 -0
  27. data/app/assets/javascripts/lang/fr_FR.js +21 -0
  28. data/app/assets/javascripts/lang/nl_NL.js +21 -0
  29. data/app/assets/javascripts/lang/zh_TW.js +17 -0
  30. data/app/assets/javascripts/lightbox.js +350 -0
  31. data/app/assets/javascripts/observe.js +28 -0
  32. data/app/assets/javascripts/publify.js +11 -0
  33. data/app/assets/javascripts/publify_admin.js +138 -0
  34. data/app/assets/javascripts/quicktags.js +440 -0
  35. data/app/assets/javascripts/set-timeago-lang.js +3 -0
  36. data/app/assets/javascripts/sidebar.js +28 -0
  37. data/app/assets/javascripts/spinnable.js +5 -0
  38. data/app/assets/javascripts/tagmanager.js +481 -0
  39. data/app/assets/javascripts/typeahead.js +1139 -0
  40. data/app/assets/javascripts/widearea.js +486 -0
  41. data/app/assets/stylesheets/accounts.css.scss +7 -0
  42. data/app/assets/stylesheets/administration_structure.css.scss +239 -0
  43. data/app/assets/stylesheets/coderay.css +135 -0
  44. data/app/assets/stylesheets/datetimepicker.css +306 -0
  45. data/app/assets/stylesheets/lightbox.css +63 -0
  46. data/app/assets/stylesheets/publify.css.scss +9 -0
  47. data/app/assets/stylesheets/publify_admin.css.scss +11 -0
  48. data/app/assets/stylesheets/rss.css +53 -0
  49. data/app/assets/stylesheets/sidebar_admin.css.scss +36 -0
  50. data/app/assets/stylesheets/tagmanager.css +102 -0
  51. data/app/assets/stylesheets/user-styles.css +29 -0
  52. data/app/assets/stylesheets/widearea.css +133 -0
  53. data/app/controllers/accounts_controller.rb +2 -0
  54. data/app/controllers/admin/base_controller.rb +41 -0
  55. data/app/controllers/admin/cache_controller.rb +33 -0
  56. data/app/controllers/admin/content_controller.rb +174 -0
  57. data/app/controllers/admin/dashboard_controller.rb +87 -0
  58. data/app/controllers/admin/feedback_controller.rb +159 -0
  59. data/app/controllers/admin/migrations_controller.rb +20 -0
  60. data/app/controllers/admin/notes_controller.rb +69 -0
  61. data/app/controllers/admin/pages_controller.rb +88 -0
  62. data/app/controllers/admin/post_types_controller.rb +56 -0
  63. data/app/controllers/admin/profiles_controller.rb +48 -0
  64. data/app/controllers/admin/redirects_controller.rb +47 -0
  65. data/app/controllers/admin/resources_controller.rb +30 -0
  66. data/app/controllers/admin/seo_controller.rb +45 -0
  67. data/app/controllers/admin/settings_controller.rb +53 -0
  68. data/app/controllers/admin/sidebar_controller.rb +66 -0
  69. data/app/controllers/admin/tags_controller.rb +53 -0
  70. data/app/controllers/admin/textfilters_controller.rb +6 -0
  71. data/app/controllers/admin/themes_controller.rb +37 -0
  72. data/app/controllers/admin/users_controller.rb +65 -0
  73. data/app/controllers/articles_controller.rb +205 -0
  74. data/app/controllers/authors_controller.rb +27 -0
  75. data/app/controllers/base_controller.rb +45 -0
  76. data/app/controllers/comments_controller.rb +69 -0
  77. data/app/controllers/content_controller.rb +31 -0
  78. data/app/controllers/feedback_controller.rb +47 -0
  79. data/app/controllers/notes_controller.rb +37 -0
  80. data/app/controllers/setup_controller.rb +62 -0
  81. data/app/controllers/tags_controller.rb +55 -0
  82. data/app/controllers/text_controller.rb +9 -0
  83. data/app/controllers/textfilter_controller.rb +3 -0
  84. data/app/controllers/theme_controller.rb +59 -0
  85. data/app/controllers/trackbacks_controller.rb +36 -0
  86. data/app/controllers/xml_controller.rb +70 -0
  87. data/app/helpers/admin/base_helper.rb +87 -0
  88. data/app/helpers/admin/feedback_helper.rb +42 -0
  89. data/app/helpers/articles_helper.rb +8 -0
  90. data/app/helpers/authors_helper.rb +39 -0
  91. data/app/helpers/base_helper.rb +246 -0
  92. data/app/helpers/blog_helper.rb +12 -0
  93. data/app/helpers/xml_helper.rb +16 -0
  94. data/app/mailers/notification_mailer.rb +38 -0
  95. data/app/models/ability.rb +52 -0
  96. data/app/models/archives_sidebar.rb +45 -0
  97. data/app/models/article/factory.rb +56 -0
  98. data/app/models/article/states.rb +178 -0
  99. data/app/models/article.rb +321 -0
  100. data/app/models/blog.rb +290 -0
  101. data/app/models/blog_sweeper.rb +86 -0
  102. data/app/models/comment.rb +53 -0
  103. data/app/models/config_manager.rb +81 -0
  104. data/app/models/content.rb +138 -0
  105. data/app/models/content_base.rb +95 -0
  106. data/app/models/feedback/states.rb +256 -0
  107. data/app/models/feedback.rb +225 -0
  108. data/app/models/meta_sidebar.rb +8 -0
  109. data/app/models/note.rb +144 -0
  110. data/app/models/page.rb +36 -0
  111. data/app/models/page_cache.rb +33 -0
  112. data/app/models/page_sidebar.rb +12 -0
  113. data/app/models/ping.rb +116 -0
  114. data/app/models/post_type.rb +15 -0
  115. data/app/models/redirect.rb +45 -0
  116. data/app/models/redirection.rb +4 -0
  117. data/app/models/resource.rb +28 -0
  118. data/app/models/search_sidebar.rb +7 -0
  119. data/app/models/sidebar.rb +138 -0
  120. data/app/models/static_sidebar.rb +20 -0
  121. data/app/models/tag.rb +63 -0
  122. data/app/models/tag_sidebar.rb +27 -0
  123. data/app/models/text_filter.rb +61 -0
  124. data/app/models/trackback.rb +58 -0
  125. data/app/models/trigger.rb +45 -0
  126. data/app/models/user.rb +148 -0
  127. data/app/services/migrator.rb +25 -0
  128. data/app/services/title_builder.rb +80 -0
  129. data/app/uploaders/resource_uploader.rb +30 -0
  130. data/app/views/accounts/confirm.html.erb +8 -0
  131. data/app/views/admin/cache/show.html.erb +18 -0
  132. data/app/views/admin/content/_article_list.html.erb +26 -0
  133. data/app/views/admin/content/_form.html.erb +165 -0
  134. data/app/views/admin/content/autosave.js.erb +5 -0
  135. data/app/views/admin/content/edit.html.erb +3 -0
  136. data/app/views/admin/content/index.html.erb +48 -0
  137. data/app/views/admin/content/index.js.erb +1 -0
  138. data/app/views/admin/content/new.html.erb +3 -0
  139. data/app/views/admin/dashboard/_comment.html.erb +18 -0
  140. data/app/views/admin/dashboard/_comments.html.erb +10 -0
  141. data/app/views/admin/dashboard/_drafts.html.erb +25 -0
  142. data/app/views/admin/dashboard/_inbound.html.erb +31 -0
  143. data/app/views/admin/dashboard/_overview.html.erb +23 -0
  144. data/app/views/admin/dashboard/_welcome.html.erb +28 -0
  145. data/app/views/admin/dashboard/index.html.erb +17 -0
  146. data/app/views/admin/feedback/_button.html.erb +19 -0
  147. data/app/views/admin/feedback/_feedback.html.erb +7 -0
  148. data/app/views/admin/feedback/_ham.html.erb +17 -0
  149. data/app/views/admin/feedback/_spam.html.erb +23 -0
  150. data/app/views/admin/feedback/article.html.erb +69 -0
  151. data/app/views/admin/feedback/edit.html.erb +48 -0
  152. data/app/views/admin/feedback/ham.js +1 -0
  153. data/app/views/admin/feedback/index.html.erb +53 -0
  154. data/app/views/admin/feedback/spam.js +1 -0
  155. data/app/views/admin/migrations/show.html.erb +39 -0
  156. data/app/views/admin/notes/_form.html.erb +37 -0
  157. data/app/views/admin/notes/_header.html.erb +6 -0
  158. data/app/views/admin/notes/_list.html.erb +13 -0
  159. data/app/views/admin/notes/_note.html.erb +14 -0
  160. data/app/views/admin/notes/edit.html.erb +11 -0
  161. data/app/views/admin/notes/index.html.erb +11 -0
  162. data/app/views/admin/notes/show.html.erb +14 -0
  163. data/app/views/admin/pages/_form.html.erb +101 -0
  164. data/app/views/admin/pages/_pages.html.erb +21 -0
  165. data/app/views/admin/pages/edit.html.erb +1 -0
  166. data/app/views/admin/pages/index.html.erb +17 -0
  167. data/app/views/admin/pages/new.html.erb +1 -0
  168. data/app/views/admin/post_types/_index_and_form.html.erb +65 -0
  169. data/app/views/admin/post_types/edit.html.erb +1 -0
  170. data/app/views/admin/post_types/index.html.erb +1 -0
  171. data/app/views/admin/profiles/index.html.erb +10 -0
  172. data/app/views/admin/redirects/_index_and_form.html.erb +68 -0
  173. data/app/views/admin/redirects/edit.html.erb +1 -0
  174. data/app/views/admin/redirects/index.html.erb +1 -0
  175. data/app/views/admin/resources/index.html.erb +68 -0
  176. data/app/views/admin/seo/_general.html.erb +123 -0
  177. data/app/views/admin/seo/_permalinks.html.erb +53 -0
  178. data/app/views/admin/seo/_titles.html.erb +210 -0
  179. data/app/views/admin/seo/show.html.erb +32 -0
  180. data/app/views/admin/settings/display.html.erb +110 -0
  181. data/app/views/admin/settings/feedback.html.erb +125 -0
  182. data/app/views/admin/settings/index.html.erb +73 -0
  183. data/app/views/admin/settings/write.html.erb +87 -0
  184. data/app/views/admin/shared/_edit.html.erb +4 -0
  185. data/app/views/admin/shared/_menu.html.erb +122 -0
  186. data/app/views/admin/shared/_twitter_alert.html.erb +3 -0
  187. data/app/views/admin/sidebar/_available.html.erb +6 -0
  188. data/app/views/admin/sidebar/_available.json.erb +6 -0
  189. data/app/views/admin/sidebar/_config.html.erb +27 -0
  190. data/app/views/admin/sidebar/_target.html.erb +9 -0
  191. data/app/views/admin/sidebar/_target_sidebar.html.erb +20 -0
  192. data/app/views/admin/sidebar/destroy.js.erb +1 -0
  193. data/app/views/admin/sidebar/index.html.erb +31 -0
  194. data/app/views/admin/sidebar/sortable.js.erb +3 -0
  195. data/app/views/admin/sidebar/update.js.erb +2 -0
  196. data/app/views/admin/tags/_index_and_form.html.erb +59 -0
  197. data/app/views/admin/tags/edit.html.erb +1 -0
  198. data/app/views/admin/tags/index.html.erb +1 -0
  199. data/app/views/admin/themes/index.html.erb +27 -0
  200. data/app/views/admin/users/_form.html.erb +215 -0
  201. data/app/views/admin/users/edit.html.erb +8 -0
  202. data/app/views/admin/users/index.html.erb +39 -0
  203. data/app/views/admin/users/new.html.erb +8 -0
  204. data/app/views/archives_sidebar/_content.html.erb +13 -0
  205. data/app/views/articles/_article.html.erb +9 -0
  206. data/app/views/articles/_article_collection.html.erb +8 -0
  207. data/app/views/articles/_article_content.html.erb +5 -0
  208. data/app/views/articles/_article_excerpt.html.erb +13 -0
  209. data/app/views/articles/_article_links.html.erb +10 -0
  210. data/app/views/articles/_comment.html.erb +1 -0
  211. data/app/views/articles/_comment_errors.html.erb +2 -0
  212. data/app/views/articles/_comment_form.html.erb +48 -0
  213. data/app/views/articles/_comment_list.html.erb +5 -0
  214. data/app/views/articles/_comment_preview.html.erb +4 -0
  215. data/app/views/articles/_full_article_content.html.erb +2 -0
  216. data/app/views/articles/_password_form.html.erb +10 -0
  217. data/app/views/articles/_protected_article_content.html.erb +6 -0
  218. data/app/views/articles/_trackback.html.erb +6 -0
  219. data/app/views/articles/archives.html.erb +25 -0
  220. data/app/views/articles/comment.js.erb +5 -0
  221. data/app/views/articles/comment_failed.js.erb +3 -0
  222. data/app/views/articles/error.html.erb +3 -0
  223. data/app/views/articles/feedback_atom_feed.atom.builder +8 -0
  224. data/app/views/articles/feedback_rss_feed.rss.builder +21 -0
  225. data/app/views/articles/index.html.erb +1 -0
  226. data/app/views/articles/index_atom_feed.atom.builder +8 -0
  227. data/app/views/articles/index_rss_feed.rss.builder +20 -0
  228. data/app/views/articles/live_search.html.erb +10 -0
  229. data/app/views/articles/read.html.erb +61 -0
  230. data/app/views/articles/search.html.erb +8 -0
  231. data/app/views/articles/trackback.xml.builder +5 -0
  232. data/app/views/articles/view_page.html.erb +3 -0
  233. data/app/views/authors/show.html.erb +40 -0
  234. data/app/views/authors/show_atom_feed.atom.builder +8 -0
  235. data/app/views/authors/show_rss_feed.rss.builder +20 -0
  236. data/app/views/comments/_comment.html.erb +16 -0
  237. data/app/views/comments/index.html.erb +1 -0
  238. data/app/views/comments/index_atom_feed.atom.builder +8 -0
  239. data/app/views/comments/index_rss_feed.rss.builder +20 -0
  240. data/app/views/comments/preview.html.erb +1 -0
  241. data/app/views/comments/preview.js.erb +3 -0
  242. data/app/views/devise/mailer/reset_password_instructions.html.erb +13 -0
  243. data/app/views/devise/passwords/edit.html.erb +28 -0
  244. data/app/views/devise/passwords/new.html.erb +20 -0
  245. data/app/views/devise/registrations/new.html.erb +36 -0
  246. data/app/views/devise/sessions/new.html.erb +32 -0
  247. data/app/views/devise/shared/_links.html.erb +15 -0
  248. data/app/views/errors/404.html.erb +2 -0
  249. data/app/views/layouts/accounts.html.erb +33 -0
  250. data/app/views/layouts/administration.html.erb +37 -0
  251. data/app/views/layouts/default.html.erb +32 -0
  252. data/app/views/layouts/editor.html.erb +31 -0
  253. data/app/views/meta_sidebar/_content.html.erb +8 -0
  254. data/app/views/notes/_note.html.erb +15 -0
  255. data/app/views/notes/error.html.erb +3 -0
  256. data/app/views/notes/index.html.erb +15 -0
  257. data/app/views/notes/show.html.erb +5 -0
  258. data/app/views/notes/show_in_reply.html.erb +16 -0
  259. data/app/views/notification_mailer/_mail_footer.html.erb +7 -0
  260. data/app/views/notification_mailer/_mail_header.html.erb +1 -0
  261. data/app/views/notification_mailer/article.html.erb +6 -0
  262. data/app/views/notification_mailer/comment.html.erb +11 -0
  263. data/app/views/notification_mailer/notif_user.html.erb +14 -0
  264. data/app/views/page_sidebar/_content.html.erb +12 -0
  265. data/app/views/search_sidebar/_content.html.erb +10 -0
  266. data/app/views/settings/done.html.erb +2 -0
  267. data/app/views/settings/install.html.erb +12 -0
  268. data/app/views/setup/index.html.erb +13 -0
  269. data/app/views/shared/_atom_header.atom.builder +6 -0
  270. data/app/views/shared/_atom_item_article.atom.builder +39 -0
  271. data/app/views/shared/_atom_item_comment.atom.builder +10 -0
  272. data/app/views/shared/_atom_item_trackback.atom.builder +9 -0
  273. data/app/views/shared/_flash.erb +10 -0
  274. data/app/views/shared/_page_header.html.erb +26 -0
  275. data/app/views/shared/_rss_item_article.rss.builder +35 -0
  276. data/app/views/shared/_rss_item_comment.rss.builder +8 -0
  277. data/app/views/shared/_rss_item_trackback.rss.builder +7 -0
  278. data/app/views/sidebar/_row.html.erb +1 -0
  279. data/app/views/sidebar/_sidebar.html.erb +5 -0
  280. data/app/views/sidebar/display_plugins.html.erb +5 -0
  281. data/app/views/sidebar/show.html.erb +1 -0
  282. data/app/views/static_sidebar/_content.html.erb +2 -0
  283. data/app/views/tag_sidebar/_content.html.erb +10 -0
  284. data/app/views/tags/index.html.erb +15 -0
  285. data/app/views/tags/show.html.erb +1 -0
  286. data/app/views/theme/static_view_test.html.erb +1 -0
  287. data/app/views/trackbacks/index_atom_feed.atom.builder +7 -0
  288. data/app/views/trackbacks/index_rss_feed.rss.builder +20 -0
  289. data/app/views/trackbacks/trackback.xml.builder +4 -0
  290. data/app/views/xml/_googlesitemap_item_article.googlesitemap.builder +5 -0
  291. data/app/views/xml/_googlesitemap_item_category.googlesitemap.builder +4 -0
  292. data/app/views/xml/_googlesitemap_item_page.googlesitemap.builder +4 -0
  293. data/app/views/xml/_googlesitemap_item_tag.googlesitemap.builder +4 -0
  294. data/app/views/xml/feed.googlesitemap.builder +7 -0
  295. data/app/views/xml/rsd.rsd.builder +8 -0
  296. data/config/i18n-tasks.yml +49 -0
  297. data/config/initializers/devise.rb +265 -0
  298. data/config/initializers/mime_types.rb +6 -0
  299. data/config/locales/da.yml +827 -0
  300. data/config/locales/de.yml +827 -0
  301. data/config/locales/en.yml +827 -0
  302. data/config/locales/es-MX.yml +827 -0
  303. data/config/locales/fr.yml +827 -0
  304. data/config/locales/he.yml +827 -0
  305. data/config/locales/it.yml +827 -0
  306. data/config/locales/ja.yml +827 -0
  307. data/config/locales/lt.yml +827 -0
  308. data/config/locales/nb-NO.yml +827 -0
  309. data/config/locales/nl.yml +827 -0
  310. data/config/locales/pl.yml +827 -0
  311. data/config/locales/pt-BR.yml +827 -0
  312. data/config/locales/ro.yml +827 -0
  313. data/config/locales/ru.yml +827 -0
  314. data/config/locales/sidebars.da.yml +20 -0
  315. data/config/locales/sidebars.de.yml +20 -0
  316. data/config/locales/sidebars.en.yml +20 -0
  317. data/config/locales/sidebars.es-MX.yml +20 -0
  318. data/config/locales/sidebars.fr.yml +20 -0
  319. data/config/locales/sidebars.he.yml +20 -0
  320. data/config/locales/sidebars.it.yml +20 -0
  321. data/config/locales/sidebars.ja.yml +20 -0
  322. data/config/locales/sidebars.lt.yml +20 -0
  323. data/config/locales/sidebars.nb-NO.yml +20 -0
  324. data/config/locales/sidebars.nl.yml +20 -0
  325. data/config/locales/sidebars.pl.yml +20 -0
  326. data/config/locales/sidebars.pt-BR.yml +20 -0
  327. data/config/locales/sidebars.ro.yml +20 -0
  328. data/config/locales/sidebars.ru.yml +20 -0
  329. data/config/locales/sidebars.zh-CN.yml +20 -0
  330. data/config/locales/sidebars.zh-TW.yml +20 -0
  331. data/config/locales/zh-CN.yml +827 -0
  332. data/config/locales/zh-TW.yml +827 -0
  333. data/config/routes.rb +177 -0
  334. data/db/migrate/113_initial_schema.rb +205 -0
  335. data/db/migrate/114_fixes_buggy_articles_and_notes.rb +52 -0
  336. data/db/migrate/115_drops_categories_for_tags.rb +34 -0
  337. data/db/migrate/20150207131657_add_missing_indexes.rb +19 -0
  338. data/db/migrate/20150807134129_simplify_redirect_relations.rb +38 -0
  339. data/db/migrate/20150808052637_add_blog_ids.rb +33 -0
  340. data/db/migrate/20150808191127_add_blog_id_to_redirects.rb +15 -0
  341. data/db/migrate/20150810094754_add_blog_id_to_tags.rb +15 -0
  342. data/db/migrate/20160108111120_add_devise_to_users.rb +53 -0
  343. data/db/migrate/20160108184201_move_last_connection_to_last_sign_in_at.rb +16 -0
  344. data/db/migrate/20160110094906_remove_profiles_rights.rb +14 -0
  345. data/db/migrate/20160605103918_replace_profile_id_with_string.rb +30 -0
  346. data/db/migrate/20160605154632_remove_profiles.rb +24 -0
  347. data/db/migrate/20160701061851_demand_blog_id_on_contents.rb +9 -0
  348. data/db/migrate/20160701062604_add_blog_id_to_resources.rb +28 -0
  349. data/db/seeds.rb +37 -0
  350. data/lib/email_notify.rb +26 -0
  351. data/lib/format.rb +17 -0
  352. data/lib/publify_core/engine.rb +23 -0
  353. data/lib/publify_core/lang.rb +5 -0
  354. data/lib/publify_core/version.rb +3 -0
  355. data/lib/publify_core.rb +56 -0
  356. data/lib/publify_guid.rb +9 -0
  357. data/lib/publify_plugins.rb +72 -0
  358. data/lib/publify_textfilter_markdown.rb +44 -0
  359. data/lib/publify_textfilter_none.rb +14 -0
  360. data/lib/publify_textfilter_smartypants.rb +14 -0
  361. data/lib/publify_textfilter_textile.rb +21 -0
  362. data/lib/publify_textfilter_twitterfilter.rb +33 -0
  363. data/lib/publify_time.rb +30 -0
  364. data/lib/sidebar_field.rb +115 -0
  365. data/lib/sidebar_registry.rb +33 -0
  366. data/lib/spam_protection.rb +101 -0
  367. data/lib/stateful.rb +106 -0
  368. data/lib/tasks/publify_core_tasks.rake +4 -0
  369. data/lib/text_filter_plugin.rb +182 -0
  370. data/lib/theme.rb +72 -0
  371. data/lib/transforms.rb +45 -0
  372. metadata +865 -0
@@ -0,0 +1,1470 @@
1
+ /**
2
+ * @preserve jQuery DateTimePicker plugin v2.3.4
3
+ * @homepage http://xdsoft.net/jqplugins/datetimepicker/
4
+ * (c) 2014, Chupurnov Valeriy.
5
+ */
6
+ (function( $ ) {
7
+ 'use strict';
8
+ var default_options = {
9
+ i18n:{
10
+ bg:{ // Bulgarian
11
+ months:[
12
+ "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
13
+ ],
14
+ dayOfWeek:[
15
+ "Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
16
+ ]
17
+ },
18
+ fa:{ // Persian/Farsi
19
+ months:[
20
+ 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
21
+ ],
22
+ dayOfWeek:[
23
+ 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
24
+ ]
25
+ },
26
+ ru:{ // Russian
27
+ months:[
28
+ 'Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'
29
+ ],
30
+ dayOfWeek:[
31
+ "Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
32
+ ]
33
+ },
34
+ uk:{ // Ukrainian
35
+ months:[
36
+ 'Січень','Лютий','Березень','Квітень','Травень','Червень','Липень','Серпень','Вересень','Жовтень','Листопад','Грудень'
37
+ ],
38
+ dayOfWeek:[
39
+ "Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
40
+ ]
41
+ },
42
+ en:{ // English
43
+ months: [
44
+ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
45
+ ],
46
+ dayOfWeek: [
47
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
48
+ ]
49
+ },
50
+ el:{ // Ελληνικά
51
+ months: [
52
+ "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
53
+ ],
54
+ dayOfWeek: [
55
+ "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
56
+ ]
57
+ },
58
+ de:{ // German
59
+ months:[
60
+ 'Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'
61
+ ],
62
+ dayOfWeek:[
63
+ "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
64
+ ]
65
+ },
66
+ nl:{ // Dutch
67
+ months:[
68
+ "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
69
+ ],
70
+ dayOfWeek:[
71
+ "zo", "ma", "di", "wo", "do", "vr", "za"
72
+ ]
73
+ },
74
+ tr:{ // Turkish
75
+ months:[
76
+ "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
77
+ ],
78
+ dayOfWeek:[
79
+ "Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
80
+ ]
81
+ },
82
+ fr:{ //French
83
+ months:[
84
+ "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
85
+ ],
86
+ dayOfWeek:[
87
+ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
88
+ ]
89
+ },
90
+ es:{ // Spanish
91
+ months: [
92
+ "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
93
+ ],
94
+ dayOfWeek: [
95
+ "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
96
+ ]
97
+ },
98
+ th:{ // Thai
99
+ months:[
100
+ 'มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'
101
+ ],
102
+ dayOfWeek:[
103
+ 'อา.','จ.','อ.','พ.','พฤ.','ศ.','ส.'
104
+ ]
105
+ },
106
+ pl:{ // Polish
107
+ months: [
108
+ "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
109
+ ],
110
+ dayOfWeek: [
111
+ "nd", "pn", "wt", "śr", "cz", "pt", "sb"
112
+ ]
113
+ },
114
+ pt:{ // Portuguese
115
+ months: [
116
+ "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
117
+ ],
118
+ dayOfWeek: [
119
+ "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
120
+ ]
121
+ },
122
+ ch:{ // Simplified Chinese
123
+ months: [
124
+ "一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"
125
+ ],
126
+ dayOfWeek: [
127
+ "日", "一","二","三","四","五","六"
128
+ ]
129
+ },
130
+ se:{ // Swedish
131
+ months: [
132
+ "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September","Oktober", "November", "December"
133
+ ],
134
+ dayOfWeek: [
135
+ "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
136
+ ]
137
+ },
138
+ kr:{ // Korean
139
+ months: [
140
+ "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
141
+ ],
142
+ dayOfWeek: [
143
+ "일", "월", "화", "수", "목", "금", "토"
144
+ ]
145
+ },
146
+ it:{ // Italian
147
+ months: [
148
+ "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
149
+ ],
150
+ dayOfWeek: [
151
+ "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
152
+ ]
153
+ },
154
+ da:{ // Dansk
155
+ months: [
156
+ "January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
157
+ ],
158
+ dayOfWeek: [
159
+ "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
160
+ ]
161
+ },
162
+ no:{ // Norwegian
163
+ months: [
164
+ "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
165
+ ],
166
+ dayOfWeek: [
167
+ "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
168
+ ]
169
+ },
170
+ ja:{ // Japanese
171
+ months: [
172
+ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
173
+ ],
174
+ dayOfWeek: [
175
+ "日", "月", "火", "水", "木", "金", "土"
176
+ ]
177
+ },
178
+ vi:{ // Vietnamese
179
+ months: [
180
+ "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"
181
+ ],
182
+ dayOfWeek: [
183
+ "CN", "T2", "T3", "T4", "T5", "T6", "T7"
184
+ ]
185
+ },
186
+ sl:{ // Slovenščina
187
+ months: [
188
+ "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
189
+ ],
190
+ dayOfWeek: [
191
+ "Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
192
+ ]
193
+ },
194
+ cs:{ // Čeština
195
+ months: [
196
+ "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
197
+ ],
198
+ dayOfWeek: [
199
+ "Ne", "Po", "Út", "St", "Čt", "Pá", "So"
200
+ ]
201
+ },
202
+ hu:{ // Hungarian
203
+ months: [
204
+ "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
205
+ ],
206
+ dayOfWeek: [
207
+ "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
208
+ ]
209
+ }
210
+ },
211
+ value:'',
212
+ lang:'en',
213
+
214
+ format: 'Y/m/d H:i',
215
+ formatTime: 'H:i',
216
+ formatDate: 'Y/m/d',
217
+
218
+ startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
219
+
220
+ step:60,
221
+ monthChangeSpinner:true,
222
+ closeOnDateSelect:false,
223
+ closeOnWithoutClick:true,
224
+ closeOnInputClick: true,
225
+
226
+ timepicker:true,
227
+ datepicker:true,
228
+ weeks:false,
229
+
230
+ defaultTime:false, // use formatTime format (ex. '10:00' for formatTime: 'H:i')
231
+ defaultDate:false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
232
+
233
+ minDate:false,
234
+ maxDate:false,
235
+ minTime:false,
236
+ maxTime:false,
237
+
238
+ allowTimes:[],
239
+ opened:false,
240
+ initTime:true,
241
+ inline:false,
242
+
243
+ onSelectDate:function() {},
244
+ onSelectTime:function() {},
245
+ onChangeMonth:function() {},
246
+ onChangeDateTime:function() {},
247
+ onShow:function() {},
248
+ onClose:function() {},
249
+ onGenerate:function() {},
250
+
251
+ withoutCopyright:true,
252
+
253
+ inverseButton:false,
254
+ hours12:false,
255
+ next: 'xdsoft_next',
256
+ prev : 'xdsoft_prev',
257
+ dayOfWeekStart:0,
258
+
259
+ timeHeightInTimePicker:25,
260
+ timepickerScrollbar:true,
261
+
262
+ todayButton:true, // 2.1.0
263
+ defaultSelect:true, // 2.1.0
264
+
265
+ scrollMonth:true,
266
+ scrollTime:true,
267
+ scrollInput:true,
268
+
269
+ lazyInit:false,
270
+
271
+ mask:false,
272
+ validateOnBlur:true,
273
+ allowBlank:true,
274
+
275
+ yearStart:1950,
276
+ yearEnd:2050,
277
+
278
+ style:'',
279
+ id:'',
280
+
281
+ fixed: false,
282
+
283
+ roundTime:'round', // ceil, floor
284
+ className:'',
285
+
286
+ weekends : [],
287
+ yearOffset:0,
288
+ beforeShowDay: null
289
+ };
290
+
291
+ // fix for ie8
292
+ if ( !Array.prototype.indexOf ) {
293
+ Array.prototype.indexOf = function(obj, start) {
294
+ for (var i = (start || 0), j = this.length; i < j; i++) {
295
+ if (this[i] === obj) { return i; }
296
+ }
297
+ return -1;
298
+ }
299
+ }
300
+
301
+ Date.prototype.countDaysInMonth = function(){
302
+ return new Date(this.getFullYear(), this.getMonth()+1, 0).getDate();
303
+ };
304
+
305
+ $.fn.xdsoftScroller = function( _percent ) {
306
+ return this.each(function() {
307
+ var timeboxparent = $(this);
308
+ if( !$(this).hasClass('xdsoft_scroller_box') ) {
309
+ var pointerEventToXY = function( e ) {
310
+ var out = {x:0, y:0};
311
+ if( e.type == 'touchstart' || e.type == 'touchmove' || e.type == 'touchend' || e.type == 'touchcancel' ) {
312
+ var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
313
+ out.x = touch.pageX;
314
+ out.y = touch.pageY;
315
+ }else if (e.type == 'mousedown' || e.type == 'mouseup' || e.type == 'mousemove' || e.type == 'mouseover'|| e.type=='mouseout' || e.type=='mouseenter' || e.type=='mouseleave') {
316
+ out.x = e.pageX;
317
+ out.y = e.pageY;
318
+ }
319
+ return out;
320
+ },
321
+ move = 0,
322
+ timebox = timeboxparent.children().eq(0),
323
+ parentHeight = timeboxparent[0].clientHeight,
324
+ height = timebox[0].offsetHeight,
325
+ scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
326
+ scroller = $('<div class="xdsoft_scroller"></div>'),
327
+ maximumOffset = 100,
328
+ start = false;
329
+
330
+ scrollbar.append(scroller);
331
+
332
+ timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
333
+ scroller.on('mousedown.xdsoft_scroller',function ( event ) {
334
+ if( !parentHeight )
335
+ timeboxparent.trigger('resize_scroll.xdsoft_scroller',[_percent]);
336
+ var pageY = event.pageY,
337
+ top = parseInt(scroller.css('margin-top')),
338
+ h1 = scrollbar[0].offsetHeight;
339
+ $(document.body).addClass('xdsoft_noselect');
340
+ $([document.body,window]).on('mouseup.xdsoft_scroller',function arguments_callee() {
341
+ $([document.body,window]).off('mouseup.xdsoft_scroller',arguments_callee)
342
+ .off('mousemove.xdsoft_scroller',move)
343
+ .removeClass('xdsoft_noselect');
344
+ });
345
+ $(document.body).on('mousemove.xdsoft_scroller',move = function(event) {
346
+ var offset = event.pageY-pageY+top;
347
+ if( offset<0 )
348
+ offset = 0;
349
+ if( offset+scroller[0].offsetHeight>h1 )
350
+ offset = h1-scroller[0].offsetHeight;
351
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[maximumOffset?offset/maximumOffset:0]);
352
+ });
353
+ });
354
+
355
+ timeboxparent
356
+ .on('scroll_element.xdsoft_scroller',function( event,percent ) {
357
+ if( !parentHeight )
358
+ timeboxparent.trigger('resize_scroll.xdsoft_scroller',[percent,true]);
359
+ percent = percent>1?1:(percent<0||isNaN(percent))?0:percent;
360
+ scroller.css('margin-top',maximumOffset*percent);
361
+ timebox.css('marginTop',-parseInt((height-parentHeight)*percent))
362
+ })
363
+ .on('resize_scroll.xdsoft_scroller',function( event,_percent,noTriggerScroll ) {
364
+ parentHeight = timeboxparent[0].clientHeight;
365
+ height = timebox[0].offsetHeight;
366
+ var percent = parentHeight/height,
367
+ sh = percent*scrollbar[0].offsetHeight;
368
+ if( percent>1 )
369
+ scroller.hide();
370
+ else{
371
+ scroller.show();
372
+ scroller.css('height',parseInt(sh>10?sh:10));
373
+ maximumOffset = scrollbar[0].offsetHeight-scroller[0].offsetHeight;
374
+ if( noTriggerScroll!==true )
375
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[_percent?_percent:Math.abs(parseInt(timebox.css('marginTop')))/(height-parentHeight)]);
376
+ }
377
+ });
378
+ timeboxparent.mousewheel&&timeboxparent.mousewheel(function(event, delta, deltaX, deltaY) {
379
+ var top = Math.abs(parseInt(timebox.css('marginTop')));
380
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[(top-delta*20)/(height-parentHeight)]);
381
+ event.stopPropagation();
382
+ return false;
383
+ });
384
+ timeboxparent.on('touchstart',function( event ) {
385
+ start = pointerEventToXY(event);
386
+ });
387
+ timeboxparent.on('touchmove',function( event ) {
388
+ if( start ) {
389
+ var coord = pointerEventToXY(event), top = Math.abs(parseInt(timebox.css('marginTop')));
390
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[(top-(coord.y-start.y))/(height-parentHeight)]);
391
+ event.stopPropagation();
392
+ event.preventDefault();
393
+ start = pointerEventToXY(event);
394
+ }
395
+ });
396
+ timeboxparent.on('touchend touchcancel',function( event ) {
397
+ start = false;
398
+ });
399
+ }
400
+ timeboxparent.trigger('resize_scroll.xdsoft_scroller',[_percent]);
401
+ });
402
+ };
403
+ $.fn.datetimepicker = function( opt ) {
404
+ var KEY0 = 48,
405
+ KEY9 = 57,
406
+ _KEY0 = 96,
407
+ _KEY9 = 105,
408
+ CTRLKEY = 17,
409
+ DEL = 46,
410
+ ENTER = 13,
411
+ ESC = 27,
412
+ BACKSPACE = 8,
413
+ ARROWLEFT = 37,
414
+ ARROWUP = 38,
415
+ ARROWRIGHT = 39,
416
+ ARROWDOWN = 40,
417
+ TAB = 9,
418
+ F5 = 116,
419
+ AKEY = 65,
420
+ CKEY = 67,
421
+ VKEY = 86,
422
+ ZKEY = 90,
423
+ YKEY = 89,
424
+ ctrlDown = false,
425
+ options = ($.isPlainObject(opt)||!opt)?$.extend(true,{},default_options,opt):$.extend({},default_options),
426
+
427
+ lazyInitTimer = 0,
428
+
429
+ lazyInit = function( input ){
430
+ input
431
+ .on('open.xdsoft focusin.xdsoft mousedown.xdsoft',function initOnActionCallback(event) {
432
+ if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||input.data( 'xdsoft_datetimepicker') )
433
+ return;
434
+
435
+ clearTimeout(lazyInitTimer);
436
+
437
+ lazyInitTimer = setTimeout(function() {
438
+
439
+ if( !input.data( 'xdsoft_datetimepicker') )
440
+ createDateTimePicker(input);
441
+
442
+ input
443
+ .off('open.xdsoft focusin.xdsoft mousedown.xdsoft',initOnActionCallback)
444
+ .trigger('open.xdsoft');
445
+ },100);
446
+
447
+ });
448
+ },
449
+
450
+ createDateTimePicker = function( input ) {
451
+
452
+ var datetimepicker = $('<div '+(options.id?'id="'+options.id+'"':'')+' '+(options.style?'style="'+options.style+'"':'')+' class="xdsoft_datetimepicker xdsoft_noselect '+(options.weeks?' xdsoft_showweeks':'')+options.className+'"></div>'),
453
+ xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
454
+ datepicker = $('<div class="xdsoft_datepicker active"></div>'),
455
+ mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button><div class="xdsoft_label xdsoft_month"><span></span></div><div class="xdsoft_label xdsoft_year"><span></span></div><button type="button" class="xdsoft_next"></button></div>'),
456
+ calendar = $('<div class="xdsoft_calendar"></div>'),
457
+ timepicker = $('<div class="xdsoft_timepicker active"><button type="button" class="xdsoft_prev"></button><div class="xdsoft_time_box"></div><button type="button" class="xdsoft_next"></button></div>'),
458
+ timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
459
+ timebox = $('<div class="xdsoft_time_variant"></div>'),
460
+ scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
461
+ scroller = $('<div class="xdsoft_scroller"></div>'),
462
+ monthselect =$('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
463
+ yearselect =$('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>');
464
+
465
+ //constructor lego
466
+ mounth_picker
467
+ .find('.xdsoft_month span')
468
+ .after(monthselect);
469
+ mounth_picker
470
+ .find('.xdsoft_year span')
471
+ .after(yearselect);
472
+
473
+ mounth_picker
474
+ .find('.xdsoft_month,.xdsoft_year')
475
+ .on('mousedown.xdsoft',function(event) {
476
+ mounth_picker
477
+ .find('.xdsoft_select')
478
+ .hide();
479
+
480
+ var select = $(this).find('.xdsoft_select').eq(0),
481
+ val = 0,
482
+ top = 0;
483
+
484
+ if( _xdsoft_datetime.currentTime )
485
+ val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month')?'getMonth':'getFullYear']();
486
+
487
+ select.show();
488
+
489
+ for(var items = select.find('div.xdsoft_option'),i = 0;i<items.length;i++) {
490
+ if( items.eq(i).data('value')==val ) {
491
+ break;
492
+ }else top+=items[0].offsetHeight;
493
+ }
494
+
495
+ select.xdsoftScroller(top/(select.children()[0].offsetHeight-(select[0].clientHeight)));
496
+ event.stopPropagation();
497
+
498
+ return false;
499
+ });
500
+
501
+ mounth_picker
502
+ .find('.xdsoft_select')
503
+ .xdsoftScroller()
504
+ .on('mousedown.xdsoft',function( event ) {
505
+ event.stopPropagation();
506
+ event.preventDefault();
507
+ })
508
+ .on('mousedown.xdsoft','.xdsoft_option',function( event ) {
509
+ if( _xdsoft_datetime&&_xdsoft_datetime.currentTime )
510
+ _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect')?'setMonth':'setFullYear']($(this).data('value'));
511
+
512
+ $(this).parent().parent().hide();
513
+
514
+ datetimepicker.trigger('xchange.xdsoft');
515
+ options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
516
+ });
517
+
518
+
519
+ // set options
520
+ datetimepicker.setOptions = function( _options ) {
521
+ options = $.extend(true,{},options,_options);
522
+
523
+ if( _options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length ){
524
+ options['allowTimes'] = $.extend(true,[],_options.allowTimes);
525
+ }
526
+
527
+ if( _options.weekends && $.isArray(_options.weekends) && _options.weekends.length ){
528
+ options['weekends'] = $.extend(true,[],_options.weekends);
529
+ }
530
+
531
+ if( (options.open||options.opened)&&(!options.inline) ) {
532
+ input.trigger('open.xdsoft');
533
+ }
534
+
535
+ if( options.inline ) {
536
+ triggerAfterOpen = true;
537
+ datetimepicker.addClass('xdsoft_inline');
538
+ input.after(datetimepicker).hide();
539
+ }
540
+
541
+ if( options.inverseButton ) {
542
+ options.next = 'xdsoft_prev';
543
+ options.prev = 'xdsoft_next';
544
+ }
545
+
546
+ if( options.datepicker )
547
+ datepicker.addClass('active');
548
+ else
549
+ datepicker.removeClass('active');
550
+
551
+ if( options.timepicker )
552
+ timepicker.addClass('active');
553
+ else
554
+ timepicker.removeClass('active');
555
+
556
+ if( options.value ){
557
+ input&&input.val&&input.val(options.value);
558
+ _xdsoft_datetime.setCurrentTime(options.value);
559
+ }
560
+
561
+ if( isNaN(options.dayOfWeekStart) )
562
+ options.dayOfWeekStart = 0;
563
+ else
564
+ options.dayOfWeekStart = parseInt(options.dayOfWeekStart)%7;
565
+
566
+ if( !options.timepickerScrollbar )
567
+ scrollbar.hide();
568
+
569
+ if( options.minDate && /^-(.*)$/.test(options.minDate) ){
570
+ options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat( options.formatDate );
571
+ }
572
+
573
+ if( options.maxDate && /^\+(.*)$/.test(options.maxDate) ) {
574
+ options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat( options.formatDate );
575
+ }
576
+
577
+ mounth_picker
578
+ .find('.xdsoft_today_button')
579
+ .css('visibility',!options.todayButton?'hidden':'visible');
580
+
581
+ if( options.mask ) {
582
+ var e,
583
+ getCaretPos = function ( input ) {
584
+ try{
585
+ if ( document.selection && document.selection.createRange ) {
586
+ var range = document.selection.createRange();
587
+ return range.getBookmark().charCodeAt(2) - 2;
588
+ }else
589
+ if ( input.setSelectionRange )
590
+ return input.selectionStart;
591
+ }catch(e) {
592
+ return 0;
593
+ }
594
+ },
595
+ setCaretPos = function ( node,pos ) {
596
+ node = (typeof node == "string" || node instanceof String) ? document.getElementById(node) : node;
597
+ if(!node) {
598
+ return false;
599
+ }else if(node.createTextRange) {
600
+ var textRange = node.createTextRange();
601
+ textRange.collapse(true);
602
+ textRange.moveEnd(pos);
603
+ textRange.moveStart(pos);
604
+ textRange.select();
605
+ return true;
606
+ }else if(node.setSelectionRange) {
607
+ node.setSelectionRange(pos,pos);
608
+ return true;
609
+ }
610
+ return false;
611
+ },
612
+ isValidValue = function ( mask,value ) {
613
+ var reg = mask
614
+ .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g,'\\$1')
615
+ .replace(/_/g,'{digit+}')
616
+ .replace(/([0-9]{1})/g,'{digit$1}')
617
+ .replace(/\{digit([0-9]{1})\}/g,'[0-$1_]{1}')
618
+ .replace(/\{digit[\+]\}/g,'[0-9_]{1}');
619
+ return RegExp(reg).test(value);
620
+ };
621
+ input.off('keydown.xdsoft');
622
+ switch(true) {
623
+ case ( options.mask===true ):
624
+
625
+ options.mask = options.format
626
+ .replace(/Y/g,'9999')
627
+ .replace(/F/g,'9999')
628
+ .replace(/m/g,'19')
629
+ .replace(/d/g,'39')
630
+ .replace(/H/g,'29')
631
+ .replace(/i/g,'59')
632
+ .replace(/s/g,'59');
633
+
634
+ case ( $.type(options.mask) == 'string' ):
635
+
636
+ if( !isValidValue( options.mask,input.val() ) )
637
+ input.val(options.mask.replace(/[0-9]/g,'_'));
638
+
639
+ input.on('keydown.xdsoft',function( event ) {
640
+ var val = this.value,
641
+ key = event.which;
642
+
643
+ switch(true) {
644
+ case (( key>=KEY0&&key<=KEY9 )||( key>=_KEY0&&key<=_KEY9 ))||(key==BACKSPACE||key==DEL):
645
+ var pos = getCaretPos(this),
646
+ digit = ( key!=BACKSPACE&&key!=DEL )?String.fromCharCode((_KEY0 <= key && key <= _KEY9)? key-KEY0 : key):'_';
647
+
648
+ if( (key==BACKSPACE||key==DEL)&&pos ) {
649
+ pos--;
650
+ digit='_';
651
+ }
652
+
653
+ while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 )
654
+ pos+=( key==BACKSPACE||key==DEL )?-1:1;
655
+
656
+ val = val.substr(0,pos)+digit+val.substr(pos+1);
657
+ if( $.trim(val)=='' ){
658
+ val = options.mask.replace(/[0-9]/g,'_');
659
+ }else{
660
+ if( pos==options.mask.length )
661
+ break;
662
+ }
663
+
664
+ pos+=(key==BACKSPACE||key==DEL)?0:1;
665
+ while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 )
666
+ pos+=(key==BACKSPACE||key==DEL)?-1:1;
667
+
668
+ if( isValidValue( options.mask,val ) ) {
669
+ this.value = val;
670
+ setCaretPos(this,pos);
671
+ }else if( $.trim(val)=='' )
672
+ this.value = options.mask.replace(/[0-9]/g,'_');
673
+ else{
674
+ input.trigger('error_input.xdsoft');
675
+ }
676
+ break;
677
+ case ( !!~([AKEY,CKEY,VKEY,ZKEY,YKEY].indexOf(key))&&ctrlDown ):
678
+ case !!~([ESC,ARROWUP,ARROWDOWN,ARROWLEFT,ARROWRIGHT,F5,CTRLKEY,TAB,ENTER].indexOf(key)):
679
+ return true;
680
+ }
681
+ event.preventDefault();
682
+ return false;
683
+ });
684
+ break;
685
+ }
686
+ }
687
+ if( options.validateOnBlur ) {
688
+ input
689
+ .off('blur.xdsoft')
690
+ .on('blur.xdsoft', function() {
691
+ if( options.allowBlank && !$.trim($(this).val()).length ) {
692
+ $(this).val(null);
693
+ datetimepicker.data('xdsoft_datetime').empty();
694
+ }else if( !Date.parseDate( $(this).val(), options.format ) ) {
695
+ $(this).val((_xdsoft_datetime.now()).dateFormat( options.format ));
696
+ datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
697
+ }
698
+ else{
699
+ datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
700
+ }
701
+ datetimepicker.trigger('changedatetime.xdsoft');
702
+ });
703
+ }
704
+ options.dayOfWeekStartPrev = (options.dayOfWeekStart==0)?6:options.dayOfWeekStart-1;
705
+
706
+ datetimepicker
707
+ .trigger('xchange.xdsoft')
708
+ .trigger('afterOpen.xdsoft')
709
+ };
710
+
711
+ datetimepicker
712
+ .data('options',options)
713
+ .on('mousedown.xdsoft',function( event ) {
714
+ event.stopPropagation();
715
+ event.preventDefault();
716
+ yearselect.hide();
717
+ monthselect.hide();
718
+ return false;
719
+ });
720
+
721
+ var scroll_element = timepicker.find('.xdsoft_time_box');
722
+ scroll_element.append(timebox);
723
+ scroll_element.xdsoftScroller();
724
+
725
+ datetimepicker.on('afterOpen.xdsoft',function() {
726
+ scroll_element.xdsoftScroller();
727
+ });
728
+
729
+ datetimepicker
730
+ .append(datepicker)
731
+ .append(timepicker);
732
+
733
+ if( options.withoutCopyright!==true )
734
+ datetimepicker
735
+ .append(xdsoft_copyright);
736
+
737
+ datepicker
738
+ .append(mounth_picker)
739
+ .append(calendar);
740
+
741
+ $('body').append(datetimepicker);
742
+
743
+ var _xdsoft_datetime = new function() {
744
+ var _this = this;
745
+ _this.now = function( norecursion ) {
746
+ var d = new Date();
747
+
748
+ if( !norecursion && options.defaultDate ){
749
+ var date = _this.strtodate(options.defaultDate);
750
+ d.setFullYear( date.getFullYear() );
751
+ d.setMonth( date.getMonth() );
752
+ d.setDate( date.getDate() );
753
+ }
754
+
755
+ if( options.yearOffset ){
756
+ d.setFullYear(d.getFullYear()+options.yearOffset);
757
+ }
758
+
759
+ if( !norecursion && options.defaultTime ){
760
+ var time = _this.strtotime(options.defaultTime);
761
+ d.setHours( time.getHours() );
762
+ d.setMinutes( time.getMinutes() );
763
+ }
764
+
765
+ return d;
766
+ };
767
+
768
+
769
+ _this.isValidDate = function (d) {
770
+ if ( Object.prototype.toString.call(d) !== "[object Date]" )
771
+ return false;
772
+ return !isNaN(d.getTime());
773
+ };
774
+
775
+ _this.setCurrentTime = function( dTime ) {
776
+ _this.currentTime = (typeof dTime == 'string')? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime: _this.now();
777
+ datetimepicker.trigger('xchange.xdsoft');
778
+ };
779
+
780
+ _this.empty = function() {
781
+ _this.currentTime = null;
782
+ };
783
+
784
+ _this.getCurrentTime = function( dTime) {
785
+ return _this.currentTime;
786
+ };
787
+
788
+ _this.nextMonth = function() {
789
+ var month = _this.currentTime.getMonth()+1;
790
+ if( month==12 ) {
791
+ _this.currentTime.setFullYear(_this.currentTime.getFullYear()+1);
792
+ month = 0;
793
+ }
794
+ _this.currentTime.setDate(
795
+ Math.min(
796
+ Date.daysInMonth[month],
797
+ _this.currentTime.getDate()
798
+ )
799
+ );
800
+ _this.currentTime.setMonth(month);
801
+ options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
802
+ datetimepicker.trigger('xchange.xdsoft');
803
+ return month;
804
+ };
805
+
806
+ _this.prevMonth = function() {
807
+ var month = _this.currentTime.getMonth()-1;
808
+ if( month==-1 ) {
809
+ _this.currentTime.setFullYear(_this.currentTime.getFullYear()-1);
810
+ month = 11;
811
+ }
812
+ _this.currentTime.setDate(
813
+ Math.min(
814
+ Date.daysInMonth[month],
815
+ _this.currentTime.getDate()
816
+ )
817
+ );
818
+ _this.currentTime.setMonth(month);
819
+ options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
820
+ datetimepicker.trigger('xchange.xdsoft');
821
+ return month;
822
+ };
823
+
824
+ _this.strToDateTime = function( sDateTime ) {
825
+ if( sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime) )
826
+ return sDateTime;
827
+
828
+ var tmpDate = [],timeOffset,currentTime;
829
+
830
+ if( ( tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime) ) && ( tmpDate[2]=Date.parseDate(tmpDate[2], options.formatDate) ) ) {
831
+ timeOffset = tmpDate[2].getTime()-(tmpDate[2].getTimezoneOffset())*60000;
832
+ currentTime = new Date((_xdsoft_datetime.now()).getTime()+parseInt(tmpDate[1]+'1')*timeOffset);
833
+ }else
834
+ currentTime = sDateTime?Date.parseDate(sDateTime, options.format):_this.now();
835
+
836
+ if( !_this.isValidDate(currentTime) )
837
+ currentTime = _this.now();
838
+
839
+ return currentTime;
840
+ };
841
+
842
+ _this.strtodate = function( sDate ) {
843
+ if( sDate && sDate instanceof Date && _this.isValidDate(sDate) )
844
+ return sDate;
845
+
846
+ var currentTime = sDate?Date.parseDate(sDate, options.formatDate):_this.now(true);
847
+ if( !_this.isValidDate(currentTime) )
848
+ currentTime = _this.now(true);
849
+
850
+ return currentTime;
851
+ };
852
+
853
+ _this.strtotime = function( sTime ) {
854
+ if( sTime && sTime instanceof Date && _this.isValidDate(sTime) )
855
+ return sTime;
856
+
857
+ var currentTime = sTime?Date.parseDate(sTime, options.formatTime):_this.now();
858
+ if( !_this.isValidDate(currentTime) )
859
+ currentTime = _this.now(true);
860
+
861
+ return currentTime;
862
+ };
863
+
864
+ _this.str = function() {
865
+ return _this.currentTime.dateFormat(options.format);
866
+ };
867
+
868
+ _this.currentTime = this.now();
869
+ };
870
+ mounth_picker
871
+ .find('.xdsoft_today_button')
872
+ .on('mousedown.xdsoft',function() {
873
+ datetimepicker.data('changed',true);
874
+ _xdsoft_datetime.setCurrentTime(0);
875
+ datetimepicker.trigger('afterOpen.xdsoft');
876
+ }).on('dblclick.xdsoft',function(){
877
+ input.val( _xdsoft_datetime.str() );
878
+ datetimepicker.trigger('close.xdsoft');
879
+ });
880
+ mounth_picker
881
+ .find('.xdsoft_prev,.xdsoft_next')
882
+ .on('mousedown.xdsoft',function() {
883
+ var $this = $(this),
884
+ timer = 0,
885
+ stop = false;
886
+
887
+ (function arguments_callee1(v) {
888
+ var month = _xdsoft_datetime.currentTime.getMonth();
889
+ if( $this.hasClass( options.next ) ) {
890
+ _xdsoft_datetime.nextMonth();
891
+ }else if( $this.hasClass( options.prev ) ) {
892
+ _xdsoft_datetime.prevMonth();
893
+ }
894
+ if (options.monthChangeSpinner) {
895
+ !stop&&(timer = setTimeout(arguments_callee1,v?v:100));
896
+ }
897
+ })(500);
898
+
899
+ $([document.body,window]).on('mouseup.xdsoft',function arguments_callee2() {
900
+ clearTimeout(timer);
901
+ stop = true;
902
+ $([document.body,window]).off('mouseup.xdsoft',arguments_callee2);
903
+ });
904
+ });
905
+
906
+ timepicker
907
+ .find('.xdsoft_prev,.xdsoft_next')
908
+ .on('mousedown.xdsoft',function() {
909
+ var $this = $(this),
910
+ timer = 0,
911
+ stop = false,
912
+ period = 110;
913
+ (function arguments_callee4(v) {
914
+ var pheight = timeboxparent[0].clientHeight,
915
+ height = timebox[0].offsetHeight,
916
+ top = Math.abs(parseInt(timebox.css('marginTop')));
917
+ if( $this.hasClass(options.next) && (height-pheight)- options.timeHeightInTimePicker>=top ) {
918
+ timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px')
919
+ }else if( $this.hasClass(options.prev) && top-options.timeHeightInTimePicker>=0 ) {
920
+ timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px')
921
+ }
922
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox.css('marginTop'))/(height-pheight))]);
923
+ period= ( period>10 )?10:period-10;
924
+ !stop&&(timer = setTimeout(arguments_callee4,v?v:period));
925
+ })(500);
926
+ $([document.body,window]).on('mouseup.xdsoft',function arguments_callee5() {
927
+ clearTimeout(timer);
928
+ stop = true;
929
+ $([document.body,window])
930
+ .off('mouseup.xdsoft',arguments_callee5);
931
+ });
932
+ });
933
+
934
+ var xchangeTimer = 0;
935
+ // base handler - generating a calendar and timepicker
936
+ datetimepicker
937
+ .on('xchange.xdsoft',function( event ) {
938
+ clearTimeout(xchangeTimer);
939
+ xchangeTimer = setTimeout(function(){
940
+ var table = '',
941
+ start = new Date(_xdsoft_datetime.currentTime.getFullYear(),_xdsoft_datetime.currentTime.getMonth(),1, 12, 0, 0),
942
+ i = 0,
943
+ today = _xdsoft_datetime.now();
944
+
945
+ while( start.getDay()!=options.dayOfWeekStart )
946
+ start.setDate(start.getDate()-1);
947
+
948
+ //generate calendar
949
+ table+='<table><thead><tr>';
950
+
951
+ if(options.weeks) {
952
+ table+='<th></th>';
953
+ }
954
+
955
+ // days
956
+ for(var j = 0; j<7; j++) {
957
+ table+='<th>'+options.i18n[options.lang].dayOfWeek[(j+options.dayOfWeekStart)%7]+'</th>';
958
+ }
959
+
960
+ table+='</tr></thead>';
961
+ table+='<tbody>';
962
+ var maxDate = false, minDate = false;
963
+
964
+ if( options.maxDate!==false ) {
965
+ maxDate = _xdsoft_datetime.strtodate(options.maxDate);
966
+ maxDate = new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate(),23,59,59,999);
967
+ }
968
+
969
+ if( options.minDate!==false ) {
970
+ minDate = _xdsoft_datetime.strtodate(options.minDate);
971
+ minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());
972
+ }
973
+
974
+ var d,y,m,w,classes = [],customDateSettings,newRow=true;
975
+
976
+ while( i<_xdsoft_datetime.currentTime.countDaysInMonth()||start.getDay()!=options.dayOfWeekStart||_xdsoft_datetime.currentTime.getMonth()==start.getMonth() ) {
977
+ classes = [];
978
+ i++;
979
+
980
+ d = start.getDate(); y = start.getFullYear(); m = start.getMonth(); w = start.getWeekOfYear();
981
+
982
+ classes.push('xdsoft_date');
983
+
984
+ if ( options.beforeShowDay && options.beforeShowDay.call ) {
985
+ customDateSettings = options.beforeShowDay.call(datetimepicker, start);
986
+ } else {
987
+ customDateSettings = null;
988
+ }
989
+
990
+ if( ( maxDate!==false && start > maxDate )||( minDate!==false && start < minDate )||(customDateSettings && customDateSettings[0] === false) ){
991
+ classes.push('xdsoft_disabled');
992
+ }
993
+
994
+ if ( customDateSettings && customDateSettings[1] != "" ) {
995
+ classes.push(customDateSettings[1]);
996
+ }
997
+
998
+ if( _xdsoft_datetime.currentTime.getMonth()!=m ) classes.push('xdsoft_other_month');
999
+
1000
+ if( (options.defaultSelect||datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat( options.formatDate )==start.dateFormat( options.formatDate ) ) {
1001
+ classes.push('xdsoft_current');
1002
+ }
1003
+
1004
+ if( today.dateFormat( options.formatDate )==start.dateFormat( options.formatDate ) ) {
1005
+ classes.push('xdsoft_today');
1006
+ }
1007
+
1008
+ if( start.getDay()==0||start.getDay()==6||~options.weekends.indexOf(start.dateFormat( options.formatDate )) ) {
1009
+ classes.push('xdsoft_weekend');
1010
+ }
1011
+
1012
+ if(options.beforeShowDay && typeof options.beforeShowDay == 'function') {
1013
+ classes.push(options.beforeShowDay(start))
1014
+ }
1015
+
1016
+ if(newRow) {
1017
+ table+='<tr>';
1018
+ newRow = false;
1019
+
1020
+ if(options.weeks) {
1021
+ table+='<th>'+w+'</th>';
1022
+ }
1023
+ }
1024
+
1025
+ table+='<td data-date="'+d+'" data-month="'+m+'" data-year="'+y+'"'+' class="xdsoft_date xdsoft_day_of_week'+start.getDay()+' '+ classes.join(' ')+'">'+
1026
+ '<div>'+d+'</div>'+
1027
+ '</td>';
1028
+
1029
+ if( start.getDay()==options.dayOfWeekStartPrev ) {
1030
+ table+='</tr>';
1031
+ newRow = true;
1032
+ }
1033
+
1034
+ start.setDate(d+1);
1035
+ }
1036
+ table+='</tbody></table>';
1037
+
1038
+ calendar.html(table);
1039
+
1040
+ mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
1041
+ mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
1042
+
1043
+ // generate timebox
1044
+ var time = '',
1045
+ h = '',
1046
+ m ='',
1047
+ line_time = function line_time( h,m ) {
1048
+ var now = _xdsoft_datetime.now();
1049
+ now.setHours(h);
1050
+ h = parseInt(now.getHours());
1051
+ now.setMinutes(m);
1052
+ m = parseInt(now.getMinutes());
1053
+
1054
+ classes = [];
1055
+ if( (options.maxTime!==false&&_xdsoft_datetime.strtotime(options.maxTime).getTime()<now.getTime())||(options.minTime!==false&&_xdsoft_datetime.strtotime(options.minTime).getTime()>now.getTime()))
1056
+ classes.push('xdsoft_disabled');
1057
+ if( (options.initTime||options.defaultSelect||datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours())==parseInt(h)&&(options.step>59||Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes()/options.step)*options.step==parseInt(m))) {
1058
+ if( options.defaultSelect||datetimepicker.data('changed')) {
1059
+ classes.push('xdsoft_current');
1060
+ } else if( options.initTime ) {
1061
+ classes.push('xdsoft_init_time');
1062
+ }
1063
+ }
1064
+ if( parseInt(today.getHours())==parseInt(h)&&parseInt(today.getMinutes())==parseInt(m))
1065
+ classes.push('xdsoft_today');
1066
+ time+= '<div class="xdsoft_time '+classes.join(' ')+'" data-hour="'+h+'" data-minute="'+m+'">'+now.dateFormat(options.formatTime)+'</div>';
1067
+ };
1068
+
1069
+ if( !options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length ) {
1070
+ for( var i=0,j=0;i<(options.hours12?12:24);i++ ) {
1071
+ for( j=0;j<60;j+=options.step ) {
1072
+ h = (i<10?'0':'')+i;
1073
+ m = (j<10?'0':'')+j;
1074
+ line_time( h,m );
1075
+ }
1076
+ }
1077
+ }else{
1078
+ for( var i=0;i<options.allowTimes.length;i++ ) {
1079
+ h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
1080
+ m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
1081
+ line_time( h,m );
1082
+ }
1083
+ }
1084
+
1085
+ timebox.html(time);
1086
+
1087
+ var opt = '',
1088
+ i = 0;
1089
+
1090
+ for( i = parseInt(options.yearStart,10)+options.yearOffset;i<= parseInt(options.yearEnd,10)+options.yearOffset;i++ ) {
1091
+ opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getFullYear()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+i+'</div>';
1092
+ }
1093
+ yearselect.children().eq(0)
1094
+ .html(opt);
1095
+
1096
+ for( i = 0,opt = '';i<= 11;i++ ) {
1097
+ opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getMonth()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+options.i18n[options.lang].months[i]+'</div>';
1098
+ }
1099
+ monthselect.children().eq(0).html(opt);
1100
+ $(datetimepicker)
1101
+ .trigger('generate.xdsoft');
1102
+ },10);
1103
+ event.stopPropagation();
1104
+ })
1105
+ .on('afterOpen.xdsoft',function() {
1106
+ if( options.timepicker ) {
1107
+ var classType;
1108
+ if( timebox.find('.xdsoft_current').length ) {
1109
+ classType = '.xdsoft_current';
1110
+ } else if( timebox.find('.xdsoft_init_time').length ) {
1111
+ classType = '.xdsoft_init_time';
1112
+ }
1113
+
1114
+ if( classType ) {
1115
+ var pheight = timeboxparent[0].clientHeight,
1116
+ height = timebox[0].offsetHeight,
1117
+ top = timebox.find(classType).index()*options.timeHeightInTimePicker+1;
1118
+ if( (height-pheight)<top )
1119
+ top = height-pheight;
1120
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[parseInt(top)/(height-pheight)]);
1121
+ }else{
1122
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[0]);
1123
+ }
1124
+ }
1125
+ });
1126
+
1127
+ var timerclick = 0;
1128
+
1129
+ calendar
1130
+ .on('click.xdsoft', 'td', function (xdevent) {
1131
+ xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
1132
+ timerclick++;
1133
+ var $this = $(this),
1134
+ currentTime = _xdsoft_datetime.currentTime;
1135
+
1136
+ if( currentTime===undefined||currentTime===null ){
1137
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1138
+ currentTime = _xdsoft_datetime.currentTime;
1139
+ }
1140
+
1141
+ if( $this.hasClass('xdsoft_disabled') )
1142
+ return false;
1143
+
1144
+ currentTime.setDate( 1 );
1145
+ currentTime.setFullYear( $this.data('year') );
1146
+ currentTime.setMonth( $this.data('month') );
1147
+ currentTime.setDate( $this.data('date') );
1148
+
1149
+ datetimepicker.trigger('select.xdsoft',[currentTime]);
1150
+
1151
+ input.val( _xdsoft_datetime.str() );
1152
+ if( (timerclick>1||(options.closeOnDateSelect===true||( options.closeOnDateSelect===0&&!options.timepicker )))&&!options.inline ) {
1153
+ datetimepicker.trigger('close.xdsoft');
1154
+ }
1155
+
1156
+ if( options.onSelectDate && options.onSelectDate.call ) {
1157
+ options.onSelectDate.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1158
+ }
1159
+
1160
+ datetimepicker.data('changed',true);
1161
+ datetimepicker.trigger('xchange.xdsoft');
1162
+ datetimepicker.trigger('changedatetime.xdsoft');
1163
+ setTimeout(function(){
1164
+ timerclick = 0;
1165
+ },200);
1166
+ });
1167
+
1168
+ timebox
1169
+ .on('click.xdsoft', 'div', function (xdevent) {
1170
+ xdevent.stopPropagation(); // NAJ: Prevents closing of Pop-ups, Modals and Flyouts
1171
+ var $this = $(this),
1172
+ currentTime = _xdsoft_datetime.currentTime;
1173
+
1174
+ if( currentTime===undefined||currentTime===null ){
1175
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1176
+ currentTime = _xdsoft_datetime.currentTime;
1177
+ }
1178
+
1179
+ if( $this.hasClass('xdsoft_disabled') )
1180
+ return false;
1181
+ currentTime.setHours($this.data('hour'));
1182
+ currentTime.setMinutes($this.data('minute'));
1183
+ datetimepicker.trigger('select.xdsoft',[currentTime]);
1184
+
1185
+ datetimepicker.data('input').val( _xdsoft_datetime.str() );
1186
+
1187
+ !options.inline&&datetimepicker.trigger('close.xdsoft');
1188
+
1189
+ if( options.onSelectTime&&options.onSelectTime.call ) {
1190
+ options.onSelectTime.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1191
+ }
1192
+ datetimepicker.data('changed',true);
1193
+ datetimepicker.trigger('xchange.xdsoft');
1194
+ datetimepicker.trigger('changedatetime.xdsoft');
1195
+ });
1196
+
1197
+ datetimepicker.mousewheel&&datepicker.mousewheel(function(event, delta, deltaX, deltaY) {
1198
+ if( !options.scrollMonth )
1199
+ return true;
1200
+ if( delta<0 )
1201
+ _xdsoft_datetime.nextMonth();
1202
+ else
1203
+ _xdsoft_datetime.prevMonth();
1204
+ return false;
1205
+ });
1206
+
1207
+ datetimepicker.mousewheel&&timeboxparent.unmousewheel().mousewheel(function(event, delta, deltaX, deltaY) {
1208
+ if( !options.scrollTime )
1209
+ return true;
1210
+ var pheight = timeboxparent[0].clientHeight,
1211
+ height = timebox[0].offsetHeight,
1212
+ top = Math.abs(parseInt(timebox.css('marginTop'))),
1213
+ fl = true;
1214
+ if( delta<0 && (height-pheight)-options.timeHeightInTimePicker>=top ) {
1215
+ timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px');
1216
+ fl = false;
1217
+ }else if( delta>0&&top-options.timeHeightInTimePicker>=0 ) {
1218
+ timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px');
1219
+ fl = false;
1220
+ }
1221
+ timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox.css('marginTop'))/(height-pheight))]);
1222
+ event.stopPropagation();
1223
+ return fl;
1224
+ });
1225
+
1226
+ var triggerAfterOpen = false;
1227
+ datetimepicker
1228
+ .on('changedatetime.xdsoft',function() {
1229
+ if( options.onChangeDateTime&&options.onChangeDateTime.call ) {
1230
+ var $input = datetimepicker.data('input');
1231
+ options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input);
1232
+ delete options.value;
1233
+ $input.trigger('change');
1234
+ }
1235
+ })
1236
+ .on('generate.xdsoft',function() {
1237
+ if( options.onGenerate&&options.onGenerate.call )
1238
+ options.onGenerate.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1239
+ if( triggerAfterOpen ){
1240
+ datetimepicker.trigger('afterOpen.xdsoft');
1241
+ triggerAfterOpen = false;
1242
+ }
1243
+ })
1244
+ .on( 'click.xdsoft', function( xdevent )
1245
+ {
1246
+ xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
1247
+ });
1248
+
1249
+ var current_time_index = 0;
1250
+ input.mousewheel&&input.mousewheel(function( event, delta, deltaX, deltaY ) {
1251
+ if( !options.scrollInput )
1252
+ return true;
1253
+ if( !options.datepicker && options.timepicker ) {
1254
+ current_time_index = timebox.find('.xdsoft_current').length?timebox.find('.xdsoft_current').eq(0).index():0;
1255
+ if( current_time_index+delta>=0&&current_time_index+delta<timebox.children().length )
1256
+ current_time_index+=delta;
1257
+ timebox.children().eq(current_time_index).length&&timebox.children().eq(current_time_index).trigger('mousedown');
1258
+ return false;
1259
+ }else if( options.datepicker && !options.timepicker ) {
1260
+ datepicker.trigger( event, [delta, deltaX, deltaY]);
1261
+ input.val&&input.val( _xdsoft_datetime.str() );
1262
+ datetimepicker.trigger('changedatetime.xdsoft');
1263
+ return false;
1264
+ }
1265
+ });
1266
+ var setPos = function() {
1267
+ var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight-1, left = offset.left, position = "absolute";
1268
+ if (options.fixed) {
1269
+ top -= $(window).scrollTop();
1270
+ left -= $(window).scrollLeft();
1271
+ position = "fixed";
1272
+ }else {
1273
+ if( top+datetimepicker[0].offsetHeight>$(window).height()+$(window).scrollTop() )
1274
+ top = offset.top-datetimepicker[0].offsetHeight+1;
1275
+ if (top < 0)
1276
+ top = 0;
1277
+ if( left+datetimepicker[0].offsetWidth>$(window).width() )
1278
+ left = offset.left-datetimepicker[0].offsetWidth+datetimepicker.data('input')[0].offsetWidth;
1279
+ }
1280
+ datetimepicker.css({
1281
+ left:left,
1282
+ top:top,
1283
+ position: position
1284
+ });
1285
+ };
1286
+ datetimepicker
1287
+ .on('open.xdsoft', function() {
1288
+ var onShow = true;
1289
+ if( options.onShow&&options.onShow.call) {
1290
+ onShow = options.onShow.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1291
+ }
1292
+ if( onShow!==false ) {
1293
+ datetimepicker.show();
1294
+ setPos();
1295
+ $(window)
1296
+ .off('resize.xdsoft',setPos)
1297
+ .on('resize.xdsoft',setPos);
1298
+
1299
+ if( options.closeOnWithoutClick ) {
1300
+ $([document.body,window]).on('mousedown.xdsoft',function arguments_callee6() {
1301
+ datetimepicker.trigger('close.xdsoft');
1302
+ $([document.body,window]).off('mousedown.xdsoft',arguments_callee6);
1303
+ });
1304
+ }
1305
+ }
1306
+ })
1307
+ .on('close.xdsoft', function( event ) {
1308
+ var onClose = true;
1309
+ if( options.onClose&&options.onClose.call ) {
1310
+ onClose=options.onClose.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));
1311
+ }
1312
+ if( onClose!==false&&!options.opened&&!options.inline ) {
1313
+ datetimepicker.hide();
1314
+ }
1315
+ event.stopPropagation();
1316
+ })
1317
+ .data('input',input);
1318
+
1319
+ var timer = 0,
1320
+ timer1 = 0;
1321
+
1322
+ datetimepicker.data('xdsoft_datetime',_xdsoft_datetime);
1323
+ datetimepicker.setOptions(options);
1324
+
1325
+ function getCurrentValue(){
1326
+
1327
+ var ct = false;
1328
+
1329
+ if ( options.startDate ) {
1330
+ ct = _xdsoft_datetime.strToDateTime(options.startDate);
1331
+ } else {
1332
+ ct = options.value?options.value:(input&&input.val&&input.val())?input.val():'';
1333
+ ct = Date.parseDate(ct, options.format);
1334
+ }
1335
+
1336
+ if ( ct && _xdsoft_datetime.isValidDate(ct) ) {
1337
+ datetimepicker.data('changed',true);
1338
+ } else {
1339
+ ct = '';
1340
+ }
1341
+
1342
+ return ct?ct:0;
1343
+ }
1344
+ //debugger
1345
+ _xdsoft_datetime.setCurrentTime( getCurrentValue() );
1346
+
1347
+ input
1348
+ .data( 'xdsoft_datetimepicker',datetimepicker )
1349
+ .on('open.xdsoft focusin.xdsoft mousedown.xdsoft',function(event) {
1350
+ if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||(input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick) )
1351
+ return;
1352
+ clearTimeout(timer);
1353
+ timer = setTimeout(function() {
1354
+ if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible') )
1355
+ return;
1356
+
1357
+ triggerAfterOpen = true;
1358
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
1359
+
1360
+ datetimepicker.trigger('open.xdsoft');
1361
+ },100);
1362
+ })
1363
+ .on('keydown.xdsoft',function( event ) {
1364
+ var val = this.value,
1365
+ key = event.which;
1366
+ switch(true) {
1367
+ case !!~([ENTER].indexOf(key)):
1368
+ var elementSelector = $("input:visible,textarea:visible");
1369
+ datetimepicker.trigger('close.xdsoft');
1370
+ elementSelector.eq(elementSelector.index(this) + 1).focus();
1371
+ return false;
1372
+ case !!~[TAB].indexOf(key):
1373
+ datetimepicker.trigger('close.xdsoft');
1374
+ return true;
1375
+ }
1376
+ });
1377
+ },
1378
+ destroyDateTimePicker = function( input ) {
1379
+ var datetimepicker = input.data('xdsoft_datetimepicker');
1380
+ if( datetimepicker ) {
1381
+ datetimepicker.data('xdsoft_datetime',null);
1382
+ datetimepicker.remove();
1383
+ input
1384
+ .data( 'xdsoft_datetimepicker',null )
1385
+ .off( 'open.xdsoft focusin.xdsoft focusout.xdsoft mousedown.xdsoft blur.xdsoft keydown.xdsoft' );
1386
+ $(window).off('resize.xdsoft');
1387
+ $([window,document.body]).off('mousedown.xdsoft');
1388
+ input.unmousewheel&&input.unmousewheel();
1389
+ }
1390
+ };
1391
+ $(document)
1392
+ .off('keydown.xdsoftctrl keyup.xdsoftctrl')
1393
+ .on('keydown.xdsoftctrl',function(e) {
1394
+ if ( e.keyCode == CTRLKEY )
1395
+ ctrlDown = true;
1396
+ })
1397
+ .on('keyup.xdsoftctrl',function(e) {
1398
+ if ( e.keyCode == CTRLKEY )
1399
+ ctrlDown = false;
1400
+ });
1401
+ return this.each(function() {
1402
+ var datetimepicker;
1403
+ if( datetimepicker = $(this).data('xdsoft_datetimepicker') ) {
1404
+ if( $.type(opt) === 'string' ) {
1405
+ switch(opt) {
1406
+ case 'show':
1407
+ $(this).select().focus();
1408
+ datetimepicker.trigger( 'open.xdsoft' );
1409
+ break;
1410
+ case 'hide':
1411
+ datetimepicker.trigger('close.xdsoft');
1412
+ break;
1413
+ case 'destroy':
1414
+ destroyDateTimePicker($(this));
1415
+ break;
1416
+ case 'reset':
1417
+ this.value = this.defaultValue;
1418
+ if(!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format)))
1419
+ datetimepicker.data('changed',false);
1420
+ datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
1421
+ break;
1422
+ }
1423
+ }else{
1424
+ datetimepicker
1425
+ .setOptions(opt);
1426
+ }
1427
+ return 0;
1428
+ }else
1429
+ if( ($.type(opt) !== 'string') ){
1430
+ if( !options.lazyInit||options.open||options.inline ){
1431
+ createDateTimePicker($(this));
1432
+ }else
1433
+ lazyInit($(this));
1434
+ }
1435
+ });
1436
+ };
1437
+ $.fn.datetimepicker.defaults = default_options;
1438
+ })( jQuery );
1439
+
1440
+ /*
1441
+ * Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net)
1442
+ *
1443
+ * Licensed under the MIT License (LICENSE.txt).
1444
+ *
1445
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
1446
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
1447
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
1448
+ *
1449
+ * Version: 3.1.3
1450
+ *
1451
+ * Requires: 1.2.2+
1452
+ */
1453
+ (function(factory) {if(typeof define==='function'&&define.amd) {define(['jquery'],factory)}else if(typeof exports==='object') {module.exports=factory}else{factory(jQuery)}}(function($) {var toFix=['wheel','mousewheel','DOMMouseScroll','MozMousePixelScroll'];var toBind='onwheel'in document||document.documentMode>=9?['wheel']:['mousewheel','DomMouseScroll','MozMousePixelScroll'];var lowestDelta,lowestDeltaXY;if($.event.fixHooks) {for(var i=toFix.length;i;) {$.event.fixHooks[toFix[--i]]=$.event.mouseHooks}}$.event.special.mousewheel={setup:function() {if(this.addEventListener) {for(var i=toBind.length;i;) {this.addEventListener(toBind[--i],handler,false)}}else{this.onmousewheel=handler}},teardown:function() {if(this.removeEventListener) {for(var i=toBind.length;i;) {this.removeEventListener(toBind[--i],handler,false)}}else{this.onmousewheel=null}}};$.fn.extend({mousewheel:function(fn) {return fn?this.bind("mousewheel",fn):this.trigger("mousewheel")},unmousewheel:function(fn) {return this.unbind("mousewheel",fn)}});function handler(event) {var orgEvent=event||window.event,args=[].slice.call(arguments,1),delta=0,deltaX=0,deltaY=0,absDelta=0,absDeltaXY=0,fn;event=$.event.fix(orgEvent);event.type="mousewheel";if(orgEvent.wheelDelta) {delta=orgEvent.wheelDelta}if(orgEvent.detail) {delta=orgEvent.detail*-1}if(orgEvent.deltaY) {deltaY=orgEvent.deltaY*-1;delta=deltaY}if(orgEvent.deltaX) {deltaX=orgEvent.deltaX;delta=deltaX*-1}if(orgEvent.wheelDeltaY!==undefined) {deltaY=orgEvent.wheelDeltaY}if(orgEvent.wheelDeltaX!==undefined) {deltaX=orgEvent.wheelDeltaX*-1}absDelta=Math.abs(delta);if(!lowestDelta||absDelta<lowestDelta) {lowestDelta=absDelta}absDeltaXY=Math.max(Math.abs(deltaY),Math.abs(deltaX));if(!lowestDeltaXY||absDeltaXY<lowestDeltaXY) {lowestDeltaXY=absDeltaXY}fn=delta>0?'floor':'ceil';delta=Math[fn](delta/lowestDelta);deltaX=Math[fn](deltaX/lowestDeltaXY);deltaY=Math[fn](deltaY/lowestDeltaXY);args.unshift(event,delta,deltaX,deltaY);return($.event.dispatch||$.event.handle).apply(this,args)}}));
1454
+
1455
+
1456
+ // Parse and Format Library
1457
+ //http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
1458
+ /*
1459
+ * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
1460
+ *
1461
+ * This program is free software; you can redistribute it and/or modify it
1462
+ * under the terms of the GNU Lesser General Public License as published by the
1463
+ * Free Software Foundation, version 2.1.
1464
+ *
1465
+ * This program is distributed in the hope that it will be useful, but WITHOUT
1466
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1467
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
1468
+ * details.
1469
+ */
1470
+ Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+" = function() {return ";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;code+="'"+String.escape(ch)+"' + ";}else{code+=Date.getFormatCode(ch);}}}eval(code.substring(0,code.length-3)+";}");};Date.getFormatCode=function(a){switch(a){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(a)+"' + ";}};Date.parseDate=function(a,c){if(c=="unixtime"){return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);}if(Date.parseFunctions[c]==null){Date.createParser(c);}var b=Date.parseFunctions[c];return Date[b](a);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes["+regexNum+"]);\nif (results && results.length > 0) {";var regex="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;regex+=String.escape(ch);}else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}}code+="if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b<this.getMonth();++b){a+=Date.daysInMonth[b];}return a+this.getDate();};Date.prototype.getWeekOfYear=function(){var b=this.getDayOfYear()+(4-this.getDay());var a=new Date(this.getFullYear(),0,1);var c=(7-a.getDay()+4);return String.leftPad(Math.ceil((b-c)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return((a&3)==0&&(a%100||(a%400==0&&a)));};Date.prototype.getFirstDayOfMonth=function(){var a=(this.getDay()-(this.getDate()-1))%7;return(a<0)?(a+7):a;};Date.prototype.getLastDayOfMonth=function(){var a=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(a<0)?(a+7):a;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};String.escape=function(a){return a.replace(/('|\\)/g,"\\$1");};String.leftPad=function(d,b,c){var a=new String(d);if(c==null){c=" ";}while(a.length<b){a=c+a;}return a;};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.patterns={ISO8601LongPattern:"Y-m-d H:i:s",ISO8601ShortPattern:"Y-m-d",ShortDatePattern:"n/j/Y",LongDatePattern:"l, F d, Y",FullDateTimePattern:"l, F d, Y g:i:s A",MonthDayPattern:"F d",ShortTimePattern:"g:i A",LongTimePattern:"g:i:s A",SortableDateTimePattern:"Y-m-d\\TH:i:s",UniversalSortableDateTimePattern:"Y-m-d H:i:sO",YearMonthPattern:"F, Y"};