binda 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +850 -18
  3. data/Rakefile +1 -13
  4. data/app/assets/javascripts/binda/application.js +23 -0
  5. data/app/assets/javascripts/binda/components/bootstrap.js +9 -0
  6. data/app/assets/javascripts/binda/components/field_group_editor.js +18 -0
  7. data/app/assets/javascripts/binda/components/fileupload.js +182 -0
  8. data/app/assets/javascripts/binda/components/form_item.js +91 -23
  9. data/app/assets/javascripts/binda/components/form_item_choice.js +15 -8
  10. data/app/assets/javascripts/binda/components/form_item_editor.js +6 -6
  11. data/app/assets/javascripts/binda/components/form_item_image.js +23 -0
  12. data/app/assets/javascripts/binda/components/form_item_repeater.js +70 -23
  13. data/app/assets/javascripts/binda/components/login-shader.js +193 -0
  14. data/app/assets/javascripts/binda/components/login_form.js +116 -0
  15. data/app/assets/javascripts/binda/components/radio-toggle.js +18 -0
  16. data/app/assets/javascripts/binda/components/select2.js +22 -0
  17. data/app/assets/javascripts/binda/components/sortable.js +53 -8
  18. data/app/assets/javascripts/binda/dist/binda.bundle.js +914 -107
  19. data/app/assets/javascripts/binda/index.js +26 -3
  20. data/app/assets/stylesheets/binda/application.scss +6 -0
  21. data/app/assets/stylesheets/binda/components/assets_manager.scss +46 -36
  22. data/app/assets/stylesheets/binda/components/b-btn.scss +114 -0
  23. data/app/assets/stylesheets/binda/components/button.scss +4 -1
  24. data/app/assets/stylesheets/binda/components/fileupload.scss +134 -0
  25. data/app/assets/stylesheets/binda/components/form_item.scss +233 -168
  26. data/app/assets/stylesheets/binda/components/form_item_image.scss +0 -0
  27. data/app/assets/stylesheets/binda/components/form_item_video.scss +25 -0
  28. data/app/assets/stylesheets/binda/components/main_container.scss +3 -0
  29. data/app/assets/stylesheets/binda/components/main_content.scss +1 -2
  30. data/app/assets/stylesheets/binda/components/main_header.scss +21 -20
  31. data/app/assets/stylesheets/binda/components/main_sidebar.scss +121 -0
  32. data/app/assets/stylesheets/binda/components/main_table.scss +84 -28
  33. data/app/assets/stylesheets/binda/components/popup_warning.scss +71 -0
  34. data/app/assets/stylesheets/binda/components/select2.scss +126 -0
  35. data/app/assets/stylesheets/binda/components/sortable.scss +83 -56
  36. data/app/assets/stylesheets/binda/components/standard-form.scss +228 -0
  37. data/app/assets/stylesheets/binda/components/texts.scss +6 -0
  38. data/app/assets/stylesheets/binda/controllers/components_index.scss +3 -0
  39. data/app/assets/stylesheets/binda/controllers/users_sessions_new.scss +309 -0
  40. data/app/assets/stylesheets/binda/index.scss +16 -8
  41. data/app/assets/stylesheets/binda/settings/bootstrap_overrides.scss +0 -0
  42. data/app/assets/stylesheets/binda/settings/buttons.scss +36 -0
  43. data/app/assets/stylesheets/binda/settings/common.scss +36 -79
  44. data/app/assets/stylesheets/binda/settings/fonts.scss +88 -31
  45. data/app/assets/stylesheets/binda/settings/tiny_mce_overrides.scss +82 -0
  46. data/app/assets/stylesheets/binda/settings/variables.scss +36 -31
  47. data/app/controllers/binda/application_controller.rb +0 -2
  48. data/app/controllers/binda/assets_controller.rb +1 -1
  49. data/app/controllers/binda/boards_controller.rb +15 -4
  50. data/app/controllers/binda/components_controller.rb +30 -15
  51. data/app/controllers/binda/field_groups_controller.rb +19 -4
  52. data/app/controllers/binda/images_controller.rb +68 -0
  53. data/app/controllers/binda/repeaters_controller.rb +3 -12
  54. data/app/controllers/binda/structures_controller.rb +8 -1
  55. data/app/controllers/binda/videos_controller.rb +68 -0
  56. data/app/controllers/concerns/binda/fieldable_helpers.rb +113 -28
  57. data/app/controllers/concerns/binda/maintenance_helpers.rb +34 -0
  58. data/app/helpers/binda/components_helper.rb +26 -2
  59. data/app/helpers/binda/field_groups_helper.rb +16 -0
  60. data/app/helpers/binda/structures_helper.rb +6 -0
  61. data/app/models/binda/asset.rb +0 -4
  62. data/app/models/binda/b.rb +5 -0
  63. data/app/models/binda/board.rb +1 -18
  64. data/app/models/binda/choice.rb +48 -12
  65. data/app/models/binda/component.rb +20 -0
  66. data/app/models/binda/field_group.rb +2 -2
  67. data/app/models/binda/field_setting.rb +61 -28
  68. data/app/models/binda/gallery.rb +0 -2
  69. data/app/models/binda/image.rb +7 -0
  70. data/app/models/binda/relation.rb +79 -0
  71. data/app/models/binda/relation_link.rb +11 -0
  72. data/app/models/binda/repeater.rb +1 -1
  73. data/app/models/binda/selection.rb +0 -9
  74. data/app/models/binda/structure.rb +41 -39
  75. data/app/models/binda/video.rb +7 -0
  76. data/app/models/concerns/binda/default_helpers.rb +186 -0
  77. data/app/models/concerns/binda/fieldable_associations.rb +276 -30
  78. data/app/uploaders/binda/{asset → image}/image_uploader.rb +27 -9
  79. data/app/uploaders/binda/video/video_uploader.rb +51 -0
  80. data/app/views/binda/boards/edit.html.erb +6 -1
  81. data/app/views/binda/categories/_form.html.erb +41 -40
  82. data/app/views/binda/categories/edit.html.erb +1 -1
  83. data/app/views/binda/categories/index.html.erb +16 -13
  84. data/app/views/binda/components/edit.html.erb +6 -3
  85. data/app/views/binda/components/index.html.erb +69 -28
  86. data/app/views/binda/components/new.html.erb +1 -1
  87. data/app/views/binda/components/sort_index.html.erb +46 -0
  88. data/app/views/binda/field_groups/_form_body.html.erb +65 -44
  89. data/app/views/binda/field_groups/_form_item.html.erb +66 -23
  90. data/app/views/binda/field_groups/_form_item_choice.erb +34 -15
  91. data/app/views/binda/field_groups/_form_section.html.erb +6 -10
  92. data/app/views/binda/field_groups/_form_section_repeater.html.erb +3 -3
  93. data/app/views/binda/field_groups/edit.html.erb +1 -1
  94. data/app/views/binda/field_settings/_form_body.html.erb +5 -5
  95. data/app/views/binda/field_settings/edit.html.erb +1 -1
  96. data/app/views/binda/fieldable/_form_body.html.erb +93 -79
  97. data/app/views/binda/fieldable/_form_item_date.html.erb +14 -14
  98. data/app/views/binda/fieldable/_form_item_image.html.erb +35 -0
  99. data/app/views/binda/fieldable/_form_item_new_repeater.html.erb +12 -5
  100. data/app/views/binda/fieldable/_form_item_relation.html.erb +44 -0
  101. data/app/views/binda/fieldable/_form_item_repeater.html.erb +80 -58
  102. data/app/views/binda/fieldable/_form_item_selections.html.erb +109 -87
  103. data/app/views/binda/fieldable/_form_item_string.html.erb +19 -17
  104. data/app/views/binda/fieldable/_form_item_text.html.erb +19 -16
  105. data/app/views/binda/fieldable/_form_item_video.html.erb +32 -0
  106. data/app/views/binda/fieldable/_form_section.html.erb +27 -5
  107. data/app/views/binda/fieldable/_form_section_repeater.html.erb +30 -10
  108. data/app/views/binda/fieldable/_form_sidebar.html.erb +44 -20
  109. data/app/views/binda/manage/users/_form_body.html.erb +42 -37
  110. data/app/views/binda/manage/users/edit.html.erb +1 -1
  111. data/app/views/binda/manage/users/index.html.erb +21 -21
  112. data/app/views/binda/structures/_form_body.html.erb +54 -60
  113. data/app/views/binda/structures/_form_section.html.erb +32 -18
  114. data/app/views/binda/structures/_form_sidebar.html.erb +35 -0
  115. data/app/views/binda/structures/edit.html.erb +2 -2
  116. data/app/views/binda/structures/index.html.erb +21 -16
  117. data/app/views/binda/structures/sort_index.html.erb +36 -0
  118. data/app/views/{users → binda/users}/confirmations/new.html.erb +1 -1
  119. data/app/views/{users → binda/users}/mailer/confirmation_instructions.html.erb +0 -0
  120. data/app/views/{users → binda/users}/mailer/password_change.html.erb +0 -0
  121. data/app/views/{users → binda/users}/mailer/reset_password_instructions.html.erb +0 -0
  122. data/app/views/{users → binda/users}/mailer/unlock_instructions.html.erb +0 -0
  123. data/app/views/{users → binda/users}/passwords/edit.html.erb +1 -1
  124. data/app/views/{users → binda/users}/passwords/new.html.erb +1 -1
  125. data/app/views/{users → binda/users}/registrations/edit.html.erb +0 -0
  126. data/app/views/{users → binda/users}/registrations/new.html.erb +1 -1
  127. data/app/views/binda/users/sessions/_background.html.erb +139 -0
  128. data/app/views/binda/users/sessions/new.html.erb +62 -0
  129. data/app/views/{users → binda/users}/shared/_links.html.erb +3 -3
  130. data/app/views/{users → binda/users}/unlocks/new.html.erb +1 -1
  131. data/app/views/kaminari/_first_page.html.erb +11 -0
  132. data/app/views/kaminari/_gap.html.erb +8 -0
  133. data/app/views/kaminari/_last_page.html.erb +11 -0
  134. data/app/views/kaminari/_next_page.html.erb +11 -0
  135. data/app/views/kaminari/_page.html.erb +12 -0
  136. data/app/views/kaminari/_paginator.html.erb +19 -0
  137. data/app/views/kaminari/_prev_page.html.erb +11 -0
  138. data/app/views/layouts/binda/_flash.html.erb +1 -1
  139. data/app/views/layouts/binda/_header.html.erb +2 -6
  140. data/app/views/layouts/binda/_sidebar.html.erb +11 -4
  141. data/app/views/layouts/binda/application.html.erb +15 -7
  142. data/config/autoprefixer.yml +5 -0
  143. data/config/database.yml.travis +3 -0
  144. data/config/initializers/assets.rb +1 -0
  145. data/config/initializers/autoprefixer.yml +5 -0
  146. data/config/initializers/carrierwave.rb +32 -0
  147. data/config/initializers/devise.rb +14 -10
  148. data/config/initializers/devise_patch.rb +8 -8
  149. data/config/initializers/simple_form.rb +4 -0
  150. data/config/initializers/simple_form__fileupload.rb +121 -0
  151. data/config/initializers/{simple_form_bootstrap.rb → simple_form_custom.rb} +79 -50
  152. data/config/locales/en.yml +61 -3
  153. data/config/locales/it.yml +51 -0
  154. data/config/locales/simple_form.en.yml +3 -3
  155. data/config/routes.rb +41 -24
  156. data/db/migrate/1_create_binda_tables.rb +18 -7
  157. data/db/migrate/20171214140451_add_preview_mode.rb +5 -0
  158. data/lib/binda.rb +1 -1
  159. data/lib/binda/engine.rb +19 -23
  160. data/lib/binda/version.rb +2 -2
  161. data/lib/generators/binda/install/install_generator.rb +59 -54
  162. data/lib/generators/binda/install/templates/config/initializers/carrierwave.rb +11 -2
  163. data/lib/generators/binda/maintenance/USAGE +8 -0
  164. data/lib/generators/binda/maintenance/maintenance_generator.rb +50 -0
  165. data/lib/generators/binda/maintenance/templates/app/assets/javascripts/maintenance.js +0 -0
  166. data/lib/generators/binda/maintenance/templates/app/assets/stylesheets/maintenance.scss +0 -0
  167. data/lib/generators/binda/maintenance/templates/app/views/layouts/maintenance.html.erb +16 -0
  168. data/lib/generators/binda/maintenance/templates/config/initializers/maintenance.rb +1 -0
  169. data/lib/generators/binda/setup/setup_generator.rb +41 -30
  170. data/lib/tasks/add_default_helpers_class_task.rake +11 -0
  171. data/lib/tasks/add_video_feature_task.rake +15 -0
  172. data/lib/tasks/remove_orphan_fields_task.rake +16 -0
  173. data/lib/tasks/set_repeater_position_task.rake +13 -0
  174. data/lib/tasks/upgrade_to_v007_task.rake +72 -0
  175. data/lib/tasks/user_tasks.rake +14 -0
  176. data/vendor/assets/fonts/font-awesome/fa-brands-400.eot +0 -0
  177. data/vendor/assets/fonts/font-awesome/fa-brands-400.svg +978 -0
  178. data/vendor/assets/fonts/font-awesome/fa-brands-400.ttf +0 -0
  179. data/vendor/assets/fonts/font-awesome/fa-brands-400.woff +0 -0
  180. data/vendor/assets/fonts/font-awesome/fa-brands-400.woff2 +0 -0
  181. data/vendor/assets/fonts/font-awesome/fa-regular-400.eot +0 -0
  182. data/vendor/assets/fonts/font-awesome/fa-regular-400.svg +363 -0
  183. data/vendor/assets/fonts/font-awesome/fa-regular-400.ttf +0 -0
  184. data/vendor/assets/fonts/font-awesome/fa-regular-400.woff +0 -0
  185. data/vendor/assets/fonts/font-awesome/fa-regular-400.woff2 +0 -0
  186. data/vendor/assets/fonts/font-awesome/fa-solid-900.eot +0 -0
  187. data/vendor/assets/fonts/font-awesome/fa-solid-900.svg +1410 -0
  188. data/vendor/assets/fonts/font-awesome/fa-solid-900.ttf +0 -0
  189. data/vendor/assets/fonts/font-awesome/fa-solid-900.woff +0 -0
  190. data/vendor/assets/fonts/font-awesome/fa-solid-900.woff2 +0 -0
  191. data/vendor/assets/javascripts/GSAP/CSSPlugin.min.js +13 -0
  192. data/vendor/assets/javascripts/GSAP/EasePack.min.js +12 -0
  193. data/vendor/assets/javascripts/GSAP/ScrollToPlugin.min.js +12 -0
  194. data/vendor/assets/javascripts/GSAP/TweenLite.min.js +12 -0
  195. data/vendor/assets/javascripts/select2/i18n/af.js +3 -0
  196. data/vendor/assets/javascripts/select2/i18n/ar.js +3 -0
  197. data/vendor/assets/javascripts/select2/i18n/az.js +3 -0
  198. data/vendor/assets/javascripts/select2/i18n/bg.js +3 -0
  199. data/vendor/assets/javascripts/select2/i18n/bs.js +3 -0
  200. data/vendor/assets/javascripts/select2/i18n/ca.js +3 -0
  201. data/vendor/assets/javascripts/select2/i18n/cs.js +3 -0
  202. data/vendor/assets/javascripts/select2/i18n/da.js +3 -0
  203. data/vendor/assets/javascripts/select2/i18n/de.js +3 -0
  204. data/vendor/assets/javascripts/select2/i18n/dsb.js +3 -0
  205. data/vendor/assets/javascripts/select2/i18n/el.js +3 -0
  206. data/vendor/assets/javascripts/select2/i18n/en.js +3 -0
  207. data/vendor/assets/javascripts/select2/i18n/es.js +3 -0
  208. data/vendor/assets/javascripts/select2/i18n/et.js +3 -0
  209. data/vendor/assets/javascripts/select2/i18n/eu.js +3 -0
  210. data/vendor/assets/javascripts/select2/i18n/fa.js +3 -0
  211. data/vendor/assets/javascripts/select2/i18n/fi.js +3 -0
  212. data/vendor/assets/javascripts/select2/i18n/fr.js +3 -0
  213. data/vendor/assets/javascripts/select2/i18n/gl.js +3 -0
  214. data/vendor/assets/javascripts/select2/i18n/he.js +3 -0
  215. data/vendor/assets/javascripts/select2/i18n/hi.js +3 -0
  216. data/vendor/assets/javascripts/select2/i18n/hr.js +3 -0
  217. data/vendor/assets/javascripts/select2/i18n/hsb.js +3 -0
  218. data/vendor/assets/javascripts/select2/i18n/hu.js +3 -0
  219. data/vendor/assets/javascripts/select2/i18n/hy.js +3 -0
  220. data/vendor/assets/javascripts/select2/i18n/id.js +3 -0
  221. data/vendor/assets/javascripts/select2/i18n/is.js +3 -0
  222. data/vendor/assets/javascripts/select2/i18n/it.js +3 -0
  223. data/vendor/assets/javascripts/select2/i18n/ja.js +3 -0
  224. data/vendor/assets/javascripts/select2/i18n/km.js +3 -0
  225. data/vendor/assets/javascripts/select2/i18n/ko.js +3 -0
  226. data/vendor/assets/javascripts/select2/i18n/lt.js +3 -0
  227. data/vendor/assets/javascripts/select2/i18n/lv.js +3 -0
  228. data/vendor/assets/javascripts/select2/i18n/mk.js +3 -0
  229. data/vendor/assets/javascripts/select2/i18n/ms.js +3 -0
  230. data/vendor/assets/javascripts/select2/i18n/nb.js +3 -0
  231. data/vendor/assets/javascripts/select2/i18n/nl.js +3 -0
  232. data/vendor/assets/javascripts/select2/i18n/pl.js +3 -0
  233. data/vendor/assets/javascripts/select2/i18n/ps.js +3 -0
  234. data/vendor/assets/javascripts/select2/i18n/pt-BR.js +3 -0
  235. data/vendor/assets/javascripts/select2/i18n/pt.js +3 -0
  236. data/vendor/assets/javascripts/select2/i18n/ro.js +3 -0
  237. data/vendor/assets/javascripts/select2/i18n/ru.js +3 -0
  238. data/vendor/assets/javascripts/select2/i18n/sk.js +3 -0
  239. data/vendor/assets/javascripts/select2/i18n/sl.js +3 -0
  240. data/vendor/assets/javascripts/select2/i18n/sr-Cyrl.js +3 -0
  241. data/vendor/assets/javascripts/select2/i18n/sr.js +3 -0
  242. data/vendor/assets/javascripts/select2/i18n/sv.js +3 -0
  243. data/vendor/assets/javascripts/select2/i18n/th.js +3 -0
  244. data/vendor/assets/javascripts/select2/i18n/tr.js +3 -0
  245. data/vendor/assets/javascripts/select2/i18n/uk.js +3 -0
  246. data/vendor/assets/javascripts/select2/i18n/vi.js +3 -0
  247. data/vendor/assets/javascripts/select2/i18n/zh-CN.js +3 -0
  248. data/vendor/assets/javascripts/select2/i18n/zh-TW.js +3 -0
  249. data/vendor/assets/javascripts/select2/select2.full.min.js +1 -0
  250. data/vendor/assets/javascripts/select2/select2.min.js +1 -0
  251. data/vendor/assets/javascripts/tether.min.js +1 -0
  252. data/vendor/assets/stylesheets/{bootstrap-select.css → bootstrap/bootstrap-select.css} +0 -0
  253. data/vendor/assets/stylesheets/font-awesome/_animated.scss +6 -20
  254. data/vendor/assets/stylesheets/font-awesome/_bordered-pulled.scss +6 -11
  255. data/vendor/assets/stylesheets/font-awesome/_core.scss +11 -7
  256. data/vendor/assets/stylesheets/font-awesome/_fixed-width.scss +1 -1
  257. data/vendor/assets/stylesheets/font-awesome/_icons.scss +785 -787
  258. data/vendor/assets/stylesheets/font-awesome/_larger.scss +16 -6
  259. data/vendor/assets/stylesheets/font-awesome/_list.scss +7 -8
  260. data/vendor/assets/stylesheets/font-awesome/_mixins.scss +17 -20
  261. data/vendor/assets/stylesheets/font-awesome/_rotated-flipped.scss +9 -6
  262. data/vendor/assets/stylesheets/font-awesome/_screen-reader.scss +2 -2
  263. data/vendor/assets/stylesheets/font-awesome/_stacked.scss +19 -8
  264. data/vendor/assets/stylesheets/font-awesome/_variables.scss +795 -795
  265. data/vendor/assets/stylesheets/font-awesome/fa-brands.scss +21 -0
  266. data/vendor/assets/stylesheets/font-awesome/fa-regular.scss +22 -0
  267. data/vendor/assets/stylesheets/font-awesome/fa-solid.scss +23 -0
  268. data/vendor/assets/stylesheets/font-awesome/fontawesome.scss +20 -0
  269. data/vendor/assets/stylesheets/select2/select2.min.css +1 -0
  270. metadata +278 -125
  271. data/app/assets/javascripts/binda/components/form_item_asset.js +0 -25
  272. data/app/assets/stylesheets/binda/application.css +0 -6
  273. data/app/assets/stylesheets/binda/components/form_body.scss +0 -2
  274. data/app/assets/stylesheets/binda/components/form_item_asset.scss +0 -20
  275. data/app/assets/stylesheets/binda/components/form_section.scss +0 -40
  276. data/app/assets/stylesheets/binda/components/sidebar.scss +0 -131
  277. data/app/assets/stylesheets/binda/layout/components_index.scss +0 -9
  278. data/app/assets/stylesheets/binda/layout/dashboard.scss +0 -7
  279. data/app/assets/stylesheets/binda/layout/users_sign_in.scss +0 -29
  280. data/app/controllers/binda/bindings_controller.rb +0 -62
  281. data/app/controllers/concerns/binda/default_helpers.rb +0 -226
  282. data/app/helpers/binda/bindings_helper.rb +0 -4
  283. data/app/models/binda/binda.rb +0 -7
  284. data/app/models/binda/binding.rb +0 -24
  285. data/app/views/binda/bindings/_form.html.erb +0 -32
  286. data/app/views/binda/bindings/edit.html.erb +0 -6
  287. data/app/views/binda/bindings/index.html.erb +0 -31
  288. data/app/views/binda/bindings/new.html.erb +0 -5
  289. data/app/views/binda/bindings/show.html.erb +0 -19
  290. data/app/views/binda/field_groups/index.html.erb +0 -34
  291. data/app/views/binda/fieldable/_form_item_asset.html.erb +0 -20
  292. data/app/views/users/sessions/new.html.erb +0 -27
  293. data/lib/tasks/binda.rake +0 -79
  294. data/vendor/assets/fonts/font-awesome/FontAwesome.otf +0 -0
  295. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.eot +0 -0
  296. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.svg +0 -2671
  297. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.ttf +0 -0
  298. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff +0 -0
  299. data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff2 +0 -0
  300. data/vendor/assets/stylesheets/font-awesome/_path.scss +0 -15
  301. data/vendor/assets/stylesheets/font-awesome/font-awesome.scss +0 -18
