spina 1.2.0 → 2.0.0.alpha

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 (142) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/spina/favicon.png +0 -0
  3. data/app/assets/javascripts/spina/admin/application.js +1 -2
  4. data/app/assets/javascripts/spina/admin/controllers/attachment_picker_controller.js +15 -0
  5. data/app/assets/javascripts/spina/admin/controllers/image_form_controller.js +5 -4
  6. data/app/assets/javascripts/spina/admin/controllers/infinite_scroll_controller.js +20 -22
  7. data/app/assets/javascripts/spina/admin/controllers/media_picker_controller.js +171 -0
  8. data/app/assets/javascripts/spina/admin/controllers/modal_controller.js +18 -0
  9. data/app/assets/javascripts/spina/admin/controllers/repeater_form_controller.js +38 -0
  10. data/app/assets/javascripts/spina/admin/media_gallery.coffee +0 -3
  11. data/app/assets/javascripts/spina/admin/notifications.coffee +1 -1
  12. data/app/assets/javascripts/spina/admin/pages.coffee.erb +3 -20
  13. data/app/assets/javascripts/spina/admin/scaffold.coffee +0 -3
  14. data/app/assets/javascripts/spina/admin/trix.coffee.erb +14 -18
  15. data/app/assets/stylesheets/spina.sass +10 -8
  16. data/app/assets/stylesheets/spina/_buttons.sass +57 -31
  17. data/app/assets/stylesheets/spina/_forms.sass +59 -73
  18. data/app/assets/stylesheets/spina/_gallery.sass +18 -2
  19. data/app/assets/stylesheets/spina/_media_picker.sass +133 -0
  20. data/app/assets/stylesheets/spina/_modal.sass +35 -2
  21. data/app/assets/stylesheets/spina/_notifications.sass +20 -14
  22. data/app/assets/stylesheets/spina/_pages.sass +131 -0
  23. data/app/assets/stylesheets/spina/_sortable_lists.sass +14 -8
  24. data/app/assets/stylesheets/spina/_trix_custom.sass +1 -1
  25. data/app/controllers/concerns/spina/frontend.rb +9 -0
  26. data/app/controllers/spina/admin/accounts_controller.rb +9 -13
  27. data/app/controllers/spina/admin/attachments_controller.rb +0 -22
  28. data/app/controllers/spina/admin/images_controller.rb +1 -1
  29. data/app/controllers/spina/admin/media_picker_controller.rb +18 -19
  30. data/app/controllers/spina/admin/pages_controller.rb +1 -5
  31. data/app/controllers/spina/admin/resources_controller.rb +9 -4
  32. data/app/controllers/spina/application_controller.rb +1 -1
  33. data/app/helpers/spina/admin/pages_helper.rb +22 -20
  34. data/app/helpers/spina/{files_helper.rb → attachments_helper.rb} +1 -1
  35. data/app/helpers/spina/images_helper.rb +6 -0
  36. data/app/helpers/spina/pages_helper.rb +23 -4
  37. data/app/models/concerns/spina/partable.rb +19 -7
  38. data/app/models/concerns/spina/translated_content.rb +19 -0
  39. data/app/models/spina/account.rb +3 -10
  40. data/app/models/spina/attachment.rb +0 -4
  41. data/app/models/spina/current.rb +1 -0
  42. data/app/models/spina/image.rb +0 -4
  43. data/app/models/spina/page.rb +7 -15
  44. data/app/models/spina/parts/attachment.rb +17 -0
  45. data/app/models/spina/parts/base.rb +12 -0
  46. data/app/models/spina/parts/image.rb +30 -0
  47. data/app/models/spina/parts/image_collection.rb +23 -0
  48. data/app/models/spina/parts/line.rb +7 -0
  49. data/app/models/spina/parts/option.rb +13 -0
  50. data/app/models/spina/parts/repeater.rb +10 -0
  51. data/app/models/spina/parts/repeater_content.rb +15 -0
  52. data/app/models/spina/parts/text.rb +7 -0
  53. data/app/models/spina/resource.rb +4 -0
  54. data/app/presenters/spina/content_presenter.rb +58 -0
  55. data/app/presenters/spina/menu_presenter.rb +2 -1
  56. data/app/views/layouts/spina/admin/admin.html.haml +3 -4
  57. data/app/views/layouts/spina/admin/pages.html.haml +5 -4
  58. data/app/views/spina/admin/accounts/_form.html.haml +13 -7
  59. data/app/views/spina/admin/accounts/analytics.html.haml +5 -3
  60. data/app/views/spina/admin/accounts/style.html.haml +26 -21
  61. data/app/views/spina/admin/images/index.html.haml +7 -5
  62. data/app/views/spina/admin/media_folders/show.html.haml +2 -2
  63. data/app/views/spina/admin/media_picker/_image.html.haml +3 -0
  64. data/app/views/spina/admin/media_picker/_media_picker.html.haml +32 -0
  65. data/app/views/spina/admin/media_picker/_media_picker_grid.html.haml +25 -0
  66. data/app/views/spina/admin/media_picker/infinite_scroll.js.erb +4 -4
  67. data/app/views/spina/admin/media_picker/select.js.erb +2 -0
  68. data/app/views/spina/admin/media_picker/show.html.haml +1 -0
  69. data/app/views/spina/admin/media_picker/show.js.erb +1 -1
  70. data/app/views/spina/admin/pages/_form.html.haml +9 -7
  71. data/app/views/spina/admin/pages/_form_advanced.html.haml +5 -5
  72. data/app/views/spina/admin/pages/_form_page_content.html.haml +14 -13
  73. data/app/views/spina/admin/pages/_form_page_seo.html.haml +9 -5
  74. data/app/views/spina/admin/pages/_page.html.haml +5 -3
  75. data/app/views/spina/admin/pages/_page_nested_list.html.haml +2 -3
  76. data/app/views/spina/admin/pages/index.html.haml +5 -4
  77. data/app/views/spina/admin/parts/attachments/_form.html.haml +6 -0
  78. data/app/views/spina/admin/parts/image_collections/_fields.html.haml +7 -0
  79. data/app/views/spina/admin/parts/image_collections/_form.html.haml +12 -0
  80. data/app/views/spina/admin/parts/images/_form.html.haml +18 -0
  81. data/app/views/spina/admin/parts/lines/_form.html.haml +2 -0
  82. data/app/views/spina/admin/parts/options/_form.html.haml +3 -0
  83. data/app/views/spina/admin/parts/repeaters/_fields.html.haml +15 -0
  84. data/app/views/spina/admin/parts/repeaters/_form.html.haml +18 -0
  85. data/app/views/spina/admin/parts/texts/_form.html.haml +6 -0
  86. data/app/views/spina/admin/resources/edit.html.haml +28 -5
  87. data/app/views/spina/admin/resources/show.html.haml +5 -2
  88. data/app/views/spina/admin/shared/_notifications.html.haml +4 -4
  89. data/db/migrate/12_add_url_title_to_spina_page_translations.rb +1 -1
  90. data/db/migrate/13_add_json_attributes_to_spina_accounts.rb +5 -0
  91. data/db/migrate/14_add_json_attributes_to_spina_pages.rb +5 -0
  92. data/db/migrate/15_add_slug_to_spina_resources.rb +5 -0
  93. data/lib/generators/spina/templates/app/views/demo/pages/demo.html.haml +13 -21
  94. data/lib/generators/spina/templates/app/views/demo/pages/homepage.html.haml +1 -1
  95. data/lib/generators/spina/templates/config/initializers/themes/default.rb +4 -4
  96. data/lib/generators/spina/templates/config/initializers/themes/demo.rb +32 -44
  97. data/lib/spina.rb +2 -0
  98. data/lib/spina/attr_json_spina_parts_model.rb +29 -0
  99. data/lib/spina/engine.rb +13 -2
  100. data/lib/spina/part.rb +19 -0
  101. data/lib/spina/theme.rb +1 -1
  102. data/lib/spina/version.rb +1 -1
  103. data/vendor/assets/javascripts/spina/sortable.js +2 -2
  104. metadata +54 -42
  105. data/app/assets/javascripts/spina/admin/account.coffee +0 -16
  106. data/app/models/concerns/spina/image_collectable.rb +0 -23
  107. data/app/models/concerns/spina/optionable.rb +0 -12
  108. data/app/models/concerns/spina/part.rb +0 -38
  109. data/app/models/spina/attachment_collection.rb +0 -20
  110. data/app/models/spina/image_collection.rb +0 -23
  111. data/app/models/spina/image_collections_image.rb +0 -6
  112. data/app/models/spina/layout_part.rb +0 -22
  113. data/app/models/spina/line.rb +0 -10
  114. data/app/models/spina/option.rb +0 -17
  115. data/app/models/spina/page_part.rb +0 -22
  116. data/app/models/spina/structure.rb +0 -14
  117. data/app/models/spina/structure_item.rb +0 -22
  118. data/app/models/spina/structure_part.rb +0 -20
  119. data/app/models/spina/text.rb +0 -10
  120. data/app/views/dummy/show.html.haml +0 -1
  121. data/app/views/spina/admin/attachments/_attachment_collection.html.haml +0 -2
  122. data/app/views/spina/admin/attachments/_select.html.haml +0 -17
  123. data/app/views/spina/admin/attachments/_select_collection.html.haml +0 -18
  124. data/app/views/spina/admin/attachments/insert.js.erb +0 -5
  125. data/app/views/spina/admin/attachments/insert_collection.js.coffee +0 -7
  126. data/app/views/spina/admin/attachments/select.js.erb +0 -2
  127. data/app/views/spina/admin/attachments/select_collection.js.erb +0 -2
  128. data/app/views/spina/admin/image_collections/_image_collection.html.haml +0 -5
  129. data/app/views/spina/admin/layout_partables/lines/_form.html.haml +0 -2
  130. data/app/views/spina/admin/partables/attachment_collections/_form.html.haml +0 -14
  131. data/app/views/spina/admin/partables/attachments/_form.html.haml +0 -13
  132. data/app/views/spina/admin/partables/image_collections/_form.html.haml +0 -16
  133. data/app/views/spina/admin/partables/images/_form.html.haml +0 -21
  134. data/app/views/spina/admin/partables/lines/_form.html.haml +0 -5
  135. data/app/views/spina/admin/partables/options/_form.html.haml +0 -7
  136. data/app/views/spina/admin/partables/photo_collections/_form.html.haml +0 -4
  137. data/app/views/spina/admin/partables/photos/_form.html.haml +0 -4
  138. data/app/views/spina/admin/partables/structures/_form.html.haml +0 -21
  139. data/app/views/spina/admin/partables/texts/_form.html.haml +0 -8
  140. data/app/views/spina/admin/structure_items/_fields.html.haml +0 -15
  141. data/app/views/spina/admin/structure_partables/attachment_collections/_form.html.haml +0 -14
  142. 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: 6fa491e01750e620e5a4e3e3b63360fee11594caf3c773810617b5971e07ac3d
