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.
- checksums.yaml +4 -4
- data/app/assets/icons/spina/preview/icons_spina-preview.html +0 -2
- data/app/assets/icons/spina/preview/ics_spina-preview.html +0 -2
- data/app/assets/images/spina/favicon.png +0 -0
- data/app/assets/javascripts/spina/admin/application.js +1 -2
- data/app/assets/javascripts/spina/admin/controllers/attachment_picker_controller.js +15 -0
- data/app/assets/javascripts/spina/admin/controllers/image_form_controller.js +5 -4
- data/app/assets/javascripts/spina/admin/controllers/infinite_scroll_controller.js +20 -22
- data/app/assets/javascripts/spina/admin/controllers/media_picker_controller.js +171 -0
- data/app/assets/javascripts/spina/admin/controllers/modal_controller.js +18 -0
- data/app/assets/javascripts/spina/admin/controllers/repeater_form_controller.js +38 -0
- data/app/assets/javascripts/spina/admin/media_gallery.coffee +0 -3
- data/app/assets/javascripts/spina/admin/notifications.coffee +1 -1
- data/app/assets/javascripts/spina/admin/pages.coffee.erb +3 -20
- data/app/assets/javascripts/spina/admin/scaffold.coffee +1 -3
- data/app/assets/javascripts/spina/admin/trix.coffee.erb +14 -18
- data/app/assets/stylesheets/spina.sass +10 -8
- data/app/assets/stylesheets/spina/_buttons.sass +57 -31
- data/app/assets/stylesheets/spina/_forms.sass +66 -74
- data/app/assets/stylesheets/spina/_gallery.sass +18 -2
- data/app/assets/stylesheets/spina/_media_picker.sass +133 -0
- data/app/assets/stylesheets/spina/_modal.sass +35 -2
- data/app/assets/stylesheets/spina/_notifications.sass +20 -14
- data/app/assets/stylesheets/spina/_pages.sass +131 -0
- data/app/assets/stylesheets/spina/_sortable_lists.sass +14 -8
- data/app/assets/stylesheets/spina/_trix_custom.sass +15 -5
- data/app/controllers/concerns/spina/current_methods.rb +26 -0
- data/app/controllers/concerns/spina/frontend.rb +9 -0
- data/app/controllers/spina/admin/accounts_controller.rb +9 -13
- data/app/controllers/spina/admin/admin_controller.rb +5 -1
- data/app/controllers/spina/admin/attachments_controller.rb +0 -22
- data/app/controllers/spina/admin/images_controller.rb +1 -1
- data/app/controllers/spina/admin/media_picker_controller.rb +18 -19
- data/app/controllers/spina/admin/pages_controller.rb +2 -6
- data/app/controllers/spina/admin/resources_controller.rb +9 -4
- data/app/controllers/spina/application_controller.rb +6 -23
- data/app/controllers/spina/pages_controller.rb +11 -13
- data/app/controllers/spina/sitemaps_controller.rb +6 -6
- data/app/helpers/spina/admin/pages_helper.rb +22 -20
- data/app/helpers/spina/{files_helper.rb → attachments_helper.rb} +1 -1
- data/app/helpers/spina/images_helper.rb +9 -18
- data/app/helpers/spina/pages_helper.rb +23 -4
- data/app/models/concerns/spina/partable.rb +19 -7
- data/app/models/concerns/spina/translated_content.rb +19 -0
- data/app/models/spina/account.rb +3 -10
- data/app/models/spina/attachment.rb +0 -4
- data/app/models/spina/current.rb +1 -0
- data/app/models/spina/image.rb +0 -4
- data/app/models/spina/page.rb +29 -21
- data/app/models/spina/parts/attachment.rb +22 -0
- data/app/models/spina/parts/base.rb +12 -0
- data/app/models/spina/parts/image.rb +39 -0
- data/app/models/spina/parts/image_collection.rb +23 -0
- data/app/models/spina/parts/image_variant.rb +19 -0
- data/app/models/spina/parts/line.rb +7 -0
- data/app/models/spina/parts/multi_line.rb +7 -0
- data/app/models/spina/parts/option.rb +13 -0
- data/app/models/spina/parts/repeater.rb +10 -0
- data/app/models/spina/parts/repeater_content.rb +15 -0
- data/app/models/spina/parts/text.rb +7 -0
- data/app/models/spina/resource.rb +4 -12
- data/app/presenters/spina/content_presenter.rb +51 -0
- data/app/presenters/spina/menu_presenter.rb +2 -1
- data/app/views/layouts/spina/admin/admin.html.haml +3 -7
- data/app/views/layouts/spina/admin/pages.html.haml +5 -4
- data/app/views/layouts/spina/login.html.haml +0 -3
- data/app/views/spina/admin/accounts/_form.html.haml +13 -7
- data/app/views/spina/admin/accounts/analytics.html.haml +5 -3
- data/app/views/spina/admin/accounts/social.html.haml +13 -7
- data/app/views/spina/admin/accounts/style.html.haml +26 -21
- data/app/views/spina/admin/attachments/index.html.haml +1 -1
- data/app/views/spina/admin/images/_image.html.haml +1 -1
- data/app/views/spina/admin/images/index.html.haml +7 -5
- data/app/views/spina/admin/media_folders/_media_folder.html.haml +1 -1
- data/app/views/spina/admin/media_folders/show.html.haml +2 -2
- data/app/views/spina/admin/media_picker/_image.html.haml +3 -0
- data/app/views/spina/admin/media_picker/_media_picker.html.haml +32 -0
- data/app/views/spina/admin/media_picker/_media_picker_grid.html.haml +25 -0
- data/app/views/spina/admin/media_picker/_modal.html.haml +1 -1
- data/app/views/spina/admin/media_picker/infinite_scroll.js.erb +4 -4
- data/app/views/spina/admin/media_picker/select.js.erb +2 -0
- data/app/views/spina/admin/media_picker/show.html.haml +1 -0
- data/app/views/spina/admin/media_picker/show.js.erb +1 -1
- data/app/views/spina/admin/pages/_form.html.haml +9 -7
- data/app/views/spina/admin/pages/_form_advanced.html.haml +19 -17
- data/app/views/spina/admin/pages/_form_page_content.html.haml +14 -13
- data/app/views/spina/admin/pages/_form_page_seo.html.haml +15 -4
- data/app/views/spina/admin/pages/_page.html.haml +5 -3
- data/app/views/spina/admin/pages/_page_nested_list.html.haml +2 -3
- data/app/views/spina/admin/pages/index.html.haml +5 -4
- data/app/views/spina/admin/parts/attachments/_form.html.haml +6 -0
- data/app/views/spina/admin/parts/image_collections/_fields.html.haml +7 -0
- data/app/views/spina/admin/parts/image_collections/_form.html.haml +12 -0
- data/app/views/spina/admin/parts/images/_form.html.haml +18 -0
- data/app/views/spina/admin/parts/lines/_form.html.haml +2 -0
- data/app/views/spina/admin/parts/multi_lines/_form.html.haml +2 -0
- data/app/views/spina/admin/parts/options/_form.html.haml +3 -0
- data/app/views/spina/admin/parts/repeaters/_fields.html.haml +15 -0
- data/app/views/spina/admin/parts/repeaters/_form.html.haml +17 -0
- data/app/views/spina/admin/parts/texts/_form.html.haml +6 -0
- data/app/views/spina/admin/resources/edit.html.haml +28 -12
- data/app/views/spina/admin/resources/show.html.haml +6 -3
- data/app/views/spina/admin/shared/_notifications.html.haml +4 -4
- data/config/locales/TH.yml +9 -0
- data/config/locales/bg.yml +9 -0
- data/config/locales/de.yml +9 -0
- data/config/locales/en.yml +9 -0
- data/config/locales/es.yml +9 -0
- data/config/locales/fr.yml +9 -0
- data/config/locales/id.yml +9 -0
- data/config/locales/it.yml +9 -0
- data/config/locales/nl.yml +9 -0
- data/config/locales/pl.yml +23 -14
- data/config/locales/pt-BR.yml +9 -0
- data/config/locales/ro.yml +9 -0
- data/config/locales/ru.yml +9 -0
- data/config/locales/sv.yml +9 -0
- data/config/locales/tr.yml +9 -0
- data/config/locales/zh-CN.yml +9 -0
- data/config/routes.rb +13 -0
- data/db/migrate/11_create_spina_resources.rb +0 -2
- data/db/migrate/12_add_url_title_to_spina_page_translations.rb +5 -0
- data/db/migrate/13_add_json_attributes_to_spina_accounts.rb +5 -0
- data/db/migrate/14_add_json_attributes_to_spina_pages.rb +5 -0
- data/db/migrate/15_add_slug_to_spina_resources.rb +5 -0
- data/lib/generators/spina/templates/app/views/demo/pages/demo.html.haml +13 -21
- data/lib/generators/spina/templates/app/views/demo/pages/homepage.html.haml +1 -1
- data/lib/generators/spina/templates/config/initializers/mobility.rb +13 -4
- data/lib/generators/spina/templates/config/initializers/spina.rb +4 -0
- data/lib/generators/spina/templates/config/initializers/themes/default.rb +7 -7
- data/lib/generators/spina/templates/config/initializers/themes/demo.rb +32 -44
- data/lib/spina.rb +18 -3
- data/lib/spina/attr_json_spina_parts_model.rb +29 -0
- data/lib/spina/engine.rb +14 -6
- data/lib/spina/part.rb +19 -0
- data/lib/spina/theme.rb +1 -1
- data/lib/spina/version.rb +1 -1
- data/lib/tasks/spina_tasks.rake +1 -1
- data/vendor/assets/javascripts/spina/sortable.js +2 -2
- metadata +73 -51
- data/app/assets/javascripts/spina/admin/account.coffee +0 -16
- data/app/models/concerns/spina/image_collectable.rb +0 -23
- data/app/models/concerns/spina/optionable.rb +0 -12
- data/app/models/concerns/spina/part.rb +0 -38
- data/app/models/spina/attachment_collection.rb +0 -20
- data/app/models/spina/image_collection.rb +0 -23
- data/app/models/spina/image_collections_image.rb +0 -6
- data/app/models/spina/layout_part.rb +0 -22
- data/app/models/spina/line.rb +0 -10
- data/app/models/spina/option.rb +0 -17
- data/app/models/spina/page_part.rb +0 -22
- data/app/models/spina/structure.rb +0 -14
- data/app/models/spina/structure_item.rb +0 -22
- data/app/models/spina/structure_part.rb +0 -20
- data/app/models/spina/text.rb +0 -10
- data/app/views/dummy/show.html.haml +0 -1
- data/app/views/spina/admin/attachments/_attachment_collection.html.haml +0 -2
- data/app/views/spina/admin/attachments/_select.html.haml +0 -17
- data/app/views/spina/admin/attachments/_select_collection.html.haml +0 -18
- data/app/views/spina/admin/attachments/insert.js.erb +0 -5
- data/app/views/spina/admin/attachments/insert_collection.js.coffee +0 -7
- data/app/views/spina/admin/attachments/select.js.erb +0 -2
- data/app/views/spina/admin/attachments/select_collection.js.erb +0 -2
- data/app/views/spina/admin/image_collections/_image_collection.html.haml +0 -5
- data/app/views/spina/admin/layout_partables/lines/_form.html.haml +0 -2
- data/app/views/spina/admin/partables/attachment_collections/_form.html.haml +0 -14
- data/app/views/spina/admin/partables/attachments/_form.html.haml +0 -13
- data/app/views/spina/admin/partables/image_collections/_form.html.haml +0 -16
- data/app/views/spina/admin/partables/images/_form.html.haml +0 -21
- data/app/views/spina/admin/partables/lines/_form.html.haml +0 -5
- data/app/views/spina/admin/partables/options/_form.html.haml +0 -7
- data/app/views/spina/admin/partables/photo_collections/_form.html.haml +0 -4
- data/app/views/spina/admin/partables/photos/_form.html.haml +0 -4
- data/app/views/spina/admin/partables/structures/_form.html.haml +0 -21
- data/app/views/spina/admin/partables/texts/_form.html.haml +0 -8
- data/app/views/spina/admin/structure_items/_fields.html.haml +0 -15
- data/app/views/spina/admin/structure_partables/attachment_collections/_form.html.haml +0 -14
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 979a0e909c387767e2094535c8ee443c048e084bf2f843ca1200dde04e791651
|
4
|
+
data.tar.gz: b53c7cd7994cd84b99a296a46ac962595268e6d70d25e08ecca543b2bbb899fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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", "
|
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.
|
17
|
-
this.
|
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
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
})
|
15
|
+
disconnect() {
|
16
|
+
this.scrollElement.removeEventListener("scroll", this.loadNextPage.bind(this))
|
17
|
+
}
|
25
18
|
|
26
|
-
|
19
|
+
get scrollElement() {
|
20
|
+
if (this.hasScrollContainerTarget) {
|
21
|
+
return this.scrollContainerTarget
|
22
|
+
} else {
|
23
|
+
return window
|
27
24
|
}
|
28
25
|
}
|
29
26
|
|
30
|
-
loadNextPage(
|
31
|
-
if (
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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('
|
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) ->
|