spina 1.1.4 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spina might be problematic. Click here for more details.

Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/icons/spina/preview/icons_spina-preview.html +0 -2
  3. data/app/assets/icons/spina/preview/ics_spina-preview.html +0 -2
  4. data/app/assets/images/spina/favicon.png +0 -0
  5. data/app/assets/javascripts/spina/admin/application.js +1 -2
  6. data/app/assets/javascripts/spina/admin/controllers/attachment_picker_controller.js +15 -0
  7. data/app/assets/javascripts/spina/admin/controllers/image_form_controller.js +5 -4
  8. data/app/assets/javascripts/spina/admin/controllers/infinite_scroll_controller.js +20 -22
  9. data/app/assets/javascripts/spina/admin/controllers/media_picker_controller.js +171 -0
  10. data/app/assets/javascripts/spina/admin/controllers/modal_controller.js +18 -0
  11. data/app/assets/javascripts/spina/admin/controllers/repeater_form_controller.js +38 -0
  12. data/app/assets/javascripts/spina/admin/media_gallery.coffee +0 -3
  13. data/app/assets/javascripts/spina/admin/notifications.coffee +1 -1
  14. data/app/assets/javascripts/spina/admin/pages.coffee.erb +3 -20
  15. data/app/assets/javascripts/spina/admin/scaffold.coffee +1 -3
  16. data/app/assets/javascripts/spina/admin/trix.coffee.erb +14 -18
  17. data/app/assets/stylesheets/spina.sass +10 -8
  18. data/app/assets/stylesheets/spina/_buttons.sass +57 -31
  19. data/app/assets/stylesheets/spina/_forms.sass +66 -74
  20. data/app/assets/stylesheets/spina/_gallery.sass +18 -2
  21. data/app/assets/stylesheets/spina/_media_picker.sass +133 -0
  22. data/app/assets/stylesheets/spina/_modal.sass +35 -2
  23. data/app/assets/stylesheets/spina/_notifications.sass +20 -14
  24. data/app/assets/stylesheets/spina/_pages.sass +131 -0
  25. data/app/assets/stylesheets/spina/_sortable_lists.sass +14 -8
  26. data/app/assets/stylesheets/spina/_trix_custom.sass +15 -5
  27. data/app/controllers/concerns/spina/current_methods.rb +26 -0
  28. data/app/controllers/concerns/spina/frontend.rb +9 -0
  29. data/app/controllers/spina/admin/accounts_controller.rb +9 -13
  30. data/app/controllers/spina/admin/admin_controller.rb +5 -1
  31. data/app/controllers/spina/admin/attachments_controller.rb +0 -22
  32. data/app/controllers/spina/admin/images_controller.rb +1 -1
  33. data/app/controllers/spina/admin/media_picker_controller.rb +18 -19
  34. data/app/controllers/spina/admin/pages_controller.rb +2 -6
  35. data/app/controllers/spina/admin/resources_controller.rb +9 -4
  36. data/app/controllers/spina/application_controller.rb +6 -23
  37. data/app/controllers/spina/pages_controller.rb +11 -13
  38. data/app/controllers/spina/sitemaps_controller.rb +6 -6
  39. data/app/helpers/spina/admin/pages_helper.rb +22 -20
  40. data/app/helpers/spina/{files_helper.rb → attachments_helper.rb} +1 -1
  41. data/app/helpers/spina/images_helper.rb +9 -18
  42. data/app/helpers/spina/pages_helper.rb +23 -4
  43. data/app/models/concerns/spina/partable.rb +19 -7
  44. data/app/models/concerns/spina/translated_content.rb +19 -0
  45. data/app/models/spina/account.rb +3 -10
  46. data/app/models/spina/attachment.rb +0 -4
  47. data/app/models/spina/current.rb +1 -0
  48. data/app/models/spina/image.rb +0 -4
  49. data/app/models/spina/page.rb +29 -21
  50. data/app/models/spina/parts/attachment.rb +22 -0
  51. data/app/models/spina/parts/base.rb +12 -0
  52. data/app/models/spina/parts/image.rb +39 -0
  53. data/app/models/spina/parts/image_collection.rb +23 -0
  54. data/app/models/spina/parts/image_variant.rb +19 -0
  55. data/app/models/spina/parts/line.rb +7 -0
  56. data/app/models/spina/parts/multi_line.rb +7 -0
  57. data/app/models/spina/parts/option.rb +13 -0
  58. data/app/models/spina/parts/repeater.rb +10 -0
  59. data/app/models/spina/parts/repeater_content.rb +15 -0
  60. data/app/models/spina/parts/text.rb +7 -0
  61. data/app/models/spina/resource.rb +4 -12
  62. data/app/presenters/spina/content_presenter.rb +51 -0
  63. data/app/presenters/spina/menu_presenter.rb +2 -1
  64. data/app/views/layouts/spina/admin/admin.html.haml +3 -7
  65. data/app/views/layouts/spina/admin/pages.html.haml +5 -4
  66. data/app/views/layouts/spina/login.html.haml +0 -3
  67. data/app/views/spina/admin/accounts/_form.html.haml +13 -7
  68. data/app/views/spina/admin/accounts/analytics.html.haml +5 -3
  69. data/app/views/spina/admin/accounts/social.html.haml +13 -7
  70. data/app/views/spina/admin/accounts/style.html.haml +26 -21
  71. data/app/views/spina/admin/attachments/index.html.haml +1 -1
  72. data/app/views/spina/admin/images/_image.html.haml +1 -1
  73. data/app/views/spina/admin/images/index.html.haml +7 -5
  74. data/app/views/spina/admin/media_folders/_media_folder.html.haml +1 -1
  75. data/app/views/spina/admin/media_folders/show.html.haml +2 -2
  76. data/app/views/spina/admin/media_picker/_image.html.haml +3 -0
  77. data/app/views/spina/admin/media_picker/_media_picker.html.haml +32 -0
  78. data/app/views/spina/admin/media_picker/_media_picker_grid.html.haml +25 -0
  79. data/app/views/spina/admin/media_picker/_modal.html.haml +1 -1
  80. data/app/views/spina/admin/media_picker/infinite_scroll.js.erb +4 -4
  81. data/app/views/spina/admin/media_picker/select.js.erb +2 -0
  82. data/app/views/spina/admin/media_picker/show.html.haml +1 -0
  83. data/app/views/spina/admin/media_picker/show.js.erb +1 -1
  84. data/app/views/spina/admin/pages/_form.html.haml +9 -7
  85. data/app/views/spina/admin/pages/_form_advanced.html.haml +19 -17
  86. data/app/views/spina/admin/pages/_form_page_content.html.haml +14 -13
  87. data/app/views/spina/admin/pages/_form_page_seo.html.haml +15 -4
  88. data/app/views/spina/admin/pages/_page.html.haml +5 -3
  89. data/app/views/spina/admin/pages/_page_nested_list.html.haml +2 -3
  90. data/app/views/spina/admin/pages/index.html.haml +5 -4
  91. data/app/views/spina/admin/parts/attachments/_form.html.haml +6 -0
  92. data/app/views/spina/admin/parts/image_collections/_fields.html.haml +7 -0
  93. data/app/views/spina/admin/parts/image_collections/_form.html.haml +12 -0
  94. data/app/views/spina/admin/parts/images/_form.html.haml +18 -0
  95. data/app/views/spina/admin/parts/lines/_form.html.haml +2 -0
  96. data/app/views/spina/admin/parts/multi_lines/_form.html.haml +2 -0
  97. data/app/views/spina/admin/parts/options/_form.html.haml +3 -0
  98. data/app/views/spina/admin/parts/repeaters/_fields.html.haml +15 -0
  99. data/app/views/spina/admin/parts/repeaters/_form.html.haml +17 -0
  100. data/app/views/spina/admin/parts/texts/_form.html.haml +6 -0
  101. data/app/views/spina/admin/resources/edit.html.haml +28 -12
  102. data/app/views/spina/admin/resources/show.html.haml +6 -3
  103. data/app/views/spina/admin/shared/_notifications.html.haml +4 -4
  104. data/config/locales/TH.yml +9 -0
  105. data/config/locales/bg.yml +9 -0
  106. data/config/locales/de.yml +9 -0
  107. data/config/locales/en.yml +9 -0
  108. data/config/locales/es.yml +9 -0
  109. data/config/locales/fr.yml +9 -0
  110. data/config/locales/id.yml +9 -0
  111. data/config/locales/it.yml +9 -0
  112. data/config/locales/nl.yml +9 -0
  113. data/config/locales/pl.yml +23 -14
  114. data/config/locales/pt-BR.yml +9 -0
  115. data/config/locales/ro.yml +9 -0
  116. data/config/locales/ru.yml +9 -0
  117. data/config/locales/sv.yml +9 -0
  118. data/config/locales/tr.yml +9 -0
  119. data/config/locales/zh-CN.yml +9 -0
  120. data/config/routes.rb +13 -0
  121. data/db/migrate/11_create_spina_resources.rb +0 -2
  122. data/db/migrate/12_add_url_title_to_spina_page_translations.rb +5 -0
  123. data/db/migrate/13_add_json_attributes_to_spina_accounts.rb +5 -0
  124. data/db/migrate/14_add_json_attributes_to_spina_pages.rb +5 -0
  125. data/db/migrate/15_add_slug_to_spina_resources.rb +5 -0
  126. data/lib/generators/spina/templates/app/views/demo/pages/demo.html.haml +13 -21
  127. data/lib/generators/spina/templates/app/views/demo/pages/homepage.html.haml +1 -1
  128. data/lib/generators/spina/templates/config/initializers/mobility.rb +13 -4
  129. data/lib/generators/spina/templates/config/initializers/spina.rb +4 -0
  130. data/lib/generators/spina/templates/config/initializers/themes/default.rb +7 -7
  131. data/lib/generators/spina/templates/config/initializers/themes/demo.rb +32 -44
  132. data/lib/spina.rb +18 -3
  133. data/lib/spina/attr_json_spina_parts_model.rb +29 -0
  134. data/lib/spina/engine.rb +14 -6
  135. data/lib/spina/part.rb +19 -0
  136. data/lib/spina/theme.rb +1 -1
  137. data/lib/spina/version.rb +1 -1
  138. data/lib/tasks/spina_tasks.rake +1 -1
  139. data/vendor/assets/javascripts/spina/sortable.js +2 -2
  140. metadata +73 -51
  141. data/app/assets/javascripts/spina/admin/account.coffee +0 -16
  142. data/app/models/concerns/spina/image_collectable.rb +0 -23
  143. data/app/models/concerns/spina/optionable.rb +0 -12
  144. data/app/models/concerns/spina/part.rb +0 -38
  145. data/app/models/spina/attachment_collection.rb +0 -20
  146. data/app/models/spina/image_collection.rb +0 -23
  147. data/app/models/spina/image_collections_image.rb +0 -6
  148. data/app/models/spina/layout_part.rb +0 -22
  149. data/app/models/spina/line.rb +0 -10
  150. data/app/models/spina/option.rb +0 -17
  151. data/app/models/spina/page_part.rb +0 -22
  152. data/app/models/spina/structure.rb +0 -14
  153. data/app/models/spina/structure_item.rb +0 -22
  154. data/app/models/spina/structure_part.rb +0 -20
  155. data/app/models/spina/text.rb +0 -10
  156. data/app/views/dummy/show.html.haml +0 -1
  157. data/app/views/spina/admin/attachments/_attachment_collection.html.haml +0 -2
  158. data/app/views/spina/admin/attachments/_select.html.haml +0 -17
  159. data/app/views/spina/admin/attachments/_select_collection.html.haml +0 -18
  160. data/app/views/spina/admin/attachments/insert.js.erb +0 -5
  161. data/app/views/spina/admin/attachments/insert_collection.js.coffee +0 -7
  162. data/app/views/spina/admin/attachments/select.js.erb +0 -2
  163. data/app/views/spina/admin/attachments/select_collection.js.erb +0 -2
  164. data/app/views/spina/admin/image_collections/_image_collection.html.haml +0 -5
  165. data/app/views/spina/admin/layout_partables/lines/_form.html.haml +0 -2
  166. data/app/views/spina/admin/partables/attachment_collections/_form.html.haml +0 -14
  167. data/app/views/spina/admin/partables/attachments/_form.html.haml +0 -13
  168. data/app/views/spina/admin/partables/image_collections/_form.html.haml +0 -16
  169. data/app/views/spina/admin/partables/images/_form.html.haml +0 -21
  170. data/app/views/spina/admin/partables/lines/_form.html.haml +0 -5
  171. data/app/views/spina/admin/partables/options/_form.html.haml +0 -7
  172. data/app/views/spina/admin/partables/photo_collections/_form.html.haml +0 -4
  173. data/app/views/spina/admin/partables/photos/_form.html.haml +0 -4
  174. data/app/views/spina/admin/partables/structures/_form.html.haml +0 -21
  175. data/app/views/spina/admin/partables/texts/_form.html.haml +0 -8
  176. data/app/views/spina/admin/structure_items/_fields.html.haml +0 -15
  177. data/app/views/spina/admin/structure_partables/attachment_collections/_form.html.haml +0 -14
  178. data/app/views/spina/admin/structure_partables/attachments/_form.html.haml +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 414bc5f87303a017e42900d1f064457e8649f11088b3b9cfd49bccb8a327e145