4
- data.tar.gz: 7445c7cab3bfe33ae822a8a99d2956e7bec095d4b3224c79a93d2ebc1ae2d7dd
3
+ metadata.gz: 840093f4a3186a7f872eb18f178f4b80619947ac14875213954e7eb956568176
4
+ data.tar.gz: 8013ac66f225fe12684596f71dbedef71fcb01cc88a404b7aa71ea6efb11afb7
5
5
  SHA512:
6
- metadata.gz: 0660aa6e59334da9af788a9cd15e58fde5e54f2d2426508ffc86b03cf8ff2937f7c5ac15713cc02769a0e1499f15083c8745317f15ca1038be17364f17c88e9f
7
- data.tar.gz: db2025173e5dd6888ed190476fd6c844ec917370597d83f44a919e205e6ca0a92fbea4b30c8698d620c457bb50ecd3e4ae9288fa144c3cf7137052539e9f40c5
6
+ metadata.gz: 63bacad75a83b92a8e95609d1d79b9174cedf521a37d08321f245b9e450c4384a539e5c4c5f3017fb449ce186e5adf40f3bf7e84459bdb1dedd241389d6dc124
7
+ data.tar.gz: 4d354cf6a05ffb631e0da43bf0707b6aab00476c6ebc7255d775ea316ec5d9ead75fae8c4489e744266af42400c47d7b7afdf1a771a072b6e31bbfd9f8877b33
@@ -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.fullImageUrl,
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) ->
@@ -73,9 +73,6 @@ ready = ->
73
73
  $('input[type="file"][data-customfileinput]:visible').each ->
