para 0.11.4 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/para/admin/main.scss +31 -0
  3. data/app/assets/stylesheets/para/admin/src/_affix.scss +7 -0
  4. data/app/assets/stylesheets/para/admin/src/_alert.scss +35 -0
  5. data/app/assets/stylesheets/para/admin/src/_base.scss +63 -0
  6. data/app/assets/stylesheets/para/admin/src/_bootstrap-variables.scss +766 -379
  7. data/app/assets/stylesheets/para/admin/src/_breadcrumb.scss +37 -0
  8. data/app/assets/stylesheets/para/admin/src/_buttons.scss +128 -0
  9. data/app/assets/stylesheets/para/admin/src/_checkable.scss +106 -0
  10. data/app/assets/stylesheets/para/admin/src/_common.scss +250 -0
  11. data/app/assets/stylesheets/para/admin/src/_dropdown.scss +52 -0
  12. data/app/assets/stylesheets/para/admin/src/_form.scss +359 -0
  13. data/app/assets/stylesheets/para/admin/src/_list.scss +96 -0
  14. data/app/assets/stylesheets/para/admin/src/_mixins.scss +109 -0
  15. data/app/assets/stylesheets/para/admin/src/_multi-select.scss +110 -0
  16. data/app/assets/stylesheets/para/admin/src/_navigation.scss +210 -0
  17. data/app/assets/stylesheets/para/admin/src/_navtabs.scss +68 -0
  18. data/app/assets/stylesheets/para/admin/src/_nested-many.scss +87 -0
  19. data/app/assets/stylesheets/para/admin/src/_nested_one.scss +26 -0
  20. data/app/assets/stylesheets/para/admin/src/_orderable.scss +48 -0
  21. data/app/assets/stylesheets/para/admin/src/_page-loading.scss +40 -0
  22. data/app/assets/stylesheets/para/admin/src/_pagination.scss +39 -0
  23. data/app/assets/stylesheets/para/admin/src/_panel.scss +61 -0
  24. data/app/assets/stylesheets/para/admin/src/_responsive.scss +133 -0
  25. data/app/assets/stylesheets/para/admin/src/_sorting.scss +43 -0
  26. data/app/assets/stylesheets/para/admin/src/_statcard.scss +46 -0
  27. data/app/assets/stylesheets/para/admin/src/_table.scss +36 -0
  28. data/app/assets/stylesheets/para/admin/src/_tree.scss +60 -0
  29. data/app/assets/stylesheets/para/admin/src/{_variables.sass → _variables.scss} +7 -7
  30. data/app/assets/stylesheets/para/admin/src/{_well.sass → _well.scss} +5 -4
  31. data/app/assets/stylesheets/para/admin.scss +15 -0
  32. data/app/assets/stylesheets/para/index.scss +1 -0
  33. data/app/assets/stylesheets/para/lib/datetimepicker.scss +15 -0
  34. data/app/assets/stylesheets/para/lib/fuelux.scss +46 -0
  35. data/app/assets/stylesheets/para/lib/jasny-bootstrap.scss +100 -0
  36. data/app/assets/stylesheets/para/lib/selectize.scss +129 -0
  37. data/app/assets/stylesheets/para/lib/slider.scss +14 -0
  38. data/app/controllers/para/admin/crud_resources_controller.rb +16 -9
  39. data/app/controllers/para/admin/imports_controller.rb +9 -9
  40. data/app/controllers/para/admin/jobs_controller.rb +7 -1
  41. data/app/controllers/para/admin/resources_controller.rb +17 -18
  42. data/app/controllers/para/admin/settings_component_controller.rb +2 -2
  43. data/app/helpers/para/admin/base_helper.rb +36 -25
  44. data/app/helpers/para/admin/page_helper.rb +8 -9
  45. data/app/helpers/para/flash_helper.rb +7 -28
  46. data/app/helpers/para/model_helper.rb +5 -8
  47. data/app/helpers/para/tree_helper.rb +4 -4
  48. data/app/javascripts/para/admin/async-progress.js +58 -0
  49. data/app/javascripts/para/admin/filters-form.js +12 -0
  50. data/app/javascripts/para/admin/job-tracker.js +33 -0
  51. data/app/javascripts/para/admin/table.js +58 -0
  52. data/app/javascripts/para/admin/tabs.js +110 -0
  53. data/app/javascripts/para/admin/theme_actions.js +39 -0
  54. data/app/javascripts/para/admin/tree.js +124 -0
  55. data/app/javascripts/para/application.js +2 -0
  56. data/app/javascripts/para/controllers/application.js +17 -0
  57. data/app/javascripts/para/controllers/index.js +10 -0
  58. data/app/javascripts/para/controllers/para_admin_flash_message_controller.js +48 -0
  59. data/app/javascripts/para/controllers/para_admin_modal_controller.js +43 -0
  60. data/app/javascripts/para/controllers/selectize_field_controller.js +142 -0
  61. data/app/javascripts/para/index.js +31 -0
  62. data/app/javascripts/para/inputs/material-input.js +7 -0
  63. data/app/javascripts/para/inputs/multi-select-input.js +343 -0
  64. data/app/javascripts/para/inputs/nested_many.js +151 -0
  65. data/app/javascripts/para/lib/fetch.js +41 -0
  66. data/app/javascripts/para/lib/page-loading.js +42 -0
  67. data/app/javascripts/para/simple_form_extension/colorpicker.js +30 -0
  68. data/app/javascripts/para/simple_form_extension/datetimepicker.js +115 -0
  69. data/app/javascripts/para/simple_form_extension/fileinput.js +57 -0
  70. data/app/javascripts/para/simple_form_extension/index.js +12 -0
  71. data/app/javascripts/para/simple_form_extension/selectize.js +160 -0
  72. data/app/javascripts/para/simple_form_extension/simple_form_extension_initialization.js +62 -0
  73. data/app/javascripts/para/simple_form_extension/slider.js +43 -0
  74. data/app/javascripts/para/simple_form_extension/spinbox.js +35 -0
  75. data/app/javascripts/para/vendor/bootstrap-colorpicker.js +1025 -0
  76. data/app/javascripts/para/vendor/bootstrap-slider.js +1610 -0
  77. data/app/javascripts/para/vendor/cocoon.js +150 -0
  78. data/app/javascripts/para/vendor/jquery.datetimepicker.js +2156 -0
  79. data/app/javascripts/para/vendor/jquery.js +3 -0
  80. data/app/javascripts/para/vendor/spinbox.js +438 -0
  81. data/app/javascripts/para/vendor/vertebra.js +224 -0
  82. data/app/views/admin/para/exporter/bases/_completed.html.haml +1 -1
  83. data/app/views/layouts/para/admin.html.haml +4 -2
  84. data/app/views/para/admin/imports/new.html.haml +12 -11
  85. data/app/views/para/admin/jobs/_completed.html.haml +1 -1
  86. data/app/views/para/admin/jobs/_failed.html.haml +1 -1
  87. data/app/views/para/admin/jobs/_job.html.haml +11 -0
  88. data/app/views/para/admin/jobs/show.html.haml +1 -10
  89. data/app/views/para/admin/resources/_add_button.html.haml +1 -1
  90. data/app/views/para/admin/resources/_exports_menu.html.haml +2 -2
  91. data/app/views/para/admin/resources/_filters.html.haml +1 -1
  92. data/app/views/para/admin/resources/_imports_menu.html.haml +2 -2
  93. data/app/views/para/admin/resources/_list.html.haml +27 -26
  94. data/app/views/para/admin/resources/_navigation.html.haml +10 -11
  95. data/app/views/para/admin/resources/_subclassable_add_button.html.haml +1 -1
  96. data/app/views/para/admin/shared/_flash.html.haml +18 -0
  97. data/app/views/para/admin/shared/_header.html.haml +1 -1
  98. data/app/views/para/form/_tabs.html.haml +1 -1
  99. data/app/views/para/inputs/_nested_many.html.haml +3 -3
  100. data/app/views/para/inputs/nested_many/_add.html.haml +1 -1
  101. data/app/views/para/inputs/nested_many/_add_with_subclasses.html.haml +2 -2
  102. data/app/views/para/inputs/nested_many/_container.html.haml +1 -1
  103. data/config/locales/fr.yml +1 -0
  104. data/lib/generators/para/install/install_generator.rb +10 -14
  105. data/lib/para/attribute_field/base.rb +3 -0
  106. data/lib/para/attribute_field/wysiwyg_editor.rb +15 -0
  107. data/lib/para/attribute_field.rb +1 -1
  108. data/lib/para/components_configuration.rb +1 -1
  109. data/lib/para/engine.rb +20 -22
  110. data/lib/para/ext/turbo_stream.rb +13 -0
  111. data/lib/para/ext.rb +1 -1
  112. data/lib/para/form_builder/containers.rb +33 -22
  113. data/lib/para/form_builder/nested_form.rb +6 -5
  114. data/lib/para/inputs/nested_many_input.rb +5 -0
  115. data/lib/para/markup/modal.rb +30 -15
  116. data/lib/para/markup/resources_buttons.rb +15 -11
  117. data/lib/para/model_field_parsers/wysiwyg_editor.rb +19 -0
  118. data/lib/para/model_field_parsers.rb +1 -1
  119. data/lib/para/version.rb +1 -1
  120. data/lib/para.rb +2 -8
  121. data/lib/simple_form_extension/components/icons.rb +13 -0
  122. data/lib/simple_form_extension/components/popovers.rb +46 -0
  123. data/lib/simple_form_extension/components.rb +8 -0
  124. data/lib/simple_form_extension/ext/form_builder.rb +20 -0
  125. data/lib/simple_form_extension/file_concern.rb +74 -0
  126. data/lib/simple_form_extension/inputs/boolean_input.rb +16 -0
  127. data/lib/simple_form_extension/inputs/collection_check_boxes_input.rb +15 -0
  128. data/lib/simple_form_extension/inputs/collection_radio_buttons_input.rb +15 -0
  129. data/lib/simple_form_extension/inputs/color_input.rb +37 -0
  130. data/lib/simple_form_extension/inputs/date_time_input.rb +48 -0
  131. data/lib/simple_form_extension/inputs/file_input.rb +41 -0
  132. data/lib/simple_form_extension/inputs/image_input.rb +110 -0
  133. data/lib/simple_form_extension/inputs/numeric_input.rb +27 -0
  134. data/lib/simple_form_extension/inputs/selectize_input.rb +210 -0
  135. data/lib/simple_form_extension/inputs/slider_input.rb +30 -0
  136. data/lib/simple_form_extension/inputs.rb +16 -0
  137. data/lib/simple_form_extension/railtie.rb +21 -0
  138. data/lib/simple_form_extension/resource_name_helper.rb +9 -0
  139. data/lib/simple_form_extension/translations.rb +7 -0
  140. data/lib/simple_form_extension/version.rb +3 -0
  141. data/lib/simple_form_extension.rb +30 -0
  142. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/alpha-horizontal.png +0 -0
  143. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/alpha.png +0 -0
  144. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/hue-horizontal.png +0 -0
  145. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/hue.png +0 -0
  146. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/saturation.png +0 -0
  147. data/vendor/assets/stylesheets/bootstrap-colorpicker.scss +227 -0
  148. data/vendor/assets/stylesheets/bootstrap-slider.scss +246 -0
  149. data/vendor/assets/stylesheets/bootstrap.scss +6032 -0
  150. data/vendor/assets/stylesheets/jquery.datetimepicker.scss +568 -0
  151. metadata +120 -188
  152. data/app/assets/javascripts/admin/app.coffee +0 -1
  153. data/app/assets/javascripts/para/admin/async-progress.coffee +0 -29
  154. data/app/assets/javascripts/para/admin/filters-form.coffee +0 -11
  155. data/app/assets/javascripts/para/admin/job-tracker.coffee +0 -39
  156. data/app/assets/javascripts/para/admin/table.coffee +0 -44
  157. data/app/assets/javascripts/para/admin/tabs.coffee +0 -63
  158. data/app/assets/javascripts/para/admin/theme_actions.coffee +0 -25
  159. data/app/assets/javascripts/para/admin/tree.coffee +0 -105
  160. data/app/assets/javascripts/para/admin.coffee +0 -22
  161. data/app/assets/javascripts/para/application.js +0 -13
  162. data/app/assets/javascripts/para/inputs/material-input.coffee +0 -4
  163. data/app/assets/javascripts/para/inputs/multi-select-input.coffee +0 -174
  164. data/app/assets/javascripts/para/inputs/nested_many.coffee +0 -108
  165. data/app/assets/javascripts/para/lib/ajax.coffee +0 -11
  166. data/app/assets/javascripts/para/lib/remote-file-forms.coffee +0 -59
  167. data/app/assets/javascripts/para/lib/turbolinks-forms.coffee +0 -23
  168. data/app/assets/javascripts/para/lib/turbolinks-loading.coffee +0 -25
  169. data/app/assets/javascripts/para/lib/turbolinks-reloader.coffee +0 -19
  170. data/app/assets/stylesheets/para/admin/main.sass +0 -33
  171. data/app/assets/stylesheets/para/admin/src/_affix.sass +0 -4
  172. data/app/assets/stylesheets/para/admin/src/_alert.sass +0 -17
  173. data/app/assets/stylesheets/para/admin/src/_base.sass +0 -54
  174. data/app/assets/stylesheets/para/admin/src/_breadcrumb.sass +0 -32
  175. data/app/assets/stylesheets/para/admin/src/_buttons.sass +0 -107
  176. data/app/assets/stylesheets/para/admin/src/_checkable.sass +0 -94
  177. data/app/assets/stylesheets/para/admin/src/_common.sass +0 -202
  178. data/app/assets/stylesheets/para/admin/src/_dropdown.sass +0 -40
  179. data/app/assets/stylesheets/para/admin/src/_form.sass +0 -299
  180. data/app/assets/stylesheets/para/admin/src/_list.sass +0 -89
  181. data/app/assets/stylesheets/para/admin/src/_mixins.sass +0 -113
  182. data/app/assets/stylesheets/para/admin/src/_multi-select.sass +0 -91
  183. data/app/assets/stylesheets/para/admin/src/_navigation.sass +0 -171
  184. data/app/assets/stylesheets/para/admin/src/_navtabs.sass +0 -58
  185. data/app/assets/stylesheets/para/admin/src/_nested-many.sass +0 -75
  186. data/app/assets/stylesheets/para/admin/src/_nested_one.sass +0 -22
  187. data/app/assets/stylesheets/para/admin/src/_orderable.sass +0 -44
  188. data/app/assets/stylesheets/para/admin/src/_page-loading.sass +0 -39
  189. data/app/assets/stylesheets/para/admin/src/_pagination.sass +0 -34
  190. data/app/assets/stylesheets/para/admin/src/_panel.sass +0 -55
  191. data/app/assets/stylesheets/para/admin/src/_responsive.sass +0 -117
  192. data/app/assets/stylesheets/para/admin/src/_sorting.sass +0 -36
  193. data/app/assets/stylesheets/para/admin/src/_statcard.sass +0 -41
  194. data/app/assets/stylesheets/para/admin/src/_table.sass +0 -33
  195. data/app/assets/stylesheets/para/admin/src/_tree.sass +0 -52
  196. data/app/assets/stylesheets/para/admin.sass +0 -12
  197. data/app/assets/stylesheets/para/lib/compass/_support.scss +0 -447
  198. data/app/assets/stylesheets/para/lib/compass/css3/_box-shadow.scss +0 -88
  199. data/app/assets/stylesheets/para/lib/compass/css3/_images.scss +0 -152
  200. data/app/assets/stylesheets/para/lib/compass/css3/_inline-block.scss +0 -31
  201. data/app/assets/stylesheets/para/lib/compass/css3/_text-shadow.scss +0 -82
  202. data/app/assets/stylesheets/para/lib/compass/css3/_transform.scss +0 -590
  203. data/app/assets/stylesheets/para/lib/compass/css3/_transition.scss +0 -190
  204. data/app/assets/stylesheets/para/lib/compass/css3/_user-interface.scss +0 -71
  205. data/app/assets/stylesheets/para/lib/compass/utilities/general/_hacks.scss +0 -65
  206. data/app/assets/stylesheets/para/lib/datetimepicker.sass +0 -15
  207. data/app/assets/stylesheets/para/lib/fuelux.sass +0 -40
  208. data/app/assets/stylesheets/para/lib/jasny-bootstrap.sass +0 -97
  209. data/app/assets/stylesheets/para/lib/redactor.sass +0 -86
  210. data/app/assets/stylesheets/para/lib/selectize.sass +0 -111
  211. data/app/assets/stylesheets/para/lib/slider.sass +0 -12
  212. data/app/assets/stylesheets/para/plugins-includes.sass.erb +0 -1
  213. data/lib/para/attribute_field/redactor.rb +0 -22
  214. data/lib/para/ext/request_iframe_xhr.rb +0 -17
  215. data/lib/para/iframe_transport/middleware.rb +0 -58
  216. data/lib/para/iframe_transport.rb +0 -7
  217. data/lib/para/model_field_parsers/redactor.rb +0 -19
  218. data/vendor/assets/javascripts/jquery.iframe-transport.js +0 -260
  219. data/vendor/assets/javascripts/jquery.remote-modal-form.coffee +0 -145
  220. /data/app/assets/stylesheets/admin/{app.sass → app.scss} +0 -0
  221. /data/app/{assets/javascripts → javascripts}/para/plugins-includes.js.erb +0 -0
  222. /data/{vendor/assets/javascripts → app/javascripts/para/vendor}/Sortable.js +0 -0
  223. /data/{vendor/assets/javascripts → app/javascripts/para/vendor}/jasny-bootstrap.js +0 -0
  224. /data/{vendor/assets/javascripts → app/javascripts/para/vendor}/jquery.scrollto.js +0 -0
  225. /data/{vendor/assets/javascripts → app/javascripts/para/vendor}/jquery.sortable.js +0 -0
  226. /data/vendor/assets/stylesheets/{animate.css → animate.scss} +0 -0
  227. /data/vendor/assets/stylesheets/{hint.css → hint.scss} +0 -0
  228. /data/vendor/assets/stylesheets/{jasny-bootstrap.css → jasny-bootstrap.scss} +0 -0