@@ -1,6 +1,6 @@
1
- ///- - - - - - - - - - - - - - - - - - - -
2
- /// FORM ITEM
3
- ///- - - - - - - - - - - - - - - - - - - -
1
+ /**
2
+ * FORM ITEM EDITOR
3
+ */
4
4
 
5
5
  class FormItemEditor {
6
6
 
@@ -26,14 +26,14 @@ class FormItemEditor {
26
26
  resize()
27
27
  {
28
28
  $( this.target ).each( function(){
29
- // If the form item edito is closed don't go any further
29
+ // If the form item editor is closed don't go any further
30
30
  if ( $(this).height() === 0 ) return
31
31
  // otherwise update the max-height which is needed for the CSS transition
32
32
  // NOTE you need to remove the max-height (inside 'style' attribute) to get the real height
33
- $(this).css( "max-height", $(this).removeAttr('style').height() )
33
+ $(this).get(0).style.height = 'auto'
34
+ $(this).get(0).style.maxHeight = $(this).get(0).scrollHeight + "px";
34
35
  })
35
36
  }
36
-
37
37
  }
38
38
 
39
39
  export let _FormItemEditor = new FormItemEditor()
@@ -0,0 +1,23 @@
1
+ /**
2
+ * FORM ITEM IMAGE
3
+ */
4
+
5
+ class FormItemImage
6
+ {
7
+ constructor()
8
+ {
9
+ this.target = '.form-item--image--uploader'
10
+ }
11
+
12
+ isSet()
13
+ {
14
+ if ( $( this.target ).length > 0 ) { return true }
15
+ else { return false }
16
+ }
17
+
18
+ setEvents()
19
+ {
20
+ }
21
+ }
22
+
23
+ export var _FormItemImage = new FormItemImage()
@@ -1,31 +1,29 @@
1
- ///- - - - - - - - - - - - - - - - - - - -
2
- /// FORM ITEM
3
- ///- - - - - - - - - - - - - - - - - - - -
1
+ /**
2
+ * FORM ITEM REPEATER
3
+ */
4
4
 
5
5
  import { _FormItemEditor } from './form_item_editor'
6
+ import { setupSelect2 } from './select2'
6
7
 
7
8
  class FormItemRepeater {
8
9
 
9
- constructor()
10
- {
11
- this.target = '.form-item--repeater-section'
12
- }
10
+ constructor(){}
13
11
 
14
12
  isSet()
15
13
  {
16
- if ( $( this.target ).length > 0 ) { return true }
14
+ if ( $('.form-item--repeater-section').length > 0 ) { return true }
17
15
  else { return false }
18
16
  }
19
17
 
20
18
  setEvents()
21
19
  {
22
- $(document).on('click', this.target + '--add-new', addNewItem )
20
+ $(document).on('click', '.form-item--repeater-section--add-new', function(event){ addNewItem(this, event)} )
23
21
 
24
22
  $(document).on('click', '.form-item--remove-item-with-js', function( event )
25
23
  {
26
24
  // Stop default behaviour
27
25
  event.preventDefault()
28
- $( this ).parent( this.target ).remove()
26
+ $( this ).parent('.form-item--repeater-section').remove()
29
27
  _FormItemEditor.resize()
30
28
  })
31
29
 
@@ -34,13 +32,24 @@ class FormItemRepeater {
34
32
  // Stop default behaviour
35
33
  event.preventDefault()
36
34
 
35
+ // if ( !confirm($(this).data('confirm')) ) return
36
+
37
+ let record_id = $( this ).data('id')
38
+ let target = $('#repeater_' + record_id).get(0)
39
+ // As max-height isn't set you need to set it manually before changing it,
40
+ // otherwise the animation doesn't get triggered
41
+ target.style.maxHeight = target.scrollHeight + 'px'
42
+ // Change max-height after 50ms to trigger css animation
43
+ setTimeout( function(){ target.style.maxHeight = 0 + 'px' }, 50)
44
+
37
45
  $.ajax({
38
46
  url: $( this ).attr('href'),
39
- data: { id: $( this ).data('id'), isAjax: true },
47
+ data: { id: record_id, isAjax: true },
40
48
  method: "DELETE"
41
49
  }).done( ()=>{
42
- $( this ).parent('li').remove()
43
- _FormItemEditor.resize()
50
+ // Make sure the animation completes before removing the item (it should last 600ms + 50ms)
51
+ setTimeout( function(){ $(target).remove() }, 700)
52
+ // _FormItemEditor.resize()
44
53
  })
45
54
  })
46
55
  }
@@ -49,25 +58,63 @@ class FormItemRepeater {
49
58
  export let _FormItemRepeater = new FormItemRepeater()
50
59
 
51
60
 
52
- ///- - - - - - - - - - - - - - - - - - - -
53
- /// COMPONENT HELPER FUNCTIONS
54
- ///- - - - - - - - - - - - - - - - - - - -
61
+ /**
62
+ * COMPONENT HELPER FUNCTIONS
63
+ *
64
+ * @param {string} target The target
65
+ * @param {object} event The event
66
+ */
55
67
 
56
- function addNewItem( event )
68
+ function addNewItem( target, event )
57
69
  {
58
70
  // Stop default behaviour
59
71
  event.preventDefault()
60
72
  // Get the child to clone
61
- let id = $( event.target ).data( 'id' )
73
+ let id = $( target ).data( 'id' )
62
74
  let $list = $('#form-item--repeater-setting-' + id )
63
- let url = $( event.target ).data( 'url' )
75
+ let url = $( target ).data( 'url' )
64
76
  $.post( url, { repeater_setting_id: id }, function( data )
65
77
  {
78
+ // Get repaeter code from Rails
79
+ // Due to the Rails way of creating nested forms it's necessary to
80
+ // create the nested item inside a different new form, then get just
81
+ // the code contained between the two SPLIT comments
66
82
  let parts = data.split('<!-- SPLIT -->')
67
83
  let newRepeater = parts[1]
68
- $list.append( newRepeater )
69
- var editor_id = $list.find('textarea').last('textarea').attr('id')
70
- tinyMCE.EditorManager.execCommand('mceAddEditor',true, editor_id);
71
- _FormItemEditor.resize()
84
+
85
+ // Append the item
86
+ $list.prepend( newRepeater )
87
+ let new_repeater_item = $list.find('.form-item--repeater').get(0)
88
+
89
+ // Prepare animation
90
+ new_repeater_item.style.maxHeight = 0
91
+
92
+ // Group fields if sotrable is enabled
93
+ if ( $list.hasClass('sortable--enabled') )
94
+ {
95
+ $(new_repeater_item).find('.form-item--repeater-fields').each(function()
96
+ {
97
+ this.style.maxHeight = 0 + 'px'
98
+ })
99
+ }
100
+
101
+ // Setup TinyMCE for the newly created item
102
+ var textarea_editor_id = $list.find('textarea').last('textarea').attr('id')
103
+ tinyMCE.EditorManager.execCommand('mceAddEditor',true, textarea_editor_id);
104
+
105
+ // Resize the editor (is it needed with the new configuration?)
106
+ // _FormItemEditor.resize()
107
+
108
+ // Update select input for Select2 plugin
109
+ setupSelect2( $list.find('select') )
110
+
111
+ // Refresh Sortable to update the added item with Sortable features
112
+ $list.sortable('refresh')
113
+
114
+ // Run animation 50ms after previous style declaration (see above) otherwise animation doesn't get triggered
115
+ setTimeout( function()
116
+ {
117
+ new_repeater_item.style.maxHeight = new_repeater_item.scrollHeight + 'px'
118
+ }, 50)
72
119
  })
73
120
  }
@@ -0,0 +1,193 @@
1
+ class Shader {
2
+ constructor(){}
3
+
4
+ isSet()
5
+ {
6
+ if ( $('#background-shader').length > 0 ) { return true }
7
+ else { return false }
8
+ }
9
+
10
+ // SETUP SHADER
11
+ setup () {
12
+
13
+ let Container = PIXI.Container,
14
+ autoDetectRenderer = PIXI.autoDetectRenderer,
15
+ loader = PIXI.loader,
16
+ resources = PIXI.loader.resources,
17
+ Sprite = PIXI.Sprite
18
+
19
+ // Create a container object called the `stage`
20
+ this.stage = new Container()
21
+
22
+ // Create 'renderer'
23
+ this.renderer = PIXI.autoDetectRenderer( window.innerWidth, window.innerHeight )
24
+
25
+ // //Add the canvas to the HTML document
26
+
27
+ document.getElementById('background-shader').appendChild(this.renderer.view)
28
+
29
+
30
+ this.renderer.backgroundColor = 0xFF00FF
31
+
32
+ // canvas full window
33
+ this.renderer.view.style.position = "fixed"
34
+ this.renderer.view.style.display = "block"
35
+
36
+ let fragmentShader = document.getElementById("fragmentShader").innerHTML
37
+
38
+ let currentTime = Math.sin( Date.now() ) + 0.5
39
+
40
+ this.uniforms = {
41
+ uTime : { type: '1f', value: 0.0 },
42
+ uCurrentTime : { type: '1f', value: currentTime },
43
+ uMouse : { type: '2f', value: [ window.innerWidth, window.innerHeight ] },
44
+ uWindowSize : { type: '2f', value: [ window.innerWidth, window.innerHeight ] }
45
+ }
46
+
47
+ this.customShader = new PIXI.AbstractFilter(null, fragmentShader, this.uniforms)
48
+ this.drawRectagle()
49
+ }
50
+
51
+
52
+ // DRAW RECTANGLE
53
+ drawRectagle() {
54
+
55
+ this.rectangle = new PIXI.Graphics()
56
+
57
+ // Set the default background color wo if browser doesn't support the filter we still see the primary color
58
+ let colorWithHash = '#FF00FF'
59
+ const colorWith0x = '0x' + colorWithHash.slice( 1, 7 )
60
+ this.rectangle.beginFill( colorWith0x )
61
+
62
+ // Create the background rectanlge
63
+ this.rectangle.drawRect( 0, 0, window.innerWidth, window.innerHeight )
64
+ this.rectangle.endFill()
65
+
66
+ // Setup the filter (shader)
67
+ this.rectangle.filters = [ this.customShader ]
68
+
69
+ // Add background to stage
70
+ this.stage.addChild( this.rectangle )
71
+ }
72
+
73
+
74
+ // START ANIMATION
75
+ start() { animate() }
76
+
77
+
78
+ // MOUSE UPDATE
79
+ mouseUpdate( event ) {
80
+
81
+ // If uniforms haven't been set yet don't do anything and exit
82
+ if ( typeof this.uniforms === 'undefined' ) return
83
+
84
+ // udpate mouse coordinates for the shader
85
+ this.customShader.uniforms.uMouse = [ event.pageX, event.pageY ]
86
+ }
87
+
88
+
89
+ // RESIZE
90
+ resize() {
91
+
92
+ // let scale = scaleToWindow( this.renderer.view )
93
+ let prevWidth = this.renderer.view.style.width
94
+ let prevHeight = this.renderer.view.style.height
95
+ this.renderer.view.style.width = window.innerWidth + "px"
96
+ this.renderer.view.style.height = window.innerHeight + "px"
97
+ this.customShader.uniforms.uWindowSize = [ window.innerWidth, window.innerHeight ]
98
+
99
+ // Plese check this out ↴↴↴
100
+ // this.rectangle.scale.x = window.innerWidth / prevWidth
101
+ // this.rectangle.scale.y = window.innerHeight / prevHeight
102
+ }
103
+ }
104
+
105
+
106
+ export let _Shader = new Shader()
107
+
108
+
109
+ // ANIMATE
110
+ // -------
111
+ function animate() {
112
+
113
+ // start the timer for the next animation loop
114
+ requestAnimationFrame( animate )
115
+ _Shader.customShader.uniforms.uTime += 0.01
116
+ // this is the main render call that makes pixi draw your container and its children.
117
+ _Shader.renderer.render( _Shader.stage )
118
+ }
119
+
120
+ // CONVERT HEX TO RGB COLORS
121
+ // -------------------------
122
+ function hexToShaderRgb( hex ) {
123
+
124
+ // Precision of the float number
125
+ var precision = 100
126
+ // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
127
+ var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i
128
+ hex = hex.replace(shorthandRegex, function(m, r, g, b) {
129
+ return r + r + g + g + b + b
130
+ })
131
+
132
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
133
+ return result ? {
134
+ // Get a number between 0.00 and 1.00
135
+ r: Math.round( parseInt(result[1], 16) * precision / 255 ) / precision,
136
+ g: Math.round( parseInt(result[2], 16) * precision / 255 ) / precision,
137
+ b: Math.round( parseInt(result[3], 16) * precision / 255 ) / precision
138
+ } : null;
139
+ }
140
+
141
+
142
+ // REQUEST ANIMATION POLYFILL
143
+ // --------------------------
144
+ // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
145
+ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
146
+ // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
147
+ // MIT license
148
+ (function() {
149
+ var lastTime = 0;
150
+ var vendors = ['ms', 'moz', 'webkit', 'o'];
151
+ for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
152
+ window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
153
+ window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
154
+ }
155
+
156
+ if (!window.requestAnimationFrame)
157
+ window.requestAnimationFrame = function(callback, element) {
158
+ var currTime = new Date().getTime();
159
+ var timeToCall = Math.max(0, 16 - (currTime - lastTime));
160
+ var id = window.setTimeout(function() { callback(currTime + timeToCall); },
161
+ timeToCall);
162
+ lastTime = currTime + timeToCall;
163
+ return id;
164
+ };
165
+
166
+ if (!window.cancelAnimationFrame)
167
+ window.cancelAnimationFrame = function(id) {
168
+ clearTimeout(id);
169
+ };
170
+ }());
171
+
172
+
173
+ // Mozilla MDN optimized resize
174
+ // https://developer.mozilla.org/en-US/docs/Web/Events/resize
175
+ (function() {
176
+ var throttle = function(type, name, obj) {
177
+ obj = obj || window;
178
+ var running = false;
179
+ var func = function() {
180
+ if (running) { return; }
181
+ running = true;
182
+ requestAnimationFrame(function() {
183
+ obj.dispatchEvent(new CustomEvent(name));
184
+ running = false;
185
+ });
186
+ };
187
+ obj.addEventListener(type, func);
188
+ };
189
+
190
+ /* init - you can init any event */
191
+ throttle("resize", "optimizedResize");
192
+ })();
193
+
@@ -0,0 +1,116 @@
1
+ /**
2
+ * LOGIN FORM
3
+ *
4
+ * https://tympanus.net/Development/MinimalForm/
5
+ * https://github.com/codrops/MinimalForm/blob/master/js/stepsForm.js
6
+ */
7
+
8
+ class LoginForm {
9
+
10
+ constructor()
11
+ {
12
+ this.current = 0
13
+ this.isFilled = false
14
+ }
15
+
16
+ isSet()
17
+ {
18
+ if ( $('.login--form').length > 0 ) { return true }
19
+ else { return false }
20
+ }
21
+
22
+ setEvents ()
23
+ {
24
+ this.$form = $('.login--form')
25
+ this.$questions = $('ol.login--questions > li')
26
+ this.questionsCount = this.$questions.length
27
+ this.$nextButton = $('button.login--next')
28
+
29
+ // Mark the first question as the current one
30
+ this.$questions.first().addClass('login--current')
31
+
32
+ //disable form autocomplete
33
+ this.$form.attr('autocomplete', 'off')
34
+
35
+ let self = this
36
+
37
+
38
+ // first input
39
+ let firstInput = this.$questions.get(this.current).querySelector( 'input, textarea, select' )
40
+
41
+ // focus
42
+ let onFocusStart = function()
43
+ {
44
+ firstInput.removeEventListener( 'focus', onFocusStart )
45
+ self.$nextButton.addClass('login--show')
46
+ }
47
+ // show the next question control first time the input gets focused
48
+ firstInput.addEventListener('focus', onFocusStart )
49
+
50
+ // show next question
51
+ this.$nextButton.on('click', function( event )
52
+ {
53
+ event.preventDefault()
54
+ self._nextQuestion()
55
+ } )
56
+
57
+ // pressing enter will jump to next question
58
+ this.$form.on('keydown', function( event )
59
+ {
60
+ let keyCode = event.keyCode || event.which
61
+ // enter
62
+ if( keyCode === 13 )
63
+ {
64
+ event.preventDefault()
65
+ self._nextQuestion()
66
+ }
67
+ })
68
+ }
69
+
70
+ _nextQuestion()
71
+ {
72
+ // check if form is filled
73
+ if( this.current === this.questionsCount - 1 )
74
+ {
75
+ this.isFilled = true
76
+ }
77
+
78
+ // current question
79
+ let currentQuestion = this.$questions.get(this.current)
80
+
81
+ // increment current question iterator
82
+ ++this.current
83
+
84
+ if( !this.isFilled )
85
+ {
86
+ // add class "show-next" to form element (start animations)
87
+ this.$form.addClass('login--show-next')
88
+
89
+ // remove class "current" from current question and add it to the next one
90
+ // current question
91
+ var nextQuestion = this.$questions.get(this.current)
92
+ $(currentQuestion).removeClass('login--current')
93
+ $(nextQuestion).addClass('login--current')
94
+ }
95
+
96
+ // after animation ends, remove class "show-next" from form element and change current question placeholder
97
+ let self = this
98
+ let onEndTransition = function()
99
+ {
100
+ if( self.isFilled )
101
+ {
102
+ self.$form.submit()
103
+ }
104
+ else
105
+ {
106
+ self.$form.removeClass('login--show-next')
107
+ // force the focus on the next input
108
+ nextQuestion.querySelector( 'input, textarea, select' ).focus()
109
+ }
110
+ }
111
+
112
+ setTimeout( onEndTransition, 400 ) // Wait for CSS transition to complete
113
+ }
114
+ }
115
+
116
+ export let _LoginForm = new LoginForm()