74
74
  $(this).customFileInput()
75
75
 
76
- $(".structure-form-menu ul").sortable
77
- handle: '.sortable-handle'
78
-
79
76
  # Switch
80
77
  if $('input[data-switch]').length > 0
81
78
  $('input[data-switch]').spinaSwitch()
@@ -44,7 +44,6 @@ Trix.config.toolbar =
44
44
  <span class="trix-button-group trix-button-group--text-tools" data-trix-button-group="text-tools">
45
45
  <button type="button" class="trix-button trix-button--icon trix-button--icon-bold" data-trix-attribute="bold" data-trix-key="b" title="#{Trix.config.lang.bold}" tabindex="-1">#{Trix.config.lang.bold}</button>
46
46
  <button type="button" class="trix-button trix-button--icon trix-button--icon-italic" data-trix-attribute="italic" data-trix-key="i" title="#{Trix.config.lang.italic}" tabindex="-1">#{Trix.config.lang.italic}</button>
47
- <button type="button" class="trix-button trix-button--icon trix-button--icon-strike" data-trix-attribute="strike" title="#{Trix.config.lang.strike}" tabindex="-1">#{Trix.config.lang.strike}</button>
48
47
  <button type="button" class="trix-button trix-button--icon trix-button--icon-link" data-trix-attribute="href" data-trix-action="link" data-trix-key="k" title="#{Trix.config.lang.link}" tabindex="-1">#{Trix.config.lang.link}</button>
