jinda_engine 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (492) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +173 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/config/jinda_engine/manifest.js +4 -0
  6. data/app/assets/images/jinda_engine/4dcity-old.ico +0 -0
  7. data/app/assets/images/jinda_engine/4dcity.ico +0 -0
  8. data/app/assets/images/jinda_engine/account.png +0 -0
  9. data/app/assets/images/jinda_engine/add.png +0 -0
  10. data/app/assets/images/jinda_engine/ajax-loader-circle.gif +0 -0
  11. data/app/assets/images/jinda_engine/ajax-loader.gif +0 -0
  12. data/app/assets/images/jinda_engine/anchor.png +0 -0
  13. data/app/assets/images/jinda_engine/application_double.png +0 -0
  14. data/app/assets/images/jinda_engine/application_form_edit.png +0 -0
  15. data/app/assets/images/jinda_engine/arrow_left.png +0 -0
  16. data/app/assets/images/jinda_engine/arrow_right.png +0 -0
  17. data/app/assets/images/jinda_engine/arrow_turn_left.png +0 -0
  18. data/app/assets/images/jinda_engine/arrow_turn_right.png +0 -0
  19. data/app/assets/images/jinda_engine/calendar.png +0 -0
  20. data/app/assets/images/jinda_engine/cancel.png +0 -0
  21. data/app/assets/images/jinda_engine/chart_bar.png +0 -0
  22. data/app/assets/images/jinda_engine/clock.png +0 -0
  23. data/app/assets/images/jinda_engine/cog.png +0 -0
  24. data/app/assets/images/jinda_engine/control_fastforward.png +0 -0
  25. data/app/assets/images/jinda_engine/control_play.png +0 -0
  26. data/app/assets/images/jinda_engine/cross.png +0 -0
  27. data/app/assets/images/jinda_engine/delete.png +0 -0
  28. data/app/assets/images/jinda_engine/external-link.png +0 -0
  29. data/app/assets/images/jinda_engine/facebook-continue-button.png +0 -0
  30. data/app/assets/images/jinda_engine/facebooksmall.png +0 -0
  31. data/app/assets/images/jinda_engine/favicon.ico +0 -0
  32. data/app/assets/images/jinda_engine/freemind(mm).png +0 -0
  33. data/app/assets/images/jinda_engine/google-continue-button.png +0 -0
  34. data/app/assets/images/jinda_engine/help.png +0 -0
  35. data/app/assets/images/jinda_engine/highway-menu.png +0 -0
  36. data/app/assets/images/jinda_engine/highway.png +0 -0
  37. data/app/assets/images/jinda_engine/house.png +0 -0
  38. data/app/assets/images/jinda_engine/icons-18-black.png +0 -0
  39. data/app/assets/images/jinda_engine/icons-18-white.png +0 -0
  40. data/app/assets/images/jinda_engine/icons-36-black.png +0 -0
  41. data/app/assets/images/jinda_engine/icons-36-white.png +0 -0
  42. data/app/assets/images/jinda_engine/logo.png +0 -0
  43. data/app/assets/images/jinda_engine/logo_jinda.png +0 -0
  44. data/app/assets/images/jinda_engine/logout.png +0 -0
  45. data/app/assets/images/jinda_engine/new.gif +0 -0
  46. data/app/assets/images/jinda_engine/new.png +0 -0
  47. data/app/assets/images/jinda_engine/page.png +0 -0
  48. data/app/assets/images/jinda_engine/page_attach.png +0 -0
  49. data/app/assets/images/jinda_engine/page_green.png +0 -0
  50. data/app/assets/images/jinda_engine/page_output.png +0 -0
  51. data/app/assets/images/jinda_engine/page_pdf.png +0 -0
  52. data/app/assets/images/jinda_engine/pencil.png +0 -0
  53. data/app/assets/images/jinda_engine/printer.png +0 -0
  54. data/app/assets/images/jinda_engine/refresh.png +0 -0
  55. data/app/assets/images/jinda_engine/report.png +0 -0
  56. data/app/assets/images/jinda_engine/rssmall.png +0 -0
  57. data/app/assets/images/jinda_engine/tick.png +0 -0
  58. data/app/assets/images/jinda_engine/twittersmall.png +0 -0
  59. data/app/assets/images/jinda_engine/user.png +0 -0
  60. data/app/assets/images/jinda_engine/user_admin_gear.png +0 -0
  61. data/app/assets/images/jinda_engine/view_code.png +0 -0
  62. data/app/assets/javascripts/jinda_engine/application.js +24 -0
  63. data/app/assets/javascripts/jinda_engine/application.js-jqm +27 -0
  64. data/app/assets/javascripts/jinda_engine/cable.js +13 -0
  65. data/app/assets/javascripts/jinda_engine/disable_enter_key.js +10 -0
  66. data/app/assets/javascripts/jinda_engine/iscroll-wrapper.js +32 -0
  67. data/app/assets/javascripts/jinda_engine/iscroll.js +1084 -0
  68. data/app/assets/javascripts/jinda_engine/jinda.js +14 -0
  69. data/app/assets/javascripts/jinda_engine/jquery.mobile-1.2.1.js +9272 -0
  70. data/app/assets/javascripts/jinda_engine/jquery.mobile.datebox.js +1778 -0
  71. data/app/assets/javascripts/jinda_engine/jquery.mobile.splitview.js +695 -0
  72. data/app/assets/stylesheets/jinda_engine/app.scss +90 -0
  73. data/app/assets/stylesheets/jinda_engine/application.css.scss +34 -0
  74. data/app/assets/stylesheets/jinda_engine/articles.scss +94 -0
  75. data/app/assets/stylesheets/jinda_engine/fonts/sarabun.eot +0 -0
  76. data/app/assets/stylesheets/jinda_engine/fonts/sarabun.ttf +0 -0
  77. data/app/assets/stylesheets/jinda_engine/fonts/sarabun.woff +0 -0
  78. data/app/assets/stylesheets/jinda_engine/fonts/sarabun_bold.ttf +0 -0
  79. data/app/assets/stylesheets/jinda_engine/fonts/sarabun_bolditalic.ttf +0 -0
  80. data/app/assets/stylesheets/jinda_engine/fonts/sarabun_italic.ttf +0 -0
  81. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew-webfont.eot +0 -0
  82. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew-webfont.ttf +0 -0
  83. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew-webfont.woff +0 -0
  84. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew.css +47 -0
  85. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_bold-webfont.eot +0 -0
  86. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_bold-webfont.ttf +0 -0
  87. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_bold-webfont.woff +0 -0
  88. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_bolditalic-webfont.eot +0 -0
  89. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_bolditalic-webfont.ttf +0 -0
  90. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_bolditalic-webfont.woff +0 -0
  91. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_italic-webfont.eot +0 -0
  92. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_italic-webfont.ttf +0 -0
  93. data/app/assets/stylesheets/jinda_engine/fonts/thsarabunnew_italic-webfont.woff +0 -0
  94. data/app/assets/stylesheets/jinda_engine/images/ajax-loader.gif +0 -0
  95. data/app/assets/stylesheets/jinda_engine/images/button_black.png +0 -0
  96. data/app/assets/stylesheets/jinda_engine/images/button_blue.png +0 -0
  97. data/app/assets/stylesheets/jinda_engine/images/button_red.png +0 -0
  98. data/app/assets/stylesheets/jinda_engine/images/icons-18-black.png +0 -0
  99. data/app/assets/stylesheets/jinda_engine/images/icons-18-white.png +0 -0
  100. data/app/assets/stylesheets/jinda_engine/images/icons-36-black.png +0 -0
  101. data/app/assets/stylesheets/jinda_engine/images/icons-36-white.png +0 -0
  102. data/app/assets/stylesheets/jinda_engine/images/indicator.gif +0 -0
  103. data/app/assets/stylesheets/jinda_engine/jinda.css +52 -0
  104. data/app/assets/stylesheets/jinda_engine/jquery.mobile-1.2.1.css +2339 -0
  105. data/app/assets/stylesheets/jinda_engine/jquery.mobile.datebox.css +65 -0
  106. data/app/assets/stylesheets/jinda_engine/jquery.mobile.grids.collapsible.css +122 -0
  107. data/app/assets/stylesheets/jinda_engine/jquery.mobile.splitview.css +128 -0
  108. data/app/assets/stylesheets/jinda_engine/kul-4.2.css +1516 -0
  109. data/app/assets/stylesheets/jinda_engine/kul-4.2.min.css +11 -0
  110. data/app/assets/stylesheets/jinda_engine/modules.scss +84 -0
  111. data/app/assets/stylesheets/jinda_engine/sarabun.css +37 -0
  112. data/app/assets/stylesheets/jinda_engine/social.scss +133 -0
  113. data/app/controllers/jindra_engine/admins_controller.rb +9 -0
  114. data/app/controllers/jindra_engine/api/v1/notes_controller.rb +81 -0
  115. data/app/controllers/jindra_engine/application_controller.rb +44 -0
  116. data/app/controllers/jindra_engine/articles_controller.rb +112 -0
  117. data/app/controllers/jindra_engine/comments_controller.rb +21 -0
  118. data/app/controllers/jindra_engine/concerns/jinda_general_concern.rb +179 -0
  119. data/app/controllers/jindra_engine/concerns/jinda_run_concern.rb +365 -0
  120. data/app/controllers/jindra_engine/devs_controller.rb +4 -0
  121. data/app/controllers/jindra_engine/docs_controller.rb +59 -0
  122. data/app/controllers/jindra_engine/identities_controller.rb +7 -0
  123. data/app/controllers/jindra_engine/jinda_controller.rb +71 -0
  124. data/app/controllers/jindra_engine/notes_controller.rb +87 -0
  125. data/app/controllers/jindra_engine/password_resets.rb +30 -0
  126. data/app/controllers/jindra_engine/password_resets_controller.rb +35 -0
  127. data/app/controllers/jindra_engine/sessions_controller.rb +45 -0
  128. data/app/controllers/jindra_engine/sitemap_controller.rb +15 -0
  129. data/app/controllers/jindra_engine/users_controller.rb +35 -0
  130. data/app/helpers/jinda_engine/jinda_helper.rb +1005 -0
  131. data/app/jinda/index.mm +366 -0
  132. data/app/jinda/template/index.mm +366 -0
  133. data/app/jinda/template/linkview.haml +21 -0
  134. data/app/jinda/template/view.html.erb +26 -0
  135. data/app/mailers/jinda_engine/application_mailer.rb +4 -0
  136. data/app/mailers/jinda_engine/jinda_mailer.rb +7 -0
  137. data/app/mailers/jinda_engine/note_mailer.rb +10 -0
  138. data/app/mailers/jinda_engine/user_mailer.rb +15 -0
  139. data/app/views/jinda_engine/adminbsbs/content.haml +241 -0
  140. data/app/views/jinda_engine/admins/edit_role/edit_role.html.erb +7 -0
  141. data/app/views/jinda_engine/admins/edit_role/select_user.html.erb +4 -0
  142. data/app/views/jinda_engine/api/v1/note.haml +0 -0
  143. data/app/views/jinda_engine/articles/edit.haml +12 -0
  144. data/app/views/jinda_engine/articles/edit_article/edit_article.html.erb +13 -0
  145. data/app/views/jinda_engine/articles/edit_article/select_article.html.erb +12 -0
  146. data/app/views/jinda_engine/articles/index.haml +23 -0
  147. data/app/views/jinda_engine/articles/my.haml +20 -0
  148. data/app/views/jinda_engine/articles/new_article/form_article.html.erb +16 -0
  149. data/app/views/jinda_engine/articles/show.html.haml +25 -0
  150. data/app/views/jinda_engine/articles/xedit_article/edit_article.html.erb +13 -0
  151. data/app/views/jinda_engine/ctrs/vfolder1/viewfile1.html.erb +23 -0
  152. data/app/views/jinda_engine/ctrs/vfolder1/viewfile2.html.erb +23 -0
  153. data/app/views/jinda_engine/ctrs/vfolder2/viewfile2.html.erb +23 -0
  154. data/app/views/jinda_engine/custom/_adsense.haml +6 -0
  155. data/app/views/jinda_engine/docs/doc_edit/doc_edit.html.erb +21 -0
  156. data/app/views/jinda_engine/docs/doc_edit/doc_select.html.erb +14 -0
  157. data/app/views/jinda_engine/docs/doc_new/doc_form.html.erb +26 -0
  158. data/app/views/jinda_engine/docs/doc_new/doc_form.md +36 -0
  159. data/app/views/jinda_engine/docs/doc_xedit/doc_edit.html.erb +21 -0
  160. data/app/views/jinda_engine/docs/edit/select_note.html.erb +14 -0
  161. data/app/views/jinda_engine/docs/index.haml +21 -0
  162. data/app/views/jinda_engine/docs/my.haml +27 -0
  163. data/app/views/jinda_engine/identities/new.html.erb +32 -0
  164. data/app/views/jinda_engine/jinda/_activity.md +10 -0
  165. data/app/views/jinda_engine/jinda/_menu.haml +27 -0
  166. data/app/views/jinda_engine/jinda/_menu_mm.haml +44 -0
  167. data/app/views/jinda_engine/jinda/_model.md +5 -0
  168. data/app/views/jinda_engine/jinda/_modul.md +9 -0
  169. data/app/views/jinda_engine/jinda/_pending_home.haml +5 -0
  170. data/app/views/jinda_engine/jinda/_pending_page.haml +24 -0
  171. data/app/views/jinda_engine/jinda/_service.md +24 -0
  172. data/app/views/jinda_engine/jinda/_static.haml +13 -0
  173. data/app/views/jinda_engine/jinda/doc-thai.md +37 -0
  174. data/app/views/jinda_engine/jinda/doc.md +36 -0
  175. data/app/views/jinda_engine/jinda/error_logs.haml +22 -0
  176. data/app/views/jinda_engine/jinda/feed.rss.builder +27 -0
  177. data/app/views/jinda_engine/jinda/help.haml +20 -0
  178. data/app/views/jinda_engine/jinda/index.html.haml +53 -0
  179. data/app/views/jinda_engine/jinda/logs.haml +22 -0
  180. data/app/views/jinda_engine/jinda/notice_logs.haml +18 -0
  181. data/app/views/jinda_engine/jinda/pending.haml +1 -0
  182. data/app/views/jinda_engine/jinda/run_form.haml +42 -0
  183. data/app/views/jinda_engine/jinda/run_output.haml +38 -0
  184. data/app/views/jinda_engine/jinda/search.haml +20 -0
  185. data/app/views/jinda_engine/jinda/status.haml +61 -0
  186. data/app/views/jinda_engine/jinda_mailer/gmail.html.erb +9 -0
  187. data/app/views/jinda_engine/layouts/_head.html.erb +10 -0
  188. data/app/views/jinda_engine/layouts/_meta_tag.html.erb +19 -0
  189. data/app/views/jinda_engine/layouts/application.haml +4 -0
  190. data/app/views/jinda_engine/layouts/bsb/_footer.haml +7 -0
  191. data/app/views/jinda_engine/layouts/bsb/_header.haml +147 -0
  192. data/app/views/jinda_engine/layouts/bsb/_menu.haml +47 -0
  193. data/app/views/jinda_engine/layouts/bsb/_menu_mm.haml +34 -0
  194. data/app/views/jinda_engine/layouts/bsb/_rightbar.haml +123 -0
  195. data/app/views/jinda_engine/layouts/bsb/_sidebar.haml +155 -0
  196. data/app/views/jinda_engine/layouts/bsb/application.haml-bsb +47 -0
  197. data/app/views/jinda_engine/layouts/gmail.html.erb +9 -0
  198. data/app/views/jinda_engine/layouts/jqm/_full.haml +33 -0
  199. data/app/views/jinda_engine/layouts/jqm/_page.haml +16 -0
  200. data/app/views/jinda_engine/layouts/jqm/application.haml-jqm +4 -0
  201. data/app/views/jinda_engine/layouts/mailer.html.erb +13 -0
  202. data/app/views/jinda_engine/layouts/mailer.html.haml +3 -0
  203. data/app/views/jinda_engine/layouts/mailer.text.erb +1 -0
  204. data/app/views/jinda_engine/layouts/mailer.text.haml +1 -0
  205. data/app/views/jinda_engine/layouts/mobile.html.erb +13 -0
  206. data/app/views/jinda_engine/layouts/mobilejq.html.erb +31 -0
  207. data/app/views/jinda_engine/layouts/print.html.erb +22 -0
  208. data/app/views/jinda_engine/layouts/utf8.html.erb +22 -0
  209. data/app/views/jinda_engine/note_mailer/gmail.html.haml +7 -0
  210. data/app/views/jinda_engine/note_mailer/gmail.text.haml +8 -0
  211. data/app/views/jinda_engine/notes/delete/select_note.html.erb +14 -0
  212. data/app/views/jinda_engine/notes/edit/edit_note.html.erb +10 -0
  213. data/app/views/jinda_engine/notes/edit/select_note.html.erb +14 -0
  214. data/app/views/jinda_engine/notes/index.haml +71 -0
  215. data/app/views/jinda_engine/notes/mail/display_mail.html.erb +20 -0
  216. data/app/views/jinda_engine/notes/mail/select_note.html.erb +19 -0
  217. data/app/views/jinda_engine/notes/mail/show.html.haml +13 -0
  218. data/app/views/jinda_engine/notes/my.haml +21 -0
  219. data/app/views/jinda_engine/notes/new/new_note.html.erb +13 -0
  220. data/app/views/jinda_engine/notes/show.haml +10 -0
  221. data/app/views/jinda_engine/notes/xedit/edit_note.html.erb +10 -0
  222. data/app/views/jinda_engine/password_resets/edit.html.erb +21 -0
  223. data/app/views/jinda_engine/password_resets/new.html.erb +7 -0
  224. data/app/views/jinda_engine/sessions/new.html.erb +20 -0
  225. data/app/views/jinda_engine/sitemap/index.xml.haml +10 -0
  226. data/app/views/jinda_engine/user_mailer/password_reset.html.haml +3 -0
  227. data/app/views/jinda_engine/user_mailer/password_reset.text.erb +3 -0
  228. data/app/views/jinda_engine/user_mailer/password_reset.text.haml +3 -0
  229. data/app/views/jinda_engine/users/index.haml +13 -0
  230. data/app/views/jinda_engine/users/pwd/enter.html.erb +6 -0
  231. data/app/views/jinda_engine/users/user/enter_user.html.erb +8 -0
  232. data/config/application.rb +58 -0
  233. data/config/initializers/jinda_engine/assets.rb +14 -0
  234. data/config/initializers/jinda_engine/jinda.rb +13 -0
  235. data/config/initializers/jinda_engine/mongoid.rb +9 -0
  236. data/config/initializers/jinda_engine/mongoid.rb-org +9 -0
  237. data/config/initializers/jinda_engine/omniauth.rb-org +17 -0
  238. data/config/jinda_engine/cloudinary.yml +9 -0
  239. data/config/routes.rb +18 -0
  240. data/db/jinda_engine/seeds.rb +6 -0
  241. data/lib/generators/jinda_engine/USAGE +2 -0
  242. data/lib/generators/jinda_engine/config_generator.rb +95 -0
  243. data/lib/generators/jinda_engine/install_generator.rb +237 -0
  244. data/lib/generators/jinda_engine/minitest_generator.rb +30 -0
  245. data/lib/generators/jinda_engine/rspec_generator.rb +30 -0
  246. data/lib/generators/jinda_engine/templates/README.md +173 -0
  247. data/lib/generators/jinda_engine/templates/app/assets/config/manifest.js +4 -0
  248. data/lib/generators/jinda_engine/templates/app/assets/images/4dcity-old.ico +0 -0
  249. data/lib/generators/jinda_engine/templates/app/assets/images/4dcity.ico +0 -0
  250. data/lib/generators/jinda_engine/templates/app/assets/images/account.png +0 -0
  251. data/lib/generators/jinda_engine/templates/app/assets/images/add.png +0 -0
  252. data/lib/generators/jinda_engine/templates/app/assets/images/ajax-loader-circle.gif +0 -0
  253. data/lib/generators/jinda_engine/templates/app/assets/images/ajax-loader.gif +0 -0
  254. data/lib/generators/jinda_engine/templates/app/assets/images/anchor.png +0 -0
  255. data/lib/generators/jinda_engine/templates/app/assets/images/application_double.png +0 -0
  256. data/lib/generators/jinda_engine/templates/app/assets/images/application_form_edit.png +0 -0
  257. data/lib/generators/jinda_engine/templates/app/assets/images/arrow_left.png +0 -0
  258. data/lib/generators/jinda_engine/templates/app/assets/images/arrow_right.png +0 -0
  259. data/lib/generators/jinda_engine/templates/app/assets/images/arrow_turn_left.png +0 -0
  260. data/lib/generators/jinda_engine/templates/app/assets/images/arrow_turn_right.png +0 -0
  261. data/lib/generators/jinda_engine/templates/app/assets/images/calendar.png +0 -0
  262. data/lib/generators/jinda_engine/templates/app/assets/images/cancel.png +0 -0
  263. data/lib/generators/jinda_engine/templates/app/assets/images/chart_bar.png +0 -0
  264. data/lib/generators/jinda_engine/templates/app/assets/images/clock.png +0 -0
  265. data/lib/generators/jinda_engine/templates/app/assets/images/cog.png +0 -0
  266. data/lib/generators/jinda_engine/templates/app/assets/images/control_fastforward.png +0 -0
  267. data/lib/generators/jinda_engine/templates/app/assets/images/control_play.png +0 -0
  268. data/lib/generators/jinda_engine/templates/app/assets/images/cross.png +0 -0
  269. data/lib/generators/jinda_engine/templates/app/assets/images/delete.png +0 -0
  270. data/lib/generators/jinda_engine/templates/app/assets/images/external-link.png +0 -0
  271. data/lib/generators/jinda_engine/templates/app/assets/images/facebook-continue-button.png +0 -0
  272. data/lib/generators/jinda_engine/templates/app/assets/images/facebooksmall.png +0 -0
  273. data/lib/generators/jinda_engine/templates/app/assets/images/favicon.ico +0 -0
  274. data/lib/generators/jinda_engine/templates/app/assets/images/freemind(mm).png +0 -0
  275. data/lib/generators/jinda_engine/templates/app/assets/images/google-continue-button.png +0 -0
  276. data/lib/generators/jinda_engine/templates/app/assets/images/help.png +0 -0
  277. data/lib/generators/jinda_engine/templates/app/assets/images/highway-menu.png +0 -0
  278. data/lib/generators/jinda_engine/templates/app/assets/images/highway.png +0 -0
  279. data/lib/generators/jinda_engine/templates/app/assets/images/house.png +0 -0
  280. data/lib/generators/jinda_engine/templates/app/assets/images/icons-18-black.png +0 -0
  281. data/lib/generators/jinda_engine/templates/app/assets/images/icons-18-white.png +0 -0
  282. data/lib/generators/jinda_engine/templates/app/assets/images/icons-36-black.png +0 -0
  283. data/lib/generators/jinda_engine/templates/app/assets/images/icons-36-white.png +0 -0
  284. data/lib/generators/jinda_engine/templates/app/assets/images/logo.png +0 -0
  285. data/lib/generators/jinda_engine/templates/app/assets/images/logo_jinda.png +0 -0
  286. data/lib/generators/jinda_engine/templates/app/assets/images/logout.png +0 -0
  287. data/lib/generators/jinda_engine/templates/app/assets/images/new.gif +0 -0
  288. data/lib/generators/jinda_engine/templates/app/assets/images/new.png +0 -0
  289. data/lib/generators/jinda_engine/templates/app/assets/images/page.png +0 -0
  290. data/lib/generators/jinda_engine/templates/app/assets/images/page_attach.png +0 -0
  291. data/lib/generators/jinda_engine/templates/app/assets/images/page_green.png +0 -0
  292. data/lib/generators/jinda_engine/templates/app/assets/images/page_output.png +0 -0
  293. data/lib/generators/jinda_engine/templates/app/assets/images/page_pdf.png +0 -0
  294. data/lib/generators/jinda_engine/templates/app/assets/images/pencil.png +0 -0
  295. data/lib/generators/jinda_engine/templates/app/assets/images/printer.png +0 -0
  296. data/lib/generators/jinda_engine/templates/app/assets/images/refresh.png +0 -0
  297. data/lib/generators/jinda_engine/templates/app/assets/images/report.png +0 -0
  298. data/lib/generators/jinda_engine/templates/app/assets/images/rssmall.png +0 -0
  299. data/lib/generators/jinda_engine/templates/app/assets/images/tick.png +0 -0
  300. data/lib/generators/jinda_engine/templates/app/assets/images/twittersmall.png +0 -0
  301. data/lib/generators/jinda_engine/templates/app/assets/images/user.png +0 -0
  302. data/lib/generators/jinda_engine/templates/app/assets/images/user_admin_gear.png +0 -0
  303. data/lib/generators/jinda_engine/templates/app/assets/images/view_code.png +0 -0
  304. data/lib/generators/jinda_engine/templates/app/assets/javascripts/application.js +24 -0
  305. data/lib/generators/jinda_engine/templates/app/assets/javascripts/application.js-jqm +27 -0
  306. data/lib/generators/jinda_engine/templates/app/assets/javascripts/cable.js +13 -0
  307. data/lib/generators/jinda_engine/templates/app/assets/javascripts/disable_enter_key.js +10 -0
  308. data/lib/generators/jinda_engine/templates/app/assets/javascripts/iscroll-wrapper.js +32 -0
  309. data/lib/generators/jinda_engine/templates/app/assets/javascripts/iscroll.js +1084 -0
  310. data/lib/generators/jinda_engine/templates/app/assets/javascripts/jinda.js +14 -0
  311. data/lib/generators/jinda_engine/templates/app/assets/javascripts/jquery.mobile-1.2.1.js +9272 -0
  312. data/lib/generators/jinda_engine/templates/app/assets/javascripts/jquery.mobile.datebox.js +1778 -0
  313. data/lib/generators/jinda_engine/templates/app/assets/javascripts/jquery.mobile.splitview.js +695 -0
  314. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/app.scss +90 -0
  315. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/application.css.scss +34 -0
  316. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/articles.scss +94 -0
  317. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/sarabun.eot +0 -0
  318. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/sarabun.ttf +0 -0
  319. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/sarabun.woff +0 -0
  320. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/sarabun_bold.ttf +0 -0
  321. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/sarabun_bolditalic.ttf +0 -0
  322. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/sarabun_italic.ttf +0 -0
  323. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.eot +0 -0
  324. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.ttf +0 -0
  325. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.woff +0 -0
  326. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew.css +47 -0
  327. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.eot +0 -0
  328. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.ttf +0 -0
  329. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.woff +0 -0
  330. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.eot +0 -0
  331. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.ttf +0 -0
  332. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.woff +0 -0
  333. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.eot +0 -0
  334. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.ttf +0 -0
  335. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.woff +0 -0
  336. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/ajax-loader.gif +0 -0
  337. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/button_black.png +0 -0
  338. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/button_blue.png +0 -0
  339. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/button_red.png +0 -0
  340. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/icons-18-black.png +0 -0
  341. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/icons-18-white.png +0 -0
  342. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/icons-36-black.png +0 -0
  343. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/icons-36-white.png +0 -0
  344. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/images/indicator.gif +0 -0
  345. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/jinda.css +52 -0
  346. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/jquery.mobile-1.2.1.css +2339 -0
  347. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/jquery.mobile.datebox.css +65 -0
  348. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/jquery.mobile.grids.collapsible.css +122 -0
  349. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/jquery.mobile.splitview.css +128 -0
  350. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/kul-4.2.css +1516 -0
  351. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/kul-4.2.min.css +11 -0
  352. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/modules.scss +84 -0
  353. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/sarabun.css +37 -0
  354. data/lib/generators/jinda_engine/templates/app/assets/stylesheets/social.scss +133 -0
  355. data/lib/generators/jinda_engine/templates/app/channels/application_cable/channel.rb +4 -0
  356. data/lib/generators/jinda_engine/templates/app/channels/application_cable/connection.rb +4 -0
  357. data/lib/generators/jinda_engine/templates/app/controllers/api/v1/notes_controller.rb +81 -0
  358. data/lib/generators/jinda_engine/templates/app/controllers/concerns/jinda_general_concern.rb-org +179 -0
  359. data/lib/generators/jinda_engine/templates/app/controllers/concerns/jinda_run_concern.rb-org +365 -0
  360. data/lib/generators/jinda_engine/templates/app/helpers/admins_helper.rb +2 -0
  361. data/lib/generators/jinda_engine/templates/app/helpers/application_helper.rb +33 -0
  362. data/lib/generators/jinda_engine/templates/app/helpers/articles_helper.rb +2 -0
  363. data/lib/generators/jinda_engine/templates/app/helpers/basic_helper.rb +2 -0
  364. data/lib/generators/jinda_engine/templates/app/helpers/comments_helper.rb +2 -0
  365. data/lib/generators/jinda_engine/templates/app/helpers/ctrs_helper.rb +2 -0
  366. data/lib/generators/jinda_engine/templates/app/helpers/devs_helper.rb +2 -0
  367. data/lib/generators/jinda_engine/templates/app/helpers/pictures_helper.rb +2 -0
  368. data/lib/generators/jinda_engine/templates/app/helpers/sitemap_helper.rb +2 -0
  369. data/lib/generators/jinda_engine/templates/app/helpers/users_helper.rb +2 -0
  370. data/lib/generators/jinda_engine/templates/app/jinda/index.mm +366 -0
  371. data/lib/generators/jinda_engine/templates/app/jinda/template/index.mm +366 -0
  372. data/lib/generators/jinda_engine/templates/app/jinda/template/linkview.haml +21 -0
  373. data/lib/generators/jinda_engine/templates/app/jinda/template/view.html.erb +26 -0
  374. data/lib/generators/jinda_engine/templates/app/mailers/application_mailer.rb +4 -0
  375. data/lib/generators/jinda_engine/templates/app/mailers/jinda_mailer.rb +7 -0
  376. data/lib/generators/jinda_engine/templates/app/mailers/note_mailer.rb +10 -0
  377. data/lib/generators/jinda_engine/templates/app/mailers/user_mailer.rb +15 -0
  378. data/lib/generators/jinda_engine/templates/app/models/address.rb +14 -0
  379. data/lib/generators/jinda_engine/templates/app/models/article.rb +14 -0
  380. data/lib/generators/jinda_engine/templates/app/models/comment.rb +11 -0
  381. data/lib/generators/jinda_engine/templates/app/models/identity.rb +18 -0
  382. data/lib/generators/jinda_engine/templates/app/models/jinda/doc.rb +36 -0
  383. data/lib/generators/jinda_engine/templates/app/models/jinda/module.rb +11 -0
  384. data/lib/generators/jinda_engine/templates/app/models/jinda/notice.rb +14 -0
  385. data/lib/generators/jinda_engine/templates/app/models/jinda/role.rb +8 -0
  386. data/lib/generators/jinda_engine/templates/app/models/jinda/runseq.rb +24 -0
  387. data/lib/generators/jinda_engine/templates/app/models/jinda/service.rb +17 -0
  388. data/lib/generators/jinda_engine/templates/app/models/jinda/xmain.rb +38 -0
  389. data/lib/generators/jinda_engine/templates/app/models/note.rb +22 -0
  390. data/lib/generators/jinda_engine/templates/app/models/param.rb +41 -0
  391. data/lib/generators/jinda_engine/templates/app/models/person.rb +14 -0
  392. data/lib/generators/jinda_engine/templates/app/models/user.rb +66 -0
  393. data/lib/generators/jinda_engine/templates/app/views/adminbsbs/content.haml +241 -0
  394. data/lib/generators/jinda_engine/templates/app/views/admins/edit_role/edit_role.html.erb +7 -0
  395. data/lib/generators/jinda_engine/templates/app/views/admins/edit_role/select_user.html.erb +4 -0
  396. data/lib/generators/jinda_engine/templates/app/views/api/v1/note.haml +0 -0
  397. data/lib/generators/jinda_engine/templates/app/views/ctrs/vfolder1/viewfile1.html.erb +23 -0
  398. data/lib/generators/jinda_engine/templates/app/views/ctrs/vfolder1/viewfile2.html.erb +23 -0
  399. data/lib/generators/jinda_engine/templates/app/views/ctrs/vfolder2/viewfile2.html.erb +23 -0
  400. data/lib/generators/jinda_engine/templates/app/views/custom/_adsense.haml +6 -0
  401. data/lib/generators/jinda_engine/templates/app/views/docs/doc_edit/doc_edit.html.erb +21 -0
  402. data/lib/generators/jinda_engine/templates/app/views/docs/doc_edit/doc_select.html.erb +14 -0
  403. data/lib/generators/jinda_engine/templates/app/views/docs/doc_new/doc_form.html.erb +26 -0
  404. data/lib/generators/jinda_engine/templates/app/views/docs/doc_new/doc_form.md +36 -0
  405. data/lib/generators/jinda_engine/templates/app/views/docs/doc_xedit/doc_edit.html.erb +21 -0
  406. data/lib/generators/jinda_engine/templates/app/views/docs/edit/select_note.html.erb +14 -0
  407. data/lib/generators/jinda_engine/templates/app/views/docs/index.haml +21 -0
  408. data/lib/generators/jinda_engine/templates/app/views/docs/my.haml +27 -0
  409. data/lib/generators/jinda_engine/templates/app/views/identities/new.html.erb +32 -0
  410. data/lib/generators/jinda_engine/templates/app/views/jinda_mailer/gmail.html.erb +9 -0
  411. data/lib/generators/jinda_engine/templates/app/views/layouts/_head.html.erb +10 -0
  412. data/lib/generators/jinda_engine/templates/app/views/layouts/_meta_tag.html.erb +19 -0
  413. data/lib/generators/jinda_engine/templates/app/views/layouts/application.haml +4 -0
  414. data/lib/generators/jinda_engine/templates/app/views/layouts/bsb/_footer.haml +7 -0
  415. data/lib/generators/jinda_engine/templates/app/views/layouts/bsb/_header.haml +147 -0
  416. data/lib/generators/jinda_engine/templates/app/views/layouts/bsb/_menu.haml +47 -0
  417. data/lib/generators/jinda_engine/templates/app/views/layouts/bsb/_menu_mm.haml +34 -0
  418. data/lib/generators/jinda_engine/templates/app/views/layouts/bsb/_rightbar.haml +123 -0
  419. data/lib/generators/jinda_engine/templates/app/views/layouts/bsb/_sidebar.haml +155 -0
  420. data/lib/generators/jinda_engine/templates/app/views/layouts/bsb/application.haml-bsb +47 -0
  421. data/lib/generators/jinda_engine/templates/app/views/layouts/gmail.html.erb +9 -0
  422. data/lib/generators/jinda_engine/templates/app/views/layouts/jqm/_full.haml +33 -0
  423. data/lib/generators/jinda_engine/templates/app/views/layouts/jqm/_page.haml +16 -0
  424. data/lib/generators/jinda_engine/templates/app/views/layouts/jqm/application.haml-jqm +4 -0
  425. data/lib/generators/jinda_engine/templates/app/views/layouts/mailer.html.erb +13 -0
  426. data/lib/generators/jinda_engine/templates/app/views/layouts/mailer.html.haml +3 -0
  427. data/lib/generators/jinda_engine/templates/app/views/layouts/mailer.text.erb +1 -0
  428. data/lib/generators/jinda_engine/templates/app/views/layouts/mailer.text.haml +1 -0
  429. data/lib/generators/jinda_engine/templates/app/views/layouts/mobile.html.erb +13 -0
  430. data/lib/generators/jinda_engine/templates/app/views/layouts/mobilejq.html.erb +31 -0
  431. data/lib/generators/jinda_engine/templates/app/views/layouts/print.html.erb +22 -0
  432. data/lib/generators/jinda_engine/templates/app/views/layouts/utf8.html.erb +22 -0
  433. data/lib/generators/jinda_engine/templates/app/views/note_mailer/gmail.html.haml +7 -0
  434. data/lib/generators/jinda_engine/templates/app/views/note_mailer/gmail.text.haml +8 -0
  435. data/lib/generators/jinda_engine/templates/app/views/notes/delete/select_note.html.erb +14 -0
  436. data/lib/generators/jinda_engine/templates/app/views/notes/edit/edit_note.html.erb +10 -0
  437. data/lib/generators/jinda_engine/templates/app/views/notes/edit/select_note.html.erb +14 -0
  438. data/lib/generators/jinda_engine/templates/app/views/notes/index.haml +71 -0
  439. data/lib/generators/jinda_engine/templates/app/views/notes/mail/display_mail.html.erb +20 -0
  440. data/lib/generators/jinda_engine/templates/app/views/notes/mail/select_note.html.erb +19 -0
  441. data/lib/generators/jinda_engine/templates/app/views/notes/mail/show.html.haml +13 -0
  442. data/lib/generators/jinda_engine/templates/app/views/notes/my.haml +21 -0
  443. data/lib/generators/jinda_engine/templates/app/views/notes/new/new_note.html.erb +13 -0
  444. data/lib/generators/jinda_engine/templates/app/views/notes/show.haml +10 -0
  445. data/lib/generators/jinda_engine/templates/app/views/notes/xedit/edit_note.html.erb +10 -0
  446. data/lib/generators/jinda_engine/templates/app/views/password_resets/edit.html.erb +21 -0
  447. data/lib/generators/jinda_engine/templates/app/views/password_resets/new.html.erb +7 -0
  448. data/lib/generators/jinda_engine/templates/app/views/sessions/new.html.erb +20 -0
  449. data/lib/generators/jinda_engine/templates/app/views/sitemap/index.xml.haml +10 -0
  450. data/lib/generators/jinda_engine/templates/app/views/user_mailer/password_reset.html.haml +3 -0
  451. data/lib/generators/jinda_engine/templates/app/views/user_mailer/password_reset.text.erb +3 -0
  452. data/lib/generators/jinda_engine/templates/app/views/user_mailer/password_reset.text.haml +3 -0
  453. data/lib/generators/jinda_engine/templates/app/views/users/index.haml +13 -0
  454. data/lib/generators/jinda_engine/templates/app/views/users/pwd/enter.html.erb +6 -0
  455. data/lib/generators/jinda_engine/templates/app/views/users/user/enter_user.html.erb +8 -0
  456. data/lib/generators/jinda_engine/templates/config/cloudinary.yml +9 -0
  457. data/lib/generators/jinda_engine/templates/db/seeds.rb +6 -0
  458. data/lib/generators/jinda_engine/templates/dot/dot.env +2 -0
  459. data/lib/generators/jinda_engine/templates/dotrspec +3 -0
  460. data/lib/generators/jinda_engine/templates/jinda.yml +10 -0
  461. data/lib/generators/jinda_engine/templates/public/404.html +67 -0
  462. data/lib/generators/jinda_engine/templates/public/422.html +67 -0
  463. data/lib/generators/jinda_engine/templates/public/500.html +66 -0
  464. data/lib/generators/jinda_engine/templates/public/assets/images/logo.png +0 -0
  465. data/lib/generators/jinda_engine/templates/public/favicon.ico +0 -0
  466. data/lib/generators/jinda_engine/templates/public/robots.txt +3 -0
  467. data/lib/generators/jinda_engine/templates/spec/controllers/api/v1_get_index_spec.rb +23 -0
  468. data/lib/generators/jinda_engine/templates/spec/controllers/api/v1_get_my_spec.rb +14 -0
  469. data/lib/generators/jinda_engine/templates/spec/controllers/api/v1_post_spec.rb +19 -0
  470. data/lib/generators/jinda_engine/templates/spec/controllers/sessions_controller_spec.rb +96 -0
  471. data/lib/generators/jinda_engine/templates/spec/features/userlogins_spec.rb +23 -0
  472. data/lib/generators/jinda_engine/templates/spec/mailers/note_spec.rb +24 -0
  473. data/lib/generators/jinda_engine/templates/spec/mailers/previews/note_preview.rb +9 -0
  474. data/lib/generators/jinda_engine/templates/spec/models/note_spec.rb +41 -0
  475. data/lib/generators/jinda_engine/templates/spec/models/user_spec.rb +12 -0
  476. data/lib/generators/jinda_engine/templates/spec/rails_helper.rb +44 -0
  477. data/lib/generators/jinda_engine/templates/spec/spec_helper.rb +77 -0
  478. data/lib/generators/jinda_engine/templates/spec/support/authentication_helper.rb +20 -0
  479. data/lib/generators/jinda_engine/templates/spec/support/factory_bot.rb +12 -0
  480. data/lib/generators/jinda_engine/templates/spec/support/omniauth_macros.rb +38 -0
  481. data/lib/generators/jinda_engine/templates/spec/support/request_spec_helper.rb +8 -0
  482. data/lib/generators/jinda_engine/templates/spec/views/articles/_article.html.erb_spec.rbx +14 -0
  483. data/lib/generators/jinda_engine/templates/test/application_system_test_case.rb +5 -0
  484. data/lib/generators/jinda_engine/templates/test/integration/jinda_routes_test.rb +42 -0
  485. data/lib/generators/jinda_engine/templates/test/test_helper.rb +6 -0
  486. data/lib/jinda_engine.rb +7 -0
  487. data/lib/jinda_engine/engine.rb +6 -0
  488. data/lib/jinda_engine/gemhelpers.rb +50 -0
  489. data/lib/jinda_engine/helpers.rb +1005 -0
  490. data/lib/jinda_engine/version.rb +3 -0
  491. data/lib/tasks/jinda_engine.rake +33 -0
  492. metadata +1203 -0
