binda 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +83 -25
  3. data/app/assets/javascripts/binda/application.js +3 -3
  4. data/app/assets/javascripts/binda/components/bootstrap.js +3 -4
  5. data/app/assets/javascripts/binda/components/field_group_editor.js +10 -10
  6. data/app/assets/javascripts/binda/components/field_setting_choices.js +61 -49
  7. data/app/assets/javascripts/binda/components/fileupload.js +135 -118
  8. data/app/assets/javascripts/binda/components/form_item.js +65 -65
  9. data/app/assets/javascripts/binda/components/form_item_editor.js +19 -19
  10. data/app/assets/javascripts/binda/components/form_item_image.js +11 -13
  11. data/app/assets/javascripts/binda/components/form_item_repeater.js +77 -71
  12. data/app/assets/javascripts/binda/components/login-shader.js +171 -164
  13. data/app/assets/javascripts/binda/components/login_form.js +65 -73
  14. data/app/assets/javascripts/binda/components/radio-toggle.js +8 -12
  15. data/app/assets/javascripts/binda/components/select2.js +19 -14
  16. data/app/assets/javascripts/binda/components/sortable.js +76 -71
  17. data/app/assets/javascripts/binda/dist/binda.bundle.js +735 -727
  18. data/app/assets/javascripts/binda/index.js +49 -35
  19. data/app/assets/stylesheets/binda/components/assets_manager.scss +13 -22
  20. data/app/assets/stylesheets/binda/components/b-alert.scss +18 -14
  21. data/app/assets/stylesheets/binda/components/b-btn.scss +24 -43
  22. data/app/assets/stylesheets/binda/components/field_setting_choices.scss +16 -31
  23. data/app/assets/stylesheets/binda/components/fileupload.scss +25 -42
  24. data/app/assets/stylesheets/binda/components/form_item.scss +51 -93
  25. data/app/assets/stylesheets/binda/components/form_item_choices.scss +7 -10
  26. data/app/assets/stylesheets/binda/components/login.scss +2 -2
  27. data/app/assets/stylesheets/binda/components/main_header.scss +5 -10
  28. data/app/assets/stylesheets/binda/components/main_sidebar.scss +42 -46
  29. data/app/assets/stylesheets/binda/components/main_sortable_table.scss +12 -21
  30. data/app/assets/stylesheets/binda/components/main_table.scss +18 -35
  31. data/app/assets/stylesheets/binda/components/popup_warning.scss +14 -27
  32. data/app/assets/stylesheets/binda/components/select2.scss +46 -48
  33. data/app/assets/stylesheets/binda/components/sortable.scss +25 -45
  34. data/app/assets/stylesheets/binda/components/standard-form.scss +43 -73
  35. data/app/assets/stylesheets/binda/controllers/users_sessions_new.scss +52 -89
  36. data/app/assets/stylesheets/binda/index.scss +0 -1
  37. data/app/assets/stylesheets/binda/settings/buttons.scss +9 -10
  38. data/app/assets/stylesheets/binda/settings/common.scss +17 -22
  39. data/app/assets/stylesheets/binda/settings/fonts.scss +112 -67
  40. data/app/assets/stylesheets/binda/settings/tiny_mce_overrides.scss +20 -36
  41. data/app/assets/stylesheets/binda/settings/variables.scss +38 -43
  42. data/app/controllers/binda/choices_controller.rb +14 -11
  43. data/app/controllers/binda/components_controller.rb +6 -4
  44. data/app/controllers/binda/structures_controller.rb +7 -3
  45. data/app/helpers/binda/components_helper.rb +69 -3
  46. data/app/helpers/binda/field_groups_helper.rb +16 -6
  47. data/app/helpers/binda/structures_helper.rb +1 -4
  48. data/app/models/binda/application_record.rb +4 -1
  49. data/app/models/binda/asset.rb +3 -1
  50. data/app/models/binda/b.rb +1 -0
  51. data/app/models/binda/category.rb +1 -0
  52. data/app/models/binda/checkbox.rb +2 -0
  53. data/app/models/binda/choice.rb +74 -41
  54. data/app/models/binda/component.rb +1 -1
  55. data/app/models/binda/date.rb +4 -0
  56. data/app/models/binda/deprecation.rb +7 -0
  57. data/app/models/binda/field_group.rb +16 -3
  58. data/app/models/binda/field_setting.rb +168 -41
  59. data/app/models/binda/image.rb +1 -0
  60. data/app/models/binda/radio.rb +2 -0
  61. data/app/models/binda/relation.rb +3 -0
  62. data/app/models/binda/repeater.rb +3 -0
  63. data/app/models/binda/selection.rb +237 -0
  64. data/app/models/binda/string.rb +4 -0
  65. data/app/models/binda/structure.rb +25 -14
  66. data/app/models/binda/text.rb +9 -0
  67. data/app/models/binda/video.rb +1 -0
  68. data/app/models/concerns/binda/default_helpers.rb +40 -31
  69. data/app/models/concerns/binda/deprecations.rb +6 -0
  70. data/app/models/concerns/binda/fieldable_association_helpers.rb +366 -0
  71. data/app/models/concerns/binda/fieldable_associations.rb +32 -369
  72. data/app/views/binda/boards/edit.html.erb +15 -2
  73. data/app/views/binda/categories/_form.html.erb +24 -51
  74. data/app/views/binda/categories/edit.html.erb +23 -3
  75. data/app/views/binda/categories/index.html.erb +49 -25
  76. data/app/views/binda/categories/new.html.erb +21 -2
  77. data/app/views/binda/components/edit.html.erb +27 -4
  78. data/app/views/binda/components/index.html.erb +47 -50
  79. data/app/views/binda/components/new.html.erb +12 -2
  80. data/app/views/binda/components/sort_index.html.erb +28 -13
  81. data/app/views/binda/field_groups/_form_body.html.erb +43 -82
  82. data/app/views/binda/field_groups/_form_item.html.erb +3 -120
  83. data/app/views/binda/field_groups/_form_section.html.erb +11 -16
  84. data/app/views/binda/field_groups/_form_section_repeater.html.erb +7 -15
  85. data/app/views/binda/field_groups/edit.html.erb +14 -2
  86. data/app/views/binda/field_groups/form_item/_form_item_choice_editor.html.erb +11 -0
  87. data/app/views/binda/field_groups/form_item/_form_item_editor.html.erb +14 -0
  88. data/app/views/binda/field_groups/form_item/_form_item_header.html.erb +25 -0
  89. data/app/views/binda/field_groups/form_item/_form_item_new_editor.html.erb +8 -0
  90. data/app/views/binda/field_groups/form_item/_form_item_persisted_editor.html.erb +27 -0
  91. data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_allow_null_choice.html.erb +11 -0
  92. data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_choice_header.html.erb +11 -0
  93. data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_default_choice.html.erb +11 -0
  94. data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_new_choice.html.erb +16 -0
  95. data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_persisted_choices.html.erb +16 -0
  96. data/app/views/binda/field_groups/new.html.erb +14 -2
  97. data/app/views/binda/field_settings/_form_body.html.erb +1 -3
  98. data/app/views/binda/field_settings/edit.html.erb +1 -1
  99. data/app/views/binda/field_settings/new.html.erb +1 -1
  100. data/app/views/binda/fieldable/_form_body.html.erb +24 -72
  101. data/app/views/binda/fieldable/_form_item_date.html.erb +1 -4
  102. data/app/views/binda/fieldable/_form_item_image.html.erb +3 -7
  103. data/app/views/binda/fieldable/_form_item_new_repeater.html.erb +0 -13
  104. data/app/views/binda/fieldable/_form_item_selections.html.erb +20 -112
  105. data/app/views/binda/fieldable/form_item_selections/_form_item_checkbox.html.erb +34 -0
  106. data/app/views/binda/fieldable/form_item_selections/_form_item_radio.html.erb +28 -0
  107. data/app/views/binda/fieldable/form_item_selections/_form_item_selection.html.erb +30 -0
  108. data/app/views/binda/manage/users/_form_body.html.erb +1 -31
  109. data/app/views/binda/manage/users/edit.html.erb +12 -2
  110. data/app/views/binda/manage/users/index.html.erb +36 -19
  111. data/app/views/binda/manage/users/new.html.erb +14 -3
  112. data/app/views/binda/structures/_form_body.html.erb +2 -25
  113. data/app/views/binda/structures/_form_section.html.erb +43 -65
  114. data/app/views/binda/structures/_form_sidebar.html.erb +19 -12
  115. data/app/views/binda/structures/edit.html.erb +20 -3
  116. data/app/views/binda/structures/index.html.erb +46 -26
  117. data/app/views/binda/structures/new.html.erb +13 -2
  118. data/app/views/binda/structures/sort_index.html.erb +37 -17
  119. data/app/views/binda/users/sessions/new.html.erb +25 -20
  120. data/app/views/layouts/binda/_form_errors.html.erb +10 -0
  121. data/app/views/layouts/binda/_sidebar.html.erb +6 -6
  122. data/app/views/layouts/binda/application.html.erb +1 -1
  123. data/config/initializers/carrierwave.rb +3 -2
  124. data/config/locales/en.yml +56 -12
  125. data/config/tinymce.yml +2 -2
  126. data/db/migrate/1_create_binda_tables.rb +1 -1
  127. data/lib/binda/version.rb +1 -1
  128. data/lib/generators/binda/setup/setup_generator.rb +2 -2
  129. data/lib/tasks/add_default_choice_to_all_selections_with_no_choices_task.rake +6 -0
  130. metadata +58 -8
  131. data/app/assets/stylesheets/binda/components/form_item_image.scss +0 -0
  132. data/app/views/binda/field_groups/_form_item_choice.erb +0 -104