@@ -0,0 +1,115 @@
1
+ var DatePicker, DateTimePicker, DateTimePickerBase, TimePicker;
2
+
3
+ DateTimePickerBase = class DateTimePickerBase {
4
+ static forInput($input, type) {
5
+ var picker;
6
+ if ((picker = $input.data('simple-form-extension-datetimepicker'))) {
7
+ return picker;
8
+ } else {
9
+ return new type($input);
10
+ }
11
+ }
12
+
13
+ constructor($input1) {
14
+ this.$input = $input1;
15
+ this.locale = $('html').attr('lang') || 'en';
16
+ $.datetimepicker.setLocale(this.locale);
17
+ this.$input.data('simple-form-extension-datetimepicker', this);
18
+ this.initializePicker();
19
+ }
20
+
21
+ initializePicker() {
22
+ return this.$input.datetimepicker(this.processOptions());
23
+ }
24
+
25
+ processOptions() {
26
+ return $.extend({}, this.defaultOptions(), this.options());
27
+ }
28
+
29
+ options() {
30
+ return {};
31
+ }
32
+
33
+ defaultOptions() {
34
+ return {
35
+ lang: this.locale,
36
+ format: this.$input.data('format'),
37
+ step: parseInt(this.$input.data('step'), 10)
38
+ };
39
+ }
40
+
41
+ show() {
42
+ return this.$input.datetimepicker('show');
43
+ }
44
+
45
+ };
46
+
47
+ DateTimePicker = class DateTimePicker extends DateTimePickerBase {
48
+ options() {
49
+ return {
50
+ formatDate: this.$input.data('format-date'),
51
+ defaultTime: this.$input.data('default-time'),
52
+ dayOfWeekStart: this.$input.data('week-start-day'),
53
+ disabledDates: this.$input.data('disabled-dates') || [],
54
+ minDate: this.$input.data('min-date'),
55
+ maxDate: this.$input.data('max-date')
56
+ };
57
+ }
58
+
59
+ };
60
+
61
+ DatePicker = class DatePicker extends DateTimePickerBase {
62
+ options() {
63
+ return {
64
+ timepicker: false,
65
+ formatDate: this.$input.data('format-date'),
66
+ dayOfWeekStart: this.$input.data('week-start-day'),
67
+ disabledDates: this.$input.data('disabled-dates') || [],
68
+ minDate: this.$input.data('min-date'),
69
+ maxDate: this.$input.data('max-date')
70
+ };
71
+ }
72
+
73
+ };
74
+
75
+ TimePicker = class TimePicker extends DateTimePickerBase {
76
+ options() {
77
+ return {
78
+ datepicker: false,
79
+ defaultTime: this.$input.data('default-time')
80
+ };
81
+ }
82
+
83
+ };
84
+
85
+ $.simpleForm.onDomReady(function($document) {
86
+ // Plugin initialization delegated to body, so we do not need to run the
87
+ // initialization process when the body has not changed
88
+ if (!$document.is('body')) {
89
+ return;
90
+ }
91
+ $('body').on('click', 'input.datetime', function(e) {
92
+ return DateTimePicker.forInput($(e.currentTarget), DateTimePicker).show();
93
+ });
94
+ $('body').on('click', '.datetime .datetimepicker-trigger', function(e) {
95
+ var $input;
96
+ $input = $(e.currentTarget).closest('.datetime').find('input.datetime');
97
+ return DateTimePicker.forInput($input, DateTimePicker).show();
98
+ });
99
+ $('body').on('click', 'input.date', function(e) {
100
+ return DatePicker.forInput($(e.currentTarget), DatePicker).show();
101
+ });
102
+ $('body').on('click', '.date .datetimepicker-trigger', function(e) {
103
+ var $input;
104
+ $input = $(e.currentTarget).closest('.date').find('input.date');
105
+ return DatePicker.forInput($input, DatePicker).show();
106
+ });
107
+ $('body').on('click', 'input.time', function(e) {
108
+ return TimePicker.forInput($(e.currentTarget), TimePicker).show();
109
+ });
110
+ return $('body').on('click', '.time .datetimepicker-trigger', function(e) {
111
+ var $input;
112
+ $input = $(e.currentTarget).closest('.time').find('input.time');
113
+ return TimePicker.forInput($input, TimePicker).show();
114
+ });
115
+ });
@@ -0,0 +1,57 @@
1
+ var ExistingFileField;
2
+
3
+ ExistingFileField = class ExistingFileField {
4
+ constructor($field1) {
5
+ this.$field = $field1;
6
+ this.$existingFile = this.$field.find('[data-toggle="existing-file"]');
7
+ this.$removeButton = this.$field.find('[data-dismiss="existing-file"]');
8
+ this.$removeInput = this.$removeButton.find('input');
9
+ this.$removeButtonIcon = this.$removeButton.find('i');
10
+ this.originalClass = this.$removeButtonIcon.attr('class');
11
+ this.removedClass = this.$removeButtonIcon.attr('data-removed-class');
12
+ this.$removeButton.on('click', $.proxy(this.removeButtonClicked, this));
13
+ }
14
+
15
+ removeButtonClicked() {
16
+ if (this.$removeInput.val()) {
17
+ return this.unsetRemoved();
18
+ } else {
19
+ return this.setRemoved();
20
+ }
21
+ }
22
+
23
+ setRemoved() {
24
+ this.$removeInput.val('1');
25
+ this.$existingFile.hide(0);
26
+ return this.$removeButtonIcon.attr({
27
+ class: this.removedClass
28
+ });
29
+ }
30
+
31
+ unsetRemoved() {
32
+ this.$removeInput.removeAttr('value');
33
+ this.$existingFile.show(0);
34
+ return this.$removeButtonIcon.attr({
35
+ class: this.originalClass
36
+ });
37
+ }
38
+
39
+ };
40
+
41
+ $.simpleForm.onDomReady(function($document) {
42
+ // Plugin initialization delegated to body, so we do not need to run the
43
+ // initialization process when the body has not changed
44
+ if (!$document.is('body')) {
45
+ return;
46
+ }
47
+ return $('body').on('click', '[data-dismiss="existing-file"]', function(e) {
48
+ var $button, $field, data;
49
+ $button = $(e.currentTarget);
50
+ $field = $button.closest('[data-provides="existing-file"]');
51
+ if (!$field.data('simple-form:existing-file')) {
52
+ data = new ExistingFileField($field);
53
+ data.removeButtonClicked();
54
+ return $field.data('simple-form:existing-file', data);
55
+ }
56
+ });
57
+ });
@@ -0,0 +1,12 @@
1
+ import "../vendor/spinbox";
2
+ import "../vendor/jasny-bootstrap";
3
+ import "../vendor/jquery.datetimepicker";
4
+ import "../vendor/bootstrap-slider";
5
+ import "../vendor/bootstrap-colorpicker";
6
+
7
+ import "./simple_form_extension_initialization";
8
+ import "./colorpicker";
9
+ import "./datetimepicker";
10
+ import "./fileinput";
11
+ import "./slider";
12
+ import "./spinbox";
@@ -0,0 +1,160 @@
1
+ // import Selectize from '@selectize/selectize';
2
+
3
+ // var SimpleFormSelectize, hash_key;
4
+
5
+ // SimpleFormSelectize = class SimpleFormSelectize {
6
+ // selectizeDefaults() {
7
+ // return {
8
+ // mode: this.single ? 'single' : 'multi',
9
+ // maxItems: this.single ? 1 : this.$el.data('max-items'),
10
+ // sortField: this.$el.data('sort-field'),
11
+ // plugins: ['remove_button'],
12
+ // create: this.$el.data('creatable'),
13
+ // render: this.renderOptions(),
14
+ // options: this.$el.data('collection'),
15
+ // load: this.load
16
+ // };
17
+ // }
18
+
19
+ // constructor($el, options1) {
20
+ // var value;
21
+ // this.load = this.load.bind(this);
22
+ // this.$el = $el;
23
+ // this.options = options1;
24
+ // this.single = this.$el.data('multi') === false;
25
+ // this.el = this.$el[0];
26
+ // this.$el.val('');
27
+ // this.searchURL = this.$el.data('search-url');
28
+ // this.searchParam = this.$el.data('search-param');
29
+ // this.escape = this.$el.data('escape') !== false;
30
+ // this.$el.selectize($.extend(this.selectizeDefaults(), this.options));
31
+ // if ((value = this.$el.data('value'))) {
32
+ // this.initializeValue(value);
33
+ // }
34
+ // // Fix for newest version of selectize that keeps the hidden input field
35
+ // // instead of converting it to a text field when we call it on a hidden
36
+ // // input.
37
+ // this.$el.next('.selectize-control').find('.selectize-input input[type="hidden"]').attr('type', 'text');
38
+ // }
39
+
40
+ // initializeValue(data) {
41
+ // if (this.single) {
42
+ // this.el.selectize.addOption(data);
43
+ // } else {
44
+ // $.each(data, (i, item) => {
45
+ // return this.el.selectize.addOption(item);
46
+ // });
47
+ // }
48
+ // if (this.single) {
49
+ // return this.el.selectize.addItem(data.value);
50
+ // } else {
51
+ // return $.each(data, (i, item) => {
52
+ // return this.el.selectize.addItem(item.value);
53
+ // });
54
+ // }
55
+ // }
56
+
57
+ // addAndSelect(data) {
58
+ // this.el.selectize.addOption(data);
59
+ // return this.el.selectize.addItem(data.value);
60
+ // }
61
+
62
+ // load(query, callback) {
63
+ // var data;
64
+ // if (!(query.length && this.searchURL)) {
65
+ // return callback();
66
+ // }
67
+ // data = {};
68
+ // data[this.searchParam] = query;
69
+ // return $.ajax({
70
+ // url: this.searchURL,
71
+ // type: 'GET',
72
+ // data: data,
73
+ // error: function() {
74
+ // return callback();
75
+ // },
76
+ // success: callback
77
+ // });
78
+ // }
79
+
80
+ // renderOptions() {
81
+ // return {
82
+ // option: (data, escape) => {
83
+ // return `<div data-value="${escape(data.value)}" class="item">\n ${(this.escape ? escape(data.text) : data.text)}\n</div>`;
84
+ // },
85
+ // item: (data, escape) => {
86
+ // return `<div data-value="${escape(data.value)}" data-selectable="" class="option">\n ${(this.escape ? escape(data.text) : data.text)}\n</div>`;
87
+ // },
88
+ // option_create: (data) => {
89
+ // return `<div class="create" data-selectable="">\n ${this.$el.data('add-translation')}\n <strong>${data.input}</strong> ...\n</div>`;
90
+ // }
91
+ // };
92
+ // }
93
+
94
+ // };
95
+
96
+ // $.fn.simpleFormSelectize = function(options = {}) {
97
+ // return this.each(function(i, el) {
98
+ // var $select, instance;
99
+ // $select = $(el);
100
+ // if ($select.data('simple-form:selectize')) {
101
+ // return;
102
+ // }
103
+ // instance = new SimpleFormSelectize($select, options);
104
+ // return $select.data('simple-form:selectize', instance);
105
+ // });
106
+ // };
107
+
108
+ // $.simpleForm.onDomReady(function($document) {
109
+ // return $document.find('[data-selectize]').simpleFormSelectize();
110
+ // });
111
+
112
+ // // Clean up selectize instances before the turbo page is cached to avoid double
113
+ // // initialization of the selectize markup when the page is restored from cache.
114
+ // $(document).on('turbo:before-cache', function(e) {
115
+ // return $('[data-selectize]').each(function(i, el) {
116
+ // var $select, selectize;
117
+ // $select = $(el);
118
+ // if (!$select.data('simple-form:selectize')) {
119
+ // return;
120
+ // }
121
+ // $select.data('simple-form:selectize', null);
122
+ // selectize = $select.data('selectize');
123
+ // if (selectize != null ? selectize.destroy : void 0) {
124
+ // return selectize.destroy();
125
+ // }
126
+ // });
127
+ // });
128
+
129
+ // // Fix for allowEmptyOption issue
130
+
131
+ // // See : https://github.com/selectize/selectize.js/issues/967
132
+
133
+ // hash_key = function(value) {
134
+ // if (typeof value === 'undefined' || value === null) {
135
+ // return null;
136
+ // }
137
+ // if (typeof value === 'boolean') {
138
+ // if (value) {
139
+ // return '1';
140
+ // } else {
141
+ // return '0';
142
+ // }
143
+ // }
144
+ // return value + '';
145
+ // };
146
+
147
+ // $.extend(Selectize.prototype, {
148
+ // registerOption: function(data) {
149
+ // var key;
150
+ // key = hash_key(data[this.settings.valueField]);
151
+ // // Line 1187 of src/selectize.js should be changed
152
+ // // if (!key || this.options.hasOwnProperty(key)) return false;
153
+ // if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) {
154
+ // return false;
155
+ // }
156
+ // data.$order = data.$order || ++this.order;
157
+ // this.options[key] = data;
158
+ // return key;
159
+ // }
160
+ // });
@@ -0,0 +1,62 @@
1
+ $.simpleForm = {
2
+ // Bind a callback to run when a DOM or sub-DOM is ready to be initialized
3
+ // Allows abstracting the following cases :
4
+ // - Document is ready with $(document).ready()
5
+ // - Document is ready with Turbo page or frame loading
6
+ // - A sub-DOM is dynamically added and needs all the plugins to be
7
+ // initialized, ex: for nested forms
8
+ //
9
+ onDomReady: function(callback) {
10
+ $(document).on('initialize.simpleform', function(_e, $fragment) {
11
+ callback($fragment);
12
+ });
13
+ }
14
+ }
15
+
16
+ // Trigger all the registered callbacks and run them on the target element
17
+ $.fn.simpleForm = function () {
18
+ this.each(function (i, fragment) {
19
+ $(document).trigger('initialize.simpleform', [$(fragment)])
20
+ });
21
+ };
22
+
23
+ const initializeSimpleForm = function (target) {
24
+ const $target = $(target);
25
+
26
+ if ($target.data('simple-form:initialized')) return;
27
+
28
+ $target.data('simple-form:initialized', true);
29
+ $target.simpleForm();
30
+ };
31
+
32
+ // Turbo document ready binding
33
+ // $(document).on('turbo:load turbo:frame-load turbo:render turbo:frame-render', function (event) {
34
+ $(document).on(
35
+ 'turbo:load turbo:frame-load turbo:render',
36
+ (event) => {
37
+ var target = event.target === document.documentElement ? 'body' : event.target;
38
+
39
+ initializeSimpleForm(target);
40
+ }
41
+ );
42
+
43
+ $(document).on('turbo:before-frame-render', function (event) {
44
+ const defaultRenderAction = event.detail.render
45
+
46
+ event.detail.render = function (currentElement, newElement) {
47
+ defaultRenderAction(currentElement, newElement);
48
+
49
+ initializeSimpleForm(newElement);
50
+ };
51
+ });
52
+
53
+ $(document).on('turbo:before-stream-render', function (event) {
54
+ const defaultRenderAction = event.detail.render
55
+
56
+ event.detail.render = function (streamElement) {
57
+ defaultRenderAction(streamElement);
58
+
59
+ const target = document.getElementById(streamElement.target);
60
+ initializeSimpleForm(target);
61
+ };
62
+ });
@@ -0,0 +1,43 @@
1
+ var Slider;
2
+
3
+ Slider = class Slider {
4
+ constructor($el) {
5
+ var ref, value, values;
6
+ this.$el = $el;
7
+ value = (values = (ref = this.$el.data('slider-value')) != null ? ref.toString().split(',') : void 0) ? values.length <= 1 ? parseFloat(values[0], 10) : (function() {
8
+ var j, len, results;
9
+ results = [];
10
+ for (j = 0, len = values.length; j < len; j++) {
11
+ value = values[j];
12
+ results.push(parseFloat(value, 10));
13
+ }
14
+ return results;
15
+ })() : void 0;
16
+ if (this.$el.bootstrapSlider) {
17
+ this.$el.bootstrapSlider({
18
+ value: value
19
+ });
20
+ } else {
21
+ this.$el.slider({
22
+ value: value
23
+ });
24
+ }
25
+ }
26
+
27
+ };
28
+
29
+ $.fn.simpleFormSlider = function() {
30
+ return this.each(function(i, el) {
31
+ var $select, instance;
32
+ $select = $(el);
33
+ if ($select.data('simple-form:slider')) {
34
+ return;
35
+ }
36
+ instance = new Slider($select);
37
+ return $select.data('simple-form:slider', instance);
38
+ });
39
+ };
40
+
41
+ $.simpleForm.onDomReady(function($document) {
42
+ return $document.find('[data-simple-form-slider]').simpleFormSlider();
43
+ });
@@ -0,0 +1,35 @@
1
+ var Spinbox;
2
+
3
+ Spinbox = class Spinbox {
4
+ constructor($el) {
5
+ var defaults, options;
6
+ this.$el = $el;
7
+ options = this.$el.find('input').data('spinner');
8
+ defaults = {
9
+ max: Number.POSITIVE_INFINITY
10
+ };
11
+ this.$el.spinbox($.extend(defaults, options));
12
+ }
13
+
14
+ };
15
+
16
+ $.fn.simpleFormSpinbox = function() {
17
+ return this.each(function(i, el) {
18
+ var $input, instance;
19
+ $input = $(el);
20
+ if ($input.data('simple-form:spinbox')) {
21
+ return;
22
+ }
23
+ instance = new Spinbox($input);
24
+ return $input.data('simple-form:spinbox', instance);
25
+ });
26
+ };
27
+
28
+ $.simpleForm.onDomReady(function($document) {
29
+ var $spinbox;
30
+ $spinbox = $document.find('.spinbox');
31
+ if (!$spinbox.length) {
32
+ return;
33
+ }
34
+ return $spinbox.simpleFormSpinbox();
35
+ });