49
48
  </span>
50
49
  <span class="trix-button-group trix-button-group--block-tools" data-trix-button-group="block-tools">
@@ -52,16 +51,8 @@ Trix.config.toolbar =
52
51
  <button type="button" class="trix-button trix-button--text" data-trix-attribute="heading2" title="#{Trix.config.lang.heading2}" tabindex="-1">#{Trix.config.lang.heading2}</button>
53
52
  <button type="button" class="trix-button trix-button--text" data-trix-attribute="heading3" title="#{Trix.config.lang.heading3}" tabindex="-1">#{Trix.config.lang.heading3}</button>
54
53
  <button type="button" class="trix-button trix-button--text" data-trix-attribute="heading4" title="#{Trix.config.lang.heading4}" tabindex="-1">#{Trix.config.lang.heading4}</button>
55
- <button type="button" class="trix-button trix-button--text" data-trix-attribute="heading5" title="#{Trix.config.lang.heading5}" tabindex="-1">#{Trix.config.lang.heading5}</button>
56
- <button type="button" class="trix-button trix-button--text" data-trix-attribute="heading6" title="#{Trix.config.lang.heading6}" tabindex="-1">#{Trix.config.lang.heading6}</button>
57
54
  </span>
58
- <span class="trix-button-group-spacer"></span>
59
- <span class="trix-button-group trix-button-group--history-tools" data-trix-button-group="history-tools">
60
- <button type="button" class="trix-button trix-button--icon trix-button--icon-undo" data-trix-action="undo" data-trix-key="z" title="#{Trix.config.lang.undo}" tabindex="-1">#{Trix.config.lang.undo}</button>
61
- <button type="button" class="trix-button trix-button--icon trix-button--icon-redo" data-trix-action="redo" data-trix-key="shift+z" title="#{Trix.config.lang.redo}" tabindex="-1">#{Trix.config.lang.redo}</button>
62
- </span>
63
- </div>
64
- <div class="trix-button-row">
55
+
65
56
  <span class="trix-button-group trix-button-group--block-tools">