4
- data.tar.gz: a922eb6f603cbc71de8fe8e353aba261a4d1ce998ad2e40a100feeda27b0b881
3
+ metadata.gz: 979a0e909c387767e2094535c8ee443c048e084bf2f843ca1200dde04e791651
4
+ data.tar.gz: b53c7cd7994cd84b99a296a46ac962595268e6d70d25e08ecca543b2bbb899fc
5
5
  SHA512:
6
- metadata.gz: a877991a1b49ad1811f1557406835a72f80da58b326c17adc923fe2460734cebdceb467ba4b380724cbe686aa61949d20e3b6972b2517f060adf84a8b2a24363
7
- data.tar.gz: 7612cd02fde4d6b3444249ff9477ba102cf7c3f87791ede3b0c0ca2e700a36c7c702f73dbb897e0a22b0a2490d7aa7781d5e3495b5dff86e4fd1983a8b8a0e41
6
+ metadata.gz: b029f327a909d773360304b911985ea1cb2a10d5361d1e0225bea267953aa57525d470a01df2ade03d3dec7e4d868fde77f4f1034e049b4ceefb44a2c6d3edd0
7
+ data.tar.gz: 03fc8375f855e25a9a17bfb078f2a432410811fd09be6f57a3f69b50929d421eca063b95ed3171357ad9157323fb1b1a90023d25ccbfc9aedd32b80d344238d2
@@ -288,8 +288,6 @@
288
288
  .icon-users-outline:before { content: "\f107"; }