@@ -0,0 +1,1778 @@
1
+ /*
2
+ * jQuery Mobile Framework : plugin to provide a date and time picker.
3
+ * Copyright (c) JTSage
4
+ * CC 3.0 Attribution. May be relicensed without permission/notifcation.
5
+ * https://github.com/jtsage/jquery-mobile-datebox
6
+ */
7
+ (function($, undefined ) {
8
+ $.widget( "mobile.datebox", $.mobile.widget, {
9
+ options: {
10
+ // All widget options, including some internal runtime details
11
+ theme: 'c',
12
+ pickPageTheme: 'b',
13
+ pickPageInputTheme: 'e',
14
+ pickPageButtonTheme: 'a',
15
+ pickPageHighButtonTheme: 'e',
16
+ pickPageOHighButtonTheme: 'e',
17
+ pickPageODHighButtonTheme: 'e',
18
+ pickPageTodayButtonTheme: 'e',
19
+ pickPageSlideButtonTheme: 'd',
20
+ pickPageFlipButtonTheme: 'b',
21
+ centerWindow: true,
22
+ calHighToday: true,
23
+ calHighPicked: true,
24
+ noAnimation: false,
25
+ disableManualInput: false,
26
+
27
+ disabled: false,
28
+ wheelExists: false,
29
+ swipeEnabled: true,
30
+ zindex: '500',
31
+ debug: false,
32
+
33
+ setDateButtonLabel: 'Set Date',
34
+ setTimeButtonLabel: 'Set Time',
35
+ setDurationButtonLabel: 'Set Duration',
36
+ calTodayButtonLabel: 'Jump to Today',
37
+ titleDateDialogLabel: 'Set Date',
38
+ titleTimeDialogLabel: 'Set Time',
39
+ titleDialogLabel: false,
40
+
41
+ meridiemLetters: ['AM', 'PM'],
42
+ /* For Thai Language
43
+ daysOfWeek: ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์'],
44
+ daysOfWeekShort: ['อา', 'จ', 'อ', 'พ', 'พฤ', 'ศ', 'ส'],
45
+ monthsOfYear: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษษยน', 'พฤษภาคม', 'มิถุนายน', 'กรกฏาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'],
46
+ */
47
+ daysOfWeek: ['Sun', 'Mon', 'Tue', 'Wed', 'Thurs', 'Fri', 'Sat'],
48
+ daysOfWeekShort: ['Sun','Mon', 'Tue', 'Wed', 'Thurs', 'Fri', 'Sat'],
49
+ monthsOfYear: ['January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
50
+ monthsOfYearShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
51
+ durationLabel: ['Days', 'Hours', 'Minutes', 'Seconds'],
52
+ durationDays: ['Day', 'Days'],
53
+ durationFormat: 'DD ddd, hh:ii:ss',
54
+ timeFormat: 24,
55
+ timeFormats: { '12': 'gg:ii AA', '24': 'HH:ii' },
56
+ timeOutput: false,
57
+ rolloverMode: { 'm': true, 'd': true, 'h': true, 'i': true, 's': true },
58
+
59
+ mode: 'datebox',
60
+ calShowDays: true,
61
+ calShowOnlyMonth: false,
62
+ useDialogForceTrue: false,
63
+ useDialogForceFalse: false,
64
+ useDialog: false,
65
+ useModal: false,
66
+ useInline: false,
67
+ noButtonFocusMode: false,
68
+ noButton: false,
69
+ noSetButton: false,
70
+ closeCallback: false,
71
+ open: false,
72
+ nestedBox: false,
73
+
74
+ fieldsOrder: false,
75
+ dateFieldOrder: ['m', 'd', 'y'],
76
+ timeFieldOrder: ['h', 'i', 'a'],
77
+ slideFieldOrder: ['y', 'm', 'd'],
78
+ durationOrder: ['d', 'h', 'i', 's'],
79
+ headerFormat: 'ddd, mmm dd, YYYY',
80
+ dateFormat: 'YYYY-MM-DD',
81
+ minuteStep: 1,
82
+ calTodayButton: false,
83
+ calWeekMode: false,
84
+ calWeekModeFirstDay: 1,
85
+ calWeekModeHighlight: true,
86
+ calStartDay: 0,
87
+ defaultPickerValue: false,
88
+ defaultDate : false, //this is deprecated and will be removed in the future versions (ok, may be not)
89
+ minYear: false,
90
+ maxYear: false,
91
+ afterToday: false,
92
+ beforeToday: false,
93
+ maxDays: false,
94
+ minDays: false,
95
+ highDays: false,
96
+ highDates: false,
97
+ blackDays: false,
98
+ blackDates: false,
99
+ durationSteppers: {'d': 1, 'h': 1, 'i': 1, 's': 1},
100
+ disabledDayColor: '#888'
101
+ },
102
+ _dateboxHandler: function(event, payload) {
103
+ // Handle all event triggers that have an internal effect
104
+ if ( ! event.isPropagationStopped() ) {
105
+ switch (payload.method) {
106
+ case 'close':
107
+ $(this).data('datebox').close();
108
+ break;
109
+ case 'open':
110
+ $(this).data('datebox').open();
111
+ break;
112
+ case 'set':
113
+ $(this).val(payload.value);
114
+ $(this).trigger('change');
115
+ break;
116
+ case 'doset':
117
+ if ( $(this).data('datebox').options.mode === 'timebox' || $(this).data('datebox').options.mode === 'durationbox' ) {
118
+ $(this).trigger('datebox', {'method':'set', 'value':$(this).data('datebox')._formatTime($(this).data('datebox').theDate)});
119
+ } else {
120
+ $(this).trigger('datebox', {'method':'set', 'value':$(this).data('datebox')._formatDate($(this).data('datebox').theDate)});
121
+ }
122
+ case 'dooffset':
123
+ $(this).data('datebox')._offset(payload.type, payload.amount, true);
124
+ break;
125
+ case 'dorefresh':
126
+ $(this).data('datebox')._update();
127
+ break;
128
+ }
129
+ }
130
+ },
131
+ _zeroPad: function(number) {
132
+ // Pad a number with a zero, to make it 2 digits
133
+ return ( ( number < 10 ) ? "0" : "" ) + String(number);
134
+ },
135
+ _makeOrd: function (num) {
136
+ // Return an ordinal suffix (1st, 2nd, 3rd, etc)
137
+ var ending = num % 10;
138
+ if ( num > 9 && num < 21 ) { return 'th'; }
139
+ if ( ending > 3 ) { return 'th'; }
140
+ return ['th','st','nd','rd'][ending];
141
+ },
142
+ _isInt: function (s) {
143
+ // Bool, return is a number is an integer
144
+ return (s.toString().search(/^[0-9]+$/) === 0);
145
+ },
146
+ _dstAdjust: function(date) {
147
+ // Make sure not to run into daylight savings time.
148
+ if (!date) { return null; }
149
+ date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
150
+ return date;
151
+ },
152
+ _getFirstDay: function(date) {
153
+ // Get the first DAY of the month (0-6)
154
+ return new Date(date.getFullYear(), date.getMonth(), 1).getDay();
155
+ },
156
+ _getLastDate: function(date) {
157
+ // Get the last DATE of the month (28,29,30,31)
158
+ return 32 - this._dstAdjust(new Date(date.getFullYear(), date.getMonth(), 32)).getDate();
159
+ },
160
+ _getLastDateBefore: function(date) {
161
+ // Get the last DATE of the PREVIOUS month (28,29,30,31)
162
+ return 32 - this._dstAdjust(new Date(date.getFullYear(), date.getMonth()-1, 32)).getDate();
163
+ },
164
+ _formatter: function(format, date) {
165
+ // Format the output date or time (not duration)
166
+ format = format.replace('SS', this._makeOrd(date.getDate()));
167
+ format = format.replace('YYYY', date.getFullYear());
168
+ format = format.replace('mmmm', this.options.monthsOfYearShort[date.getMonth()] );
169
+ format = format.replace('mmm', this.options.monthsOfYear[date.getMonth()] );
170
+ format = format.replace('MM', this._zeroPad(date.getMonth() + 1));
171
+ format = format.replace('mm', date.getMonth() + 1);
172
+ format = format.replace('dddd', this.options.daysOfWeekShort[date.getDay()] );
173
+ format = format.replace('ddd', this.options.daysOfWeek[date.getDay()] );
174
+ format = format.replace('DD', this._zeroPad(date.getDate()));
175
+ format = format.replace('dd', date.getDate());
176
+
177
+ format = format.replace('HH', this._zeroPad(date.getHours()));
178
+ format = format.replace('GG', date.getHours());
179
+
180
+ format = format.replace('hh', this._zeroPad(((date.getHours() === 0 || date.getHours() === 12)?12:((date.getHours()<12)?date.getHours():date.getHours()-12))));
181
+ format = format.replace('gg', ((date.getHours() === 0 || date.getHours() === 12)?12:((date.getHours()<12)?date.getHours():(date.getHours()-12))));
182
+
183
+ format = format.replace('ii', this._zeroPad(date.getMinutes()));
184
+ format = format.replace('ss', this._zeroPad(date.getSeconds()));
185
+ format = format.replace('AA', ((date.getHours() < 12)?this.options.meridiemLetters[0].toUpperCase():this.options.meridiemLetters[1].toUpperCase()));
186
+ format = format.replace('aa', ((date.getHours() < 12)?this.options.meridiemLetters[0].toLowerCase():this.options.meridiemLetters[1].toLowerCase()));
187
+ return format;
188
+ },
189
+ _formatHeader: function(date) {
190
+ // Shortcut function to return headerFormat date/time format
191
+ return this._formatter(this.options.headerFormat, date);
192
+ },
193
+ _formatDate: function(date) {
194
+ // Shortcut function to return dateFormat date/time format
195
+ return this._formatter(this.options.dateFormat, date);
196
+ },
197
+ _isoDate: function(y,m,d) {
198
+ // Return an ISO 8601 date (yyyy-mm-dd)
199
+ return String(y) + '-' + (( m < 10 ) ? "0" : "") + String(m) + '-' + ((d < 10 ) ? "0" : "") + String(d);
200
+ },
201
+ _formatTime: function(date) {
202
+ // Shortcut to return formatted time, also handles duration
203
+ var self = this,
204
+ dur_collapse = [false,false,false], adv, exp_format, i, j,
205
+ format = this.options.durationFormat,
206
+ dur_comps = [0,0,0,0];
207
+
208
+ if ( this.options.mode === 'durationbox' ) {
209
+ adv = this.options.durationFormat;
210
+ adv = adv.replace(/ddd/g, '.+?');
211
+ adv = adv.replace(/DD|ss|hh|ii/g, '([0-9Dhis]+)');
212
+ adv = RegExp('^' + adv + '$');
213
+ exp_format = adv.exec(this.options.durationFormat);
214
+
215
+ i = ((self.theDate.getTime() - self.theDate.getMilliseconds()) / 1000) - ((self.initDate.getTime() - self.initDate.getMilliseconds()) / 1000); j = i;
216
+
217
+ dur_comps[0] = parseInt( i / (60*60*24),10); i = i - (dur_comps[0]*60*60*24); // Days
218
+ dur_comps[1] = parseInt( i / (60*60),10); i = i - (dur_comps[1]*60*60); // Hours
219
+ dur_comps[2] = parseInt( i / (60),10); i = i - (dur_comps[2]*60); // Minutes
220
+ dur_comps[3] = i; // Seconds
221
+
222
+ if ( ! exp_format[0].match(/DD/) ) { dur_collapse[0] = true; dur_comps[1] = dur_comps[1] + (dur_comps[0]*24);}
223
+ if ( ! exp_format[0].match(/hh/) ) { dur_collapse[1] = true; dur_comps[2] = dur_comps[2] + (dur_comps[1]*60);}
224
+ if ( ! exp_format[0].match(/ii/) ) { dur_collapse[2] = true; dur_comps[3] = dur_comps[3] + (dur_comps[2]*60);}
225
+
226
+ if ( this.options.debug ) {
227
+ console.log({'format': exp_format, 'collapse': dur_collapse, 'seconds': j, 'parts': dur_comps});
228
+ }
229
+
230
+ format = format.replace('DD', dur_comps[0]);
231
+ format = format.replace('ddd', ((dur_comps[0] > 1)?this.options.durationDays[1]:this.options.durationDays[0]));
232
+ format = format.replace('hh', self._zeroPad(dur_comps[1]));
233
+ format = format.replace('ii', self._zeroPad(dur_comps[2]));
234
+ format = format.replace('ss', self._zeroPad(dur_comps[3]));
235
+ return format;
236
+ } else {
237
+ return this._formatter(self.options.timeOutput, date);
238
+ }
239
+ },
240
+ _makeDate: function (str) {
241
+ // Date Parser
242
+ str = $.trim(str);
243
+ var o = this.options,
244
+ self = this,
245
+ adv = null,
246
+ exp_input = null,
247
+ exp_format = null,
248
+ exp_temp = null,
249
+ date = new Date(),
250
+ dur_collapse = [false,false,false],
251
+ found_date = [date.getFullYear(),date.getMonth(),date.getDate(),date.getHours(),date.getMinutes(),date.getSeconds()],
252
+ i;
253
+
254
+ if ( o.mode === 'durationbox' ) {
255
+ adv = o.durationFormat;
256
+ adv = adv.replace(/ddd/g, '.+?');
257
+ adv = adv.replace(/DD|ss|hh|ii/g, '([0-9Dhis]+)');
258
+ adv = RegExp('^' + adv + '$');
259
+ exp_input = adv.exec(str);
260
+ exp_format = adv.exec(o.durationFormat);
261
+
262
+ if ( o.debug ) { // Legacy debug code - you probably never need this.
263
+ console.log({'info': 'EXPERIMENTAL REGEX MODE ENABLED', 'string': str, 'regex':adv, 'input':exp_input, 'format':exp_format});
264
+ }
265
+
266
+ if ( exp_input === null || exp_input.length !== exp_format.length ) {
267
+ if ( typeof o.defaultPickerValue === "number" && o.defaultPickerValue > 0 ) {
268
+ return new Date(self.initDate.getTime() + (parseInt(o.defaultPickerValue,10) * 1000));
269
+ } else {
270
+ return new Date(self.initDate.getTime());
271
+ }
272
+ } else {
273
+ exp_temp = ((self.initDate.getTime() - self.initDate.getMilliseconds()) / 1000);
274
+ for ( i=0; i<exp_input.length; i++ ) { //0y 1m 2d 3h 4i 5s
275
+ if ( exp_format[i].match(/^DD$/i) ) { exp_temp = exp_temp + (parseInt(exp_input[i],10)*60*60*24); }
276
+ if ( exp_format[i].match(/^hh$/i) ) { exp_temp = exp_temp + (parseInt(exp_input[i],10)*60*60); }
277
+ if ( exp_format[i].match(/^ii$/i) ) { exp_temp = exp_temp + (parseInt(exp_input[i],10)*60); }
278
+ if ( exp_format[i].match(/^ss$/i) ) { exp_temp = exp_temp + (parseInt(exp_input[i],10)); }
279
+ }
280
+ return new Date((exp_temp*1000));
281
+ }
282
+ } else {
283
+ if ( o.mode === 'timebox' || o.mode === 'timeflipbox' ) { adv = o.timeOutput; } else { adv = o.dateFormat; }
284
+
285
+ adv = adv.replace(/dddd|mmmm/g, '(.+?)');
286
+ adv = adv.replace(/ddd|SS/g, '.+?');
287
+ adv = adv.replace(/mmm/g, '(.+?)');
288
+ adv = adv.replace(/ *AA/ig, ' *(.*?)');
289
+ adv = adv.replace(/yyyy|dd|mm|gg|hh|ii/ig, '([0-9yYdDmMgGhHi]+)');
290
+ adv = adv.replace(/ss/g, '([0-9s]+)');
291
+ adv = RegExp('^' + adv + '$');
292
+ exp_input = adv.exec(str);
293
+ if ( o.mode === 'timebox' || o.mode === 'timeflipbox' ) {
294
+ exp_format = adv.exec(o.timeOutput); // If time, use timeOutput as expected format
295
+ } else {
296
+ exp_format = adv.exec(o.dateFormat); // If date, use dateFormat as expected format
297
+ }
298
+
299
+ if ( o.debug ) { // Legacy debug code - you probably never need this.
300
+ console.log({'info': 'EXPERIMENTAL REGEX MODE ENABLED', 'string': str, 'regex':adv, 'input':exp_input, 'format':exp_format});
301
+ }
302
+
303
+ if ( exp_input === null || exp_input.length !== exp_format.length ) {
304
+ if ( o.defaultPickerValue !== false ) {
305
+ if ( $.isArray(o.defaultPickerValue) && o.defaultPickerValue.length === 3 ) {
306
+ if ( o.mode === 'timebox' || o.mode === 'timeflipbox' ) {
307
+ return new Date(found_date[0], found_date[1], found_date[2], o.defaultPickerValue[0], o.defaultPickerValue[1], o.defaultPickerValue[2], 0);
308
+ }
309
+ else {
310
+ return new Date(o.defaultPickerValue[0], o.defaultPickerValue[1], o.defaultPickerValue[2], 0, 0, 0, 0);
311
+ }
312
+ }
313
+ else {
314
+ if ( o.mode === 'timebox' || o.mode === 'timeflipbox' ) {
315
+ exp_temp = o.defaultPickerValue.split(':');
316
+ if ( exp_temp.length === 3 ) {
317
+ date = new Date(found_date[0], found_date[1], found_date[2], parseInt(exp_temp[0],10),parseInt(exp_temp[1],10),parseInt(exp_temp[2],10),0);
318
+ if ( isNaN(date.getDate()) ) { date = new Date(); }
319
+ }
320
+ }
321
+ else {
322
+ exp_temp = o.defaultPickerValue.split('-');
323
+ if ( exp_temp.length === 3 ) {
324
+ date = new Date(parseInt(exp_temp[0],10),parseInt(exp_temp[1],10)-1,parseInt(exp_temp[2],10),0,0,0,0);
325
+ if ( isNaN(date.getDate()) ) { date = new Date(); }
326
+ }
327
+ }
328
+ }
329
+ }
330
+ } else {
331
+ for ( i=0; i<exp_input.length; i++ ) { //0y 1m 2d 3h 4i 5s
332
+ if ( exp_format[i].match(/^gg$/i) ) { found_date[3] = parseInt(exp_input[i],10); }
333
+ if ( exp_format[i].match(/^hh$/i) ) { found_date[3] = parseInt(exp_input[i],10); }
334
+ if ( exp_format[i].match(/^ii$/i) ) { found_date[4] = parseInt(exp_input[i],10); }
335
+ if ( exp_format[i].match(/^ss$/ ) ) { found_date[5] = parseInt(exp_input[i],10); }
336
+ if ( exp_format[i].match(/^dd$/i) ) { found_date[2] = parseInt(exp_input[i],10); }
337
+ if ( exp_format[i].match(/^mm$/i) ) { found_date[1] = parseInt(exp_input[i],10)-1; }
338
+ if ( exp_format[i].match(/^yyyy$/i) ) { found_date[0] = parseInt(exp_input[i],10); }
339
+ if ( exp_format[i].match(/^AA$/i) ) {
340
+ if ( exp_input[i].toLowerCase().charAt(0) === 'a' && found_date[3] === 12 ) {
341
+ found_date[3] = 0;
342
+ } else if ( exp_input[i].toLowerCase().charAt(0) === 'p' && found_date[3] !== 12 ) {
343
+ found_date[3] = found_date[3] + 12;
344
+ }
345
+ }
346
+ if ( exp_format[i].match(/^mmm$/i) ) {
347
+ exp_temp = $.inArray(exp_input[i], o.monthsOfYear);
348
+ if ( exp_temp > -1 ) { found_date[1] = exp_temp; }
349
+ }
350
+ if ( exp_format[i].match(/^mmmm$/i) ) {
351
+ exp_temp = $.inArray(exp_input[i], o.monthsOfYearShort);
352
+ if ( exp_temp > -1 ) { found_date[1] = exp_temp; }
353
+ }
354
+ }
355
+ }
356
+ if ( exp_format[0].match(/G|g|i|s|H|h|A/) ) {
357
+ return new Date(found_date[0], found_date[1], found_date[2], found_date[3], found_date[4], found_date[5], 0);
358
+ } else {
359
+ return new Date(found_date[0], found_date[1], found_date[2], 0, 0, 0, 0); // Normalize time for raw dates
360
+ }
361
+ }
362
+ },
363
+ _checker: function(date) {
364
+ // Return a ISO 8601 BASIC format date (YYYYMMDD) for simple comparisons
365
+ return parseInt(String(date.getFullYear()) + this._zeroPad(date.getMonth()+1) + this._zeroPad(date.getDate()),10);
366
+ },
367
+ _hoover: function(item) {
368
+ // Hover toggle class, for calendar
369
+ $(item).toggleClass('ui-btn-up-'+$(item).attr('data-theme')+' ui-btn-down-'+$(item).attr('data-theme'));
370
+ },
371
+ _offset: function(mode, amount, update) {
372
+ // Compute a date/time offset.
373
+ // update = false to prevent controls refresh
374
+ var self = this,
375
+ o = this.options;
376
+
377
+ if ( typeof(update) === "undefined" ) { update = true; }
378
+ self.input.trigger('datebox', {'method':'offset', 'type':mode, 'amount':amount});
379
+ switch(mode) {
380
+ case 'y':
381
+ self.theDate.setYear(self.theDate.getFullYear() + amount);
382
+ break;
383
+ case 'm':
384
+ console.log(o.rolloverMode);
385
+ if ( o.rolloverMode['m'] || ( self.theDate.getMonth() + amount < 12 && self.theDate.getMonth() + amount > -1 ) ) {
386
+ self.theDate.setMonth(self.theDate.getMonth() + amount);
387
+ }
388
+ break;
389
+ case 'd':
390
+ if ( o.rolloverMode['d'] || (
391
+ self.theDate.getDate() + amount > 0 &&
392
+ self.theDate.getDate() + amount < (self._getLastDate(self.theDate) + 1) ) ) {
393
+ self.theDate.setDate(self.theDate.getDate() + amount);
394
+ }
395
+ break;
396
+ case 'h':
397
+ if ( o.rolloverMode['h'] || (
398
+ self.theDate.getHours() + amount > -1 &&
399
+ self.theDate.getHours() + amount < 24 ) ) {
400
+ self.theDate.setHours(self.theDate.getHours() + amount);
401
+ }
402
+ break;
403
+ case 'i':
404
+ if ( o.rolloverMode['i'] || (
405
+ self.theDate.getMinutes() + amount > -1 &&
406
+ self.theDate.getMinutes() + amount < 60 ) ) {
407
+ self.theDate.setMinutes(self.theDate.getMinutes() + amount);
408
+ }
409
+ break;
410
+ case 's':
411
+ if ( o.rolloverMode['i'] || (
412
+ self.theDate.getSeconds() + amount > -1 &&
413
+ self.theDate.getSeconds() + amount < 60 ) ) {
414
+ self.theDate.setSeconds(self.theDate.getSeconds() + amount);
415
+ }
416
+ break;
417
+ case 'a':
418
+ if ( self.pickerMeri.val() === o.meridiemLetters[0] ) {
419
+ self._offset('h',12,false);
420
+ } else {
421
+ self._offset('h',-12,false);
422
+ }
423
+ break;
424
+ }
425
+ if ( update === true ) { self._update(); }
426
+ },
427
+ _updateduration: function() {
428
+ // Update the duration contols when inputs are directly edited.
429
+ var self = this,
430
+ secs = (self.initDate.getTime() - self.initDate.getMilliseconds()) / 1000;
431
+
432
+ if ( !self._isInt(self.pickerDay.val()) ) { self.pickerDay.val(0); }
433
+ if ( !self._isInt(self.pickerHour.val()) ) { self.pickerHour.val(0); }
434
+ if ( !self._isInt(self.pickerMins.val()) ) { self.pickerMins.val(0); }
435
+ if ( !self._isInt(self.pickerSecs.val()) ) { self.pickerSecs.val(0); }
436
+
437
+ secs = secs + (parseInt(self.pickerDay.val(),10) * 60 * 60 * 24);
438
+ secs = secs + (parseInt(self.pickerHour.val(),10) * 60 * 60);
439
+ secs = secs + (parseInt(self.pickerMins.val(),10) * 60);
440
+ secs = secs + (parseInt(self.pickerSecs.val(),10));
441
+ self.theDate.setTime( secs * 1000 );
442
+ self._update();
443
+ },
444
+ _update: function() {
445
+ // Update the display on date change
446
+ var self = this,
447
+ o = self.options,
448
+ testDate = null,
449
+ i, gridWeek, gridDay, skipThis, thisRow, y, cTheme, inheritDate, thisPRow, tmpVal,
450
+ interval = {'d': 60*60*24, 'h': 60*60, 'i': 60, 's':1},
451
+ calmode = {};
452
+
453
+ self.input.trigger('datebox', {'method':'refresh'});
454
+ /* BEGIN:DURATIONBOX */
455
+ if ( o.mode === 'durationbox' ) {
456
+ i = ((self.theDate.getTime() - self.theDate.getMilliseconds()) / 1000) - ((self.initDate.getTime() - self.initDate.getMilliseconds()) / 1000);
457
+ if ( i<0 ) { i = 0; self.theDate.setTime(self.initDate.getTime()); }
458
+
459
+ /* DAYS */
460
+ y = parseInt( i / interval['d'],10);
461
+ i = i - ( y * interval['d'] );
462
+ self.pickerDay.val(y);
463
+
464
+ /* HOURS */
465
+ y = parseInt( i / interval['h'], 10);
466
+ i = i - ( y * interval['h'] );
467
+ self.pickerHour.val(y);
468
+
469
+ /* MINS AND SECS */
470
+ y = parseInt( i / interval['i'], 10);
471
+ i = i - ( y * interval['i']);
472
+ self.pickerMins.val(y);
473
+ self.pickerSecs.val(parseInt(i,10));
474
+ }
475
+ /* END:DURATIONBOX */
476
+ /* BEGIN:TIMEBOX */
477
+ if ( o.mode === 'timebox' ) {
478
+ if ( o.minuteStep !== 1 ) {
479
+ i = self.theDate.getMinutes() % o.minuteStep;
480
+ if ( i !== 0 ) { self.theDate.setMinutes(self.theDate.getMinutes() - i); }
481
+ }
482
+ self.pickerMins.val(self._zeroPad(self.theDate.getMinutes()));
483
+ if ( o.timeFormat === 12 ) { // Handle meridiems
484
+ if ( self.theDate.getHours() > 11 ) {
485
+ self.pickerMeri.val(o.meridiemLetters[1]);
486
+ if ( self.theDate.getHours() === 12 ) {
487
+ self.pickerHour.val(12);
488
+ } else {
489
+ self.pickerHour.val(self.theDate.getHours() - 12);
490
+ }
491
+ } else {
492
+ self.pickerMeri.val(o.meridiemLetters[0]);
493
+ if ( self.theDate.getHours() === 0 ) {
494
+ self.pickerHour.val(12);
495
+ } else {
496
+ self.pickerHour.val(self.theDate.getHours());
497
+ }
498
+ }
499
+ } else {
500
+ self.pickerHour.val(self.theDate.getHours());
501
+ }
502
+ }
503
+ /* END:TIMEBOX */
504
+ /* BEGIN:FLIPBOX */
505
+ if ( o.mode === 'flipbox' || o.mode === 'timeflipbox' ) {
506
+ if ( o.afterToday !== false ) {
507
+ testDate = new Date();
508
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
509
+ }
510
+ if ( o.maxDays !== false ) {
511
+ testDate = new Date();
512
+ testDate.setDate(testDate.getDate() + o.maxDays);
513
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
514
+ }
515
+ if ( o.minDays !== false ) {
516
+ testDate = new Date();
517
+ testDate.setDate(testDate.getDate() - o.minDays);
518
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
519
+ }
520
+ if ( o.maxYear !== false ) {
521
+ testDate = new Date(o.maxYear, 0, 1);
522
+ testDate.setDate(testDate.getDate() - 1);
523
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
524
+ }
525
+ if ( o.minYear !== false ) {
526
+ testDate = new Date(o.minYear, 0, 1);
527
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
528
+ }
529
+
530
+ inheritDate = self._makeDate(self.input.val());
531
+
532
+ self.controlsHeader.html( self._formatHeader(self.theDate) );
533
+
534
+ for ( y=0; y<o.fieldsOrder.length; y++ ) {
535
+ tmpVal = true;
536
+ switch (o.fieldsOrder[y]) {
537
+ case 'y':
538
+ thisRow = self.pickerYar.find('ul');
539
+ thisRow.html('');
540
+ for ( i=-15; i<16; i++ ) {
541
+ cTheme = ((inheritDate.getFullYear()===(self.theDate.getFullYear() + i))?o.pickPageHighButtonTheme:o.pickPageFlipButtonTheme);
542
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
543
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -453px':'') })
544
+ .html("<span>"+(self.theDate.getFullYear() + i)+"</span>")
545
+ .attr('data-offset', i)
546
+ .attr('data-theme', cTheme)
547
+ .appendTo(thisRow);
548
+ if ( tmpVal === true ) { tmpVal = false; }
549
+ }
550
+ break;
551
+ case 'm':
552
+ thisRow = self.pickerMon.find('ul');
553
+ thisRow.html('');
554
+ for ( i=-12; i<13; i++ ) {
555
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), 1);
556
+ testDate.setMonth(testDate.getMonth()+i);
557
+ cTheme = ( inheritDate.getMonth() === testDate.getMonth() && inheritDate.getYear() === testDate.getYear() ) ? o.pickPageHighButtonTheme : o.pickPageFlipButtonTheme;
558
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
559
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -357px':'') })
560
+ .attr('data-offset',i)
561
+ .attr('data-theme', cTheme)
562
+ .html("<span>"+o.monthsOfYearShort[testDate.getMonth()]+"</span>")
563
+ .appendTo(thisRow);
564
+ if ( tmpVal === true ) { tmpVal = false; }
565
+ }
566
+ break;
567
+ case 'd':
568
+ thisRow = self.pickerDay.find('ul');
569
+ thisRow.html('');
570
+ for ( i=-15; i<16; i++ ) {
571
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate());
572
+ testDate.setDate(testDate.getDate()+i);
573
+ cTheme = ( inheritDate.getDate() === testDate.getDate() && inheritDate.getMonth() === testDate.getMonth() && inheritDate.getYear() === testDate.getYear() ) ? o.pickPageHighButtonTheme : o.pickPageFlipButtonTheme;
574
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
575
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -453px':'') })
576
+ .attr('data-offset', i)
577
+ .attr('data-theme', cTheme)
578
+ .html("<span>"+testDate.getDate()+"</span>")
579
+ .appendTo(thisRow);
580
+ if ( tmpVal === true ) { tmpVal = false; }
581
+ }
582
+ break;
583
+ case 'h':
584
+ thisRow = self.pickerHour.find('ul');
585
+ thisRow.html('');
586
+ for ( i=-12; i<13; i++ ) {
587
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), self.theDate.getHours());
588
+ testDate.setHours(testDate.getHours()+i);
589
+ cTheme = ( i === 0 ) ? o.pickPageButtonTheme : o.pickPageFlipButtonTheme;
590
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -357px':'') })
591
+ .attr('data-offset',i)
592
+ .attr('data-theme', cTheme)
593
+ .html("<span>"+( ( o.timeFormat === 12 ) ? ( ( testDate.getHours() === 0 ) ? '12' : ( ( testDate.getHours() < 12 ) ? testDate.getHours() : ( ( testDate.getHours() === 12 ) ? '12' : (testDate.getHours()-12) ) ) ) : testDate.getHours() )+"</span>")
594
+ .appendTo(thisRow);
595
+ if ( tmpVal === true ) { tmpVal = false; }
596
+ }
597
+ break;
598
+ case 'i':
599
+ thisRow = self.pickerMins.find('ul');
600
+ thisRow.html('');
601
+ for ( i=-30; i<31; i++ ) {
602
+ if ( o.minuteStep > 1 ) { self.theDate.setMinutes(self.theDate.getMinutes() - (self.theDate.getMinutes() % o.minuteStep)); }
603
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), self.theDate.getHours(), self.theDate.getMinutes());
604
+ testDate.setMinutes(testDate.getMinutes()+(i*o.minuteStep));
605
+ cTheme = ( i === 0 ) ? o.pickPageButtonTheme : o.pickPageFlipButtonTheme;
606
+ $("<li>", { 'class' : 'ui-body-'+cTheme, 'style':''+((tmpVal===true)?'margin-top: -933px':'') })
607
+ .attr('data-offset',(i*o.minuteStep))
608
+ .attr('data-theme', cTheme)
609
+ .html("<span>"+self._zeroPad(testDate.getMinutes())+"</span>")
610
+ .appendTo(thisRow);
611
+ if ( tmpVal === true ) { tmpVal = false; }
612
+ }
613
+ break;
614
+ case 'a':
615
+ thisRow = self.pickerMeri.find('ul');
616
+ thisRow.html('');
617
+ if ( self.theDate.getHours() > 11 ) {
618
+ tmpVal = '-65';
619
+ cTheme = [o.pickPageFlipButtonTheme, o.pickPageButtonTheme]
620
+ } else {
621
+ tmpVal = '-33';
622
+ cTheme = [o.pickPageButtonTheme, o.pickPageFlipButtonTheme]
623
+ }
624
+ $("<li>").appendTo(thisRow).clone().appendTo(thisRow);
625
+ $("<li>", { 'class' : 'ui-body-'+cTheme[0], 'style':'margin-top: '+tmpVal+'px' })
626
+ .attr('data-offset',1)
627
+ .attr('data-theme', cTheme[0])
628
+ .html("<span>"+o.meridiemLetters[0]+"</span>")
629
+ .appendTo(thisRow);
630
+ $("<li>", { 'class' : 'ui-body-'+cTheme[1] })
631
+ .attr('data-offset',1)
632
+ .attr('data-theme', cTheme[1])
633
+ .html("<span>"+o.meridiemLetters[1]+"</span>")
634
+ .appendTo(thisRow);
635
+ $("<li>").appendTo(thisRow).clone().appendTo(thisRow);
636
+ break;
637
+ }
638
+ }
639
+ }
640
+ /* END:FLIPBOX */
641
+ /* BEGIN:SLIDEBOX */
642
+ if ( o.mode === 'slidebox' ) {
643
+ if ( o.afterToday !== false ) {
644
+ testDate = new Date();
645
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
646
+ }
647
+ if ( o.maxDays !== false ) {
648
+ testDate = new Date();
649
+ testDate.setDate(testDate.getDate() + o.maxDays);
650
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
651
+ }
652
+ if ( o.minDays !== false ) {
653
+ testDate = new Date();
654
+ testDate.setDate(testDate.getDate() - o.minDays);
655
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
656
+ }
657
+ if ( o.maxYear !== false ) {
658
+ testDate = new Date(o.maxYear, 0, 1);
659
+ testDate.setDate(testDate.getDate() - 1);
660
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
661
+ }
662
+ if ( o.minYear !== false ) {
663
+ testDate = new Date(o.minYear, 0, 1);
664
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
665
+ }
666
+
667
+ inheritDate = self._makeDate(self.input.val());
668
+
669
+ self.controlsHeader.html( self._formatHeader(self.theDate) );
670
+ self.controlsInput.html('');
671
+
672
+ for ( y=0; y<o.fieldsOrder.length; y++ ) {
673
+ thisPRow = $("<div>", {'data-rowtype': o.fieldsOrder[y]});
674
+
675
+ if ( o.wheelExists ) {
676
+ thisPRow.bind('mousewheel', function(e,d) {
677
+ e.preventDefault();
678
+ self._offset($(this).attr('data-rowtype'), ((d>0)?1:-1));
679
+ });
680
+ }
681
+
682
+ thisRow = $("<div>", {'class': 'ui-datebox-sliderow-int', 'data-rowtype': o.fieldsOrder[y]}).appendTo(thisPRow);
683
+
684
+ if ( o.swipeEnabled ) {
685
+ thisRow
686
+ .bind(self.START_DRAG, function(e) {
687
+ if ( !self.dragMove ) {
688
+ self.dragMove = true;
689
+ self.dragTarget = $(this);
690
+ self.dragPos = parseInt(self.dragTarget.css('marginLeft').replace(/px/i, ''),10);
691
+ self.dragStart = self.touch ? e.originalEvent.changedTouches[0].pageX : e.pageX;
692
+ self.dragEnd = false;
693
+ e.stopPropagation();
694
+ e.preventDefault();
695
+ }
696
+ });
697
+ }
698
+ switch (o.fieldsOrder[y]) {
699
+ case 'y':
700
+ thisPRow.addClass('ui-datebox-sliderow-ym');
701
+ thisRow.css('marginLeft', '-333px');
702
+ for ( i=-5; i<6; i++ ) {
703
+ cTheme = ((inheritDate.getFullYear()===(self.theDate.getFullYear() + i))?o.pickPageHighButtonTheme:o.pickPageSlideButtonTheme);
704
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
705
+ $("<div>", { 'class' : 'ui-datebox-slideyear ui-corner-all ui-btn-up-'+cTheme })
706
+ .text(self.theDate.getFullYear() + i)
707
+ .attr('data-offset', i)
708
+ .attr('data-theme', cTheme)
709
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
710
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('y', parseInt($(this).attr('data-offset'),10)); })
711
+ .appendTo(thisRow);
712
+ }
713
+ break;
714
+ case 'm':
715
+ thisPRow.addClass('ui-datebox-sliderow-ym');
716
+ thisRow.css('marginLeft', '-204px');
717
+ for ( i=-6; i<7; i++ ) {
718
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), 1);
719
+ testDate.setMonth(testDate.getMonth()+i);
720
+ cTheme = ( inheritDate.getMonth() === testDate.getMonth() && inheritDate.getYear() === testDate.getYear() ) ? o.pickPageHighButtonTheme : o.pickPageSlideButtonTheme;
721
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
722
+ $("<div>", { 'class' : 'ui-datebox-slidemonth ui-corner-all ui-btn-up-'+cTheme })
723
+ .attr('data-offset',i)
724
+ .attr('data-theme', cTheme)
725
+ .text(o.monthsOfYearShort[testDate.getMonth()])
726
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
727
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('m', parseInt($(this).attr('data-offset'),10)); })
728
+ .appendTo(thisRow);
729
+ }
730
+ break;
731
+ case 'd':
732
+ thisPRow.addClass('ui-datebox-sliderow-d');
733
+ thisRow.css('marginLeft', '-386px');
734
+ for ( i=-15; i<16; i++ ) {
735
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate());
736
+ testDate.setDate(testDate.getDate()+i);
737
+ cTheme = ( inheritDate.getDate() === testDate.getDate() && inheritDate.getMonth() === testDate.getMonth() && inheritDate.getYear() === testDate.getYear() ) ? o.pickPageHighButtonTheme : o.pickPageSlideButtonTheme;
738
+ if ( i === 0 ) { cTheme = o.pickPageButtonTheme; }
739
+
740
+ $("<div>", { 'class' : 'ui-datebox-slideday ui-corner-all ui-btn-up-'+cTheme })
741
+ .attr('data-offset', i)
742
+ .attr('data-theme', cTheme)
743
+ .html(testDate.getDate() + '<br /><span class="ui-datebox-slidewday">' + o.daysOfWeekShort[testDate.getDay()] + '</span>')
744
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
745
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('d', parseInt($(this).attr('data-offset'),10)); })
746
+ .appendTo(thisRow);
747
+ }
748
+ break;
749
+ case 'h':
750
+ thisPRow.addClass('ui-datebox-sliderow-hi');
751
+ thisRow.css('marginLeft', '-284px');
752
+ for ( i=-12; i<13; i++ ) {
753
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), self.theDate.getHours());
754
+ testDate.setHours(testDate.getHours()+i);
755
+ cTheme = ( i === 0 ) ? o.pickPageButtonTheme : o.pickPageSlideButtonTheme;
756
+ $("<div>", { 'class' : 'ui-datebox-slidehour ui-corner-all ui-btn-up-'+cTheme })
757
+ .attr('data-offset',i)
758
+ .attr('data-theme', cTheme)
759
+ .html(( ( o.timeFormat === 12 ) ? ( ( testDate.getHours() === 0 ) ? '12<span class="ui-datebox-slidewday">AM</span>' : ( ( testDate.getHours() < 12 ) ? testDate.getHours() + '<span class="ui-datebox-slidewday">AM</span>' : ( ( testDate.getHours() === 12 ) ? '12<span class="ui-datebox-slidewday">PM</span>' : (testDate.getHours()-12) + '<span class="ui-datebox-slidewday">PM</span>') ) ) : testDate.getHours() ))
760
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
761
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('h', parseInt($(this).attr('data-offset'),10)); })
762
+ .appendTo(thisRow);
763
+ }
764
+ break;
765
+ case 'i':
766
+ thisPRow.addClass('ui-datebox-sliderow-hi');
767
+ thisRow.css('marginLeft', '-896px');
768
+ for ( i=-30; i<31; i++ ) {
769
+ testDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), self.theDate.getHours(), self.theDate.getMinutes());
770
+ testDate.setMinutes(testDate.getMinutes()+i);
771
+ cTheme = ( i === 0 ) ? o.pickPageButtonTheme : o.pickPageSlideButtonTheme;
772
+ $("<div>", { 'class' : 'ui-datebox-slidemins ui-corner-all ui-btn-up-'+cTheme })
773
+ .attr('data-offset',i)
774
+ .attr('data-theme', cTheme)
775
+ .text(self._zeroPad(testDate.getMinutes()))
776
+ .bind('vmouseover vmouseout', function() { self._hoover(this); })
777
+ .bind('vclick', function(e) { e.preventDefault(); self._offset('i', parseInt($(this).attr('data-offset'),10)); })
778
+ .appendTo(thisRow);
779
+ }
780
+ break;
781
+ }
782
+ thisPRow.appendTo(self.controlsInput);
783
+ }
784
+ }
785
+ /* END:SLIDEBOX */
786
+ /* BEGIN:DATEBOX */
787
+ if ( o.mode === 'datebox' ) {
788
+ if ( o.afterToday !== false ) {
789
+ testDate = new Date();
790
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
791
+ }
792
+ if ( o.beforeToday !== false ) {
793
+ testDate = new Date();
794
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
795
+ }
796
+ if ( o.maxDays !== false ) {
797
+ testDate = new Date();
798
+ testDate.setDate(testDate.getDate() + o.maxDays);
799
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
800
+ }
801
+ if ( o.minDays !== false ) {
802
+ testDate = new Date();
803
+ testDate.setDate(testDate.getDate() - o.minDays);
804
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
805
+ }
806
+ if ( o.maxYear !== false ) {
807
+ testDate = new Date(o.maxYear, 0, 1);
808
+ testDate.setDate(testDate.getDate() - 1);
809
+ if ( self.theDate > testDate ) { self.theDate = testDate; }
810
+ }
811
+ if ( o.minYear !== false ) {
812
+ testDate = new Date(o.minYear, 0, 1);
813
+ if ( self.theDate < testDate ) { self.theDate = testDate; }
814
+ }
815
+
816
+ self.controlsHeader.html( self._formatHeader(self.theDate) );
817
+ self.pickerMon.val(self.theDate.getMonth() + 1);
818
+ self.pickerDay.val(self.theDate.getDate());
819
+ self.pickerYar.val(self.theDate.getFullYear());
820
+ }
821
+ /* END:DATEBOX */
822
+ /* BEGIN:CALBOX */
823
+ if ( o.mode === 'calbox' ) { // Meat and potatos - make the calendar grid.
824
+ self.controlsInput.text( o.monthsOfYear[self.theDate.getMonth()] + " " + self.theDate.getFullYear() );
825
+ self.controlsSet.html('');
826
+
827
+ calmode = {'today': -1, 'highlightDay': -1, 'presetDay': -1, 'nexttoday': 1,
828
+ 'thisDate': new Date(), 'maxDate': new Date(), 'minDate': new Date(),
829
+ 'currentMonth': false, 'weekMode': 0, 'weekDays': null, 'thisTheme': o.pickPageButtonTheme };
830
+ calmode.start = self._getFirstDay(self.theDate);
831
+ calmode.end = self._getLastDate(self.theDate);
832
+ calmode.lastend = self._getLastDateBefore(self.theDate);
833
+ calmode.presetDate = self._makeDate(self.input.val());
834
+
835
+ if ( o.calStartDay > 0 ) {
836
+ calmode.start = calmode.start - o.calStartDay;
837
+ if ( calmode.start < 0 ) { calmode.start = calmode.start + 7; }
838
+ }
839
+
840
+ calmode.prevtoday = calmode.lastend - (calmode.start - 1);
841
+ calmode.checkDates = ( o.afterToday !== false || o.beforeToday !== false || o.notToday !== false || o.maxDays !== false || o.minDays !== false || o.blackDates !== false || o.blackDays !== false );
842
+
843
+ if ( calmode.thisDate.getMonth() === self.theDate.getMonth() && calmode.thisDate.getFullYear() === self.theDate.getFullYear() ) { calmode.currentMonth = true; calmode.highlightDay = calmode.thisDate.getDate(); }
844
+ if ( self._checker(calmode.presetDate) === self._checker(self.theDate) ) { calmode.presetDay = calmode.presetDate.getDate(); }
845
+
846
+ self.calNoPrev = false; self.calNoNext = false;
847
+
848
+ if ( o.afterToday === true &&
849
+ ( calmode.currentMonth === true || ( calmode.thisDate.getMonth() >= self.theDate.getMonth() && self.theDate.getFullYear() === calmode.thisDate.getFullYear() ) ) ) {
850
+ self.calNoPrev = true; }
851
+ if ( o.beforeToday === true &&
852
+ ( calmode.currentMonth === true || ( calmode.thisDate.getMonth() <= self.theDate.getMonth() && self.theDate.getFullYear() === calmode.thisDate.getFullYear() ) ) ) {
853
+ self.calNoNext = true; }
854
+
855
+ if ( o.minDays !== false ) {
856
+ calmode.minDate.setDate(calmode.minDate.getDate() - o.minDays);
857
+ if ( self.theDate.getFullYear() === calmode.minDate.getFullYear() && self.theDate.getMonth() <= calmode.minDate.getMonth() ) { self.calNoPrev = true;}
858
+ }
859
+ if ( o.maxDays !== false ) {
860
+ calmode.maxDate.setDate(calmode.maxDate.getDate() + o.maxDays);
861
+ if ( self.theDate.getFullYear() === calmode.maxDate.getFullYear() && self.theDate.getMonth() >= calmode.maxDate.getMonth() ) { self.calNoNext = true;}
862
+ }
863
+
864
+ if ( o.calShowDays ) {
865
+ if ( o.daysOfWeekShort.length < 8 ) { o.daysOfWeekShort = o.daysOfWeekShort.concat(o.daysOfWeekShort); }
866
+ calmode.weekDays = $("<div>", {'class':'ui-datebox-gridrow'}).appendTo(self.controlsSet);
867
+ for ( i=0; i<=6;i++ ) {
868
+ $("<div>"+o.daysOfWeekShort[i+o.calStartDay]+"</div>").addClass('ui-datebox-griddate ui-datebox-griddate-empty ui-datebox-griddate-label').appendTo(calmode.weekDays);
869
+ }
870
+ }
871
+
872
+ for ( gridWeek=0; gridWeek<=5; gridWeek++ ) {
873
+ if ( gridWeek === 0 || ( gridWeek > 0 && (calmode.today > 0 && calmode.today <= calmode.end) ) ) {
874
+ thisRow = $("<div>", {'class': 'ui-datebox-gridrow'}).appendTo(self.controlsSet);
875
+ for ( gridDay=0; gridDay<=6; gridDay++) {
876
+ if ( gridDay === 0 ) { calmode.weekMode = ( calmode.today < 1 ) ? (calmode.prevtoday - calmode.lastend + o.calWeekModeFirstDay) : (calmode.today + o.calWeekModeFirstDay); }
877
+ if ( gridDay === calmode.start && gridWeek === 0 ) { calmode.today = 1; }
878
+ if ( calmode.today > calmode.end ) { calmode.today = -1; }
879
+ if ( calmode.today < 1 ) {
880
+ if ( o.calShowOnlyMonth ) {
881
+ $("<div>", {'class': 'ui-datebox-griddate ui-datebox-griddate-empty'}).appendTo(thisRow);
882
+ } else {
883
+ if (
884
+ ( o.blackDays !== false && $.inArray(gridDay, o.blackDays) > -1 ) ||
885
+ ( o.blackDates !== false && $.inArray(self._isoDate(self.theDate.getFullYear(), (self.theDate.getMonth()), calmode.prevtoday), o.blackDates) > -1 ) ||
886
+ ( o.blackDates !== false && $.inArray(self._isoDate(self.theDate.getFullYear(), (self.theDate.getMonth()+2), calmode.nexttoday), o.blackDates) > -1 ) ) {
887
+ skipThis = true;
888
+ } else { skipThis = false; }
889
+
890
+ if ( gridWeek === 0 ) {
891
+ $("<div>"+String(calmode.prevtoday)+"</div>")
892
+ .addClass('ui-datebox-griddate ui-datebox-griddate-empty').appendTo(thisRow)
893
+ .attr('data-date', ((o.calWeekMode)?(calmode.weekMode+calmode.lastend):calmode.prevtoday))
894
+ .bind((!skipThis)?'vclick':'error', function(e) {
895
+ e.preventDefault();
896
+ if ( !self.calNoPrev ) {
897
+ self.theDate.setMonth(self.theDate.getMonth() - 1);
898
+ self.theDate.setDate($(this).attr('data-date'));
899
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)});
900
+ self.input.trigger('datebox', {'method':'close'});
901
+ }
902
+ });
903
+ calmode.prevtoday++;
904
+ } else {
905
+ $("<div>"+String(calmode.nexttoday)+"</div>")
906
+ .addClass('ui-datebox-griddate ui-datebox-griddate-empty').appendTo(thisRow)
907
+ .attr('data-date', ((o.calWeekMode)?calmode.weekMode:calmode.nexttoday))
908
+ .bind((!skipThis)?'vclick':'error', function(e) {
909
+ e.preventDefault();
910
+ if ( !self.calNoNext ) {
911
+ self.theDate.setDate($(this).attr('data-date'));
912
+ if ( !o.calWeekMode ) { self.theDate.setMonth(self.theDate.getMonth() + 1); }
913
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)});
914
+ self.input.trigger('datebox', {'method':'close'});
915
+ }
916
+ });
917
+ calmode.nexttoday++;
918
+ }
919
+ }
920
+ } else {
921
+ skipThis = false;
922
+ if ( calmode.checkDates ) {
923
+ if ( o.afterToday && self._checker(calmode.thisDate) > (self._checker(self.theDate)+calmode.today-self.theDate.getDate()) ) {
924
+ skipThis = true;
925
+ }
926
+ if ( !skipThis && o.beforeToday && self._checker(calmode.thisDate) < (self._checker(self.theDate)+calmode.today-self.theDate.getDate()) ) {
927
+ skipThis = true;
928
+ }
929
+ if ( !skipThis && o.notToday && calmode.today === calmode.highlightDay ) {
930
+ skipThis = true;
931
+ }
932
+ if ( !skipThis && o.maxDays !== false && self._checker(calmode.maxDate) < (self._checker(self.theDate)+calmode.today-self.theDate.getDate()) ) {
933
+ skipThis = true;
934
+ }
935
+ if ( !skipThis && o.minDays !== false && self._checker(calmode.minDate) > (self._checker(self.theDate)+calmode.today-self.theDate.getDate()) ) {
936
+ skipThis = true;
937
+ }
938
+ if ( !skipThis && ( o.blackDays !== false || o.blackDates !== false ) ) { // Blacklists
939
+ if (
940
+ ( $.inArray(gridDay, o.blackDays) > -1 ) ||
941
+ ( $.inArray(self._isoDate(self.theDate.getFullYear(), self.theDate.getMonth()+1, calmode.today), o.blackDates) > -1 ) ) {
942
+ skipThis = true;
943
+ }
944
+ }
945
+ }
946
+
947
+ if ( o.calHighPicked && calmode.today === calmode.presetDay ) {
948
+ calmode.thisTheme = o.pickPageHighButtonTheme;
949
+ } else if ( o.calHighToday && calmode.today === calmode.highlightDay ) {
950
+ calmode.thisTheme = o.pickPageTodayButtonTheme;
951
+ } else if ( $.isArray(o.highDates) && ($.inArray(self._isoDate(self.theDate.getFullYear(), self.theDate.getMonth()+1, calmode.today), o.highDates) > -1 ) ) {
952
+ calmode.thisTheme = o.pickPageOHighButtonTheme;
953
+ } else if ( $.isArray(o.highDays) && $.inArray(gridDay, o.highDays) > -1 ) {
954
+ calmode.thisTheme = o.pickPageODHighButtonTheme;
955
+ } else {
956
+ calmode.thisTheme = o.pickPageButtonTheme;
957
+ }
958
+
959
+ $("<div>"+String(calmode.today)+"</div>")
960
+ .addClass('ui-datebox-griddate ui-corner-all')
961
+ .attr('data-date', ((o.calWeekMode)?calmode.weekMode:calmode.today))
962
+ .attr('data-theme', calmode.thisTheme)
963
+ .appendTo(thisRow)
964
+ .addClass('ui-btn-up-'+calmode.thisTheme)
965
+ .bind('vmouseover vmouseout', function() {
966
+ if ( o.calWeekMode !== false && o.calWeekModeHighlight === true ) {
967
+ $(this).parent().find('div').each(function() { self._hoover(this); });
968
+ } else { self._hoover(this); }
969
+ })
970
+ .bind((!skipThis)?'vclick':'error', function(e) {
971
+ e.preventDefault();
972
+ self.theDate.setDate($(this).attr('data-date'));
973
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)});
974
+ self.input.trigger('datebox', {'method':'close'});
975
+ })
976
+ .css((skipThis)?'color':'nocolor', o.disabledDayColor);
977
+
978
+ calmode.today++;
979
+ }
980
+ }
981
+ }
982
+ }
983
+ }
984
+ /* END:CALBOX */
985
+ },
986
+ _create: function() {
987
+ // Create the widget, called automatically by widget system
988
+ var self = this,
989
+ o = $.extend(this.options, this.element.data('options')),
990
+ input = this.element,
991
+ focusedEl = input.wrap('<div class="ui-input-datebox ui-shadow-inset ui-corner-all ui-body-'+ o.theme +'"></div>').parent(),
992
+ theDate = new Date(), // Internal date object, used for all operations
993
+ initDate = new Date(theDate.getTime()), // Initilization time - used for duration
994
+ dialogTitle = ((o.titleDialogLabel === false)?((o.mode==='timebox')?o.titleTimeDialogLabel:o.titleDateDialogLabel):o.titleDialogLabel),
995
+
996
+ // This is the button that is added to the original input
997
+ openbutton = $('<a href="#" class="ui-input-clear" title="date picker">date picker</a>')
998
+ .bind('vclick', function (e) {
999
+ e.preventDefault();
1000
+ if ( !o.disabled ) { self.input.trigger('datebox', {'method': 'open'}); }
1001
+ setTimeout( function() { $(e.target).closest("a").removeClass($.mobile.activeBtnClass); }, 300);
1002
+ })
1003
+ .appendTo(focusedEl).buttonMarkup({icon: 'grid', iconpos: 'notext', corners:true, shadow:true})
1004
+ .css({'vertical-align': 'middle', 'float': 'right'}),
1005
+ thisPage = input.closest('.ui-page'),
1006
+ pickPage = $("<div data-role='dialog' class='ui-dialog-datebox' data-theme='" + o.pickPageTheme + "' >" +
1007
+ "<div data-role='header' data-backbtn='false' data-theme='a'>" +
1008
+ "<div class='ui-title'>" + dialogTitle + "</div>"+
1009
+ "</div>"+
1010
+ "<div data-role='content'></div>"+
1011
+ "</div>")
1012
+ .appendTo( $.mobile.pageContainer )
1013
+ .page().css('minHeight', '0px').css('zIndex', o.zindex).addClass('pop'),
1014
+ pickPageContent = pickPage.find( ".ui-content" ),
1015
+ touch = ('ontouchstart' in window),
1016
+ START_EVENT = touch ? 'touchstart' : 'mousedown',
1017
+ MOVE_EVENT = touch ? 'touchmove' : 'mousemove',
1018
+ END_EVENT = touch ? 'touchend' : 'mouseup',
1019
+ dragMove = false,
1020
+ dragStart = false,
1021
+ dragEnd = false,
1022
+ dragPos = false,
1023
+ dragTarget = false,
1024
+ dragThisDelta = 0;
1025
+
1026
+ if(o.defaultPickerValue===false && o.defaultDate!==false){
1027
+ o.defaultPickerValue = o.defaultDate;
1028
+ }
1029
+
1030
+ $('label[for='+input.attr('id')+']').addClass('ui-input-text').css('verticalAlign', 'middle');
1031
+
1032
+ /* BUILD:MODE */
1033
+
1034
+ if ( o.mode === "timeflipbox" ) { // No header in time flipbox.
1035
+ o.headerFormat = ' ';
1036
+ }
1037
+
1038
+ // Select the appropriate output format if not otherwise specified
1039
+ if ( o.timeOutput === false ) {
1040
+ o.timeOutput = o.timeFormats[o.timeFormat];
1041
+ }
1042
+ if ( o.fieldsOrder === false ) {
1043
+ switch (o.mode) {
1044
+ case 'timebox':
1045
+ case 'timeflipbox':
1046
+ o.fieldsOrder = o.timeFieldOrder;
1047
+ break;
1048
+ case 'slidebox':
1049
+ o.fieldsOrder = o.slideFieldOrder;
1050
+ break;
1051
+ default:
1052
+ o.fieldsOrder = o.dateFieldOrder;
1053
+ }
1054
+ }
1055
+
1056
+ // For focus mode, disable button, and bind click of input element and it's parent
1057
+ if ( o.noButtonFocusMode || o.useInline || o.noButton ) { openbutton.hide(); }
1058
+
1059
+ focusedEl.bind('vclick', function() {
1060
+ if ( !o.disabled && o.noButtonFocusMode ) { input.trigger('datebox', {'method': 'open'}); }
1061
+ });
1062
+
1063
+
1064
+ input
1065
+ .removeClass('ui-corner-all ui-shadow-inset')
1066
+ .focus(function(){
1067
+ if ( ! o.disabled ) {
1068
+ focusedEl.addClass('ui-focus');
1069
+ if ( o.noButtonFocusMode ) { focusedEl.addClass('ui-focus'); input.trigger('datebox', {'method': 'open'}); }
1070
+ }
1071
+ input.removeClass('ui-focus');
1072
+ })
1073
+ .blur(function(){
1074
+ focusedEl.removeClass('ui-focus');
1075
+ input.removeClass('ui-focus');
1076
+ })
1077
+ .change(function() {
1078
+ self.theDate = self._makeDate(self.input.val());
1079
+ self._update();
1080
+ });
1081
+
1082
+ // Bind the master handler.
1083
+ input.bind('datebox', self._dateboxHandler);
1084
+
1085
+ // Bind the close button on the DIALOG mode.
1086
+ pickPage.find( ".ui-header a").bind('vclick', function(e) {
1087
+ e.preventDefault();
1088
+ e.stopImmediatePropagation();
1089
+ self.input.trigger('datebox', {'method':'close'});
1090
+ });
1091
+
1092
+ $.extend(self, {
1093
+ pickPage: pickPage,
1094
+ thisPage: thisPage,
1095
+ pickPageContent: pickPageContent,
1096
+ input: input,
1097
+ theDate: theDate,
1098
+ initDate: initDate,
1099
+ focusedEl: focusedEl,
1100
+ touch: touch,
1101
+ START_DRAG: START_EVENT,
1102
+ MOVE_DRAG: MOVE_EVENT,
1103
+ END_DRAG: END_EVENT,
1104
+ dragMove: dragMove,
1105
+ dragStart: dragStart,
1106
+ dragEnd: dragEnd,
1107
+ dragPos: dragPos
1108
+ });
1109
+
1110
+ // Check if mousewheel plugin is loaded
1111
+ if ( typeof $.event.special.mousewheel !== 'undefined' ) { o.wheelExists = true; }
1112
+
1113
+ self._buildPage();
1114
+
1115
+ // drag and drop support, all ending and moving events are defined here, start events are handled in _buildPage or update
1116
+ if ( o.swipeEnabled ) {
1117
+ $(document).bind(self.MOVE_DRAG, function(e) {
1118
+ if ( self.dragMove ) {
1119
+ if ( o.mode === 'slidebox' ) {
1120
+ self.dragEnd = self.touch ? e.originalEvent.changedTouches[0].pageX : e.pageX;
1121
+ self.dragTarget.css('marginLeft', (self.dragPos + self.dragEnd - self.dragStart) + 'px');
1122
+ e.preventDefault();
1123
+ e.stopPropagation();
1124
+ return false;
1125
+ } else if ( o.mode === 'flipbox' || o.mode === 'timeflipbox' ) {
1126
+ self.dragEnd = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1127
+ self.dragTarget.css('marginTop', (self.dragPos + self.dragEnd - self.dragStart) + 'px');
1128
+ e.preventDefault();
1129
+ e.stopPropagation();
1130
+ return false;
1131
+ } else if ( o.mode === 'durationbox' || o.mode === 'timebox' || o.mode === 'datebox' ) {
1132
+ self.dragEnd = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1133
+ if ( (self.dragEnd - self.dragStart) % 2 === 0 ) {
1134
+ dragThisDelta = (self.dragEnd - self.dragStart) / -2;
1135
+ if ( dragThisDelta < self.dragPos ) {
1136
+ self._offset(self.dragTarget, -1*(self.dragTarget==='i'?o.minuteStep:1));
1137
+ } else if ( dragThisDelta > self.dragPos ) {
1138
+ self._offset(self.dragTarget, 1*(self.dragTarget==='i'?o.minuteStep:1));
1139
+ }
1140
+ self.dragPos = dragThisDelta;
1141
+ }
1142
+ e.preventDefault();
1143
+ e.stopPropagation();
1144
+ return false;
1145
+ }
1146
+ }
1147
+ });
1148
+ $(document).bind(self.END_DRAG, function(e) {
1149
+ if ( self.dragMove ) {
1150
+ self.dragMove = false;
1151
+ if ( o.mode === 'slidebox' ) {
1152
+ if ( self.dragEnd !== false && Math.abs(self.dragStart - self.dragEnd) > 25 ) {
1153
+ e.preventDefault();
1154
+ e.stopPropagation();
1155
+ switch(self.dragTarget.parent().data('rowtype')) {
1156
+ case 'y':
1157
+ self._offset('y', parseInt(( self.dragStart - self.dragEnd ) / 84, 10));
1158
+ break;
1159
+ case 'm':
1160
+ self._offset('m', parseInt(( self.dragStart - self.dragEnd ) / 51, 10));
1161
+ break;
1162
+ case 'd':
1163
+ self._offset('d', parseInt(( self.dragStart - self.dragEnd ) / 32, 10));
1164
+ break;
1165
+ case 'h':
1166
+ self._offset('h', parseInt(( self.dragStart - self.dragEnd ) / 32, 10));
1167
+ break;
1168
+ case 'i':
1169
+ self._offset('i', parseInt(( self.dragStart - self.dragEnd ) / 32, 10));
1170
+ break;
1171
+ }
1172
+ }
1173
+ } else if ( o.mode === 'flipbox' || o.mode === 'timeflipbox' ) {
1174
+ if ( self.dragEnd !== false ) {
1175
+ e.preventDefault();
1176
+ e.stopPropagation();
1177
+ self._offset(self.dragTarget.parent().parent().data('field'), parseInt(( self.dragStart - self.dragEnd ) / 30, 10));
1178
+ }
1179
+ }
1180
+ self.dragStart = false;
1181
+ self.dragEnd = false;
1182
+ }
1183
+ });
1184
+ }
1185
+
1186
+ // Disable when done if element attribute disabled is true.
1187
+ if ( input.is(':disabled') ) {
1188
+ self.disable();
1189
+ }
1190
+ // Turn input readonly if requested (on by default)
1191
+ if ( o.disableManualInput === true ) {
1192
+ input.attr("readonly", true);
1193
+ }
1194
+ },
1195
+ _buildPage: function () {
1196
+ // Build the controls
1197
+ var self = this,
1198
+ o = self.options, x, newHour, fld,
1199
+ linkdiv =$("<div><a href='#'></a></div>"),
1200
+ pickerContent = $("<div>", { "class": 'ui-datebox-container ui-overlay-shadow ui-corner-all ui-datebox-hidden pop ui-body-'+o.pickPageTheme} ).css('zIndex', o.zindex),
1201
+ templInput = $("<input type='text' />").addClass('ui-input-text ui-corner-all ui-shadow-inset ui-datebox-input ui-body-'+o.pickPageInputTheme),
1202
+ templControls = $("<div>", { "class":'ui-datebox-controls' }),
1203
+ templFlip = $("<div class='ui-overlay-shadow'><ul></ul></div>"),
1204
+ controlsPlus, controlsInput, controlsMinus, controlsSet, controlsHeader,
1205
+ pickerHour, pickerMins, pickerMeri, pickerMon, pickerDay, pickerYar, pickerSecs,
1206
+ calNoNext = false,
1207
+ calNoPrev = false,
1208
+ screen = $("<div>", {'class':'ui-datebox-screen ui-datebox-hidden'+((o.useModal)?' ui-datebox-screen-modal':'')})
1209
+ .css({'z-index': o.zindex-1})
1210
+ .appendTo(self.thisPage)
1211
+ .bind("vclick", function(event) {
1212
+ event.preventDefault();
1213
+ self.input.trigger('datebox', {'method':'close'});
1214
+ });
1215
+
1216
+ if ( o.noAnimation ) { pickerContent.removeClass('pop'); }
1217
+
1218
+ /* BEGIN:FLIPBOX */
1219
+ if ( o.mode === 'flipbox' || o.mode === 'timeflipbox' ) {
1220
+ controlsHeader = $("<div class='ui-datebox-header'><h4>Unitialized</h4></div>").appendTo(pickerContent).find("h4");
1221
+ controlsInput = $("<div>", {"class":'ui-datebox-flipcontent'}).appendTo(pickerContent);
1222
+ controlsPlus = $("<div>", {"class":'ui-datebox-flipcenter ui-overlay-shadow'}).appendTo(pickerContent);
1223
+ controlsSet = templControls.clone().appendTo(pickerContent);
1224
+
1225
+ pickerDay = templFlip.clone().attr('data-field', 'd');
1226
+ pickerMon = templFlip.clone().attr('data-field', 'm');
1227
+ pickerYar = templFlip.clone().attr('data-field', 'y');
1228
+ pickerHour = templFlip.clone().attr('data-field', 'h');
1229
+ pickerMins = templFlip.clone().attr('data-field', 'i');
1230
+ pickerMeri = templFlip.clone().attr('data-field', 'a');
1231
+
1232
+ if ( o.wheelExists ) { // Mousewheel operation, if the plugin is loaded.
1233
+ pickerYar.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('y', (d<0)?-1:1); });
1234
+ pickerMon.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('m', (d<0)?-1:1); });
1235
+ pickerDay.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('d', (d<0)?-1:1); });
1236
+ pickerHour.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('h', (d<0)?-1:1); });
1237
+ pickerMins.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('i', ((d<0)?-1:1)*o.minuteStep); });
1238
+ pickerMeri.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('a', d); });
1239
+ controlsPlus.bind('mousewheel', function(e,d) {
1240
+ e.preventDefault();
1241
+ if ( o.fieldsOrder.length === 3 ) {
1242
+ fld = o.fieldsOrder[parseInt((e.pageX - $(e.currentTarget).offset().left) / 87, 10)];
1243
+ } else if ( o.fieldsOrder.length === 2 ) {
1244
+ fld = o.fieldsOrder[parseInt((e.pageX - $(e.currentTarget).offset().left) / 130, 10)];
1245
+ }
1246
+ self._offset(fld, ((d<0)?-1:1) * ((fld==="i")?o.minuteStep:1));
1247
+ });
1248
+ }
1249
+
1250
+ for(x=0; x<=o.fieldsOrder.length; x++) { // Use fieldsOrder to decide which to show.
1251
+ if (o.fieldsOrder[x] === 'y') { pickerYar.appendTo(controlsInput); }
1252
+ if (o.fieldsOrder[x] === 'm') { pickerMon.appendTo(controlsInput); }
1253
+ if (o.fieldsOrder[x] === 'd') { pickerDay.appendTo(controlsInput); }
1254
+ if (o.fieldsOrder[x] === 'h') { pickerHour.appendTo(controlsInput); }
1255
+ if (o.fieldsOrder[x] === 'i') { pickerMins.appendTo(controlsInput); }
1256
+ if (o.fieldsOrder[x] === 'a' && o.timeFormat === 12 ) { pickerMeri.appendTo(controlsInput); }
1257
+ }
1258
+
1259
+ if ( o.swipeEnabled ) { // Drag and drop support
1260
+ controlsInput.find('ul').bind(self.START_DRAG, function(e,f) {
1261
+ if ( !self.dragMove ) {
1262
+ if ( typeof f !== "undefined" ) { e = f; }
1263
+ self.dragMove = true;
1264
+ self.dragTarget = $(this).find('li').first();
1265
+ self.dragPos = parseInt(self.dragTarget.css('marginTop').replace(/px/i, ''),10);
1266
+ self.dragStart = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1267
+ self.dragEnd = false;
1268
+ e.stopPropagation();
1269
+ e.preventDefault();
1270
+ }
1271
+ });
1272
+ controlsPlus.bind(self.START_DRAG, function(e) {
1273
+ if ( !self.dragMove ) {
1274
+ self.dragTarget = self.touch ? e.originalEvent.changedTouches[0].pageX - $(e.currentTarget).offset().left : e.pageX - $(e.currentTarget).offset().left;
1275
+ if ( o.fieldsOrder.length === 3 ) {
1276
+ $(self.controlsInput.find('ul').get(parseInt(self.dragTarget / 87, 10))).trigger(self.START_DRAG, e);
1277
+ } else if ( o.fieldsOrder.length === 2 ) {
1278
+ $(self.controlsInput.find('ul').get(parseInt(self.dragTarget / 130, 10))).trigger(self.START_DRAG, e);
1279
+ }
1280
+ }
1281
+ });
1282
+ }
1283
+
1284
+ if ( o.noSetButton === false ) { // Set button at bottom
1285
+ $("<a href='#'>" + ((o.mode==='timeflipbox')?o.setTimeButtonLabel:o.setDateButtonLabel) + "</a>")
1286
+ .appendTo(controlsSet).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1287
+ .bind('vclick', function(e) {
1288
+ e.preventDefault();
1289
+ if ( o.mode === 'timeflipbox' ) { self.input.trigger('datebox', {'method':'set', 'value':self._formatTime(self.theDate)}); }
1290
+ else { self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)}); }
1291
+ self.input.trigger('datebox', {'method':'close'});
1292
+ });
1293
+ }
1294
+
1295
+ $.extend(self, {
1296
+ controlsHeader: controlsHeader,
1297
+ controlsInput: controlsInput,
1298
+ pickerDay: pickerDay,
1299
+ pickerMon: pickerMon,
1300
+ pickerYar: pickerYar,
1301
+ pickerHour: pickerHour,
1302
+ pickerMins: pickerMins,
1303
+ pickerMeri: pickerMeri
1304
+ });
1305
+
1306
+ pickerContent.appendTo(self.thisPage);
1307
+
1308
+ }
1309
+ /* END:FLIPBOX */
1310
+ /* BEGIN:DURATIONBOX */
1311
+ if ( o.mode === 'durationbox' ) {
1312
+ controlsPlus = templControls.clone().removeClass('ui-datebox-controls').addClass('ui-datebox-scontrols').appendTo(pickerContent);
1313
+ controlsInput = controlsPlus.clone().appendTo(pickerContent);
1314
+ controlsMinus = controlsPlus.clone().appendTo(pickerContent);
1315
+ controlsSet = templControls.clone().appendTo(pickerContent);
1316
+
1317
+ pickerDay = templInput.removeClass('ui-datebox-input').clone()
1318
+ .keyup(function() { if ( $(this).val() !== '' ) { self._updateduration(); } });
1319
+
1320
+ pickerHour = pickerDay.clone().keyup(function() { if ( $(this).val() !== '' ) { self._updateduration(); } });
1321
+ pickerMins = pickerDay.clone().keyup(function() { if ( $(this).val() !== '' ) { self._updateduration(); } });
1322
+ pickerSecs = pickerDay.clone().keyup(function() { if ( $(this).val() !== '' ) { self._updateduration(); } });
1323
+
1324
+ if ( o.wheelExists ) { // Mousewheel operation, if the plgin is loaded
1325
+ pickerDay.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('d', ((d<0)?-1:1)*o.durationSteppers['d']); });
1326
+ pickerHour.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('h', ((d<0)?-1:1)*o.durationSteppers['h']); });
1327
+ pickerMins.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('i', ((d<0)?-1:1)*o.durationSteppers['i']); });
1328
+ pickerSecs.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('s', ((d<0)?-1:1)*o.durationSteppers['s']); });
1329
+ }
1330
+
1331
+ for ( x=0; x<o.durationOrder.length; x++ ) { // Use durationOrder to decide what goes where
1332
+ switch ( o.durationOrder[x] ) {
1333
+ case 'd':
1334
+ $('<div>', {'class': 'ui-datebox-sinput', 'data-field': 'd'}).append(pickerDay).appendTo(controlsInput).prepend('<label>'+o.durationLabel[0]+'</label>');
1335
+ break;
1336
+ case 'h':
1337
+ $('<div>', {'class': 'ui-datebox-sinput', 'data-field': 'h'}).append(pickerHour).appendTo(controlsInput).prepend('<label>'+o.durationLabel[1]+'</label>');
1338
+ break;
1339
+ case 'i':
1340
+ $('<div>', {'class': 'ui-datebox-sinput', 'data-field': 'i'}).append(pickerMins).appendTo(controlsInput).prepend('<label>'+o.durationLabel[2]+'</label>');
1341
+ break;
1342
+ case 's':
1343
+ $('<div>', {'class': 'ui-datebox-sinput', 'data-field': 's'}).append(pickerSecs).appendTo(controlsInput).prepend('<label>'+o.durationLabel[3]+'</label>');
1344
+ break;
1345
+ }
1346
+ }
1347
+
1348
+ if ( o.swipeEnabled ) { // Drag and drop operation
1349
+ controlsInput.find('input').bind(self.START_DRAG, function(e) {
1350
+ if ( !self.dragMove ) {
1351
+ self.dragMove = true;
1352
+ self.dragTarget = $(this).parent().data('field');
1353
+ self.dragPos = 0;
1354
+ self.dragStart = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1355
+ self.dragEnd = false;
1356
+ e.stopPropagation();
1357
+ }
1358
+ });
1359
+ }
1360
+
1361
+ if ( o.noSetButton === false ) { // Bottom set button
1362
+ $("<a href='#'>" + o.setDurationButtonLabel + "</a>")
1363
+ .appendTo(controlsSet).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1364
+ .bind('vclick', function(e) {
1365
+ e.preventDefault();
1366
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatTime(self.theDate)});
1367
+ self.input.trigger('datebox', {'method':'close'});
1368
+ });
1369
+ }
1370
+
1371
+ for ( x=0; x<o.durationOrder.length; x++ ) {
1372
+ linkdiv.clone()
1373
+ .appendTo(controlsPlus).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'plus', iconpos: 'bottom', corners:true, shadow:true})
1374
+ .attr('data-field', o.durationOrder[x])
1375
+ .bind('vclick', function(e) {
1376
+ e.preventDefault();
1377
+ self._offset($(this).attr('data-field'),o.durationSteppers[$(this).attr('data-field')]);
1378
+ });
1379
+
1380
+ linkdiv.clone()
1381
+ .appendTo(controlsMinus).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'minus', iconpos: 'top', corners:true, shadow:true})
1382
+ .attr('data-field', o.durationOrder[x])
1383
+ .bind('vclick', function(e) {
1384
+ e.preventDefault();
1385
+ self._offset($(this).attr('data-field'),-1*o.durationSteppers[$(this).attr('data-field')]);
1386
+ });
1387
+ }
1388
+
1389
+ $.extend(self, {
1390
+ pickerHour: pickerHour,
1391
+ pickerMins: pickerMins,
1392
+ pickerDay: pickerDay,
1393
+ pickerSecs: pickerSecs
1394
+ });
1395
+
1396
+ pickerContent.appendTo(self.thisPage);
1397
+ }
1398
+ /* END:DURATIONBOX */
1399
+ /* BEGIN:DATETIME */
1400
+ if ( o.mode === 'datebox' || o.mode === 'timebox' ) {
1401
+ controlsHeader = $("<div class='ui-datebox-header'><h4>Unitialized</h4></div>").appendTo(pickerContent).find("h4");
1402
+ controlsPlus = templControls.clone().appendTo(pickerContent);
1403
+ controlsInput = templControls.clone().appendTo(pickerContent);
1404
+ controlsMinus = templControls.clone().appendTo(pickerContent);
1405
+ controlsSet = templControls.clone().appendTo(pickerContent);
1406
+
1407
+ if ( o.mode === 'timebox' ) { controlsHeader.parent().html(''); } // Time mode has no header
1408
+
1409
+ pickerMon = templInput.clone()
1410
+ .attr('data-field', 'm')
1411
+ .keyup(function() {
1412
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1413
+ self.theDate.setMonth(parseInt($(this).val(),10)-1);
1414
+ self._update();
1415
+ }
1416
+ });
1417
+
1418
+ pickerDay = pickerMon.clone()
1419
+ .attr('data-field', 'd')
1420
+ .keyup(function() {
1421
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1422
+ self.theDate.setDate(parseInt($(this).val(),10));
1423
+ self._update();
1424
+ }
1425
+ });
1426
+
1427
+ pickerYar = pickerMon.clone()
1428
+ .attr('data-field', 'y')
1429
+ .keyup(function() {
1430
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1431
+ self.theDate.setFullYear(parseInt($(this).val(),10));
1432
+ self._update();
1433
+ }
1434
+ });
1435
+
1436
+ pickerHour = templInput.clone()
1437
+ .attr('data-field', 'h')
1438
+ .keyup(function() {
1439
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1440
+ newHour = parseInt($(this).val(),10);
1441
+ if ( newHour === 12 ) {
1442
+ if ( o.timeFormat === 12 && pickerMeri.val() === o.meridiemLetters[0] ) { newHour = 0; }
1443
+ }
1444
+ self.theDate.setHours(newHour);
1445
+ self._update();
1446
+ }
1447
+ });
1448
+
1449
+ pickerMins = templInput.clone()
1450
+ .attr('data-field', 'i')
1451
+ .keyup(function() {
1452
+ if ( $(this).val() !== '' && self._isInt($(this).val()) ) {
1453
+ self.theDate.setMinutes(parseInt($(this).val(),10));
1454
+ self._update();
1455
+ }
1456
+ });
1457
+
1458
+ pickerMeri = templInput.clone()
1459
+ .attr('data-field', 'a')
1460
+ .keyup(function() {
1461
+ if ( $(this).val() !== '' ) {
1462
+ self._update();
1463
+ }
1464
+ });
1465
+
1466
+ if ( o.wheelExists ) { // Mousewheel operation, if plugin is loaded
1467
+ pickerYar.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('y', (d<0)?-1:1); });
1468
+ pickerMon.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('m', (d<0)?-1:1); });
1469
+ pickerDay.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('d', (d<0)?-1:1); });
1470
+ pickerHour.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('h', (d<0)?-1:1); });
1471
+ pickerMins.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('i', ((d<0)?-1:1)*o.minuteStep); });
1472
+ pickerMeri.bind('mousewheel', function(e,d) { e.preventDefault(); self._offset('a', d); });
1473
+ }
1474
+
1475
+ for(x=0; x<=o.fieldsOrder.length; x++) { // Use fieldsOrder to decide what goes where
1476
+ if (o.fieldsOrder[x] === 'y') { pickerYar.appendTo(controlsInput); }
1477
+ if (o.fieldsOrder[x] === 'm') { pickerMon.appendTo(controlsInput); }
1478
+ if (o.fieldsOrder[x] === 'd') { pickerDay.appendTo(controlsInput); }
1479
+ if (o.fieldsOrder[x] === 'h') { pickerHour.appendTo(controlsInput); }
1480
+ if (o.fieldsOrder[x] === 'i') { pickerMins.appendTo(controlsInput); }
1481
+ if (o.fieldsOrder[x] === 'a' && o.timeFormat === 12 ) { pickerMeri.appendTo(controlsInput); }
1482
+ }
1483
+
1484
+ if ( o.swipeEnabled ) { // Drag and drop support
1485
+ controlsInput.find('input').bind(self.START_DRAG, function(e) {
1486
+ if ( !self.dragMove ) {
1487
+ self.dragMove = true;
1488
+ self.dragTarget = $(this).data('field');
1489
+ self.dragPos = 0;
1490
+ self.dragStart = self.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
1491
+ self.dragEnd = false;
1492
+ e.stopPropagation();
1493
+ }
1494
+ });
1495
+ }
1496
+
1497
+ if ( o.noSetButton === false ) { // Set button at bottom
1498
+ $("<a href='#'>" + ((o.mode==='timebox')?o.setTimeButtonLabel:o.setDateButtonLabel) + "</a>")
1499
+ .appendTo(controlsSet).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1500
+ .bind('vclick', function(e) {
1501
+ e.preventDefault();
1502
+ if ( o.mode === 'timebox' ) { self.input.trigger('datebox', {'method':'set', 'value':self._formatTime(self.theDate)}); }
1503
+ else { self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)}); }
1504
+ self.input.trigger('datebox', {'method':'close'});
1505
+ });
1506
+ }
1507
+
1508
+ for( x=0; x<self.options.fieldsOrder.length; x++ ) { // Generate the plus and minus buttons, use fieldsOrder again
1509
+ if ( o.fieldsOrder[x] !== 'a' || o.timeFormat === 12 ) {
1510
+ linkdiv.clone()
1511
+ .appendTo(controlsPlus).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'plus', iconpos: 'bottom', corners:true, shadow:true})
1512
+ .attr('data-field', o.fieldsOrder[x])
1513
+ .bind('vclick', function(e) {
1514
+ e.preventDefault();
1515
+ self._offset($(this).attr('data-field'),1*($(this).attr('data-field')==='i'?o.minuteStep:1));
1516
+ });
1517
+ linkdiv.clone()
1518
+ .appendTo(controlsMinus).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'minus', iconpos: 'top', corners:true, shadow:true})
1519
+ .attr('data-field', o.fieldsOrder[x])
1520
+ .bind('vclick', function(e) {
1521
+ e.preventDefault();
1522
+ self._offset($(this).attr('data-field'),-1*($(this).attr('data-field')==='i'?o.minuteStep:1));
1523
+ });
1524
+ }
1525
+ }
1526
+
1527
+ $.extend(self, {
1528
+ controlsHeader: controlsHeader,
1529
+ pickerDay: pickerDay,
1530
+ pickerMon: pickerMon,
1531
+ pickerYar: pickerYar,
1532
+ pickerHour: pickerHour,
1533
+ pickerMins: pickerMins,
1534
+ pickerMeri: pickerMeri
1535
+ });
1536
+
1537
+ pickerContent.appendTo(self.thisPage);
1538
+ }
1539
+ /* END:DATETIME */
1540
+ /* BEGIN:CALBOX */
1541
+ if ( o.mode === 'calbox' ) {
1542
+ controlsHeader = $("<div>", {"class": 'ui-datebox-gridheader'}).appendTo(pickerContent);
1543
+ controlsSet = $("<div>", {"class": 'ui-datebox-grid'}).appendTo(pickerContent);
1544
+ controlsInput = $("<div class='ui-datebox-gridlabel'><h4>Uninitialized</h4></div>").appendTo(controlsHeader).find('h4');
1545
+
1546
+ if ( o.swipeEnabled ) { // Calendar swipe left and right
1547
+ pickerContent
1548
+ .bind('swipeleft', function() { if ( !self.calNoNext ) { self._offset('m', 1); } })
1549
+ .bind('swiperight', function() { if ( !self.calNoPrev ) { self._offset('m', -1); } });
1550
+ }
1551
+
1552
+ if ( o.wheelExists) { // Mousewheel operations, if plugin is loaded
1553
+ pickerContent.bind('mousewheel', function(e,d) {
1554
+ e.preventDefault();
1555
+ if ( d > 0 && !self.calNoNext ) {
1556
+ if ( self.theDate.getDate() > 28 ) { self.theDate.setDate(1); }
1557
+ self._offset('m', 1);
1558
+ }
1559
+ if ( d < 0 && !self.calNoPrev ) {
1560
+ if ( self.theDate.getDate() > 28 ) { self.theDate.setDate(1); }
1561
+ self._offset('m', -1);
1562
+ }
1563
+ });
1564
+ }
1565
+
1566
+ // Previous and next month buttons, define booleans to decide if they should do anything
1567
+ $("<div class='ui-datebox-gridplus'><a href='#'>Next Month</a></div>")
1568
+ .prependTo(controlsHeader).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'plus', inline: true, iconpos: 'notext', corners:true, shadow:true})
1569
+ .bind('vclick', function(e) {
1570
+ e.preventDefault();
1571
+ if ( ! self.calNoNext ) {
1572
+ if ( self.theDate.getDate() > 28 ) { self.theDate.setDate(1); }
1573
+ self._offset('m',1);
1574
+ }
1575
+ });
1576
+ $("<div class='ui-datebox-gridminus'><a href='#'>Prev Month</a></div>")
1577
+ .prependTo(controlsHeader).buttonMarkup({theme: o.pickPageButtonTheme, icon: 'minus', inline: true, iconpos: 'notext', corners:true, shadow:true})
1578
+ .bind('vclick', function(e) {
1579
+ e.preventDefault();
1580
+ if ( ! self.calNoPrev ) {
1581
+ if ( self.theDate.getDate() > 28 ) { self.theDate.setDate(1); }
1582
+ self._offset('m',-1);
1583
+ }
1584
+ });
1585
+
1586
+ if ( o.calTodayButton === true ) { // Show today button at bottom
1587
+ $("<a href='#'>" + o.calTodayButtonLabel + "</a>")
1588
+ .appendTo(pickerContent).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1589
+ .bind('vclick', function(e) {
1590
+ e.preventDefault();
1591
+ self.theDate = new Date();
1592
+ self.theDate = new Date(self.theDate.getFullYear(), self.theDate.getMonth(), self.theDate.getDate(), 0,0,0,0);
1593
+ self.input.trigger('datebox', {'method':'doset'});
1594
+ });
1595
+ }
1596
+
1597
+ $.extend(self, {
1598
+ controlsInput: controlsInput,
1599
+ controlsSet: controlsSet,
1600
+ calNoNext: calNoNext,
1601
+ calNoPrev: calNoPrev
1602
+ });
1603
+
1604
+ pickerContent.appendTo(self.thisPage);
1605
+ }
1606
+ /* END:CALBOX */
1607
+ /* BEGIN:SLIDEBOX */
1608
+ if ( o.mode === 'slidebox' ) {
1609
+ controlsHeader = $("<div class='ui-datebox-header'><h4>Unitialized</h4></div>").appendTo(pickerContent).find("h4");
1610
+ controlsInput = $('<div>').addClass('ui-datebox-slide').appendTo(pickerContent);
1611
+ controlsSet = $("<div>", { "class":'ui-datebox-controls'}).appendTo(pickerContent);
1612
+
1613
+ if ( o.noSetButton === false ) { // Show set button at bottom
1614
+ $("<a href='#'>" + o.setDateButtonLabel + "</a>")
1615
+ .appendTo(controlsSet).buttonMarkup({theme: o.pickPageTheme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
1616
+ .bind('vclick', function(e) {
1617
+ e.preventDefault();
1618
+ self.input.trigger('datebox', {'method':'set', 'value':self._formatDate(self.theDate)});
1619
+ self.input.trigger('datebox', {'method':'close'});
1620
+ });
1621
+ }
1622
+
1623
+ $.extend(self, {
1624
+ controlsHeader: controlsHeader,
1625
+ controlsInput: controlsInput
1626
+ });
1627
+
1628
+ pickerContent.appendTo(self.thisPage);
1629
+ }
1630
+ /* END:SLIDEBOX */
1631
+
1632
+ $.extend(self, {
1633
+ pickerContent: pickerContent,
1634
+ screen: screen
1635
+ });
1636
+
1637
+ // If useInline mode, drop it into the document, and stop a few events from working (or just hide the trigger)
1638
+ if ( o.useInline ) {
1639
+ self.input.parent().parent().append(self.pickerContent);
1640
+ if ( o.useInlineHideInput ) { self.input.parent().hide(); }
1641
+ self.input.trigger('change');
1642
+ self.pickerContent.removeClass('ui-datebox-hidden');
1643
+ }
1644
+
1645
+ },
1646
+ refresh: function() {
1647
+ // Pulic shortcut to _update, with an extra hook for inline mode.
1648
+ if ( this.options.useInline === true ) {
1649
+ this.input.trigger('change');
1650
+ }
1651
+ this._update();
1652
+ },
1653
+ open: function() {
1654
+ // Open the controls
1655
+ if ( this.options.useInline ) { return false; } // Ignore if inline
1656
+ if ( this.pickPage.is(':visible') ) { return false; } // Ignore if already open
1657
+
1658
+ this.input.trigger('change').blur(); // Grab latest value of input, in case it changed
1659
+
1660
+ var self = this,
1661
+ o = this.options,
1662
+ inputOffset = self.focusedEl.offset(),
1663
+ pickWinHeight = self.pickerContent.outerHeight(),
1664
+ pickWinWidth = self.pickerContent.innerWidth(),
1665
+ pickWinTop = inputOffset.top + ( self.focusedEl.outerHeight() / 2 )- ( pickWinHeight / 2),
1666
+ pickWinLeft = inputOffset.left + ( self.focusedEl.outerWidth() / 2) - ( pickWinWidth / 2),
1667
+ transition = o.noAnimation ? 'none' : 'pop',
1668
+ activePage;
1669
+
1670
+ // TOO FAR RIGHT TRAP
1671
+ if ( (pickWinLeft + pickWinWidth) > $(document).width() ) {
1672
+ pickWinLeft = $(document).width() - pickWinWidth - 1;
1673
+ }
1674
+ // TOO FAR LEFT TRAP
1675
+ if ( pickWinLeft < 0 ) {
1676
+ pickWinLeft = 0;
1677
+ }
1678
+ // Center popup on request - centered in document, not any containing div.
1679
+ if ( o.centerWindow ) {
1680
+ pickWinLeft = ( $(document).width() / 2 ) - ( pickWinWidth / 2 );
1681
+ }
1682
+
1683
+ if ( (pickWinHeight + pickWinTop) > $(document).height() ) {
1684
+ pickWinTop = $(document).height() - (pickWinHeight + 2);
1685
+ }
1686
+ if ( pickWinTop < 45 ) { pickWinTop = 45; }
1687
+
1688
+ // If the window is less than 400px wide, use the jQM dialog method unless otherwise forced
1689
+ if ( ( $(document).width() > 400 && !o.useDialogForceTrue ) || o.useDialogForceFalse ) {
1690
+ o.useDialog = false;
1691
+ if ( o.nestedBox ) {
1692
+ if ( pickWinHeight === 0 ) { // The box may have no height since it dosen't exist yet. working on it.
1693
+ pickWinHeight = 250;
1694
+ pickWinTop = inputOffset.top + ( self.focusedEl.outerHeight() / 2 )- ( pickWinHeight / 2);
1695
+ }
1696
+ activePage = $('.ui-page-active').first();
1697
+ $(activePage).append(self.pickerContent);
1698
+ $(activePage).append(self.screen);
1699
+ }
1700
+ if ( o.useModal ) { // If model, fade the background screen
1701
+ self.screen.fadeIn('slow');
1702
+ } else { // Else just unhide it since it's transparent
1703
+ self.screen.removeClass('ui-datebox-hidden');
1704
+ }
1705
+ self.pickerContent.addClass('ui-overlay-shadow in').css({'position': 'absolute', 'top': pickWinTop, 'left': pickWinLeft}).removeClass('ui-datebox-hidden');
1706
+ } else {
1707
+ // prevent the parent page from being removed from the DOM,
1708
+ self.thisPage.unbind( "pagehide.remove" );
1709
+ o.useDialog = true;
1710
+ self.pickPageContent.append(self.pickerContent);
1711
+ self.pickerContent.css({'top': 'auto', 'left': 'auto', 'marginLeft': 'auto', 'marginRight': 'auto'}).removeClass('ui-overlay-shadow ui-datebox-hidden');
1712
+ $.mobile.changePage(self.pickPage, {'transition': transition});
1713
+ }
1714
+ },
1715
+ close: function() {
1716
+ // Close the controls
1717
+ var self = this,
1718
+ callback;
1719
+
1720
+ if ( self.options.useInline ) {
1721
+ return true;
1722
+ }
1723
+
1724
+ // Check options to see if we are closing a dialog, or removing a popup
1725
+ if ( self.options.useDialog ) {
1726
+ $(self.pickPage).dialog('close');
1727
+ if( !self.thisPage.data("page").options.domCache ){
1728
+ self.thisPage.bind( "pagehide.remove", function() {
1729
+ $(self).remove();
1730
+ });
1731
+ }
1732
+ self.pickerContent.addClass('ui-datebox-hidden').removeAttr('style').css('zIndex', self.options.zindex);
1733
+ self.thisPage.append(self.pickerContent);
1734
+ } else {
1735
+ if ( self.options.useModal ) {
1736
+ self.screen.fadeOut('slow');
1737
+ } else {
1738
+ self.screen.addClass('ui-datebox-hidden');
1739
+ }
1740
+ self.pickerContent.addClass('ui-datebox-hidden').removeAttr('style').css('zIndex', self.options.zindex).removeClass('in');
1741
+ }
1742
+ self.focusedEl.removeClass('ui-focus');
1743
+
1744
+ if ( self.options.closeCallback !== false ) { callback = new Function(self.options.closeCallback); callback(); }
1745
+ },
1746
+ disable: function(){
1747
+ // Disable the element
1748
+ this.element.attr("disabled",true);
1749
+ this.element.parent().addClass("ui-disabled");
1750
+ this.options.disabled = true;
1751
+ this.element.blur();
1752
+ this.input.trigger('datebox', {'method':'disable'});
1753
+ },
1754
+ enable: function(){
1755
+ // Enable the element
1756
+ this.element.attr("disabled", false);
1757
+ this.element.parent().removeClass("ui-disabled");
1758
+ this.options.disabled = false;
1759
+ this.input.trigger('datebox', {'method':'enable'});
1760
+ }
1761
+
1762
+ });
1763
+
1764
+ // Degrade date inputs to text inputs, suppress standard UI functions.
1765
+ $( document ).bind( "pagebeforecreate", function( e ) {
1766
+ $( ":jqmData(role='datebox')", e.target ).each(function() {
1767
+ $(this).replaceWith(
1768
+ $( "<div>" ).html( $(this).clone() ).html()
1769
+ .replace( /\s+type=["']date['"]?/, " type=\"text\" " )
1770
+ );
1771
+ });
1772
+ });
1773
+ // Automatically bind to data-role='datebox' items.
1774
+ $( document ).bind( "pagecreate", function( e ){
1775
+ $( ":jqmData(role='datebox')", e.target ).datebox();
1776
+ });
1777
+
1778
+ })( jQuery );