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,1084 @@
1
+ /*!
2
+ * iScroll v4.1.9 ~ Copyright (c) 2011 Matteo Spinelli, http://cubiq.org
3
+ * Released under MIT license, http://cubiq.org/license
4
+ */
5
+ (function(){
6
+ var m = Math,
7
+ mround = function (r) { return r >> 0; },
8
+ vendor = (/webkit/i).test(navigator.appVersion) ? 'webkit' :
9
+ (/firefox/i).test(navigator.userAgent) ? 'Moz' :
10
+ 'opera' in window ? 'O' : '',
11
+
12
+ // Browser capabilities
13
+ isAndroid = (/android/gi).test(navigator.appVersion),
14
+ isIDevice = (/iphone|ipad/gi).test(navigator.appVersion),
15
+ isPlaybook = (/playbook/gi).test(navigator.appVersion),
16
+ isTouchPad = (/hp-tablet/gi).test(navigator.appVersion),
17
+
18
+ has3d = 'WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix(),
19
+ hasTouch = 'ontouchstart' in window && !isTouchPad,
20
+ hasTransform = vendor + 'Transform' in document.documentElement.style,
21
+ hasTransitionEnd = isIDevice || isPlaybook,
22
+
23
+ nextFrame = (function() {
24
+ return window.requestAnimationFrame
25
+ || window.webkitRequestAnimationFrame
26
+ || window.mozRequestAnimationFrame
27
+ || window.oRequestAnimationFrame
28
+ || window.msRequestAnimationFrame
29
+ || function(callback) { return setTimeout(callback, 1); }
30
+ })(),
31
+ cancelFrame = (function () {
32
+ return window.cancelRequestAnimationFrame
33
+ || window.webkitCancelRequestAnimationFrame
34
+ || window.mozCancelRequestAnimationFrame
35
+ || window.oCancelRequestAnimationFrame
36
+ || window.msCancelRequestAnimationFrame
37
+ || clearTimeout
38
+ })(),
39
+
40
+ // Events
41
+ RESIZE_EV = 'onorientationchange' in window ? 'orientationchange' : 'resize',
42
+ START_EV = hasTouch ? 'touchstart' : 'mousedown',
43
+ MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
44
+ END_EV = hasTouch ? 'touchend' : 'mouseup',
45
+ CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup',
46
+ WHEEL_EV = vendor == 'Moz' ? 'DOMMouseScroll' : 'mousewheel',
47
+
48
+ // Helpers
49
+ trnOpen = 'translate' + (has3d ? '3d(' : '('),
50
+ trnClose = has3d ? ',0)' : ')',
51
+
52
+ // Constructor
53
+ iScroll = function (el, options) {
54
+ var that = this,
55
+ doc = document,
56
+ i;
57
+
58
+ that.wrapper = typeof el == 'object' ? el : doc.getElementById(el);
59
+ that.wrapper.style.overflow = 'hidden';
60
+ that.scroller = that.wrapper.children[0];
61
+
62
+ // Default options
63
+ that.options = {
64
+ hScroll: true,
65
+ vScroll: true,
66
+ x: 0,
67
+ y: 0,
68
+ bounce: true,
69
+ bounceLock: false,
70
+ momentum: true,
71
+ lockDirection: true,
72
+ useTransform: true,
73
+ useTransition: false,
74
+ topOffset: 0,
75
+ checkDOMChanges: false, // Experimental
76
+
77
+ // Scrollbar
78
+ hScrollbar: true,
79
+ vScrollbar: true,
80
+ fixedScrollbar: isAndroid,
81
+ hideScrollbar: isIDevice,
82
+ fadeScrollbar: isIDevice && has3d,
83
+ scrollbarClass: '',
84
+
85
+ // Zoom
86
+ zoom: false,
87
+ zoomMin: 1,
88
+ zoomMax: 4,
89
+ doubleTapZoom: 2,
90
+ wheelAction: 'scroll',
91
+
92
+ // Snap
93
+ snap: false,
94
+ snapThreshold: 1,
95
+
96
+ // Events
97
+ onRefresh: null,
98
+ onBeforeScrollStart: function (e) { e.preventDefault(); },
99
+ onScrollStart: null,
100
+ onBeforeScrollMove: null,
101
+ onScrollMove: null,
102
+ onBeforeScrollEnd: null,
103
+ onScrollEnd: null,
104
+ onTouchEnd: null,
105
+ onDestroy: null,
106
+ onZoomStart: null,
107
+ onZoom: null,
108
+ onZoomEnd: null
109
+ };
110
+
111
+ // User defined options
112
+ for (i in options) that.options[i] = options[i];
113
+
114
+ // Set starting position
115
+ that.x = that.options.x;
116
+ that.y = that.options.y;
117
+
118
+ // Normalize options
119
+ that.options.useTransform = hasTransform ? that.options.useTransform : false;
120
+ that.options.hScrollbar = that.options.hScroll && that.options.hScrollbar;
121
+ that.options.vScrollbar = that.options.vScroll && that.options.vScrollbar;
122
+ that.options.zoom = that.options.useTransform && that.options.zoom;
123
+ that.options.useTransition = hasTransitionEnd && that.options.useTransition;
124
+
125
+ // Helpers FIX ANDROID BUG!
126
+ // translate3d and scale doesn't work together!
127
+ // Ignoring 3d ONLY WHEN YOU SET that.options.zoom
128
+ if ( that.options.zoom && isAndroid ){
129
+ trnOpen = 'translate(';
130
+ trnClose = ')';
131
+ }
132
+
133
+ // Set some default styles
134
+ that.scroller.style[vendor + 'TransitionProperty'] = that.options.useTransform ? '-' + vendor.toLowerCase() + '-transform' : 'top left';
135
+ that.scroller.style[vendor + 'TransitionDuration'] = '0';
136
+ that.scroller.style[vendor + 'TransformOrigin'] = '0 0';
137
+ if (that.options.useTransition) that.scroller.style[vendor + 'TransitionTimingFunction'] = 'cubic-bezier(0.33,0.66,0.66,1)';
138
+
139
+ if (that.options.useTransform) that.scroller.style[vendor + 'Transform'] = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose;
140
+ else that.scroller.style.cssText += ';position:absolute;top:' + that.y + 'px;left:' + that.x + 'px';
141
+
142
+ if (that.options.useTransition) that.options.fixedScrollbar = true;
143
+
144
+ that.refresh();
145
+
146
+ that._bind(RESIZE_EV, window);
147
+ that._bind(START_EV);
148
+ if (!hasTouch) {
149
+ that._bind('mouseout', that.wrapper);
150
+ if (that.options.wheelAction != 'none')
151
+ that._bind(WHEEL_EV);
152
+ }
153
+
154
+ if (that.options.checkDOMChanges) that.checkDOMTime = setInterval(function () {
155
+ that._checkDOMChanges();
156
+ }, 500);
157
+ };
158
+
159
+ // Prototype
160
+ iScroll.prototype = {
161
+ enabled: true,
162
+ x: 0,
163
+ y: 0,
164
+ steps: [],
165
+ scale: 1,
166
+ currPageX: 0, currPageY: 0,
167
+ pagesX: [], pagesY: [],
168
+ aniTime: null,
169
+ wheelZoomCount: 0,
170
+
171
+ handleEvent: function (e) {
172
+ var that = this;
173
+ switch(e.type) {
174
+ case START_EV:
175
+ if (!hasTouch && e.button !== 0) return;
176
+ that._start(e);
177
+ break;
178
+ case MOVE_EV: that._move(e); break;
179
+ case END_EV:
180
+ case CANCEL_EV: that._end(e); break;
181
+ case RESIZE_EV: that._resize(); break;
182
+ case WHEEL_EV: that._wheel(e); break;
183
+ case 'mouseout': that._mouseout(e); break;
184
+ case 'webkitTransitionEnd': that._transitionEnd(e); break;
185
+ }
186
+ },
187
+
188
+ _checkDOMChanges: function () {
189
+ if (this.moved || this.zoomed || this.animating ||
190
+ (this.scrollerW == this.scroller.offsetWidth * this.scale && this.scrollerH == this.scroller.offsetHeight * this.scale)) return;
191
+
192
+ this.refresh();
193
+ },
194
+
195
+ _scrollbar: function (dir) {
196
+ var that = this,
197
+ doc = document,
198
+ bar;
199
+
200
+ if (!that[dir + 'Scrollbar']) {
201
+ if (that[dir + 'ScrollbarWrapper']) {
202
+ if (hasTransform) that[dir + 'ScrollbarIndicator'].style[vendor + 'Transform'] = '';
203
+ that[dir + 'ScrollbarWrapper'].parentNode.removeChild(that[dir + 'ScrollbarWrapper']);
204
+ that[dir + 'ScrollbarWrapper'] = null;
205
+ that[dir + 'ScrollbarIndicator'] = null;
206
+ }
207
+
208
+ return;
209
+ }
210
+
211
+ if (!that[dir + 'ScrollbarWrapper']) {
212
+ // Create the scrollbar wrapper
213
+ bar = doc.createElement('div');
214
+
215
+ if (that.options.scrollbarClass) bar.className = that.options.scrollbarClass + dir.toUpperCase();
216
+ else bar.style.cssText = 'position:absolute;z-index:100;' + (dir == 'h' ? 'height:7px;bottom:1px;left:2px;right:' + (that.vScrollbar ? '7' : '2') + 'px' : 'width:7px;bottom:' + (that.hScrollbar ? '7' : '2') + 'px;top:2px;right:1px');
217
+
218
+ bar.style.cssText += ';pointer-events:none;-' + vendor + '-transition-property:opacity;-' + vendor + '-transition-duration:' + (that.options.fadeScrollbar ? '350ms' : '0') + ';overflow:hidden;opacity:' + (that.options.hideScrollbar ? '0' : '1');
219
+
220
+ that.wrapper.appendChild(bar);
221
+ that[dir + 'ScrollbarWrapper'] = bar;
222
+
223
+ // Create the scrollbar indicator
224
+ bar = doc.createElement('div');
225
+ if (!that.options.scrollbarClass) {
226
+ bar.style.cssText = 'position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);-' + vendor + '-background-clip:padding-box;-' + vendor + '-box-sizing:border-box;' + (dir == 'h' ? 'height:100%' : 'width:100%') + ';-' + vendor + '-border-radius:3px;border-radius:3px';
227
+ }
228
+ bar.style.cssText += ';pointer-events:none;-' + vendor + '-transition-property:-' + vendor + '-transform;-' + vendor + '-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);-' + vendor + '-transition-duration:0;-' + vendor + '-transform:' + trnOpen + '0,0' + trnClose;
229
+ if (that.options.useTransition) bar.style.cssText += ';-' + vendor + '-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)';
230
+
231
+ that[dir + 'ScrollbarWrapper'].appendChild(bar);
232
+ that[dir + 'ScrollbarIndicator'] = bar;
233
+ }
234
+
235
+ if (dir == 'h') {
236
+ that.hScrollbarSize = that.hScrollbarWrapper.clientWidth;
237
+ that.hScrollbarIndicatorSize = m.max(mround(that.hScrollbarSize * that.hScrollbarSize / that.scrollerW), 8);
238
+ that.hScrollbarIndicator.style.width = that.hScrollbarIndicatorSize + 'px';
239
+ that.hScrollbarMaxScroll = that.hScrollbarSize - that.hScrollbarIndicatorSize;
240
+ that.hScrollbarProp = that.hScrollbarMaxScroll / that.maxScrollX;
241
+ } else {
242
+ that.vScrollbarSize = that.vScrollbarWrapper.clientHeight;
243
+ that.vScrollbarIndicatorSize = m.max(mround(that.vScrollbarSize * that.vScrollbarSize / that.scrollerH), 8);
244
+ that.vScrollbarIndicator.style.height = that.vScrollbarIndicatorSize + 'px';
245
+ that.vScrollbarMaxScroll = that.vScrollbarSize - that.vScrollbarIndicatorSize;
246
+ that.vScrollbarProp = that.vScrollbarMaxScroll / that.maxScrollY;
247
+ }
248
+
249
+ // Reset position
250
+ that._scrollbarPos(dir, true);
251
+ },
252
+
253
+ _resize: function () {
254
+ var that = this;
255
+ setTimeout(function () { that.refresh(); }, isAndroid ? 200 : 0);
256
+ },
257
+
258
+ _pos: function (x, y) {
259
+ x = this.hScroll ? x : 0;
260
+ y = this.vScroll ? y : 0;
261
+
262
+ if (this.options.useTransform) {
263
+ this.scroller.style[vendor + 'Transform'] = trnOpen + x + 'px,' + y + 'px' + trnClose + ' scale(' + this.scale + ')';
264
+ } else {
265
+ x = mround(x);
266
+ y = mround(y);
267
+ this.scroller.style.left = x + 'px';
268
+ this.scroller.style.top = y + 'px';
269
+ }
270
+
271
+ this.x = x;
272
+ this.y = y;
273
+
274
+ this._scrollbarPos('h');
275
+ this._scrollbarPos('v');
276
+ },
277
+
278
+ _scrollbarPos: function (dir, hidden) {
279
+ var that = this,
280
+ pos = dir == 'h' ? that.x : that.y,
281
+ size;
282
+
283
+ if (!that[dir + 'Scrollbar']) return;
284
+
285
+ pos = that[dir + 'ScrollbarProp'] * pos;
286
+
287
+ if (pos < 0) {
288
+ if (!that.options.fixedScrollbar) {
289
+ size = that[dir + 'ScrollbarIndicatorSize'] + mround(pos * 3);
290
+ if (size < 8) size = 8;
291
+ that[dir + 'ScrollbarIndicator'].style[dir == 'h' ? 'width' : 'height'] = size + 'px';
292
+ }
293
+ pos = 0;
294
+ } else if (pos > that[dir + 'ScrollbarMaxScroll']) {
295
+ if (!that.options.fixedScrollbar) {
296
+ size = that[dir + 'ScrollbarIndicatorSize'] - mround((pos - that[dir + 'ScrollbarMaxScroll']) * 3);
297
+ if (size < 8) size = 8;
298
+ that[dir + 'ScrollbarIndicator'].style[dir == 'h' ? 'width' : 'height'] = size + 'px';
299
+ pos = that[dir + 'ScrollbarMaxScroll'] + (that[dir + 'ScrollbarIndicatorSize'] - size);
300
+ } else {
301
+ pos = that[dir + 'ScrollbarMaxScroll'];
302
+ }
303
+ }
304
+
305
+ that[dir + 'ScrollbarWrapper'].style[vendor + 'TransitionDelay'] = '0';
306
+ that[dir + 'ScrollbarWrapper'].style.opacity = hidden && that.options.hideScrollbar ? '0' : '1';
307
+ that[dir + 'ScrollbarIndicator'].style[vendor + 'Transform'] = trnOpen + (dir == 'h' ? pos + 'px,0' : '0,' + pos + 'px') + trnClose;
308
+ },
309
+
310
+ _start: function (e) {
311
+ var that = this,
312
+ point = hasTouch ? e.touches[0] : e,
313
+ matrix, x, y,
314
+ c1, c2,
315
+ tagName = e.target.nodeName.toLowerCase();
316
+
317
+ if (tagName === "select" || tagName === "input" || tagName === "textarea") {
318
+ e.target.focus();
319
+ that.focusedInput = e.target;
320
+ return;
321
+ }
322
+
323
+ if (that.focusedInput){
324
+ that.focusedInput.blur();
325
+ that.focusedInput = false;
326
+ }
327
+
328
+ if (!that.enabled) return;
329
+
330
+ if (that.options.onBeforeScrollStart) that.options.onBeforeScrollStart.call(that, e);
331
+
332
+ if (that.options.useTransition || that.options.zoom) that._transitionTime(0);
333
+
334
+ that.moved = false;
335
+ that.animating = false;
336
+ that.zoomed = false;
337
+ that.distX = 0;
338
+ that.distY = 0;
339
+ that.absDistX = 0;
340
+ that.absDistY = 0;
341
+ that.dirX = 0;
342
+ that.dirY = 0;
343
+
344
+ // Gesture start
345
+ if (that.options.zoom && hasTouch && e.touches.length > 1) {
346
+ c1 = m.abs(e.touches[0].pageX-e.touches[1].pageX);
347
+ c2 = m.abs(e.touches[0].pageY-e.touches[1].pageY);
348
+ that.touchesDistStart = m.sqrt(c1 * c1 + c2 * c2);
349
+
350
+ that.originX = m.abs(e.touches[0].pageX + e.touches[1].pageX - that.wrapperOffsetLeft * 2) / 2 - that.x;
351
+ that.originY = m.abs(e.touches[0].pageY + e.touches[1].pageY - that.wrapperOffsetTop * 2) / 2 - that.y;
352
+
353
+ if (that.options.onZoomStart) that.options.onZoomStart.call(that, e);
354
+ }
355
+
356
+ if (that.options.momentum) {
357
+ if (that.options.useTransform) {
358
+ // Very lame general purpose alternative to CSSMatrix
359
+ matrix = getComputedStyle(that.scroller, null)[vendor + 'Transform'].replace(/[^0-9-.,]/g, '').split(',');
360
+ x = matrix[4] * 1;
361
+ y = matrix[5] * 1;
362
+ } else {
363
+ x = getComputedStyle(that.scroller, null).left.replace(/[^0-9-]/g, '') * 1;
364
+ y = getComputedStyle(that.scroller, null).top.replace(/[^0-9-]/g, '') * 1;
365
+ }
366
+
367
+ if (x != that.x || y != that.y) {
368
+ if (that.options.useTransition) that._unbind('webkitTransitionEnd');
369
+ else cancelFrame(that.aniTime);
370
+ that.steps = [];
371
+ that._pos(x, y);
372
+ }
373
+ }
374
+
375
+ that.absStartX = that.x; // Needed by snap threshold
376
+ that.absStartY = that.y;
377
+
378
+ that.startX = that.x;
379
+ that.startY = that.y;
380
+ that.pointX = point.pageX;
381
+ that.pointY = point.pageY;
382
+
383
+ that.startTime = e.timeStamp || Date.now();
384
+
385
+ if (that.options.onScrollStart) that.options.onScrollStart.call(that, e);
386
+
387
+ that._bind(MOVE_EV);
388
+ that._bind(END_EV);
389
+ that._bind(CANCEL_EV);
390
+ },
391
+
392
+ _move: function (e) {
393
+ var that = this,
394
+ point = hasTouch ? e.touches[0] : e,
395
+ deltaX = point.pageX - that.pointX,
396
+ deltaY = point.pageY - that.pointY,
397
+ newX = that.x + deltaX,
398
+ newY = that.y + deltaY,
399
+ c1, c2, scale,
400
+ timestamp = e.timeStamp || Date.now();
401
+
402
+ if (that.options.onBeforeScrollMove) that.options.onBeforeScrollMove.call(that, e);
403
+
404
+ // Zoom
405
+ if (that.options.zoom && hasTouch && e.touches.length > 1) {
406
+ c1 = m.abs(e.touches[0].pageX - e.touches[1].pageX);
407
+ c2 = m.abs(e.touches[0].pageY - e.touches[1].pageY);
408
+ that.touchesDist = m.sqrt(c1*c1+c2*c2);
409
+
410
+ that.zoomed = true;
411
+
412
+ scale = 1 / that.touchesDistStart * that.touchesDist * this.scale;
413
+
414
+ if (scale < that.options.zoomMin) scale = 0.5 * that.options.zoomMin * Math.pow(2.0, scale / that.options.zoomMin);
415
+ else if (scale > that.options.zoomMax) scale = 2.0 * that.options.zoomMax * Math.pow(0.5, that.options.zoomMax / scale);
416
+
417
+ that.lastScale = scale / this.scale;
418
+
419
+ newX = this.originX - this.originX * that.lastScale + this.x,
420
+ newY = this.originY - this.originY * that.lastScale + this.y;
421
+
422
+ this.scroller.style[vendor + 'Transform'] = trnOpen + newX + 'px,' + newY + 'px' + trnClose + ' scale(' + scale + ')';
423
+
424
+ if (that.options.onZoom) that.options.onZoom.call(that, e);
425
+ return;
426
+ }
427
+
428
+ that.pointX = point.pageX;
429
+ that.pointY = point.pageY;
430
+
431
+ // Slow down if outside of the boundaries
432
+ if (newX > 0 || newX < that.maxScrollX) {
433
+ newX = that.options.bounce ? that.x + (deltaX / 2) : newX >= 0 || that.maxScrollX >= 0 ? 0 : that.maxScrollX;
434
+ }
435
+ if (newY > that.minScrollY || newY < that.maxScrollY) {
436
+ newY = that.options.bounce ? that.y + (deltaY / 2) : newY >= that.minScrollY || that.maxScrollY >= 0 ? that.minScrollY : that.maxScrollY;
437
+ }
438
+
439
+ if (that.absDistX < 6 && that.absDistY < 6) {
440
+ that.distX += deltaX;
441
+ that.distY += deltaY;
442
+ that.absDistX = m.abs(that.distX);
443
+ that.absDistY = m.abs(that.distY);
444
+
445
+ return;
446
+ }
447
+
448
+ // Lock direction
449
+ if (that.options.lockDirection) {
450
+ if (that.absDistX > that.absDistY + 5) {
451
+ newY = that.y;
452
+ deltaY = 0;
453
+ } else if (that.absDistY > that.absDistX + 5) {
454
+ newX = that.x;
455
+ deltaX = 0;
456
+ }
457
+ }
458
+
459
+ that.moved = true;
460
+ that._pos(newX, newY);
461
+ that.dirX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
462
+ that.dirY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
463
+
464
+ if (timestamp - that.startTime > 300) {
465
+ that.startTime = timestamp;
466
+ that.startX = that.x;
467
+ that.startY = that.y;
468
+ }
469
+
470
+ if (that.options.onScrollMove) that.options.onScrollMove.call(that, e);
471
+ },
472
+
473
+ _end: function (e) {
474
+ if (hasTouch && e.touches.length != 0) return;
475
+
476
+ var that = this,
477
+ point = hasTouch ? e.changedTouches[0] : e,
478
+ target, ev,
479
+ momentumX = { dist:0, time:0 },
480
+ momentumY = { dist:0, time:0 },
481
+ duration = (e.timeStamp || Date.now()) - that.startTime,
482
+ newPosX = that.x,
483
+ newPosY = that.y,
484
+ distX, distY,
485
+ newDuration,
486
+ snap,
487
+ scale;
488
+
489
+ that._unbind(MOVE_EV);
490
+ that._unbind(END_EV);
491
+ that._unbind(CANCEL_EV);
492
+
493
+ if (that.options.onBeforeScrollEnd) that.options.onBeforeScrollEnd.call(that, e);
494
+
495
+ if (that.zoomed) {
496
+ scale = that.scale * that.lastScale;
497
+ scale = Math.max(that.options.zoomMin, scale);
498
+ scale = Math.min(that.options.zoomMax, scale);
499
+ that.lastScale = scale / that.scale;
500
+ that.scale = scale;
501
+
502
+ that.x = that.originX - that.originX * that.lastScale + that.x;
503
+ that.y = that.originY - that.originY * that.lastScale + that.y;
504
+
505
+ that.scroller.style[vendor + 'TransitionDuration'] = '200ms';
506
+ that.scroller.style[vendor + 'Transform'] = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose + ' scale(' + that.scale + ')';
507
+
508
+ that.zoomed = false;
509
+ that.refresh();
510
+
511
+ if (that.options.onZoomEnd) that.options.onZoomEnd.call(that, e);
512
+ return;
513
+ }
514
+
515
+ if (!that.moved) {
516
+ if (hasTouch) {
517
+ if (that.doubleTapTimer && that.options.zoom) {
518
+ // Double tapped
519
+ clearTimeout(that.doubleTapTimer);
520
+ that.doubleTapTimer = null;
521
+ if (that.options.onZoomStart) that.options.onZoomStart.call(that, e);
522
+ that.zoom(that.pointX, that.pointY, that.scale == 1 ? that.options.doubleTapZoom : 1);
523
+ if (that.options.onZoomEnd) {
524
+ setTimeout(function() {
525
+ that.options.onZoomEnd.call(that, e);
526
+ }, 200); // 200 is default zoom duration
527
+ }
528
+ } else {
529
+ that.doubleTapTimer = setTimeout(function () {
530
+ that.doubleTapTimer = null;
531
+
532
+ // Find the last touched element
533
+ target = point.target;
534
+ while (target.nodeType != 1) target = target.parentNode;
535
+
536
+ if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') {
537
+ ev = document.createEvent('MouseEvents');
538
+ ev.initMouseEvent('click', true, true, e.view, 1,
539
+ point.screenX, point.screenY, point.clientX, point.clientY,
540
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
541
+ 0, null);
542
+ ev._fake = true;
543
+ target.dispatchEvent(ev);
544
+ }
545
+ }, that.options.zoom ? 250 : 0);
546
+ }
547
+ }
548
+
549
+ that._resetPos(200);
550
+
551
+ if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
552
+ return;
553
+ }
554
+
555
+ if (duration < 300 && that.options.momentum) {
556
+ momentumX = newPosX ? that._momentum(newPosX - that.startX, duration, -that.x, that.scrollerW - that.wrapperW + that.x, that.options.bounce ? that.wrapperW : 0) : momentumX;
557
+ momentumY = newPosY ? that._momentum(newPosY - that.startY, duration, -that.y, (that.maxScrollY < 0 ? that.scrollerH - that.wrapperH + that.y - that.minScrollY : 0), that.options.bounce ? that.wrapperH : 0) : momentumY;
558
+
559
+ newPosX = that.x + momentumX.dist;
560
+ newPosY = that.y + momentumY.dist;
561
+
562
+ if ((that.x > 0 && newPosX > 0) || (that.x < that.maxScrollX && newPosX < that.maxScrollX)) momentumX = { dist:0, time:0 };
563
+ if ((that.y > that.minScrollY && newPosY > that.minScrollY) || (that.y < that.maxScrollY && newPosY < that.maxScrollY)) momentumY = { dist:0, time:0 };
564
+ }
565
+
566
+ if (momentumX.dist || momentumY.dist) {
567
+ newDuration = m.max(m.max(momentumX.time, momentumY.time), 10);
568
+
569
+ // Do we need to snap?
570
+ if (that.options.snap) {
571
+ distX = newPosX - that.absStartX;
572
+ distY = newPosY - that.absStartY;
573
+ if (m.abs(distX) < that.options.snapThreshold && m.abs(distY) < that.options.snapThreshold) { that.scrollTo(that.absStartX, that.absStartY, 200); }
574
+ else {
575
+ snap = that._snap(newPosX, newPosY);
576
+ newPosX = snap.x;
577
+ newPosY = snap.y;
578
+ newDuration = m.max(snap.time, newDuration);
579
+ }
580
+ }
581
+
582
+ that.scrollTo(mround(newPosX), mround(newPosY), newDuration);
583
+
584
+ if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
585
+ return;
586
+ }
587
+
588
+ // Do we need to snap?
589
+ if (that.options.snap) {
590
+ distX = newPosX - that.absStartX;
591
+ distY = newPosY - that.absStartY;
592
+ if (m.abs(distX) < that.options.snapThreshold && m.abs(distY) < that.options.snapThreshold) that.scrollTo(that.absStartX, that.absStartY, 200);
593
+ else {
594
+ snap = that._snap(that.x, that.y);
595
+ if (snap.x != that.x || snap.y != that.y) that.scrollTo(snap.x, snap.y, snap.time);
596
+ }
597
+
598
+ if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
599
+ return;
600
+ }
601
+
602
+ that._resetPos(200);
603
+ if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
604
+ },
605
+
606
+ _resetPos: function (time) {
607
+ var that = this,
608
+ resetX = that.x >= 0 ? 0 : that.x < that.maxScrollX ? that.maxScrollX : that.x,
609
+ resetY = that.y >= that.minScrollY || that.maxScrollY > 0 ? that.minScrollY : that.y < that.maxScrollY ? that.maxScrollY : that.y;
610
+
611
+ if (resetX == that.x && resetY == that.y) {
612
+ if (that.moved) {
613
+ that.moved = false;
614
+ if (that.options.onScrollEnd) that.options.onScrollEnd.call(that); // Execute custom code on scroll end
615
+ }
616
+
617
+ if (that.hScrollbar && that.options.hideScrollbar) {
618
+ if (vendor == 'webkit') that.hScrollbarWrapper.style[vendor + 'TransitionDelay'] = '300ms';
619
+ that.hScrollbarWrapper.style.opacity = '0';
620
+ }
621
+ if (that.vScrollbar && that.options.hideScrollbar) {
622
+ if (vendor == 'webkit') that.vScrollbarWrapper.style[vendor + 'TransitionDelay'] = '300ms';
623
+ that.vScrollbarWrapper.style.opacity = '0';
624
+ }
625
+
626
+ return;
627
+ }
628
+
629
+ that.scrollTo(resetX, resetY, time || 0);
630
+ },
631
+
632
+ _wheel: function (e) {
633
+ var that = this,
634
+ wheelDeltaX, wheelDeltaY,
635
+ deltaX, deltaY,
636
+ deltaScale;
637
+
638
+ if ('wheelDeltaX' in e) {
639
+ wheelDeltaX = e.wheelDeltaX / 12;
640
+ wheelDeltaY = e.wheelDeltaY / 12;
641
+ } else if ('detail' in e) {
642
+ wheelDeltaX = wheelDeltaY = -e.detail * 3;
643
+ } else {
644
+ wheelDeltaX = wheelDeltaY = -e.wheelDelta;
645
+ }
646
+
647
+ if (that.options.wheelAction == 'zoom') {
648
+ deltaScale = that.scale * Math.pow(2, 1/3 * (wheelDeltaY ? wheelDeltaY / Math.abs(wheelDeltaY) : 0));
649
+ if (deltaScale < that.options.zoomMin) deltaScale = that.options.zoomMin;
650
+ if (deltaScale > that.options.zoomMax) deltaScale = that.options.zoomMax;
651
+
652
+ if (deltaScale != that.scale) {
653
+ if (!that.wheelZoomCount && that.options.onZoomStart) that.options.onZoomStart.call(that, e);
654
+ that.wheelZoomCount++;
655
+
656
+ that.zoom(e.pageX, e.pageY, deltaScale, 400);
657
+
658
+ setTimeout(function() {
659
+ that.wheelZoomCount--;
660
+ if (!that.wheelZoomCount && that.options.onZoomEnd) that.options.onZoomEnd.call(that, e);
661
+ }, 400);
662
+ }
663
+
664
+ return;
665
+ }
666
+
667
+ deltaX = that.x + wheelDeltaX;
668
+ deltaY = that.y + wheelDeltaY;
669
+
670
+ if (deltaX > 0) deltaX = 0;
671
+ else if (deltaX < that.maxScrollX) deltaX = that.maxScrollX;
672
+
673
+ if (deltaY > that.minScrollY) deltaY = that.minScrollY;
674
+ else if (deltaY < that.maxScrollY) deltaY = that.maxScrollY;
675
+
676
+ that.scrollTo(deltaX, deltaY, 0);
677
+ },
678
+
679
+ _mouseout: function (e) {
680
+ var t = e.relatedTarget;
681
+
682
+ if (!t) {
683
+ this._end(e);
684
+ return;
685
+ }
686
+
687
+ while (t = t.parentNode) if (t == this.wrapper) return;
688
+
689
+ this._end(e);
690
+ },
691
+
692
+ _transitionEnd: function (e) {
693
+ var that = this;
694
+
695
+ if (e.target != that.scroller) return;
696
+
697
+ that._unbind('webkitTransitionEnd');
698
+
699
+ that._startAni();
700
+ },
701
+
702
+
703
+ /**
704
+ *
705
+ * Utilities
706
+ *
707
+ */
708
+ _startAni: function () {
709
+ var that = this,
710
+ startX = that.x, startY = that.y,
711
+ startTime = Date.now(),
712
+ step, easeOut,
713
+ animate;
714
+
715
+ if (that.animating) return;
716
+
717
+ if (!that.steps.length) {
718
+ that._resetPos(400);
719
+ return;
720
+ }
721
+
722
+ step = that.steps.shift();
723
+
724
+ if (step.x == startX && step.y == startY) step.time = 0;
725
+
726
+ that.animating = true;
727
+ that.moved = true;
728
+
729
+ if (that.options.useTransition) {
730
+ that._transitionTime(step.time);
731
+ that._pos(step.x, step.y);
732
+ that.animating = false;
733
+ if (step.time) that._bind('webkitTransitionEnd');
734
+ else that._resetPos(0);
735
+ return;
736
+ }
737
+
738
+ animate = function () {
739
+ var now = Date.now(),
740
+ newX, newY;
741
+
742
+ if (now >= startTime + step.time) {
743
+ that._pos(step.x, step.y);
744
+ that.animating = false;
745
+ if (that.options.onAnimationEnd) that.options.onAnimationEnd.call(that); // Execute custom code on animation end
746
+ that._startAni();
747
+ return;
748
+ }
749
+
750
+ now = (now - startTime) / step.time - 1;
751
+ easeOut = m.sqrt(1 - now * now);
752
+ newX = (step.x - startX) * easeOut + startX;
753
+ newY = (step.y - startY) * easeOut + startY;
754
+ that._pos(newX, newY);
755
+ if (that.animating) that.aniTime = nextFrame(animate);
756
+ };
757
+
758
+ animate();
759
+ },
760
+
761
+ _transitionTime: function (time) {
762
+ time += 'ms';
763
+ this.scroller.style[vendor + 'TransitionDuration'] = time;
764
+ if (this.hScrollbar) this.hScrollbarIndicator.style[vendor + 'TransitionDuration'] = time;
765
+ if (this.vScrollbar) this.vScrollbarIndicator.style[vendor + 'TransitionDuration'] = time;
766
+ },
767
+
768
+ _momentum: function (dist, time, maxDistUpper, maxDistLower, size) {
769
+ var deceleration = 0.0006,
770
+ speed = m.abs(dist) / time,
771
+ newDist = (speed * speed) / (2 * deceleration),
772
+ newTime = 0, outsideDist = 0;
773
+
774
+ // Proportinally reduce speed if we are outside of the boundaries
775
+ if (dist > 0 && newDist > maxDistUpper) {
776
+ outsideDist = size / (6 / (newDist / speed * deceleration));
777
+ maxDistUpper = maxDistUpper + outsideDist;
778
+ speed = speed * maxDistUpper / newDist;
779
+ newDist = maxDistUpper;
780
+ } else if (dist < 0 && newDist > maxDistLower) {
781
+ outsideDist = size / (6 / (newDist / speed * deceleration));
782
+ maxDistLower = maxDistLower + outsideDist;
783
+ speed = speed * maxDistLower / newDist;
784
+ newDist = maxDistLower;
785
+ }
786
+
787
+ newDist = newDist * (dist < 0 ? -1 : 1);
788
+ newTime = speed / deceleration;
789
+
790
+ return { dist: newDist, time: mround(newTime) };
791
+ },
792
+
793
+ _offset: function (el) {
794
+ var left = -el.offsetLeft,
795
+ top = -el.offsetTop;
796
+
797
+ while (el = el.offsetParent) {
798
+ left -= el.offsetLeft;
799
+ top -= el.offsetTop;
800
+ }
801
+
802
+ if (el != this.wrapper) {
803
+ left *= this.scale;
804
+ top *= this.scale;
805
+ }
806
+
807
+ return { left: left, top: top };
808
+ },
809
+
810
+ _snap: function (x, y) {
811
+ var that = this,
812
+ i, l,
813
+ page, time,
814
+ sizeX, sizeY;
815
+
816
+ // Check page X
817
+ page = that.pagesX.length - 1;
818
+ for (i=0, l=that.pagesX.length; i<l; i++) {
819
+ if (x >= that.pagesX[i]) {
820
+ page = i;
821
+ break;
822
+ }
823
+ }
824
+ if (page == that.currPageX && page > 0 && that.dirX < 0) page--;
825
+ x = that.pagesX[page];
826
+ sizeX = m.abs(x - that.pagesX[that.currPageX]);
827
+ sizeX = sizeX ? m.abs(that.x - x) / sizeX * 500 : 0;
828
+ that.currPageX = page;
829
+
830
+ // Check page Y
831
+ page = that.pagesY.length-1;
832
+ for (i=0; i<page; i++) {
833
+ if (y >= that.pagesY[i]) {
834
+ page = i;
835
+ break;
836
+ }
837
+ }
838
+ if (page == that.currPageY && page > 0 && that.dirY < 0) page--;
839
+ y = that.pagesY[page];
840
+ sizeY = m.abs(y - that.pagesY[that.currPageY]);
841
+ sizeY = sizeY ? m.abs(that.y - y) / sizeY * 500 : 0;
842
+ that.currPageY = page;
843
+
844
+ // Snap with constant speed (proportional duration)
845
+ time = mround(m.max(sizeX, sizeY)) || 200;
846
+
847
+ return { x: x, y: y, time: time };
848
+ },
849
+
850
+ _bind: function (type, el, bubble) {
851
+ (el || this.scroller).addEventListener(type, this, !!bubble);
852
+ },
853
+
854
+ _unbind: function (type, el, bubble) {
855
+ (el || this.scroller).removeEventListener(type, this, !!bubble);
856
+ },
857
+
858
+
859
+ /**
860
+ *
861
+ * Public methods
862
+ *
863
+ */
864
+ destroy: function () {
865
+ var that = this;
866
+
867
+ that.scroller.style[vendor + 'Transform'] = '';
868
+
869
+ // Remove the scrollbars
870
+ that.hScrollbar = false;
871
+ that.vScrollbar = false;
872
+ that._scrollbar('h');
873
+ that._scrollbar('v');
874
+
875
+ // Remove the event listeners
876
+ that._unbind(RESIZE_EV, window);
877
+ that._unbind(START_EV);
878
+ that._unbind(MOVE_EV);
879
+ that._unbind(END_EV);
880
+ that._unbind(CANCEL_EV);
881
+
882
+ if (!that.options.hasTouch) {
883
+ that._unbind('mouseout', that.wrapper);
884
+ that._unbind(WHEEL_EV);
885
+ }
886
+
887
+ if (that.options.useTransition) that._unbind('webkitTransitionEnd');
888
+
889
+ if (that.options.checkDOMChanges) clearInterval(that.checkDOMTime);
890
+
891
+ if (that.options.onDestroy) that.options.onDestroy.call(that);
892
+ },
893
+
894
+ refresh: function () {
895
+ var that = this,
896
+ offset,
897
+ i, l,
898
+ els,
899
+ pos = 0,
900
+ page = 0;
901
+
902
+ if (that.scale < that.options.zoomMin) that.scale = that.options.zoomMin;
903
+ that.wrapperW = that.wrapper.clientWidth || 1;
904
+ that.wrapperH = that.wrapper.clientHeight || 1;
905
+
906
+ that.minScrollY = -that.options.topOffset || 0;
907
+ that.scrollerW = mround(that.scroller.offsetWidth * that.scale);
908
+ that.scrollerH = mround((that.scroller.offsetHeight + that.minScrollY) * that.scale);
909
+ that.maxScrollX = that.wrapperW - that.scrollerW;
910
+ that.maxScrollY = that.wrapperH - that.scrollerH + that.minScrollY;
911
+ that.dirX = 0;
912
+ that.dirY = 0;
913
+
914
+ if (that.options.onRefresh) that.options.onRefresh.call(that);
915
+
916
+ that.hScroll = that.options.hScroll && that.maxScrollX < 0;
917
+ that.vScroll = that.options.vScroll && (!that.options.bounceLock && !that.hScroll || that.scrollerH > that.wrapperH);
918
+
919
+ that.hScrollbar = that.hScroll && that.options.hScrollbar;
920
+ that.vScrollbar = that.vScroll && that.options.vScrollbar && that.scrollerH > that.wrapperH;
921
+
922
+ offset = that._offset(that.wrapper);
923
+ that.wrapperOffsetLeft = -offset.left;
924
+ that.wrapperOffsetTop = -offset.top;
925
+
926
+ // Prepare snap
927
+ if (typeof that.options.snap == 'string') {
928
+ that.pagesX = [];
929
+ that.pagesY = [];
930
+ els = that.scroller.querySelectorAll(that.options.snap);
931
+ for (i=0, l=els.length; i<l; i++) {
932
+ pos = that._offset(els[i]);
933
+ pos.left += that.wrapperOffsetLeft;
934
+ pos.top += that.wrapperOffsetTop;
935
+ that.pagesX[i] = pos.left < that.maxScrollX ? that.maxScrollX : pos.left * that.scale;
936
+ that.pagesY[i] = pos.top < that.maxScrollY ? that.maxScrollY : pos.top * that.scale;
937
+ }
938
+ } else if (that.options.snap) {
939
+ that.pagesX = [];
940
+ while (pos >= that.maxScrollX) {
941
+ that.pagesX[page] = pos;
942
+ pos = pos - that.wrapperW;
943
+ page++;
944
+ }
945
+ if (that.maxScrollX%that.wrapperW) that.pagesX[that.pagesX.length] = that.maxScrollX - that.pagesX[that.pagesX.length-1] + that.pagesX[that.pagesX.length-1];
946
+
947
+ pos = 0;
948
+ page = 0;
949
+ that.pagesY = [];
950
+ while (pos >= that.maxScrollY) {
951
+ that.pagesY[page] = pos;
952
+ pos = pos - that.wrapperH;
953
+ page++;
954
+ }
955
+ if (that.maxScrollY%that.wrapperH) that.pagesY[that.pagesY.length] = that.maxScrollY - that.pagesY[that.pagesY.length-1] + that.pagesY[that.pagesY.length-1];
956
+ }
957
+
958
+ // Prepare the scrollbars
959
+ that._scrollbar('h');
960
+ that._scrollbar('v');
961
+
962
+ if (!that.zoomed) {
963
+ that.scroller.style[vendor + 'TransitionDuration'] = '0';
964
+ that._resetPos(200);
965
+ }
966
+ },
967
+
968
+ scrollTo: function (x, y, time, relative) {
969
+ var that = this,
970
+ step = x,
971
+ i, l;
972
+
973
+ that.stop();
974
+
975
+ if (!step.length) step = [{ x: x, y: y, time: time, relative: relative }];
976
+
977
+ for (i=0, l=step.length; i<l; i++) {
978
+ if (step[i].relative) { step[i].x = that.x - step[i].x; step[i].y = that.y - step[i].y; }
979
+ that.steps.push({ x: step[i].x, y: step[i].y, time: step[i].time || 0 });
980
+ }
981
+
982
+ that._startAni();
983
+ },
984
+
985
+ scrollToElement: function (el, time) {
986
+ var that = this, pos;
987
+ el = el.nodeType ? el : that.scroller.querySelector(el);
988
+ if (!el) return;
989
+
990
+ pos = that._offset(el);
991
+ pos.left += that.wrapperOffsetLeft;
992
+ pos.top += that.wrapperOffsetTop;
993
+
994
+ pos.left = pos.left > 0 ? 0 : pos.left < that.maxScrollX ? that.maxScrollX : pos.left;
995
+ pos.top = pos.top > that.minScrollY ? that.minScrollY : pos.top < that.maxScrollY ? that.maxScrollY : pos.top;
996
+ time = time === undefined ? m.max(m.abs(pos.left)*2, m.abs(pos.top)*2) : time;
997
+
998
+ that.scrollTo(pos.left, pos.top, time);
999
+ },
1000
+
1001
+ scrollToPage: function (pageX, pageY, time) {
1002
+ var that = this, x, y;
1003
+
1004
+ time = time === undefined ? 400 : time;
1005
+
1006
+ if (that.options.onScrollStart) that.options.onScrollStart.call(that);
1007
+
1008
+ if (that.options.snap) {
1009
+ pageX = pageX == 'next' ? that.currPageX+1 : pageX == 'prev' ? that.currPageX-1 : pageX;
1010
+ pageY = pageY == 'next' ? that.currPageY+1 : pageY == 'prev' ? that.currPageY-1 : pageY;
1011
+
1012
+ pageX = pageX < 0 ? 0 : pageX > that.pagesX.length-1 ? that.pagesX.length-1 : pageX;
1013
+ pageY = pageY < 0 ? 0 : pageY > that.pagesY.length-1 ? that.pagesY.length-1 : pageY;
1014
+
1015
+ that.currPageX = pageX;
1016
+ that.currPageY = pageY;
1017
+ x = that.pagesX[pageX];
1018
+ y = that.pagesY[pageY];
1019
+ } else {
1020
+ x = -that.wrapperW * pageX;
1021
+ y = -that.wrapperH * pageY;
1022
+ if (x < that.maxScrollX) x = that.maxScrollX;
1023
+ if (y < that.maxScrollY) y = that.maxScrollY;
1024
+ }
1025
+
1026
+ that.scrollTo(x, y, time);
1027
+ },
1028
+
1029
+ disable: function () {
1030
+ this.stop();
1031
+ this._resetPos(0);
1032
+ this.enabled = false;
1033
+
1034
+ // If disabled after touchstart we make sure that there are no left over events
1035
+ this._unbind(MOVE_EV);
1036
+ this._unbind(END_EV);
1037
+ this._unbind(CANCEL_EV);
1038
+ },
1039
+
1040
+ enable: function () {
1041
+ this.enabled = true;
1042
+ },
1043
+
1044
+ stop: function () {
1045
+ if (this.options.useTransition) this._unbind('webkitTransitionEnd');
1046
+ else cancelFrame(this.aniTime);
1047
+ this.steps = [];
1048
+ this.moved = false;
1049
+ this.animating = false;
1050
+ },
1051
+
1052
+ zoom: function (x, y, scale, time) {
1053
+ var that = this,
1054
+ relScale = scale / that.scale;
1055
+
1056
+ if (!that.options.useTransform) return;
1057
+
1058
+ that.zoomed = true;
1059
+ time = time === undefined ? 200 : time;
1060
+ x = x - that.wrapperOffsetLeft - that.x;
1061
+ y = y - that.wrapperOffsetTop - that.y;
1062
+ that.x = x - x * relScale + that.x;
1063
+ that.y = y - y * relScale + that.y;
1064
+
1065
+ that.scale = scale;
1066
+ that.refresh();
1067
+
1068
+ that.x = that.x > 0 ? 0 : that.x < that.maxScrollX ? that.maxScrollX : that.x;
1069
+ that.y = that.y > that.minScrollY ? that.minScrollY : that.y < that.maxScrollY ? that.maxScrollY : that.y;
1070
+
1071
+ that.scroller.style[vendor + 'TransitionDuration'] = time + 'ms';
1072
+ that.scroller.style[vendor + 'Transform'] = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose + ' scale(' + scale + ')';
1073
+ that.zoomed = false;
1074
+ },
1075
+
1076
+ isReady: function () {
1077
+ return !this.moved && !this.zoomed && !this.animating;
1078
+ }
1079
+ };
1080
+
1081
+ if (typeof exports !== 'undefined') exports.iScroll = iScroll;
1082
+ else window.iScroll = iScroll;
1083
+
1084
+ })();