@@ -1,18 +1,14 @@
1
- export default function()
2
- {
3
- $('input[name="login"]').click(function(){
1
+ export default function() {
2
+ $('input[name="login"]').click(function() {
4
3
  let $radio = $(this);
5
4
 
6
5
  // if this was previously checked
7
- if ($radio.data('waschecked') === true)
8
- {
9
- $radio.prop('checked', false);
10
- $radio.data('waschecked', false);
11
- }
12
- else
13
- $radio.data('waschecked', true);
6
+ if ($radio.data("waschecked") === true) {
7
+ $radio.prop("checked", false);
8
+ $radio.data("waschecked", false);
9
+ } else $radio.data("waschecked", true);
14
10
 
15
11
  // remove was checked from other radios
16
- $radio.siblings('input[name="login"]').data('waschecked', false);
12
+ $radio.siblings('input[name="login"]').data("waschecked", false);
17
13
  });
18
- }
14
+ }
@@ -2,21 +2,26 @@
2
2
  * OPTIONAL (SELECT2 PLUGIN)
3
3
  */
4
4
 
5
- export default function ()
6
- {
7
- setupSelect2('.select2-item')
5
+ export default function() {
6
+ setupSelect2(".select2-item");
8
7
  }
9
8
 
10
- export function setupSelect2(target)
11
- {
12
- $(target).each(function()
13
- {
14
- let placeholder = $(this).attr('placeholder')
15
- if ( typeof placeholder == 'undefined' ) { placeholder = 'Select a option' }
9
+ export function setupSelect2(target) {
10
+ $(target).each(function() {
11
+ let placeholder = $(this).attr("placeholder");
12
+ if (typeof placeholder == "undefined") {
13
+ placeholder = "Select a option";
14
+ }
16
15
 
17
- $(this).select2({
16
+ let allowClear = false;
17
+ if ($(this).hasClass("select2-item-include-blank")) {
18
+ allowClear = true;
19
+ }
20
+
21
+ $(this).select2({
18
22
  minimumResultsForSearch: 32, // 31 are max number of day in a month, which you don't want to be searchable
19
- placeholder: placeholder
20
- })
21
- })
22
- }
23
+ placeholder: placeholder,
24
+ allowClear: allowClear
25
+ });
26
+ });
27
+ }
@@ -2,102 +2,107 @@
2
2
  * SORTABLE
3
3
  */
4
4
 
5
-
6
5
  var sortableOptions = {
7
- stop: function(event, ui){ ui.item.css('z-index', 0) },
8
- placeholder: "ui-state-highlight",
9
- update: updateSortable
10
- }
6
+ stop: function(event, ui) {
7
+ ui.item.css("z-index", 0);
8
+ },
9
+ placeholder: "ui-state-highlight",
10
+ update: updateSortable
11
+ };
11
12
 
12
- export default function()
13
- {
14
- if ( $('.sortable').length > 0 )
15
- {
13
+ export default function() {
14
+ if ($(".sortable").length > 0) {
16
15
  // Initialize sortable item
17
- $('.sortable').sortable( sortableOptions )
16
+ $(".sortable").sortable(sortableOptions);
18
17
 
19
18
  // Check if sortable item needs handles
20
- $('.sortable').each( function()
21
- {
22
- if ( $(this).find('.sortable--handle').length > 0 )
23
- { $(this).sortable('option', 'handle', '.sortable--handle') }
24
- else
25
- { $(this).addClass('sortable--no-handle') }
26
- })
19
+ $(".sortable").each(function() {
20
+ if ($(this).find(".sortable--handle").length > 0) {
21
+ $(this).sortable("option", "handle", ".sortable--handle");
22
+ } else {
23
+ $(this).addClass("sortable--no-handle");
24
+ }
25
+ });
27
26
 
28
- $('.sortable--disabled').sortable('disable')
27
+ $(".sortable--disabled").sortable("disable");
29
28
  }
30
29
 
31
30
  // If there is a sortable toggle button prepare the sortable items accordingly
32
- if ( $('.sortable--toggle').length > 0 ) { setupSortableToggle() }
31
+ if ($(".sortable--toggle").length > 0) {
32
+ setupSortableToggle();
33
+ }
33
34
 
34
35
  // Add event to any sortable toggle button
35
36
  // TODO: make this event available to element which aren't standard form repeaters
36
- $(document).on('click', '.standard-form--repeater .sortable--toggle', toggleSortable)
37
+ $(document).on(
38
+ "click",
39
+ ".standard-form--repeater .sortable--toggle",
40
+ toggleSortable
41
+ );
37
42
  }
38
43
 
39
-
40
- function setupSortableToggle()
41
- {
42
- $('.sortable--toggle').each(function()
43
- {
44
- let id = '#' + $( this ).data('repeater-id')
45
- $( id ).find('.form-item--collapsable').addClass('form-item--collapsed')
46
- $( id ).find('.form-item--repeater-fields').each(close)
47
- })
44
+ function setupSortableToggle() {
45
+ $(".sortable--toggle").each(function() {
46
+ let id = "#" + $(this).data("repeater-id");
47
+ $(id)
48
+ .find(".form-item--collapsable")
49
+ .addClass("form-item--collapsed");
50
+ $(id)
51
+ .find(".form-item--repeater-fields")
52
+ .each(close);
53
+ });
48
54
  }
49
55
 
50
- function close()
51
- {
52
- this.style.maxHeight = '0px'
56
+ function close() {
57
+ this.style.maxHeight = "0px";
53
58
  }
54
59
 
55
- function open()
56
- {
60
+ function open() {
57
61
  this.style.maxHeight = this.scrollHeight + "px";
58
62
  }
59
63
 
60
- function toggleSortable(event)
61
- {
62
- event.preventDefault()
63
- let id = '#' + $( this ).data('repeater-id')
64
+ function toggleSortable(event) {
65
+ event.preventDefault();
66
+ let id = "#" + $(this).data("repeater-id");
64
67
 
65
- if ( $( id ).hasClass('sortable--disabled') )
66
- {
67
- $( id ).sortable('enable')
68
- $( id ).find('.form-item--repeater-fields').each(close)
69
- $( id ).find('.form-item--collapsable').addClass('form-item--collapsed')
70
- }
71
- else
72
- {
73
- $( id ).sortable('disable')
68
+ if ($(id).hasClass("sortable--disabled")) {
69
+ $(id).sortable("enable");
70
+ $(id)
71
+ .find(".form-item--repeater-fields")
72
+ .each(close);
73
+ $(id)
74
+ .find(".form-item--collapsable")
75
+ .addClass("form-item--collapsed");
76
+ } else {
77
+ $(id).sortable("disable");
74
78
  }
75
79
 
76
- $( id ).toggleClass('sortable--disabled')
77
- $( id ).toggleClass('sortable--enabled')
78
- $( this ).children('.sortable--toggle-text').toggle()
80
+ $(id).toggleClass("sortable--disabled");
81
+ $(id).toggleClass("sortable--enabled");
82
+ $(this)
83
+ .children(".sortable--toggle-text")
84
+ .toggle();
79
85
  }
80
86
 
81
- function updateSortable()
82
- {
83
- if ( $('.popup-warning').length > 0 )
84
- {
85
- $(this).addClass('sortable--disabled')
86
- $('.popup-warning--message').text( $(this).data('message') )
87
- $('.popup-warning').removeClass('popup-warning--hidden')
88
- $(this).sortable('option','disabled', true)
87
+ function updateSortable() {
88
+ if ($(".popup-warning").length > 0) {
89
+ $(this).addClass("sortable--disabled");
90
+ $(".popup-warning--message").text($(this).data("message"));
91
+ $(".popup-warning").removeClass("popup-warning--hidden");
92
+ $(this).sortable("option", "disabled", true);
89
93
  }
90
- let url = $(this).data('update-url')
91
- let data = $(this).sortable('serialize')
94
+ let url = $(this).data("update-url");
95
+ let data = $(this).sortable("serialize");
92
96
  // If there is a pagination update accordingly
93
- data = data.concat(`&id=${$(this).attr('id')}`)
94
- $.post( url, data ).done( function(doneData)
95
- {
96
- $(doneData.id).sortable('option', 'disabled', false)
97
- $('.popup-warning').addClass('popup-warning--hidden')
98
- $(doneData.id).removeClass('sortable--disabled')
99
- }).fail(function(failData){
100
- $('.popup-warning').addClass('popup-warning--hidden')
101
- alert('Error: ' + failData.message)
102
- })
103
- }
97
+ data = data.concat(`&id=${$(this).attr("id")}`);
98
+ $.post(url, data)
99
+ .done(function(doneData) {
100
+ $(doneData.id).sortable("option", "disabled", false);
101
+ $(".popup-warning").addClass("popup-warning--hidden");
102
+ $(doneData.id).removeClass("sortable--disabled");
103
+ })
104
+ .fail(function(failData) {
105
+ $(".popup-warning").addClass("popup-warning--hidden");
106
+ alert("Error: " + failData.message);
107
+ });
108
+ }
@@ -33,9 +33,6 @@
33
33
  /******/ // expose the module cache
34
34
  /******/ __webpack_require__.c = installedModules;
35
35
  /******/
36
- /******/ // identity function for calling harmony imports with the correct context
37
- /******/ __webpack_require__.i = function(value) { return value; };
38
- /******/
39
36
  /******/ // define getter function for harmony exports
40
37
  /******/ __webpack_require__.d = function(exports, name, getter) {
41
38
  /******/ if(!__webpack_require__.o(exports, name)) {
@@ -63,7 +60,7 @@
63
60
  /******/ __webpack_require__.p = "";
64
61
  /******/
65
62
  /******/ // Load entry module and return exports
66
- /******/ return __webpack_require__(__webpack_require__.s = 13);
63
+ /******/ return __webpack_require__(__webpack_require__.s = 2);
67
64
  /******/ })
68
65
  /************************************************************************/
69
66
  /******/ ([
@@ -84,11 +81,11 @@ var FormItemEditor = function () {
84
81
  function FormItemEditor() {
85
82
  _classCallCheck(this, FormItemEditor);
86
83
 
87
- this.target = '.form-item--editor';
84
+ this.target = ".form-item--editor";
88
85
  }
89
86
 
90
87
  _createClass(FormItemEditor, [{
91
- key: 'isSet',
88
+ key: "isSet",
92
89
  value: function isSet() {
93
90
  if ($(this.target).length > 0) {
94
91
  return true;
@@ -97,7 +94,7 @@ var FormItemEditor = function () {
97
94
  }
98
95
  }
99
96
  }, {
100
- key: 'setEvents',
97
+ key: "setEvents",
101
98
  value: function setEvents() {
102
99
  var _this = this;
103
100
 
@@ -109,14 +106,14 @@ var FormItemEditor = function () {
109
106
  });
110
107
  }
111
108
  }, {
112
- key: 'resize',
109
+ key: "resize",
113
110
  value: function resize() {
114
111
  $(this.target).each(function () {
115
112
  // If the form item editor is closed don't go any further
116
113
  if ($(this).height() === 0) return;
117
114
  // otherwise update the max-height which is needed for the CSS transition
118
115
  // NOTE you need to remove the max-height (inside 'style' attribute) to get the real height
119
- $(this).get(0).style.height = 'auto';
116
+ $(this).get(0).style.height = "auto";
120
117
  $(this).get(0).style.maxHeight = $(this).get(0).scrollHeight + "px";
121
118
  });
122
119
  }
@@ -138,19 +135,25 @@ var _FormItemEditor = new FormItemEditor();
138
135
  */
139
136
 
140
137
  /* harmony default export */ __webpack_exports__["a"] = (function () {
141
- setupSelect2('.select2-item');
138
+ setupSelect2(".select2-item");
142
139
  });
143
140
 
144
141
  function setupSelect2(target) {
145
142
  $(target).each(function () {
146
- var placeholder = $(this).attr('placeholder');
147
- if (typeof placeholder == 'undefined') {
148
- placeholder = 'Select a option';
143
+ var placeholder = $(this).attr("placeholder");
144
+ if (typeof placeholder == "undefined") {
145
+ placeholder = "Select a option";
146
+ }
147
+
148
+ var allowClear = false;
149
+ if ($(this).hasClass("select2-item-include-blank")) {
150
+ allowClear = true;
149
151
  }
150
152
 
151
153
  $(this).select2({
152
154
  minimumResultsForSearch: 32, // 31 are max number of day in a month, which you don't want to be searchable
153
- placeholder: placeholder
155
+ placeholder: placeholder,
156
+ allowClear: allowClear
154
157
  });
155
158
  });
156
159
  }
@@ -160,332 +163,211 @@ function setupSelect2(target) {
160
163
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
161
164
 
162
165
  "use strict";
163
- /**
164
- * BOOSTRAP SCRIPT
165
- */
166
-
167
- /* harmony default export */ __webpack_exports__["a"] = (function () {
168
- // See https://v4-alpha.getbootstrap.com/components/tooltips/#example-enable-tooltips-everywhere
169
- $('[data-toggle="tooltip"]').tooltip();
170
- });
171
-
172
- /***/ }),
173
- /* 3 */
174
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
175
-
176
- "use strict";
177
- /**
178
- * FIELD GROUP EDITOR
179
- */
180
-
181
- /* harmony default export */ __webpack_exports__["a"] = (function () {
182
- $('.field_groups-edit #save').on('click', function (event) {
183
- var instanceType = $(this).data('instance-type');
184
- var entriesNumber = $(this).data('entries-number');
185
-
186
- // If the current structure have many entries updating the field group
187
- // might be a slow operation, therefore it's good practice to inform the user
188
- if (entriesNumber > 500) {
189
- alert('You have ' + entriesNumber + ' ' + instanceType + '. This operation might take some time to complete. To avoid unexpected behaviour don\'t leave or refresh the page');
190
- }
191
- });
192
- });
166
+ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
167
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_form_item__ = __webpack_require__(3);
168
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__ = __webpack_require__(4);
169
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_form_item_image__ = __webpack_require__(5);
170
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_field_setting_choices__ = __webpack_require__(6);
171
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__ = __webpack_require__(0);
172
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_fileupload__ = __webpack_require__(7);
173
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__components_login_shader__ = __webpack_require__(8);
174
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__components_login_form__ = __webpack_require__(9);
175
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__components_sortable__ = __webpack_require__(10);
176
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__components_field_group_editor__ = __webpack_require__(11);
177
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__components_bootstrap__ = __webpack_require__(12);
178
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__components_select2__ = __webpack_require__(1);
179
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__components_radio_toggle__ = __webpack_require__(13);
180
+ ///- - - - - - - - - - - - - - - - - - - -
181
+ /// INDEX OF BINDA'S SCRIPTS
182
+ ///- - - - - - - - - - - - - - - - - - - -
193
183
 
194
- /***/ }),
195
- /* 4 */
196
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
197
184
 
198
- "use strict";
199
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FieldSettingChoices; });
200
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
201
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
202
185
 
203
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
204
186
 
205
- /**
206
- * FORM ITEM CHOICE
207
- */
208
187
 
209
188
 
210
189
 
211
- var FieldSettingChoices = function () {
212
- function FieldSettingChoices() {
213
- _classCallCheck(this, FieldSettingChoices);
214
190
 
215
- this.target = '.field-setting-choices--choice';
216
- }
217
-
218
- _createClass(FieldSettingChoices, [{
219
- key: 'isSet',
220
- value: function isSet() {
221
- if ($(this.target).length > 0) {
222
- return true;
223
- } else {
224
- return false;
225
- }
226
- }
227
- }, {
228
- key: 'setEvents',
229
- value: function setEvents() {
230
- $(document).on('click', '.field-setting-choices--add-choice', addChoice);
231
191
 
232
- $(document).on('click', '.field-setting-choices--delete-choice', deleteChoice);
233
- $(document).on('click', '.field-setting-choices--js-delete-choice', function (event) {
234
- event.preventDefault();
235
- $(this).closest('.field-setting-choices--choice').remove();
236
- // Update form item editor size
237
- __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
238
- });
239
- }
240
- }]);
241
192
 
242
- return FieldSettingChoices;
243
- }();
244
193
 
245
- var _FieldSettingChoices = new FieldSettingChoices();
246
194
 
247
- /**
248
- * HELPER FUNCTIONS
249
- */
250
195
 
251
- function addChoice(event) {
252
- event.preventDefault();
253
- // Clone the new choice field
254
- var choices_id = $(this).data('choices-id');
255
- var choices = $('#' + choices_id);
256
- var newchoice = choices.find('.field-setting-choices--new-choice');
257
- var clone = newchoice.clone().removeClass('field-setting-choices--new-choice').toggle();
258
- clone.find('.field-setting-choices--toggle-choice').toggle();
259
- // Append the clone right after
260
- choices.prepend(clone);
261
- // Update form item editor size
262
- __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
263
- }
264
196
 
265
- function deleteChoice(event) {
266
- event.preventDefault();
267
197
 
268
- var choice = $(this).closest('.field-setting-choices--choice');
269
- var destination = $(this).attr('href');
270
- var self = this;
198
+ $(document).ready(function () {
199
+ if (__WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].isSet()) {
200
+ __WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].setEvents();
201
+ }
202
+ if (__WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__["a" /* _FormItemRepeater */].isSet()) {
203
+ __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__["a" /* _FormItemRepeater */].setEvents();
204
+ }
205
+ if (__WEBPACK_IMPORTED_MODULE_2__components_form_item_image__["a" /* _FormItemImage */].isSet()) {
206
+ __WEBPACK_IMPORTED_MODULE_2__components_form_item_image__["a" /* _FormItemImage */].setEvents();
207
+ }
208
+ if (__WEBPACK_IMPORTED_MODULE_3__components_field_setting_choices__["a" /* _FieldSettingChoices */].isSet()) {
209
+ __WEBPACK_IMPORTED_MODULE_3__components_field_setting_choices__["a" /* _FieldSettingChoices */].setEvents();
210
+ }
211
+ if (__WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__["a" /* _FormItemEditor */].isSet()) {
212
+ __WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__["a" /* _FormItemEditor */].setEvents();
213
+ }
214
+ if (__WEBPACK_IMPORTED_MODULE_5__components_fileupload__["a" /* _FileUpload */].isSet()) {
215
+ __WEBPACK_IMPORTED_MODULE_5__components_fileupload__["a" /* _FileUpload */].setEvents();
216
+ }
217
+ if (__WEBPACK_IMPORTED_MODULE_7__components_login_form__["a" /* _LoginForm */].isSet()) {
218
+ __WEBPACK_IMPORTED_MODULE_7__components_login_form__["a" /* _LoginForm */].init();
219
+ }
220
+ if (__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].isSet()) {
221
+ __WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].setup();
222
+ __WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].start();
223
+ }
224
+ Object(__WEBPACK_IMPORTED_MODULE_12__components_radio_toggle__["a" /* default */])();
225
+ Object(__WEBPACK_IMPORTED_MODULE_8__components_sortable__["a" /* default */])();
226
+ Object(__WEBPACK_IMPORTED_MODULE_9__components_field_group_editor__["a" /* default */])();
227
+ Object(__WEBPACK_IMPORTED_MODULE_10__components_bootstrap__["a" /* default */])();
228
+ Object(__WEBPACK_IMPORTED_MODULE_11__components_select2__["a" /* default */])();
229
+ });
271
230
 
272
- $.ajax({
273
- url: destination,
274
- type: 'DELETE',
275
- success: function success() {
276
- choice.remove();
277
- // Update form item editor size
278
- __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
279
- }
280
- });
281
- }
231
+ // handle event
232
+ window.addEventListener("optimizedResize", function () {
233
+ if (__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].isSet()) {
234
+ __WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].resize();
235
+ }
236
+ });
282
237
 
283
238
  /***/ }),
284
- /* 5 */
239
+ /* 3 */
285
240
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
286
241
 
287
242
  "use strict";
288
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FileUpload; });
289
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
290
-
243
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItem; });
244
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
245
+ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__select2__ = __webpack_require__(1);
291
246
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
292
247
 