66
57
  <button type="button" class="trix-button trix-button--icon trix-button--icon-image" data-trix-attribute="image" data-trix-action="image" title="#{Trix.config.lang.image}" tabindex="-1">#{Trix.config.lang.image}</button>
67
58
  <button type="button" class="trix-button trix-button--icon trix-button--icon-quote" data-trix-attribute="quote" title="#{Trix.config.lang.quote}" tabindex="-1">#{Trix.config.lang.quote}</button>
@@ -71,6 +62,11 @@ Trix.config.toolbar =
71
62
  <button type="button" class="trix-button trix-button--icon trix-button--icon-decrease-nesting-level" data-trix-action="decreaseNestingLevel" title="#{Trix.config.lang.outdent}" tabindex="-1">#{Trix.config.lang.outdent}</button>
72
63
  <button type="button" class="trix-button trix-button--icon trix-button--icon-increase-nesting-level" data-trix-action="increaseNestingLevel" title="#{Trix.config.lang.indent}" tabindex="-1">#{Trix.config.lang.indent}</button>
73
64
  </span>
65
+
66
+ <span class="trix-button-group-spacer"></span>
67
+ </div>
68
+ <div class="trix-button-row">
69
+
74
70
  </div>
75
71
  <div class="trix-dialogs" data-trix-dialogs>
76
72
  <div class="trix-dialog trix-dialog--link" data-trix-dialog="href" data-trix-dialog-attribute="href">
@@ -88,21 +84,21 @@ Trix.config.toolbar =
88
84
  class Spina.TrixAttachment
89
85
  @imageSelect: (e) ->
90
86
  toolbar_id = $(this).closest('trix-toolbar').attr('id')
91
- $.get("<%= Spina::Engine.routes.url_helpers.admin_media_picker_path %>" + "?trix_toolbar_id=#{toolbar_id}")
87
+ $.getScript("<%= Spina::Engine.routes.url_helpers.admin_media_picker_path %>" + "?input=#{toolbar_id}&mode=trix")
92
88
 
93
- @imageInsert: (e, url, alt = "", link_to_url = "") ->
89
+ @imageInsert: (e) ->
94
90
  labels = []
95
- labels.push "✍️ #{alt}" if alt != ""
96
- labels.push "🔗 #{link_to_url}" if link_to_url != ""
91
+ labels.push "✍️ #{e.detail.alt}" if e.detail.alt != ""
92
+ labels.push "🔗 #{e.detail.link_to_url}" if e.detail.link_to_url != ""
97
93
  label = labels.join("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
98
94
 
99
- if link_to_url != ""
100
- attachment = new Trix.Attachment({content: "<a href='#{link_to_url}' class='trix-attachment-spina-image' data-label='#{label}'>
101
- <img src='#{url}' alt='#{alt}' />
95
+ if e.detail.link_to_url != ""
96
+ attachment = new Trix.Attachment({content: "<a href='#{e.detail.link_to_url}' class='trix-attachment-spina-image' data-label='#{label}'>
97
+ <img src='#{e.detail.url}' alt='#{e.detail.alt}' />
102
98
  </a>"})
103
99
  else
104
100
  attachment = new Trix.Attachment({content: "<span class='trix-attachment-spina-image' data-label='#{label}'>
105
- <img src='#{url}' alt='#{alt}' />
101
+ <img src='#{e.detail.url}' alt='#{e.detail.alt}' />
106
102
  </span>"})
107
103
 
108
104
  this.editor.insertAttachment(attachment)