289
289
  </style>
290
290
 
291
- <!--[if lte IE 8]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
292
-
293
291
  <script>
294
292
  function toggleCharacters() {
295
293
  var body = document.getElementsByTagName('body')[0];
@@ -309,8 +309,6 @@
309
309
  .icon-users-outline:before { content: "\f137"; }
310
310
  </style>
311
311
 
312
- <!--[if lte IE 8]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
313
-
314
312
  <script>
315
313
  function toggleCharacters() {
316
314
  var body = document.getElementsByTagName('body')[0];
Binary file
@@ -1,7 +1,7 @@
1
1
  // jQuery
2
2
 
3
3
  //= require jquery
4
- //= require jquery_ujs
4
+ //= require rails-ujs
5
5
 
6
6
  // Turbolinks
7
7
 
@@ -38,7 +38,6 @@
38
38
  //= require ./notifications
39
39
  //= require ./media_gallery
40
40
 
41
- //= require ./account
42
41
  //= require ./confirm_delete
43
42
  //= require ./pages
44
43
 
@@ -0,0 +1,15 @@
1
+ (() => {
2
+ const application = Stimulus.Application.start()
3
+
4
+ application.register("attachment-picker", class extends Stimulus.Controller {
5
+ static get targets() {
6
+ return ["signedBlobId", "filename"]
7
+ }
8
+
9
+ chooseAttachment(event) {
10
+ let option = event.currentTarget.options[event.currentTarget.selectedIndex]
11
+ this.signedBlobIdTarget.value = option.dataset.signedBlobId || ""
12
+ this.filenameTarget.value = option.dataset.filename || ""
13
+ }
14
+ })
15
+ })()
@@ -3,7 +3,7 @@
3
3
 
4
4
  application.register("image-form", class extends Stimulus.Controller {
5
5
  static get targets() {
6
- return ["image", "field", "button"]
6
+ return ["image", "imageId", "signedBlobId", "filename"]
7
7
  }
8
8
 
9
9
  remove(e) {
@@ -12,9 +12,10 @@
12
12
  e.stopPropagation()
13
13
 
14
14
  // Remove image and reset field
15
- this.imageTarget.remove()
16
- this.buttonTarget.remove()
17
- this.fieldTarget.value = null
15
+ this.imageTarget.querySelectorAll('img').forEach(image => image.remove())
16
+ this.imageIdTarget.value = null
17
+ this.signedBlobIdTarget.value = null
18
+ this.filenameTarget.value = null
18
19
  }
19
20
 
20
21
  })
@@ -3,36 +3,34 @@
3
3
 
4
4
  application.register("infinite-scroll", class extends Stimulus.Controller {
5
5
  static get targets() {
6
- return ["link"]
6
+ return ["link", "scrollContainer"]
7
7
  }
8
8
 
9
9
  connect() {
10
- // Disable scroll event listeners
11
- $(window).off('scroll.infiniteScroll')
12
- $('#overlay section').off('scroll.infiniteScroll')
13
-
14
- let $link = $(this.linkTarget)
15
-
16
- // If the link has an actual href
17
- if ($link.attr('href')) {
18
- // If the window scrolls
19
- $(window).on('scroll.infiniteScroll', this.loadNextPage($link))
10
+ this.element["infiniteScroll"] = this
11
+ this.scrollElement.addEventListener("scroll", this.loadNextPage.bind(this))
12
+ this.loadNextPage()
13
+ }
20
14
 
21
- // If the overlay scrolls
22
- $('#overlay section').on('scroll.infiniteScroll', function() {
23
- $(window).trigger('scroll.infiniteScroll')
24
- })
15
+ disconnect() {
16
+ this.scrollElement.removeEventListener("scroll", this.loadNextPage.bind(this))
17
+ }
25
18
 
26
- $(window).trigger('scroll.infiniteScroll')
19
+ get scrollElement() {
20
+ if (this.hasScrollContainerTarget) {
21
+ return this.scrollContainerTarget
22
+ } else {
23
+ return window
27
24
  }
28
25
  }
29
26
 
30
- loadNextPage(link) {
31
- if ($(window).scrollTop() > link.offset().top - $(window).height() - 500) {
32
- $(window).off('scroll.infiniteScroll')
33
- $('#overlay section').off('scroll.infiniteScroll')
34
- $.rails.disableElement(link)
35
- $.getScript(link.attr('href'))
27
+ loadNextPage() {
28
+ if (this.hasLinkTarget) {
29
+ let top = this.linkTarget.getBoundingClientRect().top
30
+ if (top < window.innerHeight + 500) {
31
+ this.linkTarget.dataset.disableWith = "..."
32
+ this.linkTarget.click()
33
+ }
36
34
  }
37
35
  }
38
36
 
@@ -0,0 +1,171 @@
1
+ (() => {
2
+ const application = Stimulus.Application.start()
3
+
4
+ application.register("media-picker", class extends Stimulus.Controller {
5
+ static get targets() {
6
+ return ["input", "image", "grid", "selectedImage", "selectedImages", "selectedCount", "alt", "linkToUrl", "trixImage"]
7
+ }
8
+
9
+ connect() {
10
+ this.toggleActive()
11
+
12
+ if (this.hasSelectedImagesTarget) {
13
+ this.sortable = Sortable.create(this.selectedImagesTarget)
14
+ }
15
+ }
16
+
17
+ choose(event) {
18
+ switch(this.element.dataset.mode) {
19
+ case "single":
20
+ this.imageTargets.forEach((image) => image.querySelector('input').checked = false)
21
+ event.currentTarget.checked = true
22
+ this.imageIdInput.value = event.currentTarget.value
23
+ this.signedBlobIdInput.value = event.currentTarget.dataset.signedBlobId
24
+ this.filenameInput.value = event.currentTarget.dataset.filename
25
+ this.placeholder.innerHTML = `<img src="${event.currentTarget.dataset.thumbnailUrl}" width="200" height="150" />`
26
+ this.element.modal.close()
27
+ break
28
+ case "multiple":
29
+ if(event.currentTarget.checked) {
30
+ this.addImage(event.currentTarget.dataset.imageId, event.currentTarget.dataset.signedBlobId, event.currentTarget.dataset.filename, event.currentTarget.dataset.thumbnailUrl)
31
+ } else {
32
+ this.removeImage(event.currentTarget.dataset.imageId)
33
+ }
34
+ this.setCount()
35
+ break
36
+ case "trix":
37
+ this.imageTargets.forEach((image) => image.querySelector('input').checked = false)
38
+ event.currentTarget.checked = true
39
+ this.trixImage = event.currentTarget
40
+ break
41
+ }
42
+ }
43
+
44
+ choose_multiple(event) {
45
+ // Set image id's
46
+ let fields = this.imageCollectionPlaceholder.dataset.fields
47
+ let id = this.imageCollectionPlaceholder.dataset.id
48
+
49
+ let timeIndex = 0
50
+
51
+ // Set image thumbnails
52
+ this.imageCollectionPlaceholder.innerHTML = ""
53
+ this.selectedImageTargets.forEach(function(image) {
54
+ // this.imageCollectionPlaceholder.insertAdjacentHTML("beforeend", `<img src="${image.src}" />`)
55
+
56
+ // Time
57
+ let time = new Date().getTime() + timeIndex
58
+ timeIndex += 1
59
+
60
+ // Regexp
61
+ let regexp = new RegExp(`${id}|new_association`, 'g')
62
+
63
+ // Document generation
64
+ let doc = document.createRange().createContextualFragment(fields.replace(regexp, time))
65
+ doc.querySelector(".image-id").value = image.dataset.imageId
66
+ doc.querySelector(".signed-blob-id").value = image.dataset.signedBlobId
67
+ doc.querySelector(".filename").value = image.dataset.filename
68
+ doc.querySelector("img").src = image.src
69
+
70
+ this.imageCollectionPlaceholder.appendChild(doc)
71
+ }.bind(this))
72
+
73
+ // Close modal
74
+ this.element.modal.close()
75
+ }
76
+
77
+ insert_trix(event) {
78
+ let customEvent = new CustomEvent("image-insert", {bubbles: true, cancelable: true, detail: {
79
+ url: this.trixImage.dataset.imageUrl,
80
+ alt: this.altTarget.value,
81
+ link_to_url: this.linkToUrlTarget.value
82
+ }})
83
+ this.trixEditor.dispatchEvent(customEvent)
84
+
85
+ // Close modal
86
+ this.element.modal.close()
87
+ }
88
+
89
+ startUpload(event) {
90
+ event.currentTarget.querySelector('.media-picker-uploader').classList.add("uploading")
91
+ }
92
+
93
+ refresh(event) {
94
+ fetch(event.currentTarget.dataset.mediaPickerUrl)
95
+ .then(response => response.text())
96
+ .then(function(html) {
97
+ this.gridTarget.innerHTML = html
98
+ this.toggleActive()
99
+ }.bind(this))
100
+ }
101
+
102
+ toggleActive() {
103
+ this.imageTargets.forEach(function(image) {
104
+ let input = image.querySelector('input')
105
+ if (this.selectedIds.includes(input.value)) input.checked = true
106
+ }.bind(this))
107
+ }
108
+
109
+ openFolder(event) {
110
+ event.preventDefault()
111
+ fetch(event.currentTarget.href)
112
+ .then(response => response.text())
113
+ .then(function(html) {
114
+ this.gridTarget.innerHTML = html
115
+ this.toggleActive()
116
+ }.bind(this))
117
+ }
118
+
119
+ setCount() {
120
+ this.selectedCountTarget.innerHTML = `(${this.selectedIds.length})`
121
+ }
122
+
123
+ addImage(id, signed_blob_id, filename, url) {
124
+ this.selectedImagesTarget.insertAdjacentHTML("beforeend", `<img src="${url}" data-image-id="${id}" data-signed-blob-id="${signed_blob_id}" data-filename="${filename}" data-target="media-picker.selectedImage" />`)
125
+ }
126
+
127
+ removeImage(id) {
128
+ let image = this.selectedImagesTarget.querySelector(`img[data-image-id="${id}"]`)
129
+ this.selectedImagesTarget.removeChild(image)
130
+ }
131
+
132
+ get trixEditor() {
133
+ return document.querySelector(`trix-editor[toolbar="${this.inputTarget.value}"]`)
134
+ }
135
+
136
+ get selectedIds() {
137
+ return this.selectedImageTargets.map(function(image) {
138
+ return image.dataset.imageId
139
+ })
140
+ }
141
+
142
+ get imageCollectionPlaceholder() {
143
+ return document.querySelector(`#${this.inputTarget.value}`)
144
+ }
145
+
146
+ get hiddenInputs() {
147
+ return document.querySelector(`#${this.inputTarget.value}`)
148
+ }
149
+
150
+ get imageIdInput() {
151
+ return this.hiddenInputs.querySelector("input[data-target='image-form.imageId']")
152
+ }
153
+
154
+ get signedBlobIdInput() {
155
+ return this.hiddenInputs.querySelector("input[data-target='image-form.signedBlobId']")
156
+ }
157
+
158
+ get filenameInput() {
159
+ return this.hiddenInputs.querySelector("input[data-target='image-form.filename']")
160
+ }
161
+
162
+ get placeholder() {
163
+ return this.hiddenInputs.nextElementSibling
164
+ }
165
+
166
+ get token() {
167
+ return document.querySelector('meta[name="csrf-token"]').content
168
+ }
169
+
170
+ })
171
+ })()
@@ -0,0 +1,18 @@
1
+ (() => {
2
+ const application = Stimulus.Application.start()
3
+
4
+ application.register("modal", class extends Stimulus.Controller {
5
+ static get targets() {
6
+ return []
7
+ }
8
+
9
+ connect() {
10
+ this.element[this.identifier] = this
11
+ }
12
+
13
+ close() {
14
+ document.querySelector('body').removeChild(this.element)
15
+ }
16
+
17
+ })
18
+ })()
@@ -0,0 +1,38 @@
1
+ (() => {
2
+ const application = Stimulus.Application.start()
3
+
4
+ application.register("repeater-form", class extends Stimulus.Controller {
5
+ static get targets() {
6
+ return ["list", "listItem", "content", "pane"]
7
+ }
8
+
9
+ connect() {
10
+ Sortable.create(this.listTarget, {
11
+ handle: '.sortable-handle',
12
+ onUpdate: function(event) {
13
+ let order_of_ids = [...this.listTarget.children].map(function(item) {
14
+ return parseInt(item.dataset.partId)
15
+ })
16
+
17
+ // Sort the DOM elements containing the repeater fields
18
+ let array = [...this.contentTarget.children]
19
+ array.sort(function(a, b) {
20
+ return order_of_ids.indexOf(parseInt(a.dataset.partId)) - order_of_ids.indexOf(parseInt(b.dataset.partId))
21
+ }).map(node => this.contentTarget.appendChild(node))
22
+ }.bind(this)
23
+ })
24
+ }
25
+
26
+ delete(event) {
27
+ event.preventDefault()
28
+ let part_id = event.currentTarget.dataset.partId
29
+
30
+ let pane = this.element.querySelector(`.structure-form-pane[data-part-id="${part_id}"]`)
31
+ let listItem = this.element.querySelector(`.structure-form-menu li[data-part-id="${part_id}"]`)
32
+
33
+ pane.parentElement.removeChild(pane)
34
+ listItem.parentElement.removeChild(listItem)
35
+ }
36
+
37
+ })
38
+ })()
@@ -4,9 +4,6 @@ $(document).on 'direct-uploads:start', 'form', (e) ->
4
4
  $(document).on 'direct-uploads:end', 'form', (e) ->
5
5
  $(this).find('.customfile').removeClass('loading')
6
6
 
7
- $(document).on 'direct-upload:progress', 'input', (e) ->
8
- console.log(e.detail.progress)
9
-
10
7
  $(document).on 'change', 'input[type="file"]', (e) ->
11
8
  $form = $(this).parents('form')
12
9
  $form.find('input[type="submit"]').click()
@@ -1,6 +1,6 @@
1
1
  $(document).on 'click', '.notification [data-close-notification]', (e) ->
2
2
  $notification = $(this).parents('.notification')
3
- $notification.removeClass('fadeInRight').addClass('fadeOutRight')
3
+ $notification.removeClass('fadeInLeft').addClass('fadeOutLeft')
4
4
  setTimeout ->
5
5
  $notification.remove()
6
6
  , 400
@@ -3,33 +3,14 @@ ready = ->
3
3
  $('.dd').nestable
4
4
  maxDepth: "<%= Spina.config.max_page_depth %>"
5
5
 
6
- if $('.page-template').length > 0
7
- page_parts = $('.page-template').data('page-parts')
8
- show_page_parts(page_parts)
9
-
10
6
  $('.sortable-grid').sortable().bind 'sortupdate', (e) ->
11
7
  position_array = []
12
8
  $(e.target).find('li.image').each (index) ->
13
9
  position_array.push $(this).data('image-id')
14
10
  $(e.target).parents('.horizontal-form-content').find('.image-positions').val(position_array.join(","))
15
11
 
16
- $('.structure-form-menu ul').sortable().bind 'sortupdate', (e) ->
17
- $(e.target).find('li').each (index) ->
18
- id = $(this).data('structure-item-id')
19
- $(".structure_form_pane_#{id}_position").val(index)
20
-
21
12
  $(document).on 'turbolinks:load', ready
22
13
 
23
- # Change templates makes page parts appear and disappear
24
- $(document).on 'change', '.page-template select', ->
25
- page_parts = $(this).find('option:selected').data('page-parts').split(" ")
26
- show_page_parts(page_parts)
27
-
28
- show_page_parts = (page_parts) ->
29
- $('.horizontal-form-group.page-part').hide()
30
- for page_part in page_parts
31
- $('.horizontal-form-group.page-part[data-name=' + page_part + ']').show()
32
-
33
14
  # Dynamically add and remove structures
34
15
  $(document).on 'click', 'form .add_structure_item_fields', (event) ->
35
16
  $structureForm = $(this).parents('.structure-form')
@@ -39,7 +20,7 @@ $(document).on 'click', 'form .add_structure_item_fields', (event) ->
39
20
  $fields = $($(this).data('fields').replace(regexp, time))
40
21
  $structureForm.find('.structure-form-content').append($fields)
41
22
 
42
- $link = $("<li><a href='#structure_form_pane_#{time}'><i class='icon icon-bars'></i> </a></li>")
23
+ $link = $("<li data-part-id='#{time}'><a href='#structure_form_pane_#{time}'><i class='icon icon-bars'></i> </a></li>")
43
24
 
44
25
  $structureForm.find('.structure-form-menu ul').append($link)
45
26
  $fields.attr('id', "structure_form_pane_#{time}")
@@ -60,6 +41,8 @@ $(document).on 'click', 'form .remove_structure_item_fields', (event) ->
60
41
  $previousLink.find('a').trigger('click')
61
42
  $link.hide()
62
43
  $pane.hide()
44
+ $link.remove()
45
+ $pane.remove()
63
46
  event.preventDefault()
64
47
 
65
48
  $(document).on 'change', '.structure-form-pane .structure-form-part:first-child input', (event) ->