293
248
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
294
249
 
295
250
  /**
296
- * FILE UPLOAD
297
- *
298
- * see https://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/
299
- *
251
+ * FORM ITEM
300
252
  */
301
253
 
302
- var FileUpload = function () {
303
- function FileUpload() {
304
- _classCallCheck(this, FileUpload);
305
254
 
306
- this.target = '.fileupload';
255
+
256
+
257
+ // Component Global Variables
258
+ var newFormItemId = 1;
259
+
260
+ var FormItem = function () {
261
+ function FormItem() {
262
+ _classCallCheck(this, FormItem);
307
263
  }
308
264
 
309
- _createClass(FileUpload, [{
310
- key: 'isSet',
265
+ _createClass(FormItem, [{
266
+ key: "isSet",
311
267
  value: function isSet() {
312
- if ($(this.target).length > 0) {
268
+ if ($(".form-item").length > 0) {
313
269
  return true;
314
270
  } else {
315
271
  return false;
316
272
  }
317
273
  }
318
274
  }, {
319
- key: 'setEvents',
275
+ key: "setEvents",
320
276
  value: function setEvents() {
321
- var self = this;
277
+ $(document).on("click", ".form-item--add-new", addNewItem);
322
278
 
323
- $(document).on('click', '.fileupload--remove-image-btn', remove_preview);
279
+ $(document).on("click", ".form-item--remove-item-with-js", function (event) {
280
+ // Stop default behaviour
281
+ event.preventDefault();
282
+ $(this).closest(".form-item").remove();
283
+ });
324
284
 
325
- $(document).on('change', this.target + ' input.file', handle_file);
285
+ $(document).on("click", ".form-item--collapse-btn", collapseToggle);
326
286
  }
327
287
  }]);
328
288
 
329
- return FileUpload;
289
+ return FormItem;
330
290
  }();
331
291
 
332
- var _FileUpload = new FileUpload();
333
-
334
- /**
335
- * HELPER FUNCTIONS
336
- */
337
-
338
- // Reference --> http://blog.teamtreehouse.com/uploading-files-ajax
339
- function handle_file(event) {
340
- var id = event.target.getAttribute('data-id');
341
- var $parent = $('#fileupload-' + id);
342
-
343
- // Get the selected file from the input
344
- // This script doesn't consider multiple files upload
345
- var file = event.target.files[0];
292
+ var _FormItem = new FormItem();
346
293
 
347
- // Don't go any further if no file has been selected
348
- if (typeof file === 'undefined') {
349
- return;
350
- }
294
+ ///- - - - - - - - - - - - - - - - - - - -
295
+ /// COMPONENT HELPER FUNCTIONS
296
+ ///- - - - - - - - - - - - - - - - - - - -
351
297
 
352
- // Create a new FormData object which will be sent to the server
353
- var formData = new FormData();
298
+ // This function could be improved as it generates an issue with
299
+ // input ids which are duplicated after the entire target has been cloned
300
+ function addNewItem(event) {
301
+ // Stop default behaviour
302
+ event.preventDefault();
303
+ // Get the child to clone
304
+ // (`this` always refers to the second argument of the $(document).on() method, in this case '.form-item--add-new')
305
+ var id = $(this).data("new-form-item-id");
306
+ var $newChild = $("#" + id);
307
+ // Clone child and remove id and styles from cloned child
308
+ $newChild.clone().insertAfter($newChild);
309
+ // Remove class in order to remove styles, and change id so it's reachable when testing
310
+ $newChild.removeClass("form-item--new").attr("id", "new-form-item-" + newFormItemId);
354
311
 
355
- // Get data from the input element
356
- $parent.find('input').each(function () {
357
- if (this.isSameNode(event.target)) {
358
- // Add the file to the request
359
- formData.append(this.getAttribute('name'), file, file.name);
360
- } else {
361
- // Add secondary values to the request
362
- formData.append(this.getAttribute('name'), this.getAttribute('value'));
312
+ // // Update all ids to avoid duplication
313
+ $newChild.find("[id]").each(function () {
314
+ var oldId = $(this).attr("id");
315
+ var newId = oldId + "-" + newFormItemId;
316
+ $(this).attr("id", newId);
317
+ var $forId = $newChild.find("[for=" + oldId + "]");
318
+ if ($forId.length > 0) {
319
+ $forId.attr("for", newId);
363
320
  }
364
321
  });
365
322
 
366
- // If it's inside a repeater add repeater parameters
367
- var $parent_repeater = $parent.closest('.form-item--repeater-fields');
368
- if ($parent.closest('.form-item--repeater-fields').length > 0) {
369
- $parent_repeater.children('.form-group').find('input').each(function () {
370
- formData.append(this.getAttribute('name'), this.getAttribute('value'));
371
- });
372
- }
373
-
374
- // Is this needed? Apparently it works without it. Is it a security issue?
375
- // let token = document.querySelector('meta[name="csrf-token"]').content
376
- // formData.append('authenticity_token', token)
377
-
378
- // Display loader
379
- $('.popup-warning--message').text($parent.data('message'));
380
- $('.popup-warning').removeClass('popup-warning--hidden');
323
+ // Update height (max-height) of the new element
324
+ var $formItemEditor = $("#new-form-item-" + newFormItemId).find(".form-item--editor");
381
325
 
382
- // Once form data are gathered make the request
383
- makeRequest(event, formData);
384
- }
326
+ // override current max-height which is set to 0
327
+ $formItemEditor.get(0).style.maxHeight = $formItemEditor.get(0).scrollHeight + "px";
385
328
 
386
- function makeRequest(event, formData) {
387
- var id = event.target.getAttribute('data-id');
388
- var $parent = $('#fileupload-' + id);
389
- // Make request
390
- $.ajax({
391
- url: event.target.getAttribute('data-url'),
392
- type: 'PATCH',
393
- processData: false, // needed to pass formData with the current format
394
- contentType: false, // needed to pass formData with the current format
395
- data: formData
396
- }).done(function (data) {
397
- if (data.type == 'image') {
398
- setup_image_preview(data, id);
399
- } else if (data.type == 'video') {
400
- setup_video_preview(data, id);
401
- } else {
402
- alert('Something went wrong. No preview has been received.');
403
- }
329
+ __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
404
330
 
405
- // Hide loaded
406
- $('.popup-warning').addClass('popup-warning--hidden');
331
+ // Increment global id variable `newFormItemId` in case needs to be used again
332
+ newFormItemId++;
407
333
 
408
- // Display details and buttons
409
- $parent.find('.fileupload--details').removeClass('fileupload--details--hidden');
410
- $parent.find('.fileupload--remove-image-btn').removeClass('fileupload--remove-image-btn--hidden');
411
- }).fail(function (dataFail) {
412
- console.error("Error:", dataFail.responseJSON);
413
- // Hide loaded
414
- $('.popup-warning').addClass('popup-warning--hidden');
415
- alert($parent.data('error'));
416
- });
334
+ Object(__WEBPACK_IMPORTED_MODULE_1__select2__["b" /* setupSelect2 */])($formItemEditor.find("select"));
417
335
  }
418
336
 
419
- function reset_file(input) {
420
- input.value = '';
421
-
422
- if (!/safari/i.test(navigator.userAgent)) {
423
- input.type = '';
424
- input.type = 'file';
425
- }
337
+ function close() {
338
+ this.style.maxHeight = "0px";
426
339
  }
427
340
 
428
- function remove_preview(event) {
429
- var id = event.target.getAttribute('data-id');
430
- var $parent = $('#fileupload-' + id);
431
-
432
- // Reset previews (either image or video)
433
- $parent.find('.fileupload--preview').css('background-image', '').removeClass('fileupload--preview--uploaded');
434
- $parent.find('video source').removeAttr('src');
435
-
436
- // Clear input field
437
- reset_file($parent.find('input[type=file]').get(0));
438
-
439
- // Reset buttons to initial state
440
- $parent.find('.fileupload--remove-image-btn').addClass('fileupload--remove-image-btn--hidden');
441
- $parent.find('.fileupload--details').addClass('fileupload--details--hidden');
341
+ function open() {
342
+ this.style.maxHeight = this.scrollHeight + "px";
442
343
  }
443
344
 
444
- function setup_image_preview(data, id) {
445
- var $parent = $('#fileupload-' + id);
446
- var $preview = $('#fileupload-' + id + ' .fileupload--preview');
447
-
448
- // Update thumbnail
449
- $preview.css('background-image', 'url(' + data.thumbnailUrl + ')');
450
-
451
- // Remove and add class to trigger css animation
452
- var uploadedClass = 'fileupload--preview--uploaded';
453
- $preview.removeClass(uploadedClass).addClass(uploadedClass);
454
-
455
- // Update details
456
- $parent.find('.fileupload--width').text(data.width);
457
- $parent.find('.fileupload--height').text(data.height);
458
- $parent.find('.fileupload--filesize').text(data.size);
459
- $parent.find('.fileupload--filename').text(data.name);
460
- }
345
+ function collapseToggle(event) {
346
+ // This function is temporarely just set for repeaters.
347
+ // TODO: Need refactoring in order to be available also for generic form items
461
348
 
462
- function setup_video_preview(data, id) {
463
- var $parent = $('#fileupload-' + id);
464
- var $preview = $('#fileupload-' + id + ' .fileupload--preview');
349
+ // Stop default behaviour
350
+ event.preventDefault();
465
351
 
466
- $preview.removeClass('fileupload--preview--uploaded').find('video').attr('id', 'video-' + id).find('source').attr('src', data.url).attr('type', 'video/' + data.ext);
352
+ var $collapsable = $(this).closest(".form-item--collapsable");
467
353
 
468
- // If video source isn't blank load it (consider that a video tag is always present)
469
- if (_typeof($preview.find('video source').attr('src')) != undefined) {
470
- $preview.find('video').get(0).load();
354
+ if ($collapsable.hasClass("form-item--collapsed")) {
355
+ $collapsable.find(".form-item--repeater-fields").each(open);
356
+ $collapsable.find(".form-item--editor").each(open);
357
+ $collapsable.removeClass("form-item--collapsed");
358
+ } else {
359
+ $collapsable.find(".form-item--repeater-fields").each(close);
360
+ $collapsable.find(".form-item--editor").each(close);
361
+ $collapsable.addClass("form-item--collapsed");
471
362
  }
472
-
473
- // Remove and add class to trigger css animation
474
- var uploadedClass = 'fileupload--preview--uploaded';
475
- $preview.removeClass(uploadedClass).addClass(uploadedClass);
476
-
477
- // Update details
478
- $parent.find('.fileupload--filesize').text(data.size);
479
- $parent.find('.fileupload--filename').text(data.name);
480
- $parent.find('.fileupload--videolink a').attr('href', data.url);
481
363
  }
482
364
 
483
365
  /***/ }),
484
- /* 6 */
366
+ /* 4 */
485
367
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
486
368
 
487
369
  "use strict";
488
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItem; });
370
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemRepeater; });
489
371
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
490
372
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__select2__ = __webpack_require__(1);
491
373
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -493,122 +375,132 @@ var _createClass = function () { function defineProperties(target, props) { for
493
375
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
494
376
 
495
377
  /**
496
- * FORM ITEM
378
+ * FORM ITEM REPEATER
497
379
  */
498
380
 
499
381
 
500
382
 
501
383
 
502
- // Component Global Variables
503
- var newFormItemId = 1;
504
-
505
- var FormItem = function () {
506
- function FormItem() {
507
- _classCallCheck(this, FormItem);
384
+ var FormItemRepeater = function () {
385
+ function FormItemRepeater() {
386
+ _classCallCheck(this, FormItemRepeater);
508
387
  }
509
388
 
510
- _createClass(FormItem, [{
511
- key: 'isSet',
389
+ _createClass(FormItemRepeater, [{
390
+ key: "isSet",
512
391
  value: function isSet() {
513
- if ($('.form-item').length > 0) {
392
+ if ($(".form-item--repeater-section").length > 0) {
514
393
  return true;
515
394
  } else {
516
395
  return false;
517
396
  }
518
397
  }
519
398
  }, {
520
- key: 'setEvents',
399
+ key: "setEvents",
521
400
  value: function setEvents() {
522
- $(document).on('click', '.form-item--add-new', addNewItem);
401
+ $(document).on("click", ".form-item--repeater-section--add-new", addNewItem);
523
402
 
524
- $(document).on('click', '.form-item--remove-item-with-js', function (event) {
403
+ $(document).on("click", ".form-item--remove-item-with-js", function (event) {
525
404
  // Stop default behaviour
526
405
  event.preventDefault();
527
- $(this).closest('.form-item').remove();
406
+ $(this).parent(".form-item--repeater-section").remove();
407
+ __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
528
408
  });
529
409
 
530
- $(document).on('click', '.form-item--collapse-btn', collapseToggle);
410
+ $(document).on("click", ".form-item--delete-repeater-item", deleteRepeter);
531
411
  }
532
412
  }]);
533
413
 
534
- return FormItem;
414
+ return FormItemRepeater;
535
415
  }();
536
416
 
537
- var _FormItem = new FormItem();
417
+ var _FormItemRepeater = new FormItemRepeater();
538
418
 
539
- ///- - - - - - - - - - - - - - - - - - - -
540
- /// COMPONENT HELPER FUNCTIONS
541
- ///- - - - - - - - - - - - - - - - - - - -
419
+ /**
420
+ * COMPONENT HELPER FUNCTIONS
421
+ */
542
422
 
543
- // This function could be improved as it generates an issue with
544
- // input ids which are duplicated after the entire target has been cloned
545
423
  function addNewItem(event) {
546
424
  // Stop default behaviour
547
425
  event.preventDefault();
548
- // Get the child to clone
549
- // (`this` always refers to the second argument of the $(document).on() method, in this case '.form-item--add-new')
550
- var id = $(this).data('new-form-item-id');
551
- var $newChild = $('#' + id);
552
- // Clone child and remove id and styles from cloned child
553
- $newChild.clone().insertAfter($newChild);
554
- // Remove class in order to remove styles, and change id so it's reachable when testing
555
- $newChild.removeClass('form-item--new').attr('id', 'new-form-item-' + newFormItemId);
556
-
557
- // // Update all ids to avoid duplication
558
- $newChild.find('[id]').each(function () {
559
- var oldId = $(this).attr('id');
560
- var newId = oldId + '-' + newFormItemId;
561
- $(this).attr('id', newId);
562
- var $forId = $newChild.find('[for=' + oldId + ']');
563
- if ($forId.length > 0) {
564
- $forId.attr('for', newId);
565
- }
426
+ // Get the child to clone
427
+ var id = $(this).data("id");
428
+ var $list = $("#form-item--repeater-setting-" + id);
429
+ var url = $(this).data("url");
430
+ $.post(url, { repeater_setting_id: id }, function (data) {
431
+ // Get repaeter code from Rails
432
+ // Due to the Rails way of creating nested forms it's necessary to
433
+ // create the nested item inside a different new form, then get just
434
+ // the code contained between the two SPLIT comments
435
+ var parts = data.split("<!-- SPLIT -->");
436
+ var newRepeater = parts[1];
437
+ setupAndAppend(newRepeater, $list);
566
438
  });
439
+ }
567
440
 
568
- // Update height (max-height) of the new element
569
- var $formItemEditor = $('#new-form-item-' + newFormItemId).find('.form-item--editor');
441
+ function setupAndAppend(newRepeater, $list) {
442
+ // Append the item
443
+ $list.prepend(newRepeater);
444
+ var new_repeater_item = $list.find(".form-item--repeater").get(0);
570
445
 
571
- // override current max-height which is set to 0
572
- $formItemEditor.get(0).style.maxHeight = $formItemEditor.get(0).scrollHeight + "px";
446
+ // Prepare animation
447
+ new_repeater_item.style.maxHeight = 0;
573
448
 
574
- __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
449
+ // Group fields if sotrable is enabled
450
+ if ($list.hasClass("sortable--enabled")) {
451
+ $(new_repeater_item).find(".form-item--repeater-fields").each(function () {
452
+ this.style.maxHeight = 0 + "px";
453
+ });
454
+ }
575
455
 
576
- // Increment global id variable `newFormItemId` in case needs to be used again
577
- newFormItemId++;
456
+ // Setup TinyMCE for the newly created item
457
+ var textarea_editor_id = $list.find("textarea").last("textarea").attr("id");
458
+ tinyMCE.EditorManager.execCommand("mceAddEditor", true, textarea_editor_id);
578
459
 
579
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__select2__["b" /* setupSelect2 */])($formItemEditor.find('select'));
580
- }
460
+ // Resize the editor (is it needed with the new configuration?)
461
+ // _FormItemEditor.resize()
581
462
 
582
- function close() {
583
- this.style.maxHeight = '0px';
584
- }
463
+ // Update select input for Select2 plugin
464
+ Object(__WEBPACK_IMPORTED_MODULE_1__select2__["b" /* setupSelect2 */])($list.find("select"));
585
465
 
586
- function open() {
587
- this.style.maxHeight = this.scrollHeight + "px";
588
- }
466
+ // Refresh Sortable to update the added item with Sortable features
467
+ $list.sortable("refresh");
589
468
 
590
- function collapseToggle(event) {
591
- // This function is temporarely just set for repeaters.
592
- // TODO: Need refactoring in order to be available also for generic form items
469
+ // Run animation 50ms after previous style declaration (see above) otherwise animation doesn't get triggered
470
+ setTimeout(function () {
471
+ new_repeater_item.style.maxHeight = new_repeater_item.scrollHeight + "px";
472
+ }, 50);
473
+ }
593
474
 
475
+ function deleteRepeter(event) {
594
476
  // Stop default behaviour
595
477
  event.preventDefault();
596
478
 
597
- var $collapsable = $(this).closest('.form-item--collapsable');
479
+ var record_id = $(this).data("id");
480
+ var target = $("#repeater_" + record_id).get(0);
481
+ // As max-height isn't set you need to set it manually before changing it,
482
+ // otherwise the animation doesn't get triggered
483
+ target.style.maxHeight = target.scrollHeight + "px";
484
+ // Change max-height after 50ms to trigger css animation
485
+ setTimeout(function () {
486
+ target.style.maxHeight = 0 + "px";
487
+ }, 50);
598
488
 
599
- if ($collapsable.hasClass('form-item--collapsed')) {
600
- $collapsable.find('.form-item--repeater-fields').each(open);
601
- $collapsable.find('.form-item--editor').each(open);
602
- $collapsable.removeClass('form-item--collapsed');
603
- } else {
604
- $collapsable.find('.form-item--repeater-fields').each(close);
605
- $collapsable.find('.form-item--editor').each(close);
606
- $collapsable.addClass('form-item--collapsed');
607
- }
489
+ $.ajax({
490
+ url: $(this).attr("href"),
491
+ data: { id: record_id, isAjax: true },
492
+ method: "DELETE"
493
+ }).done(function () {
494
+ // Make sure the animation completes before removing the item (it should last 600ms + 50ms)
495
+ setTimeout(function () {
496
+ $(target).remove();
497
+ }, 700);
498
+ // _FormItemEditor.resize()
499
+ });
608
500
  }
609
501
 
610
502
  /***/ }),
611
- /* 7 */
503
+ /* 5 */
612
504
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
613
505
 
614
506
  "use strict";
@@ -625,11 +517,11 @@ var FormItemImage = function () {
625
517
  function FormItemImage() {
626
518
  _classCallCheck(this, FormItemImage);
627
519
 
628
- this.target = '.form-item--image--uploader';
520
+ this.target = ".form-item--image--uploader";
629
521
  }
630
522
 
631
523
  _createClass(FormItemImage, [{
632
- key: 'isSet',
524
+ key: "isSet",
633
525
  value: function isSet() {
634
526
  if ($(this.target).length > 0) {
635
527
  return true;
@@ -638,7 +530,7 @@ var FormItemImage = function () {
638
530
  }
639
531
  }
640
532
  }, {
641
- key: 'setEvents',
533
+ key: "setEvents",
642
534
  value: function setEvents() {}
643
535
  }]);
644
536
 
@@ -648,275 +540,432 @@ var FormItemImage = function () {
648
540
  var _FormItemImage = new FormItemImage();
649
541
 
650
542
  /***/ }),
651
- /* 8 */
543
+ /* 6 */
652
544
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
653
545
 
654
546
  "use strict";
655
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemRepeater; });
547
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FieldSettingChoices; });
656
548
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
657
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__select2__ = __webpack_require__(1);
658
549
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
659
550
 
660
551
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
661
552
 
662
553
  /**
663
- * FORM ITEM REPEATER
554
+ * FORM ITEM CHOICE
664
555
  */
665
556
 
666
557
 
667
558
 
559
+ var FieldSettingChoices = function () {
560
+ function FieldSettingChoices() {
561
+ _classCallCheck(this, FieldSettingChoices);
668
562
 
669
- var FormItemRepeater = function () {
670
- function FormItemRepeater() {
671
- _classCallCheck(this, FormItemRepeater);
563
+ this.target = ".field-setting-choices--choice";
672
564
  }
673
565
 
674
- _createClass(FormItemRepeater, [{
675
- key: 'isSet',
566
+ _createClass(FieldSettingChoices, [{
567
+ key: "isSet",
676
568
  value: function isSet() {
677
- if ($('.form-item--repeater-section').length > 0) {
569
+ if ($(this.target).length > 0) {
570
+ return true;
571
+ } else {
572
+ return false;
573
+ }
574
+ }
575
+ }, {
576
+ key: "setEvents",
577
+ value: function setEvents() {
578
+ $(document).on("click", ".field-setting-choices--add-choice", addChoice);
579
+
580
+ $(document).on("click", ".field-setting-choices--delete-choice", deleteChoice);
581
+
582
+ $(document).on("click", ".field-setting-choices--js-delete-choice", function (event) {
583
+ event.preventDefault();
584
+ $(this).closest(".field-setting-choices--choice").remove();
585
+ // Update form item editor size
586
+ __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
587
+ });
588
+ }
589
+ }]);
590
+
591
+ return FieldSettingChoices;
592
+ }();
593
+
594
+ var _FieldSettingChoices = new FieldSettingChoices();
595
+
596
+ /**
597
+ * HELPER FUNCTIONS
598
+ */
599
+
600
+ function addChoice(event) {
601
+ event.preventDefault();
602
+ // Clone the new choice field
603
+ var choices_id = $(this).data("choices-id");
604
+ var choices = $("#" + choices_id);
605
+ var newchoice = choices.find(".field-setting-choices--new-choice");
606
+ var clone = newchoice.clone().removeClass("field-setting-choices--new-choice").toggle();
607
+ clone.find(".field-setting-choices--toggle-choice").toggle();
608
+ // Append the clone right after
609
+ choices.prepend(clone);
610
+ // Update form item editor size
611
+ __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
612
+ }
613
+
614
+ function deleteChoice(event) {
615
+ event.preventDefault();
616
+
617
+ var choice = $(this).closest(".field-setting-choices--choice");
618
+ var destination = $(this).attr("href");
619
+ var self = this;
620
+
621
+ $.ajax({
622
+ url: destination,
623
+ type: "DELETE"
624
+ }).done(function () {
625
+ choice.remove();
626
+ // Update form item editor size
627
+ __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
628
+ }).fail(function (data) {
629
+ alert(data.responseJSON.errors);
630
+ });
631
+ }
632
+
633
+ /***/ }),
634
+ /* 7 */
635
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
636
+
637
+ "use strict";
638
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FileUpload; });
639
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
640
+
641
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
642
+
643
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
644
+
645
+ /**
646
+ * FILE UPLOAD
647
+ *
648
+ * see https://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/
649
+ *
650
+ */
651
+
652
+ var FileUpload = function () {
653
+ function FileUpload() {
654
+ _classCallCheck(this, FileUpload);
655
+
656
+ this.target = ".fileupload";
657
+ }
658
+
659
+ _createClass(FileUpload, [{
660
+ key: "isSet",
661
+ value: function isSet() {
662
+ if ($(this.target).length > 0) {
678
663
  return true;
679
664
  } else {
680
665
  return false;
681
666
  }
682
667
  }
683
668
  }, {
684
- key: 'setEvents',
669
+ key: "setEvents",
685
670
  value: function setEvents() {
686
- $(document).on('click', '.form-item--repeater-section--add-new', addNewItem);
671
+ var self = this;
687
672
 
688
- $(document).on('click', '.form-item--remove-item-with-js', function (event) {
689
- // Stop default behaviour
690
- event.preventDefault();
691
- $(this).parent('.form-item--repeater-section').remove();
692
- __WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
693
- });
673
+ $(document).on("click", ".fileupload--remove-image-btn", remove_preview);
694
674
 
695
- $(document).on('click', '.form-item--delete-repeater-item', deleteRepeter);
675
+ $(document).on("change", this.target + " input.file", handle_file);
696
676
  }
697
677
  }]);
698
678
 
699
- return FormItemRepeater;
679
+ return FileUpload;
700
680
  }();
701
681
 
702
- var _FormItemRepeater = new FormItemRepeater();
682
+ var _FileUpload = new FileUpload();
703
683
 
704
684
  /**
705
- * COMPONENT HELPER FUNCTIONS
685
+ * HELPER FUNCTIONS
706
686
  */
707
687
 
708
- function addNewItem(event) {
709
- // Stop default behaviour
710
- event.preventDefault();
711
- // Get the child to clone
712
- var id = $(this).data('id');
713
- var $list = $('#form-item--repeater-setting-' + id);
714
- var url = $(this).data('url');
715
- $.post(url, { repeater_setting_id: id }, function (data) {
716
- // Get repaeter code from Rails
717
- // Due to the Rails way of creating nested forms it's necessary to
718
- // create the nested item inside a different new form, then get just
719
- // the code contained between the two SPLIT comments
720
- var parts = data.split('<!-- SPLIT -->');
721
- var newRepeater = parts[1];
722
- setupAndAppend(newRepeater, $list);
723
- });
724
- }
725
-
726
- function setupAndAppend(newRepeater, $list) {
727
- // Append the item
728
- $list.prepend(newRepeater);
729
- var new_repeater_item = $list.find('.form-item--repeater').get(0);
688
+ // Reference --> http://blog.teamtreehouse.com/uploading-files-ajax
689
+ function handle_file(event) {
690
+ var id = event.target.getAttribute("data-id");
691
+ var $parent = $("#fileupload-" + id);
730
692
 
731
- // Prepare animation
732
- new_repeater_item.style.maxHeight = 0;
693
+ // Get the selected file from the input
694
+ // This script doesn't consider multiple files upload
695
+ var file = event.target.files[0];
733
696
 
734
- // Group fields if sotrable is enabled
735
- if ($list.hasClass('sortable--enabled')) {
736
- $(new_repeater_item).find('.form-item--repeater-fields').each(function () {
737
- this.style.maxHeight = 0 + 'px';
738
- });
697
+ // Don't go any further if no file has been selected
698
+ if (typeof file == "undefined") {
699
+ return;
739
700
  }
740
701
 
741
- // Setup TinyMCE for the newly created item
742
- var textarea_editor_id = $list.find('textarea').last('textarea').attr('id');
743
- tinyMCE.EditorManager.execCommand('mceAddEditor', true, textarea_editor_id);
702
+ // Create a new FormData object which will be sent to the server
703
+ var formData = new FormData();
744
704
 
745
- // Resize the editor (is it needed with the new configuration?)
746
- // _FormItemEditor.resize()
705
+ // Get data from the input element
706
+ $parent.find("input").each(function () {
707
+ if (this.isSameNode(event.target)) {
708
+ // Add the file to the request
709
+ formData.append(this.getAttribute("name"), file, file.name);
710
+ } else {
711
+ // Add secondary values to the request
712
+ formData.append(this.getAttribute("name"), this.getAttribute("value"));
713
+ }
714
+ });
747
715
 
748
- // Update select input for Select2 plugin
749
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__select2__["b" /* setupSelect2 */])($list.find('select'));
716
+ // If it's inside a repeater add repeater parameters
717
+ var $parent_repeater = $parent.closest(".form-item--repeater-fields");
718
+ if ($parent.closest(".form-item--repeater-fields").length > 0) {
719
+ gatherData($parent_repeater, formData);
720
+ }
750
721
 
751
- // Refresh Sortable to update the added item with Sortable features
752
- $list.sortable('refresh');
722
+ // Is this needed? Apparently it works without it. Is it a security issue?
723
+ // let token = document.querySelector('meta[name="csrf-token"]').content
724
+ // formData.append('authenticity_token', token)
753
725
 
754
- // Run animation 50ms after previous style declaration (see above) otherwise animation doesn't get triggered
755
- setTimeout(function () {
756
- new_repeater_item.style.maxHeight = new_repeater_item.scrollHeight + 'px';
757
- }, 50);
758
- }
726
+ // Display loader
727
+ $(".popup-warning--message").text($parent.data("message"));
728
+ $(".popup-warning").removeClass("popup-warning--hidden");
759
729
 
760
- function deleteRepeter(event) {
761
- // Stop default behaviour
762
- event.preventDefault();
730
+ // Once form data are gathered make the request
731
+ makeRequest(event, formData);
732
+ }
763
733
 
764
- var record_id = $(this).data('id');
765
- var target = $('#repeater_' + record_id).get(0);
766
- // As max-height isn't set you need to set it manually before changing it,
767
- // otherwise the animation doesn't get triggered
768
- target.style.maxHeight = target.scrollHeight + 'px';
769
- // Change max-height after 50ms to trigger css animation
770
- setTimeout(function () {
771
- target.style.maxHeight = 0 + 'px';
772
- }, 50);
734
+ function gatherData($parent_repeater, formData) {
735
+ $parent_repeater.children(".form-group").find("input").each(function () {
736
+ formData.append(this.getAttribute("name"), this.getAttribute("value"));
737
+ });
738
+ }
773
739
 
740
+ function makeRequest(event, formData) {
741
+ var id = event.target.getAttribute("data-id");
742
+ var $parent = $("#fileupload-" + id);
743
+ // Make request
774
744
  $.ajax({
775
- url: $(this).attr('href'),
776
- data: { id: record_id, isAjax: true },
777
- method: "DELETE"
778
- }).done(function () {
779
- // Make sure the animation completes before removing the item (it should last 600ms + 50ms)
780
- setTimeout(function () {
781
- $(target).remove();
782
- }, 700);
783
- // _FormItemEditor.resize()
745
+ url: event.target.getAttribute("data-url"),
746
+ type: "PATCH",
747
+ processData: false, // needed to pass formData with the current format
748
+ contentType: false, // needed to pass formData with the current format
749
+ data: formData
750
+ }).done(function (data) {
751
+ updateFileuploadField(data, id);
752
+ }).fail(function (dataFail) {
753
+ // Hide loaded
754
+ $(".popup-warning").addClass("popup-warning--hidden");
755
+ alert($parent.data("error"));
784
756
  });
785
757
  }
786
758
 
787
- /***/ }),
788
- /* 9 */
789
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
759
+ function updateFileuploadField(data, id) {
760
+ var $parent = $("#fileupload-" + id);
790
761
 
791
- "use strict";
792
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _Shader; });
793
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
762
+ if (data.type == "image") {
763
+ setup_image_preview(data, id);
764
+ } else if (data.type == "video") {
765
+ setup_video_preview(data, id);
766
+ } else {
767
+ alert("Something went wrong. No preview has been received.");
768
+ }
794
769
 
795
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
770
+ // Hide loaded
771
+ $(".popup-warning").addClass("popup-warning--hidden");
796
772
 
797
- var Shader = function () {
798
- function Shader() {
799
- _classCallCheck(this, Shader);
800
- }
773
+ // Display details and buttons
774
+ $parent.find(".fileupload--details").removeClass("fileupload--details--hidden");
775
+ $parent.find(".fileupload--remove-image-btn").removeClass("fileupload--remove-image-btn--hidden");
776
+ }
777
+
778
+ function reset_file(input) {
779
+ input.value = "";
780
+
781
+ if (!/safari/i.test(navigator.userAgent)) {
782
+ input.type = "";
783
+ input.type = "file";
784
+ }
785
+ }
786
+
787
+ function remove_preview(event) {
788
+ var id = event.target.getAttribute("data-id");
789
+ var $parent = $("#fileupload-" + id);
790
+
791
+ // Reset previews (either image or video)
792
+ $parent.find(".fileupload--preview").css("background-image", "").removeClass("fileupload--preview--uploaded");
793
+ $parent.find("video source").removeAttr("src");
801
794
 
802
- _createClass(Shader, [{
803
- key: 'isSet',
804
- value: function isSet() {
805
- if ($('#background-shader').length > 0) {
806
- return true;
807
- } else {
808
- return false;
809
- }
810
- }
795
+ // Clear input field
796
+ reset_file($parent.find("input[type=file]").get(0));
811
797
 
812
- // SETUP SHADER
798
+ // Reset buttons to initial state
799
+ $parent.find(".fileupload--remove-image-btn").addClass("fileupload--remove-image-btn--hidden");
800
+ $parent.find(".fileupload--details").addClass("fileupload--details--hidden");
801
+ }
802
+
803
+ function setup_image_preview(data, id) {
804
+ var $parent = $("#fileupload-" + id);
805
+ var $preview = $("#fileupload-" + id + " .fileupload--preview");
806
+
807
+ // Update thumbnail
808
+ $preview.css("background-image", "url(" + data.thumbnailUrl + ")");
809
+
810
+ // Remove and add class to trigger css animation
811
+ var uploadedClass = "fileupload--preview--uploaded";
812
+ $preview.removeClass(uploadedClass).addClass(uploadedClass);
813
+
814
+ // Update details
815
+ $parent.find(".fileupload--width").text(data.width);
816
+ $parent.find(".fileupload--height").text(data.height);
817
+ $parent.find(".fileupload--filesize").text(data.size);
818
+ $parent.find(".fileupload--filename").text(data.name);
819
+ }
813
820
 
814
- }, {
815
- key: 'setup',
816
- value: function setup() {
821
+ function setup_video_preview(data, id) {
822
+ var $parent = $("#fileupload-" + id);
823
+ var $preview = $("#fileupload-" + id + " .fileupload--preview");
824
+
825
+ $preview.removeClass("fileupload--preview--uploaded").find("video").attr("id", "video-" + id).find("source").attr("src", data.url).attr("type", "video/" + data.ext);
817
826
 
818
- var Container = PIXI.Container,
819
- autoDetectRenderer = PIXI.autoDetectRenderer,
820
- loader = PIXI.loader,
821
- resources = PIXI.loader.resources,
822
- Sprite = PIXI.Sprite;
827
+ // If video source isn't blank load it (consider that a video tag is always present)
828
+ if (_typeof($preview.find("video source").attr("src")) != undefined) {
829
+ $preview.find("video").get(0).load();
830
+ }
823
831
 
824
- // Create a container object called the `stage`
825
- this.stage = new Container();
832
+ // Remove and add class to trigger css animation
833
+ var uploadedClass = "fileupload--preview--uploaded";
834
+ $preview.removeClass(uploadedClass).addClass(uploadedClass);
826
835
 
827
- // Create 'renderer'
828
- this.renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight);
836
+ // Update details
837
+ $parent.find(".fileupload--filesize").text(data.size);
838
+ $parent.find(".fileupload--filename").text(data.name);
839
+ $parent.find(".fileupload--videolink a").attr("href", data.url);
840
+ }
829
841
 
830
- // //Add the canvas to the HTML document
842
+ /***/ }),
843
+ /* 8 */
844
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
831
845
 
832
- document.getElementById('background-shader').appendChild(this.renderer.view);
846
+ "use strict";
847
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _Shader; });
848
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
833
849
 
834
- this.renderer.backgroundColor = 0xFF00FF;
850
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
835
851
 
836
- // canvas full window
837
- this.renderer.view.style.position = "fixed";
838
- this.renderer.view.style.display = "block";
852
+ var Shader = function () {
853
+ function Shader() {
854
+ _classCallCheck(this, Shader);
855
+
856
+ this.uniforms = {
857
+ uTime: { type: "1f", value: 0.0 },
858
+ uCurrentTime: { type: "1f", value: Math.sin(Date.now()) + 0.5 },
859
+ uMouse: {
860
+ type: "2f",
861
+ value: [window.innerWidth, window.innerHeight]
862
+ },
863
+ uWindowSize: {
864
+ type: "2f",
865
+ value: [window.innerWidth, window.innerHeight]
866
+ }
867
+ };
868
+ }
869
+
870
+ _createClass(Shader, [{
871
+ key: "isSet",
872
+ value: function isSet() {
873
+ if ($("#background-shader").length > 0) {
874
+ return true;
875
+ } else {
876
+ return false;
877
+ }
878
+ }
839
879
 
840
- var fragmentShader = document.getElementById("fragmentShader").innerHTML;
880
+ // SETUP SHADER
841
881
 
842
- var currentTime = Math.sin(Date.now()) + 0.5;
882
+ }, {
883
+ key: "setup",
884
+ value: function setup() {
885
+ // Create a container object called the `stage`
886
+ this.stage = new PIXI.Container();
843
887
 
844
- this.uniforms = {
845
- uTime: { type: '1f', value: 0.0 },
846
- uCurrentTime: { type: '1f', value: currentTime },
847
- uMouse: { type: '2f', value: [window.innerWidth, window.innerHeight] },
848
- uWindowSize: { type: '2f', value: [window.innerWidth, window.innerHeight] }
849
- };
888
+ // Create 'renderer'
889
+ this.renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight);
850
890
 
851
- this.customShader = new PIXI.AbstractFilter(null, fragmentShader, this.uniforms);
852
- this.drawRectagle();
853
- }
891
+ // //Add the canvas to the HTML document
854
892
 
855
- // DRAW RECTANGLE
893
+ document.getElementById("background-shader").appendChild(this.renderer.view);
856
894
 
857
- }, {
858
- key: 'drawRectagle',
859
- value: function drawRectagle() {
895
+ this.renderer.backgroundColor = 0xff00ff;
860
896
 
861
- this.rectangle = new PIXI.Graphics();
897
+ // canvas full window
898
+ this.renderer.view.style.position = "fixed";
899
+ this.renderer.view.style.display = "block";
862
900
 
863
- // Set the default background color wo if browser doesn't support the filter we still see the primary color
864
- var colorWithHash = '#FF00FF';
865
- var colorWith0x = '0x' + colorWithHash.slice(1, 7);
866
- this.rectangle.beginFill(colorWith0x);
901
+ var fragmentShader = document.getElementById("fragmentShader").innerHTML;
867
902
 
868
- // Create the background rectanlge
869
- this.rectangle.drawRect(0, 0, window.innerWidth, window.innerHeight);
870
- this.rectangle.endFill();
903
+ this.customShader = new PIXI.AbstractFilter(null, fragmentShader, this.uniforms);
904
+ this.drawRectagle();
905
+ }
871
906
 
872
- // Setup the filter (shader)
873
- this.rectangle.filters = [this.customShader];
907
+ // DRAW RECTANGLE
874
908
 
875
- // Add background to stage
876
- this.stage.addChild(this.rectangle);
877
- }
909
+ }, {
910
+ key: "drawRectagle",
911
+ value: function drawRectagle() {
912
+ this.rectangle = new PIXI.Graphics();
878
913
 
879
- // START ANIMATION
914
+ // Set the default background color wo if browser doesn't support the filter we still see the primary color
915
+ var colorWithHash = "#FF00FF";
916
+ var colorWith0x = "0x" + colorWithHash.slice(1, 7);
917
+ this.rectangle.beginFill(colorWith0x);
880
918
 
881
- }, {
882
- key: 'start',
883
- value: function start() {
884
- animate();
885
- }
919
+ // Create the background rectanlge
920
+ this.rectangle.drawRect(0, 0, window.innerWidth, window.innerHeight);
921
+ this.rectangle.endFill();
886
922
 
887
- // MOUSE UPDATE
923
+ // Setup the filter (shader)
924
+ this.rectangle.filters = [this.customShader];
888
925
 
889
- }, {
890
- key: 'mouseUpdate',
891
- value: function mouseUpdate(event) {
926
+ // Add background to stage
927
+ this.stage.addChild(this.rectangle);
928
+ }
892
929
 
893
- // If uniforms haven't been set yet don't do anything and exit
894
- if (typeof this.uniforms === 'undefined') return;
930
+ // START ANIMATION
895
931
 
896
- // udpate mouse coordinates for the shader
897
- this.customShader.uniforms.uMouse = [event.pageX, event.pageY];
898
- }
932
+ }, {
933
+ key: "start",
934
+ value: function start() {
935
+ animate();
936
+ }
899
937
 
900
- // RESIZE
938
+ // MOUSE UPDATE
901
939
 
902
- }, {
903
- key: 'resize',
904
- value: function resize() {
940
+ }, {
941
+ key: "mouseUpdate",
942
+ value: function mouseUpdate(event) {
943
+ // If uniforms haven't been set yet don't do anything and exit
944
+ if (typeof this.uniforms === "undefined") return;
905
945
 
906
- // let scale = scaleToWindow( this.renderer.view )
907
- var prevWidth = this.renderer.view.style.width;
908
- var prevHeight = this.renderer.view.style.height;
909
- this.renderer.view.style.width = window.innerWidth + "px";
910
- this.renderer.view.style.height = window.innerHeight + "px";
911
- this.customShader.uniforms.uWindowSize = [window.innerWidth, window.innerHeight];
946
+ // udpate mouse coordinates for the shader
947
+ this.customShader.uniforms.uMouse = [event.pageX, event.pageY];
948
+ }
912
949
 
913
- // Plese check this out ↴↴↴
914
- // this.rectangle.scale.x = window.innerWidth / prevWidth
915
- // this.rectangle.scale.y = window.innerHeight / prevHeight
916
- }
917
- }]);
950
+ // RESIZE
951
+
952
+ }, {
953
+ key: "resize",
954
+ value: function resize() {
955
+ // let scale = scaleToWindow( this.renderer.view )
956
+ var prevWidth = this.renderer.view.style.width;
957
+ var prevHeight = this.renderer.view.style.height;
958
+ this.renderer.view.style.width = window.innerWidth + "px";
959
+ this.renderer.view.style.height = window.innerHeight + "px";
960
+ this.customShader.uniforms.uWindowSize = [window.innerWidth, window.innerHeight];
961
+
962
+ // Plese check this out ↴↴↴
963
+ // this.rectangle.scale.x = window.innerWidth / prevWidth
964
+ // this.rectangle.scale.y = window.innerHeight / prevHeight
965
+ }
966
+ }]);
918
967
 
919
- return Shader;
968
+ return Shader;
920
969
  }();
921
970
 
922
971
  var _Shader = new Shader();
@@ -924,33 +973,35 @@ var _Shader = new Shader();
924
973
  // ANIMATE
925
974
  // -------
926
975
  function animate() {
927
-
928
- // start the timer for the next animation loop
929
- requestAnimationFrame(animate);
930
- _Shader.customShader.uniforms.uTime += 0.01;
931
- // this is the main render call that makes pixi draw your container and its children.
932
- _Shader.renderer.render(_Shader.stage);
976
+ // start the timer for the next animation loop
977
+ requestAnimationFrame(animate);
978
+ _Shader.customShader.uniforms.uTime += 0.01;
979
+ // this is the main render call that makes pixi draw your container and its children.
980
+ _Shader.renderer.render(_Shader.stage);
933
981
  }
934
982
 
935
983
  // CONVERT HEX TO RGB COLORS
936
984
  // -------------------------
937
985
  function hexToShaderRgb(hex) {
938
-
939
- // Precision of the float number
940
- var precision = 100;
941
- // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
942
- var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
943
- hex = hex.replace(shorthandRegex, function (m, r, g, b) {
944
- return r + r + g + g + b + b;
945
- });
946
-
947
- var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
948
- return result ? {
949
- // Get a number between 0.00 and 1.00
950
- r: Math.round(parseInt(result[1], 16) * precision / 255) / precision,
951
- g: Math.round(parseInt(result[2], 16) * precision / 255) / precision,
952
- b: Math.round(parseInt(result[3], 16) * precision / 255) / precision
953
- } : null;
986
+ // Precision of the float number
987
+ var precision = 100;
988
+ // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
989
+ var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
990
+ hex = hex.replace(shorthandRegex, function (m, r, g, b) {
991
+ return r + r + g + g + b + b;
992
+ });
993
+
994
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
995
+ if (result) {
996
+ return {
997
+ // Get a number between 0.00 and 1.00
998
+ r: Math.round(parseInt(result[1], 16) * precision / 255) / precision,
999
+ g: Math.round(parseInt(result[2], 16) * precision / 255) / precision,
1000
+ b: Math.round(parseInt(result[3], 16) * precision / 255) / precision
1001
+ };
1002
+ } else {
1003
+ return null;
1004
+ }
954
1005
  }
955
1006
 
956
1007
  // REQUEST ANIMATION POLYFILL
@@ -960,53 +1011,53 @@ function hexToShaderRgb(hex) {
960
1011
  // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
961
1012
  // MIT license
962
1013
  (function () {
963
- var lastTime = 0;
964
- var vendors = ['ms', 'moz', 'webkit', 'o'];
965
- for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
966
- window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
967
- window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
968
- }
969
-
970
- if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback, element) {
971
- var currTime = new Date().getTime();
972
- var timeToCall = Math.max(0, 16 - (currTime - lastTime));
973
- var id = window.setTimeout(function () {
974
- callback(currTime + timeToCall);
975
- }, timeToCall);
976
- lastTime = currTime + timeToCall;
977
- return id;
978
- };
979
-
980
- if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) {
981
- clearTimeout(id);
982
- };
1014
+ var lastTime = 0;
1015
+ var vendors = ["ms", "moz", "webkit", "o"];
1016
+ for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
1017
+ window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
1018
+ window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || window[vendors[x] + "CancelRequestAnimationFrame"];
1019
+ }
1020
+
1021
+ if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback, element) {
1022
+ var currTime = new Date().getTime();
1023
+ var timeToCall = Math.max(0, 16 - (currTime - lastTime));
1024
+ var id = window.setTimeout(function () {
1025
+ callback(currTime + timeToCall);
1026
+ }, timeToCall);
1027
+ lastTime = currTime + timeToCall;
1028
+ return id;
1029
+ };
1030
+
1031
+ if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) {
1032
+ clearTimeout(id);
1033
+ };
983
1034
  })();
984
1035
 
985
1036
  // Mozilla MDN optimized resize
986
1037
  // https://developer.mozilla.org/en-US/docs/Web/Events/resize
987
1038
  (function () {
988
- var throttle = function throttle(type, name, obj) {
989
- obj = obj || window;
990
- var running = false;
991
- var func = function func() {
992
- if (running) {
993
- return;
994
- }
995
- running = true;
996
- requestAnimationFrame(function () {
997
- obj.dispatchEvent(new CustomEvent(name));
998
- running = false;
999
- });
1000
- };
1001
- obj.addEventListener(type, func);
1039
+ var throttle = function throttle(type, name, obj) {
1040
+ obj = obj || window;
1041
+ var running = false;
1042
+ var func = function func() {
1043
+ if (running) {
1044
+ return;
1045
+ }
1046
+ running = true;
1047
+ requestAnimationFrame(function () {
1048
+ obj.dispatchEvent(new CustomEvent(name));
1049
+ running = false;
1050
+ });
1002
1051
  };
1052
+ obj.addEventListener(type, func);
1053
+ };
1003
1054
 
1004
- /* init - you can init any event */
1005
- throttle("resize", "optimizedResize");
1055
+ /* init - you can init any event */
1056
+ throttle("resize", "optimizedResize");
1006
1057
  })();
1007
1058
 
1008
1059
  /***/ }),
1009
- /* 10 */
1060
+ /* 9 */
1010
1061
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1011
1062
 
1012
1063
  "use strict";
@@ -1017,7 +1068,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
1017
1068
 
1018
1069
  /**
1019
1070
  * LOGIN FORM
1020
- *
1071
+ *
1021
1072
  * https://tympanus.net/Development/MinimalForm/
1022
1073
  * https://github.com/codrops/MinimalForm/blob/master/js/stepsForm.js
1023
1074
  */
@@ -1031,57 +1082,55 @@ var LoginForm = function () {
1031
1082
  }
1032
1083
 
1033
1084
  _createClass(LoginForm, [{
1034
- key: 'isSet',
1085
+ key: "isSet",
1035
1086
  value: function isSet() {
1036
- if ($('.login--form').length > 0) {
1087
+ if ($(".login--form").length > 0) {
1037
1088
  return true;
1038
1089
  } else {
1039
1090
  return false;
1040
1091
  }
1041
1092
  }
1042
1093
  }, {
1043
- key: 'init',
1094
+ key: "init",
1044
1095
  value: function init() {
1045
- this.$form = $('.login--form');
1046
- this.$questions = $('ol.login--questions > li');
1096
+ this.$form = $(".login--form");
1097
+ this.$questions = $("ol.login--questions > li");
1047
1098
  this.questionsCount = this.$questions.length;
1048
- this.$nextButton = $('button.login--next');
1099
+ this.$nextButton = $("button.login--next");
1049
1100
 
1050
1101
  // Mark the first question as the current one
1051
- this.$questions.first().addClass('login--current');
1102
+ this.$questions.first().addClass("login--current");
1052
1103
 
1053
1104
  //disable form autocomplete
1054
- this.$form.attr('autocomplete', 'off');
1105
+ this.$form.attr("autocomplete", "off");
1055
1106
  this.setEvents();
1056
1107
  }
1057
1108
  }, {
1058
- key: 'setEvents',
1109
+ key: "setEvents",
1059
1110
  value: function setEvents() {
1060
1111
  var _this = this;
1061
1112
 
1062
1113
  var self = this;
1063
1114
 
1064
1115
  // first input
1065
- var firstInput = this.$questions.get(this.current).querySelector('input, textarea, select');
1116
+ var firstInput = this.$questions.get(this.current).querySelector("input, textarea, select");
1066
1117
 
1067
1118
  // focus
1068
1119
  var onFocusStart = function onFocusStart() {
1069
- firstInput.removeEventListener('focus', onFocusStart);
1070
- self.$nextButton.addClass('login--show');
1120
+ firstInput.removeEventListener("focus", onFocusStart);
1121
+ self.$nextButton.addClass("login--show");
1071
1122
  };
1072
1123
  // show the next question control first time the input gets focused
1073
- firstInput.addEventListener('focus', onFocusStart);
1124
+ firstInput.addEventListener("focus", onFocusStart);
1074
1125
 
1075
1126
  // show next question
1076
- this.$nextButton.on('click', function (event) {
1077
-
1127
+ this.$nextButton.on("click", function (event) {
1078
1128
  event.preventDefault();
1079
1129
  _this._nextQuestion();
1080
1130
  });
1081
1131
 
1082
1132
  // pressing enter will jump to next question
1083
- this.$form.on('keydown', function (event) {
1084
-
1133
+ this.$form.on("keydown", function (event) {
1085
1134
  var keyCode = event.keyCode || event.which;
1086
1135
  // enter
1087
1136
  if (keyCode === 13) {
@@ -1091,7 +1140,7 @@ var LoginForm = function () {
1091
1140
  });
1092
1141
  }
1093
1142
  }, {
1094
- key: '_nextQuestion',
1143
+ key: "_nextQuestion",
1095
1144
  value: function _nextQuestion() {
1096
1145
  // check if form is filled
1097
1146
  if (this.current === this.questionsCount - 1) {
@@ -1106,13 +1155,13 @@ var LoginForm = function () {
1106
1155
 
1107
1156
  if (!this.isFilled) {
1108
1157
  // add class "show-next" to form element (start animations)
1109
- this.$form.addClass('login--show-next');
1158
+ this.$form.addClass("login--show-next");
1110
1159
 
1111
1160
  // remove class "current" from current question and add it to the next one
1112
1161
  // current question
1113
1162
  var nextQuestion = this.$questions.get(this.current);
1114
- $(currentQuestion).removeClass('login--current');
1115
- $(nextQuestion).addClass('login--current');
1163
+ $(currentQuestion).removeClass("login--current");
1164
+ $(nextQuestion).addClass("login--current");
1116
1165
  }
1117
1166
 
1118
1167
  // after animation ends, remove class "show-next" from form element and change current question placeholder
@@ -1121,9 +1170,9 @@ var LoginForm = function () {
1121
1170
  if (self.isFilled) {
1122
1171
  self.$form.submit();
1123
1172
  } else {
1124
- self.$form.removeClass('login--show-next');
1173
+ self.$form.removeClass("login--show-next");
1125
1174
  // force the focus on the next input
1126
- nextQuestion.querySelector('input, textarea, select').focus();
1175
+ nextQuestion.querySelector("input, textarea, select").focus();
1127
1176
  }
1128
1177
  };
1129
1178
 
@@ -1137,27 +1186,7 @@ var LoginForm = function () {
1137
1186
  var _LoginForm = new LoginForm();
1138
1187
 
1139
1188
  /***/ }),
1140
- /* 11 */
1141
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1142
-
1143
- "use strict";
1144
- /* harmony default export */ __webpack_exports__["a"] = (function () {
1145
- $('input[name="login"]').click(function () {
1146
- var $radio = $(this);
1147
-
1148
- // if this was previously checked
1149
- if ($radio.data('waschecked') === true) {
1150
- $radio.prop('checked', false);
1151
- $radio.data('waschecked', false);
1152
- } else $radio.data('waschecked', true);
1153
-
1154
- // remove was checked from other radios
1155
- $radio.siblings('input[name="login"]').data('waschecked', false);
1156
- });
1157
- });
1158
-
1159
- /***/ }),
1160
- /* 12 */
1189
+ /* 10 */
1161
1190
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1162
1191
 
1163
1192
  "use strict";
@@ -1167,49 +1196,49 @@ var _LoginForm = new LoginForm();
1167
1196
 
1168
1197
  var sortableOptions = {
1169
1198
  stop: function stop(event, ui) {
1170
- ui.item.css('z-index', 0);
1199
+ ui.item.css("z-index", 0);
1171
1200
  },
1172
1201
  placeholder: "ui-state-highlight",
1173
1202
  update: updateSortable
1174
1203
  };
1175
1204
 
1176
1205
  /* harmony default export */ __webpack_exports__["a"] = (function () {
1177
- if ($('.sortable').length > 0) {
1206
+ if ($(".sortable").length > 0) {
1178
1207
  // Initialize sortable item
1179
- $('.sortable').sortable(sortableOptions);
1208
+ $(".sortable").sortable(sortableOptions);
1180
1209
 
1181
1210
  // Check if sortable item needs handles
1182
- $('.sortable').each(function () {
1183
- if ($(this).find('.sortable--handle').length > 0) {
1184
- $(this).sortable('option', 'handle', '.sortable--handle');
1211
+ $(".sortable").each(function () {
1212
+ if ($(this).find(".sortable--handle").length > 0) {
1213
+ $(this).sortable("option", "handle", ".sortable--handle");
1185
1214
  } else {
1186
- $(this).addClass('sortable--no-handle');
1215
+ $(this).addClass("sortable--no-handle");
1187
1216
  }
1188
1217
  });
1189
1218
 
1190
- $('.sortable--disabled').sortable('disable');
1219
+ $(".sortable--disabled").sortable("disable");
1191
1220
  }
1192
1221
 
1193
1222
  // If there is a sortable toggle button prepare the sortable items accordingly
1194
- if ($('.sortable--toggle').length > 0) {
1223
+ if ($(".sortable--toggle").length > 0) {
1195
1224
  setupSortableToggle();
1196
1225
  }
1197
1226
 
1198
1227
  // Add event to any sortable toggle button
1199
1228
  // TODO: make this event available to element which aren't standard form repeaters
1200
- $(document).on('click', '.standard-form--repeater .sortable--toggle', toggleSortable);
1229
+ $(document).on("click", ".standard-form--repeater .sortable--toggle", toggleSortable);
1201
1230
  });
1202
1231
 
1203
1232
  function setupSortableToggle() {
1204
- $('.sortable--toggle').each(function () {
1205
- var id = '#' + $(this).data('repeater-id');
1206
- $(id).find('.form-item--collapsable').addClass('form-item--collapsed');
1207
- $(id).find('.form-item--repeater-fields').each(close);
1233
+ $(".sortable--toggle").each(function () {
1234
+ var id = "#" + $(this).data("repeater-id");
1235
+ $(id).find(".form-item--collapsable").addClass("form-item--collapsed");
1236
+ $(id).find(".form-item--repeater-fields").each(close);
1208
1237
  });
1209
1238
  }
1210
1239
 
1211
1240
  function close() {
1212
- this.style.maxHeight = '0px';
1241
+ this.style.maxHeight = "0px";
1213
1242
  }
1214
1243
 
1215
1244
  function open() {
@@ -1218,117 +1247,96 @@ function open() {
1218
1247
 
1219
1248
  function toggleSortable(event) {
1220
1249
  event.preventDefault();
1221
- var id = '#' + $(this).data('repeater-id');
1250
+ var id = "#" + $(this).data("repeater-id");
1222
1251
 
1223
- if ($(id).hasClass('sortable--disabled')) {
1224
- $(id).sortable('enable');
1225
- $(id).find('.form-item--repeater-fields').each(close);
1226
- $(id).find('.form-item--collapsable').addClass('form-item--collapsed');
1252
+ if ($(id).hasClass("sortable--disabled")) {
1253
+ $(id).sortable("enable");
1254
+ $(id).find(".form-item--repeater-fields").each(close);
1255
+ $(id).find(".form-item--collapsable").addClass("form-item--collapsed");
1227
1256
  } else {
1228
- $(id).sortable('disable');
1257
+ $(id).sortable("disable");
1229
1258
  }
1230
1259
 
1231
- $(id).toggleClass('sortable--disabled');
1232
- $(id).toggleClass('sortable--enabled');
1233
- $(this).children('.sortable--toggle-text').toggle();
1260
+ $(id).toggleClass("sortable--disabled");
1261
+ $(id).toggleClass("sortable--enabled");
1262
+ $(this).children(".sortable--toggle-text").toggle();
1234
1263
  }
1235
1264
 
1236
1265
  function updateSortable() {
1237
- if ($('.popup-warning').length > 0) {
1238
- $(this).addClass('sortable--disabled');
1239
- $('.popup-warning--message').text($(this).data('message'));
1240
- $('.popup-warning').removeClass('popup-warning--hidden');
1241
- $(this).sortable('option', 'disabled', true);
1266
+ if ($(".popup-warning").length > 0) {
1267
+ $(this).addClass("sortable--disabled");
1268
+ $(".popup-warning--message").text($(this).data("message"));
1269
+ $(".popup-warning").removeClass("popup-warning--hidden");
1270
+ $(this).sortable("option", "disabled", true);
1242
1271
  }
1243
- var url = $(this).data('update-url');
1244
- var data = $(this).sortable('serialize');
1272
+ var url = $(this).data("update-url");
1273
+ var data = $(this).sortable("serialize");
1245
1274
  // If there is a pagination update accordingly
1246
- data = data.concat('&id=' + $(this).attr('id'));
1275
+ data = data.concat("&id=" + $(this).attr("id"));
1247
1276
  $.post(url, data).done(function (doneData) {
1248
- $(doneData.id).sortable('option', 'disabled', false);
1249
- $('.popup-warning').addClass('popup-warning--hidden');
1250
- $(doneData.id).removeClass('sortable--disabled');
1277
+ $(doneData.id).sortable("option", "disabled", false);
1278
+ $(".popup-warning").addClass("popup-warning--hidden");
1279
+ $(doneData.id).removeClass("sortable--disabled");
1251
1280
  }).fail(function (failData) {
1252
- $('.popup-warning').addClass('popup-warning--hidden');
1253
- alert('Error: ' + failData.message);
1281
+ $(".popup-warning").addClass("popup-warning--hidden");
1282
+ alert("Error: " + failData.message);
1254
1283
  });
1255
1284
  }
1256
1285
 
1257
1286
  /***/ }),
1258
- /* 13 */
1287
+ /* 11 */
1259
1288
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1260
1289
 
1261
1290
  "use strict";
1262
- Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
1263
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_form_item__ = __webpack_require__(6);
1264
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__ = __webpack_require__(8);
1265
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_form_item_image__ = __webpack_require__(7);
1266
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_field_setting_choices__ = __webpack_require__(4);
1267
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__ = __webpack_require__(0);
1268
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_fileupload__ = __webpack_require__(5);
1269
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__components_login_shader__ = __webpack_require__(9);
1270
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__components_login_form__ = __webpack_require__(10);
1271
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__components_sortable__ = __webpack_require__(12);
1272
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__components_field_group_editor__ = __webpack_require__(3);
1273
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__components_bootstrap__ = __webpack_require__(2);
1274
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__components_select2__ = __webpack_require__(1);
1275
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__components_radio_toggle__ = __webpack_require__(11);
1276
- ///- - - - - - - - - - - - - - - - - - - -
1277
- /// INDEX OF BINDA'S SCRIPTS
1278
- ///- - - - - - - - - - - - - - - - - - - -
1279
-
1280
-
1281
-
1282
-
1283
-
1284
-
1285
-
1291
+ /**
1292
+ * FIELD GROUP EDITOR
1293
+ */
1286
1294
 
1295
+ /* harmony default export */ __webpack_exports__["a"] = (function () {
1296
+ $(".field_groups-edit #save").on("click", function (event) {
1297
+ var instanceType = $(this).data("instance-type");
1298
+ var entriesNumber = $(this).data("entries-number");
1287
1299
 
1300
+ // If the current structure have many entries updating the field group
1301
+ // might be a slow operation, therefore it's good practice to inform the user
1302
+ if (entriesNumber > 500) {
1303
+ alert("You have " + entriesNumber + " " + instanceType + ". This operation might take some time to complete. To avoid unexpected behaviour don't leave or refresh the page");
1304
+ }
1305
+ });
1306
+ });
1288
1307
 
1308
+ /***/ }),
1309
+ /* 12 */
1310
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1289
1311
 
1312
+ "use strict";
1313
+ /**
1314
+ * BOOSTRAP SCRIPT
1315
+ */
1290
1316
 
1317
+ /* harmony default export */ __webpack_exports__["a"] = (function () {
1318
+ // See https://v4-alpha.getbootstrap.com/components/tooltips/#example-enable-tooltips-everywhere
1319
+ $('[data-toggle="tooltip"]').tooltip();
1320
+ });
1291
1321
 
1322
+ /***/ }),
1323
+ /* 13 */
1324
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1292
1325
 
1326
+ "use strict";
1327
+ /* harmony default export */ __webpack_exports__["a"] = (function () {
1328
+ $('input[name="login"]').click(function () {
1329
+ var $radio = $(this);
1293
1330
 
1294
- $(document).ready(function () {
1295
- if (__WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].isSet()) {
1296
- __WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].setEvents();
1297
- }
1298
- if (__WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__["a" /* _FormItemRepeater */].isSet()) {
1299
- __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__["a" /* _FormItemRepeater */].setEvents();
1300
- }
1301
- if (__WEBPACK_IMPORTED_MODULE_2__components_form_item_image__["a" /* _FormItemImage */].isSet()) {
1302
- __WEBPACK_IMPORTED_MODULE_2__components_form_item_image__["a" /* _FormItemImage */].setEvents();
1303
- }
1304
- if (__WEBPACK_IMPORTED_MODULE_3__components_field_setting_choices__["a" /* _FieldSettingChoices */].isSet()) {
1305
- __WEBPACK_IMPORTED_MODULE_3__components_field_setting_choices__["a" /* _FieldSettingChoices */].setEvents();
1306
- }
1307
- if (__WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__["a" /* _FormItemEditor */].isSet()) {
1308
- __WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__["a" /* _FormItemEditor */].setEvents();
1309
- }
1310
- if (__WEBPACK_IMPORTED_MODULE_5__components_fileupload__["a" /* _FileUpload */].isSet()) {
1311
- __WEBPACK_IMPORTED_MODULE_5__components_fileupload__["a" /* _FileUpload */].setEvents();
1312
- }
1313
- if (__WEBPACK_IMPORTED_MODULE_7__components_login_form__["a" /* _LoginForm */].isSet()) {
1314
- __WEBPACK_IMPORTED_MODULE_7__components_login_form__["a" /* _LoginForm */].init();
1315
- }
1316
- if (__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].isSet()) {
1317
- __WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].setup();
1318
- __WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].start();
1319
- }
1320
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_12__components_radio_toggle__["a" /* default */])();
1321
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_8__components_sortable__["a" /* default */])();
1322
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__components_field_group_editor__["a" /* default */])();
1323
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_10__components_bootstrap__["a" /* default */])();
1324
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_11__components_select2__["a" /* default */])();
1325
- });
1331
+ // if this was previously checked
1332
+ if ($radio.data("waschecked") === true) {
1333
+ $radio.prop("checked", false);
1334
+ $radio.data("waschecked", false);
1335
+ } else $radio.data("waschecked", true);
1326
1336
 
1327
- // handle event
1328
- window.addEventListener("optimizedResize", function () {
1329
- if (__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].isSet()) {
1330
- __WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].resize();
1331
- }
1337
+ // remove was checked from other radios
1338
+ $radio.siblings('input[name="login"]').data("waschecked", false);
1339
+ });
1332
1340
  });
1333
1341
 
1334
1342
  /***/ })