blacklight-spotlight 5.3.2 → 6.0.0.rc2
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.
- checksums.yaml +4 -4
- data/README.md +41 -4
- data/Rakefile +1 -2
- data/app/assets/javascripts/spotlight/spotlight.esm.js +2168 -4560
- data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
- data/app/assets/javascripts/spotlight/spotlight.js +2167 -4559
- data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
- data/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +4 -0
- data/app/assets/stylesheets/spotlight/_browse.scss +0 -4
- data/app/assets/stylesheets/spotlight/{_collapse_toggle.scss → _collapse_toggle.css} +2 -2
- data/app/assets/stylesheets/spotlight/_exhibit_admin.scss +8 -0
- data/app/assets/stylesheets/spotlight/_exhibits_index.scss +2 -1
- data/app/assets/stylesheets/spotlight/_footer.scss +2 -2
- data/app/assets/stylesheets/spotlight/_header.scss +8 -8
- data/app/assets/stylesheets/spotlight/_pages.scss +1 -1
- data/app/assets/stylesheets/spotlight/_slideshow_block.scss +15 -0
- data/app/assets/stylesheets/spotlight/_spotlight.scss +1 -1
- data/app/assets/stylesheets/spotlight/_translations.scss +3 -3
- data/app/assets/stylesheets/spotlight/_uploaded_items_block.css +7 -0
- data/app/assets/stylesheets/spotlight/_variables.css +15 -0
- data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +0 -76
- data/app/components/blacklight/icons/pause_component.rb +15 -0
- data/app/components/blacklight/icons/play_arrow_component.rb +15 -0
- data/app/components/spotlight/analytics/dashboard_component.html.erb +1 -1
- data/app/components/spotlight/custom_field_form_group_component.rb +40 -0
- data/app/components/spotlight/document_admin_table_component.html.erb +2 -2
- data/app/components/spotlight/edit_sidecar_component.html.erb +18 -0
- data/app/components/spotlight/edit_sidecar_component.rb +41 -0
- data/app/components/spotlight/masthead_component.html.erb +18 -0
- data/app/components/spotlight/masthead_component.rb +46 -0
- data/app/components/spotlight/save_search_component.html.erb +1 -1
- data/app/components/spotlight/sidecar_form_field_component.html.erb +18 -0
- data/app/components/spotlight/sidecar_form_field_component.rb +71 -0
- data/app/components/spotlight/solr_document_legacy_embed_component.html.erb +0 -4
- data/app/components/spotlight/solr_document_legacy_embed_component.rb +2 -2
- data/app/components/spotlight/tag_selector_component.html.erb +1 -1
- data/app/components/spotlight/tag_selector_component.rb +3 -2
- data/app/components/spotlight/upload_field_form_group_component.rb +33 -0
- data/app/controllers/concerns/spotlight/controller.rb +15 -14
- data/app/controllers/concerns/spotlight/search_helper.rb +2 -5
- data/app/controllers/spotlight/browse_controller.rb +1 -6
- data/app/controllers/spotlight/catalog_controller.rb +2 -3
- data/app/controllers/spotlight/concerns/application_controller.rb +4 -6
- data/app/controllers/spotlight/exhibits_controller.rb +22 -10
- data/app/controllers/spotlight/lock_controller.rb +1 -1
- data/app/controllers/spotlight/pages_controller.rb +11 -11
- data/app/controllers/spotlight/resources/upload_controller.rb +1 -1
- data/app/controllers/spotlight/resources_controller.rb +1 -1
- data/app/controllers/spotlight/solr_controller.rb +5 -1
- data/app/helpers/spotlight/application_helper.rb +14 -26
- data/app/helpers/spotlight/crud_link_helpers.rb +0 -12
- data/app/helpers/spotlight/main_app_helpers.rb +2 -2
- data/app/javascript/spotlight/admin/add_another.js +37 -25
- data/app/javascript/spotlight/admin/add_image_selector.js +43 -26
- data/app/javascript/spotlight/admin/add_new_button.js +51 -36
- data/app/javascript/spotlight/admin/blacklight_configuration.js +76 -54
- data/app/javascript/spotlight/admin/block_mixins/autocompleteable.js +102 -101
- data/app/javascript/spotlight/admin/block_mixins/formable.js +91 -75
- data/app/javascript/spotlight/admin/block_mixins/plustextable.js +46 -48
- data/app/javascript/spotlight/admin/blocks/block.js +27 -28
- data/app/javascript/spotlight/admin/blocks/browse_block.js +14 -10
- data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +14 -10
- data/app/javascript/spotlight/admin/blocks/pages_block.js +5 -4
- data/app/javascript/spotlight/admin/blocks/resources_block.js +61 -41
- data/app/javascript/spotlight/admin/blocks/search_result_block.js +24 -7
- data/app/javascript/spotlight/admin/blocks/solr_documents_base_block.js +103 -50
- data/app/javascript/spotlight/admin/blocks/solr_documents_carousel_block.js +50 -26
- data/app/javascript/spotlight/admin/blocks/solr_documents_features_block.js +47 -23
- data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +35 -19
- data/app/javascript/spotlight/admin/crop.js +146 -66
- data/app/javascript/spotlight/admin/croppable.js +5 -4
- data/app/javascript/spotlight/admin/croppable_modal.js +67 -32
- data/app/javascript/spotlight/admin/edit_in_place.js +69 -54
- data/app/javascript/spotlight/admin/exhibits.js +92 -45
- data/app/javascript/spotlight/admin/form_observer.js +92 -78
- data/app/javascript/spotlight/admin/multi_image_selector.js +201 -153
- data/app/javascript/spotlight/admin/pages.js +13 -7
- data/app/javascript/spotlight/admin/progress_monitor.js +65 -50
- data/app/javascript/spotlight/admin/readonly_checkbox.js +7 -3
- data/app/javascript/spotlight/admin/search_typeahead.js +20 -11
- data/app/javascript/spotlight/admin/select_related_input.js +23 -23
- data/app/javascript/spotlight/admin/serialize_json.js +120 -0
- data/app/javascript/spotlight/admin/sir-trevor/block_controls.js +24 -11
- data/app/javascript/spotlight/admin/sir-trevor/block_limits.js +9 -6
- data/app/javascript/spotlight/admin/sir-trevor/locales.js +2 -2
- data/app/javascript/spotlight/admin/spotlight_nestable.js +2 -5
- data/app/javascript/spotlight/admin/translation_progress.js +18 -13
- data/app/javascript/spotlight/admin/users.js +151 -64
- data/app/javascript/spotlight/user/carousel.js +104 -32
- data/app/javascript/spotlight/user/clear_form_button.js +24 -14
- data/app/javascript/spotlight/user/index.js +0 -2
- data/app/javascript/spotlight/user/zpr_links.js +99 -40
- data/app/jobs/concerns/spotlight/gather_documents.rb +1 -1
- data/app/jobs/spotlight/add_uploads_from_csv.rb +31 -8
- data/app/jobs/spotlight/cleanup_job_trackers_job.rb +5 -3
- data/app/models/concerns/spotlight/access_controls_enforcement_search_builder.rb +13 -2
- data/app/models/concerns/spotlight/browse_category_search_builder.rb +3 -3
- data/app/models/concerns/spotlight/exhibit_documents.rb +2 -2
- data/app/models/concerns/spotlight/sitemap.rb +2 -2
- data/app/models/concerns/spotlight/solr_document/finder.rb +2 -2
- data/app/models/concerns/spotlight/solr_document.rb +1 -47
- data/app/models/sir_trevor_rails/blocks/browse_block.rb +0 -4
- data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +2 -1
- data/app/models/spotlight/blacklight_configuration.rb +5 -3
- data/app/models/spotlight/contact_email.rb +2 -2
- data/app/models/spotlight/custom_field.rb +17 -0
- data/app/models/spotlight/exhibit.rb +28 -0
- data/app/models/spotlight/featured_image.rb +1 -1
- data/app/models/spotlight/field_metadata.rb +10 -5
- data/app/models/spotlight/job_tracker.rb +0 -18
- data/app/models/spotlight/main_navigation.rb +2 -2
- data/app/models/spotlight/page.rb +3 -3
- data/app/models/spotlight/resources/iiif_harvester.rb +7 -4
- data/app/models/spotlight/resources/iiif_manifest.rb +0 -4
- data/app/models/spotlight/resources/iiif_manifest_metadata.rb +1 -3
- data/app/models/spotlight/resources/iiif_service.rb +21 -6
- data/app/models/spotlight/resources/upload.rb +6 -0
- data/app/models/spotlight/search.rb +5 -9
- data/app/models/spotlight/solr_document_sidecar.rb +18 -0
- data/app/services/spotlight/bulk_updates_csv_template_service.rb +1 -1
- data/app/services/spotlight/etl/pipeline.rb +2 -2
- data/app/services/spotlight/etl/step.rb +2 -2
- data/app/views/catalog/_remove_tags.html.erb +2 -2
- data/app/views/layouts/spotlight/base.html.erb +3 -6
- data/app/views/layouts/spotlight/spotlight.html.erb +2 -2
- data/app/views/shared/_analytics.html.erb +4 -3
- data/app/views/shared/_masthead.html.erb +2 -18
- data/app/views/spotlight/about_pages/_empty.html.erb +1 -1
- data/app/views/spotlight/about_pages/_sidebar.html.erb +10 -8
- data/app/views/spotlight/browse/_search.html.erb +2 -2
- data/app/views/spotlight/browse/_search_box.html.erb +6 -14
- data/app/views/spotlight/browse/index.html.erb +1 -1
- data/app/views/spotlight/browse/show.html.erb +1 -1
- data/app/views/spotlight/catalog/_document_admin_table.html.erb +1 -1
- data/app/views/spotlight/catalog/_edit_default.html.erb +1 -1
- data/app/views/spotlight/catalog/edit.html.erb +1 -1
- data/app/views/spotlight/dashboards/_page.html.erb +1 -1
- data/app/views/spotlight/exhibits/_exhibit_card.html.erb +3 -1
- data/app/views/spotlight/exhibits/_export.html.erb +17 -1
- data/app/views/spotlight/exhibits/_form.html.erb +20 -4
- data/app/views/spotlight/exhibits/_missing_exhibits.html.erb +3 -3
- data/app/views/spotlight/exhibits/index.html.erb +21 -8
- data/app/views/spotlight/feature_pages/_empty.html.erb +1 -1
- data/app/views/spotlight/feature_pages/_sidebar.html.erb +17 -15
- data/app/views/spotlight/home_pages/_empty.html.erb +7 -7
- data/app/views/spotlight/pages/show.html.erb +1 -0
- data/app/views/spotlight/resources/upload/_form.html.erb +2 -2
- data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +5 -16
- data/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb +3 -5
- data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +11 -2
- data/app/views/spotlight/sites/_exhibit.html.erb +1 -1
- data/config/i18n-tasks.yml +1 -1
- data/config/locales/spotlight.ar.yml +1 -2
- data/config/locales/spotlight.de.yml +1 -2
- data/config/locales/spotlight.en.yml +39 -10
- data/config/locales/spotlight.es.yml +1 -2
- data/config/locales/spotlight.fr.yml +1 -2
- data/config/locales/spotlight.it.yml +1 -2
- data/config/locales/spotlight.ja.yml +39 -0
- data/config/locales/spotlight.zh.yml +1 -2
- data/db/migrate/20261007133748_add_discovery_enabled_to_spotlight_exhibits.rb +5 -0
- data/lib/generators/spotlight/assets/importmap_generator.rb +2 -10
- data/lib/generators/spotlight/assets/propshaft_generator.rb +5 -4
- data/lib/generators/spotlight/install_generator.rb +2 -4
- data/lib/generators/spotlight/templates/catalog_controller.rb +0 -1
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +26 -4
- data/lib/generators/spotlight/templates/solr/conf/schema.xml +4 -3
- data/lib/generators/spotlight/templates/solr/conf/solrconfig.xml +3 -8
- data/lib/migration/page_language.rb +0 -2
- data/lib/spotlight/engine.rb +28 -9
- data/lib/spotlight/search_state.rb +7 -11
- data/lib/spotlight/upload_field_config.rb +19 -1
- data/lib/spotlight/version.rb +1 -1
- data/lib/spotlight.rb +1 -1
- data/spec/support/features/capybara_wait_metadata_helper.rb +3 -1
- data/spec/support/features/test_features_helpers.rb +24 -1
- data/spec/support/iiif_manifest_fixtures.rb +33 -0
- data/spec/support/stub_dns_resolution.rb +12 -0
- metadata +50 -80
- data/app/assets/stylesheets/spotlight/_uploaded_items_block.scss +0 -7
- data/app/assets/stylesheets/spotlight/_variables.scss +0 -13
- data/app/components/blacklight/icons/arrow_alt_circle_left_component.rb +0 -15
- data/app/components/blacklight/icons/arrow_alt_circle_right_component.rb +0 -15
- data/app/components/blacklight/icons/info_component.rb +0 -15
- data/app/components/blacklight/icons/zoom_in_component.rb +0 -15
- data/app/components/blacklight/icons/zoom_out_component.rb +0 -15
- data/app/components/spotlight/icon_component.rb +0 -13
- data/app/javascript/spotlight/user/browse_group_categories.js +0 -54
- data/app/mailers/spotlight/invitation_mailer.rb +0 -21
- data/app/models/concerns/spotlight/resources/web.rb +0 -38
- data/app/services/spotlight/iiif_resource_resolver.rb +0 -78
- data/app/views/catalog/_image_default.html.erb +0 -6
- data/app/views/shared/_exhibit_navbar.html.erb +0 -2
- data/app/views/shared/_header_navbar.html.erb +0 -6
- data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +0 -23
- data/app/views/spotlight/catalog/_admin_thumbnail_default.html.erb +0 -7
- data/app/views/spotlight/catalog/_curation_mode_toggle_default.html.erb +0 -1
- data/app/views/spotlight/catalog/_document_row.html.erb +0 -2
- data/app/views/spotlight/catalog/_edit_sidecar.html.erb +0 -24
- data/app/views/spotlight/catalog/_index_compact_default.html.erb +0 -21
- data/app/views/spotlight/custom_fields/form_group/_text.html.erb +0 -23
- data/app/views/spotlight/custom_fields/form_group/_vocab.html.erb +0 -23
- data/app/views/spotlight/invitation_mailer/exhibit_invitation_notification.html.erb +0 -12
- data/lib/generators/spotlight/templates/javascript/jquery-shim.js +0 -1
- data/vendor/assets/javascripts/tiny-slider.js +0 -3221
- data/vendor/assets/stylesheets/tiny-slider.css +0 -1
- /data/app/assets/stylesheets/spotlight/{_breadcrumbs.scss → _breadcrumbs.css} +0 -0
- /data/app/assets/stylesheets/spotlight/{_croppable.scss → _croppable.css} +0 -0
- /data/app/assets/stylesheets/spotlight/{_modals.scss → _modals.css} +0 -0
- /data/app/assets/stylesheets/spotlight/{_utilities.scss → _utilities.css} +0 -0
|
@@ -1,175 +1,223 @@
|
|
|
1
1
|
// Module to add multi-image selector to widget panels
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
function initMultiImageSelector(
|
|
4
|
+
panel,
|
|
5
|
+
image_versions,
|
|
6
|
+
clickCallback,
|
|
7
|
+
activeImageId,
|
|
8
|
+
) {
|
|
9
|
+
const changeLink = document.createElement("a")
|
|
10
|
+
changeLink.href = "javascript:;"
|
|
11
|
+
changeLink.textContent = "Change"
|
|
12
|
+
|
|
13
|
+
const thumbsListContainer = document.createElement("div")
|
|
14
|
+
thumbsListContainer.className = "thumbs-list"
|
|
15
|
+
thumbsListContainer.style.display = "none"
|
|
16
|
+
|
|
17
|
+
const thumbList = document.createElement("ul")
|
|
18
|
+
|
|
19
|
+
const imageIds = (image_versions || []).map((e) => e["imageId"])
|
|
20
|
+
|
|
21
|
+
init()
|
|
22
|
+
|
|
23
|
+
function init() {
|
|
24
|
+
destroyExistingImageSelector()
|
|
25
|
+
if (image_versions && image_versions.length > 1) {
|
|
26
|
+
addChangeLink()
|
|
27
|
+
addThumbsList()
|
|
28
|
+
}
|
|
29
|
+
}
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
function addChangeLink() {
|
|
32
|
+
const pagination = panel.querySelector("[data-panel-image-pagination]")
|
|
33
|
+
if (pagination) {
|
|
34
|
+
pagination.innerHTML =
|
|
35
|
+
"Image <span data-current-image='true'>" +
|
|
36
|
+
indexOf(activeImageId) +
|
|
37
|
+
"</span> of " +
|
|
38
|
+
image_versions.length
|
|
39
|
+
pagination.style.display = ""
|
|
40
|
+
pagination.appendChild(document.createTextNode(" "))
|
|
41
|
+
pagination.appendChild(changeLink)
|
|
42
|
+
}
|
|
43
|
+
addChangeLinkBehavior()
|
|
44
|
+
}
|
|
24
45
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
function destroyExistingImageSelector() {
|
|
47
|
+
const pagination = panel.querySelector("[data-panel-image-pagination]")
|
|
48
|
+
if (pagination) {
|
|
49
|
+
pagination.innerHTML = ""
|
|
50
|
+
const nextEl = pagination.nextElementSibling
|
|
51
|
+
if (nextEl && nextEl.classList.contains("thumbs-list")) {
|
|
52
|
+
nextEl.remove()
|
|
29
53
|
}
|
|
30
54
|
}
|
|
31
|
-
|
|
32
|
-
$("[data-panel-image-pagination]", panel)
|
|
33
|
-
.html(
|
|
34
|
-
"Image <span data-current-image='true'>" +
|
|
35
|
-
indexOf(activeImageId) +
|
|
36
|
-
"</span> of " +
|
|
37
|
-
image_versions.length,
|
|
38
|
-
)
|
|
39
|
-
.show()
|
|
40
|
-
.append(" ")
|
|
41
|
-
.append(changeLink)
|
|
42
|
-
addChangeLinkBehavior()
|
|
43
|
-
}
|
|
55
|
+
}
|
|
44
56
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
57
|
+
function indexOf(thumb) {
|
|
58
|
+
const index = imageIds.indexOf(thumb)
|
|
59
|
+
if (index > -1) {
|
|
60
|
+
return index + 1
|
|
61
|
+
} else {
|
|
62
|
+
return 1
|
|
49
63
|
}
|
|
64
|
+
}
|
|
50
65
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
66
|
+
function addChangeLinkBehavior() {
|
|
67
|
+
changeLink.addEventListener("click", () => {
|
|
68
|
+
if (thumbsListContainer.style.display === "none") {
|
|
69
|
+
thumbsListContainer.style.display = ""
|
|
55
70
|
} else {
|
|
56
|
-
|
|
71
|
+
thumbsListContainer.style.display = "none"
|
|
57
72
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
updateThumbListWidth()
|
|
74
|
+
addScrollBehavior()
|
|
75
|
+
scrollToActiveThumb()
|
|
76
|
+
loadVisibleThumbs()
|
|
77
|
+
swapChangeLinkText(changeLink)
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function updateThumbListWidth() {
|
|
82
|
+
let width = 0
|
|
83
|
+
thumbList.querySelectorAll("li").forEach((li) => {
|
|
84
|
+
width += li.offsetWidth
|
|
85
|
+
})
|
|
86
|
+
thumbList.style.width = width + 5 + "px"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function loadVisibleThumbs() {
|
|
90
|
+
const viewportWidth = thumbsListContainer.clientWidth
|
|
91
|
+
let width = 0
|
|
92
|
+
thumbList.querySelectorAll("li").forEach((thisThumb) => {
|
|
93
|
+
const image = thisThumb.querySelector("img")
|
|
94
|
+
if (!image) return
|
|
95
|
+
const thumbWidth = thisThumb.offsetWidth
|
|
96
|
+
width += thumbWidth
|
|
97
|
+
const totalWidth = width
|
|
98
|
+
const position = thumbList.offsetLeft + totalWidth - thumbWidth
|
|
99
|
+
|
|
100
|
+
if (position >= 0 && position < viewportWidth) {
|
|
101
|
+
const dataSrc = image.dataset.src || image.getAttribute("data-src")
|
|
102
|
+
if (dataSrc) {
|
|
103
|
+
image.src = dataSrc
|
|
87
104
|
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let scrollTimeout
|
|
110
|
+
function addScrollBehavior() {
|
|
111
|
+
thumbsListContainer.addEventListener("scroll", () => {
|
|
112
|
+
if (scrollTimeout) {
|
|
113
|
+
clearTimeout(scrollTimeout)
|
|
114
|
+
}
|
|
115
|
+
scrollTimeout = setTimeout(() => {
|
|
92
116
|
loadVisibleThumbs()
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
117
|
+
}, 250)
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function scrollToActiveThumb() {
|
|
122
|
+
const halfContainerWidth = thumbsListContainer.clientWidth / 2
|
|
123
|
+
const activeThumb =
|
|
124
|
+
thumbList.querySelector(".active") || thumbList.querySelector("li")
|
|
125
|
+
const activeThumbLeftPosition = activeThumb ? activeThumb.offsetLeft : 0
|
|
126
|
+
const halfActiveThumbWidth = activeThumb ? activeThumb.offsetWidth / 2 : 0
|
|
127
|
+
|
|
128
|
+
thumbsListContainer.scrollLeft =
|
|
129
|
+
activeThumbLeftPosition - halfContainerWidth + halfActiveThumbWidth
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function addThumbsList() {
|
|
133
|
+
addThumbsToList()
|
|
134
|
+
updateActiveThumb()
|
|
135
|
+
thumbsListContainer.appendChild(thumbList)
|
|
136
|
+
const cardHeader = panel.querySelector(".card-header")
|
|
137
|
+
if (cardHeader) {
|
|
138
|
+
cardHeader.appendChild(thumbsListContainer)
|
|
110
139
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function updateActiveThumb() {
|
|
143
|
+
thumbList.querySelectorAll("li").forEach((item) => {
|
|
144
|
+
const img = item.querySelector("img")
|
|
145
|
+
if (
|
|
146
|
+
img &&
|
|
147
|
+
(img.dataset.imageId == activeImageId ||
|
|
148
|
+
img.getAttribute("data-image-id") == activeImageId)
|
|
149
|
+
) {
|
|
150
|
+
item.classList.add("active")
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function swapChangeLinkText(link) {
|
|
156
|
+
link.textContent = link.textContent === "Change" ? "Close" : "Change"
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function addThumbsToList() {
|
|
160
|
+
;(image_versions || []).forEach((version, i) => {
|
|
161
|
+
const listItem = document.createElement("li")
|
|
162
|
+
listItem.setAttribute("data-index", i.toString())
|
|
163
|
+
|
|
164
|
+
const anchor = document.createElement("a")
|
|
165
|
+
anchor.href = "javascript:;"
|
|
166
|
+
|
|
167
|
+
const img = document.createElement("img")
|
|
168
|
+
img.src = version["thumb"]
|
|
169
|
+
img.setAttribute("data-image-id", version["imageId"])
|
|
170
|
+
|
|
171
|
+
if (version["src"]) {
|
|
172
|
+
img.setAttribute("data-src", version["src"])
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
anchor.appendChild(img)
|
|
176
|
+
listItem.appendChild(anchor)
|
|
177
|
+
|
|
178
|
+
listItem.addEventListener("click", () => {
|
|
179
|
+
const src = img.getAttribute("src")
|
|
180
|
+
|
|
181
|
+
if (typeof clickCallback === "function") {
|
|
182
|
+
clickCallback(version)
|
|
116
183
|
}
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
function swapChangeLinkText(link) {
|
|
120
|
-
link.text(link.text() == "Change" ? "Close" : "Change")
|
|
121
|
-
}
|
|
122
184
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
185
|
+
const activeItem = thumbList.querySelector("li.active")
|
|
186
|
+
if (activeItem) {
|
|
187
|
+
activeItem.classList.remove("active")
|
|
188
|
+
}
|
|
189
|
+
listItem.classList.add("active")
|
|
190
|
+
|
|
191
|
+
const panelImg = panel.querySelector(".pic img.img-thumbnail")
|
|
192
|
+
if (panelImg) {
|
|
193
|
+
panelImg.setAttribute("src", src)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const currentImgSpan = panel.querySelector(
|
|
197
|
+
"[data-panel-image-pagination] [data-current-image]",
|
|
133
198
|
)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (typeof clickCallback === "function") {
|
|
139
|
-
clickCallback(image_versions[i])
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// mark the current selection as active
|
|
143
|
-
$("li.active", thumbList).removeClass("active")
|
|
144
|
-
$(this).addClass("active")
|
|
145
|
-
|
|
146
|
-
// update the multi-image selector image
|
|
147
|
-
$(".pic img.img-thumbnail", panel).attr("src", src)
|
|
148
|
-
|
|
149
|
-
$("[data-panel-image-pagination] [data-current-image]", panel).text(
|
|
150
|
-
$("li", thumbList).index($(this)) + 1,
|
|
151
|
-
)
|
|
152
|
-
scrollToActiveThumb()
|
|
153
|
-
})
|
|
154
|
-
$("img", listItem).on("load", function () {
|
|
155
|
-
updateThumbListWidth()
|
|
156
|
-
})
|
|
157
|
-
thumbList.append(listItem)
|
|
199
|
+
if (currentImgSpan) {
|
|
200
|
+
currentImgSpan.textContent = (i + 1).toString()
|
|
201
|
+
}
|
|
202
|
+
scrollToActiveThumb()
|
|
158
203
|
})
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
})(jQuery)
|
|
162
204
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var self = this,
|
|
167
|
-
$this = $(self)
|
|
205
|
+
img.addEventListener("load", () => {
|
|
206
|
+
updateThumbListWidth()
|
|
207
|
+
})
|
|
168
208
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
209
|
+
thumbList.appendChild(listItem)
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export default function multiImageSelector(
|
|
215
|
+
panel,
|
|
216
|
+
image_versions,
|
|
217
|
+
clickCallback,
|
|
218
|
+
activeImageId,
|
|
219
|
+
) {
|
|
220
|
+
if (!panel) return
|
|
172
221
|
|
|
173
|
-
|
|
174
|
-
})
|
|
222
|
+
initMultiImageSelector(panel, image_versions, clickCallback, activeImageId)
|
|
175
223
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
// Place all the behaviors and hooks related to the matching controller here.
|
|
2
2
|
// All this logic will automatically be available in application.js.
|
|
3
3
|
import Core from "spotlight/core"
|
|
4
|
+
import { SerializedForm } from "spotlight/admin/form_observer"
|
|
4
5
|
|
|
5
6
|
export default class {
|
|
6
7
|
connect() {
|
|
8
|
+
var attachmentEndpointEl = document.querySelector(
|
|
9
|
+
"[data-attachment-endpoint]",
|
|
10
|
+
)
|
|
7
11
|
SirTrevor.setDefaults({
|
|
8
12
|
iconUrl: Spotlight.sirTrevorIcon,
|
|
9
|
-
uploadUrl:
|
|
13
|
+
uploadUrl: attachmentEndpointEl
|
|
14
|
+
? attachmentEndpointEl.dataset.attachmentEndpoint
|
|
15
|
+
: undefined,
|
|
10
16
|
ajaxOptions: {
|
|
11
17
|
headers: {
|
|
12
18
|
"X-CSRF-Token": Core.csrfToken() || "",
|
|
@@ -19,16 +25,16 @@ export default class {
|
|
|
19
25
|
SirTrevor.Blocks.Quote.prototype.toolbarEnabled = true
|
|
20
26
|
SirTrevor.Blocks.Text.prototype.toolbarEnabled = true
|
|
21
27
|
|
|
22
|
-
var instance =
|
|
28
|
+
var instance = document.querySelector(".js-st-instance")
|
|
23
29
|
|
|
24
|
-
if (instance
|
|
30
|
+
if (instance) {
|
|
25
31
|
var editor = new SirTrevor.Editor({
|
|
26
|
-
el: instance
|
|
27
|
-
blockTypes: instance.
|
|
28
|
-
altTextSettings: instance.
|
|
32
|
+
el: instance,
|
|
33
|
+
blockTypes: JSON.parse(instance.dataset.blockTypes),
|
|
34
|
+
altTextSettings: JSON.parse(instance.dataset.altTextSettings),
|
|
29
35
|
defaultType: ["Text"],
|
|
30
36
|
onEditorRender: function () {
|
|
31
|
-
|
|
37
|
+
SerializedForm.init()
|
|
32
38
|
},
|
|
33
39
|
blockTypeLimits: {
|
|
34
40
|
SearchResults: 1,
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export default class {
|
|
2
2
|
connect() {
|
|
3
|
-
var monitorElements =
|
|
3
|
+
var monitorElements = document.querySelectorAll(
|
|
4
|
+
'[data-behavior="progress-panel"]',
|
|
5
|
+
)
|
|
4
6
|
var defaultRefreshRate = 3000
|
|
5
7
|
var panelContainer
|
|
6
8
|
var pollers = []
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
panelContainer =
|
|
10
|
-
panelContainer.
|
|
11
|
-
var monitorUrl = panelContainer.
|
|
12
|
-
var refreshRate = panelContainer.
|
|
10
|
+
monitorElements.forEach(function (el) {
|
|
11
|
+
panelContainer = el
|
|
12
|
+
panelContainer.style.display = "none"
|
|
13
|
+
var monitorUrl = panelContainer.dataset.monitorUrl
|
|
14
|
+
var refreshRate = panelContainer.dataset.refreshRate || defaultRefreshRate
|
|
13
15
|
pollers.push(
|
|
14
16
|
setInterval(function () {
|
|
15
17
|
checkMonitorUrl(monitorUrl)
|
|
@@ -18,71 +20,86 @@ export default class {
|
|
|
18
20
|
})
|
|
19
21
|
|
|
20
22
|
// Clear the intervals on turbolink:click event (e.g. when the user navigates away from the page)
|
|
21
|
-
|
|
23
|
+
document.addEventListener("turbolinks:click", function () {
|
|
22
24
|
if (pollers.length > 0) {
|
|
23
|
-
|
|
24
|
-
clearInterval(
|
|
25
|
+
pollers.forEach(function (poller) {
|
|
26
|
+
clearInterval(poller)
|
|
25
27
|
})
|
|
26
28
|
pollers = []
|
|
27
29
|
}
|
|
28
30
|
})
|
|
29
31
|
|
|
30
32
|
function checkMonitorUrl(url) {
|
|
31
|
-
|
|
33
|
+
fetch(url)
|
|
34
|
+
.then(function (response) {
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error("Network response was not ok")
|
|
37
|
+
}
|
|
38
|
+
return response.json()
|
|
39
|
+
})
|
|
40
|
+
.then(success)
|
|
41
|
+
.catch(fail)
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
function success(data) {
|
|
45
|
+
var panel = monitorPanel()
|
|
46
|
+
if (!panel) return
|
|
35
47
|
if (data.recently_in_progress) {
|
|
36
48
|
updateMonitorPanel(data)
|
|
37
|
-
|
|
49
|
+
panel.style.display = ""
|
|
38
50
|
} else {
|
|
39
|
-
|
|
51
|
+
panel.style.display = "none"
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
|
|
43
55
|
function fail() {
|
|
44
|
-
monitorPanel()
|
|
56
|
+
var panel = monitorPanel()
|
|
57
|
+
if (panel) panel.style.display = "none"
|
|
45
58
|
}
|
|
46
59
|
|
|
47
60
|
function updateMonitorPanel(data) {
|
|
48
|
-
panelStartDate()
|
|
49
|
-
panelCurrentDate()
|
|
50
|
-
panelCompletedDate()
|
|
51
|
-
panelCurrent()
|
|
61
|
+
setText(panelStartDate(), data.started_at)
|
|
62
|
+
setText(panelCurrentDate(), data.updated_at)
|
|
63
|
+
setText(panelCompletedDate(), data.updated_at)
|
|
64
|
+
setText(panelCurrent(), data.completed)
|
|
52
65
|
setPanelCompleted(data.finished)
|
|
53
66
|
updatePanelTotals(data)
|
|
54
67
|
updatePanelErrorMessage(data)
|
|
55
68
|
updateProgressBar(data)
|
|
56
69
|
|
|
57
|
-
panelContainer.
|
|
70
|
+
panelContainer.style.display = ""
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function setText(el, value) {
|
|
74
|
+
if (el) el.textContent = value
|
|
58
75
|
}
|
|
59
76
|
|
|
60
77
|
function updateProgressBar(data) {
|
|
61
78
|
var percentage = calculatePercentage(data)
|
|
62
|
-
progressBar()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
var bar = progressBar()
|
|
80
|
+
if (!bar) return
|
|
81
|
+
bar.setAttribute("aria-valuemax", data.total)
|
|
82
|
+
bar.setAttribute("aria-valuenow", percentage)
|
|
83
|
+
bar.style.width = percentage + "%"
|
|
84
|
+
bar.textContent = percentage + "%"
|
|
67
85
|
|
|
68
86
|
if (data.finished) {
|
|
69
|
-
|
|
87
|
+
bar.classList.remove("active")
|
|
88
|
+
bar.classList.remove("progress-bar-striped")
|
|
70
89
|
}
|
|
71
90
|
}
|
|
72
91
|
|
|
73
92
|
function updatePanelErrorMessage(data) {
|
|
74
93
|
// We currently do not store this state,
|
|
75
94
|
// but with this code we can in the future.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
panelErrorMessage().hide()
|
|
80
|
-
}
|
|
95
|
+
var message = panelErrorMessage()
|
|
96
|
+
if (!message) return
|
|
97
|
+
message.style.display = data.errored ? "" : "none"
|
|
81
98
|
}
|
|
82
99
|
|
|
83
100
|
function updatePanelTotals(data) {
|
|
84
|
-
panelTotals().
|
|
85
|
-
|
|
101
|
+
panelTotals().forEach(function (el) {
|
|
102
|
+
el.textContent = data.total
|
|
86
103
|
})
|
|
87
104
|
}
|
|
88
105
|
|
|
@@ -92,53 +109,51 @@ export default class {
|
|
|
92
109
|
}
|
|
93
110
|
|
|
94
111
|
function monitorPanel() {
|
|
95
|
-
return panelContainer.
|
|
112
|
+
return panelContainer.querySelector(".index-status")
|
|
96
113
|
}
|
|
97
114
|
|
|
98
115
|
function panelStartDate() {
|
|
99
116
|
return monitorPanel()
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
?.querySelector('[data-behavior="monitor-start"]')
|
|
118
|
+
?.querySelector('[data-behavior="date"]')
|
|
102
119
|
}
|
|
103
120
|
|
|
104
121
|
function panelCurrentDate() {
|
|
105
122
|
return monitorPanel()
|
|
106
|
-
|
|
107
|
-
|
|
123
|
+
?.querySelector('[data-behavior="monitor-current"]')
|
|
124
|
+
?.querySelector('[data-behavior="date"]')
|
|
108
125
|
}
|
|
109
126
|
|
|
110
127
|
function panelCompletedDate() {
|
|
111
128
|
return monitorPanel()
|
|
112
|
-
|
|
113
|
-
|
|
129
|
+
?.querySelector('[data-behavior="monitor-completed"]')
|
|
130
|
+
?.querySelector('[data-behavior="date"]')
|
|
114
131
|
}
|
|
115
132
|
|
|
116
133
|
function panelTotals() {
|
|
117
|
-
return monitorPanel().
|
|
134
|
+
return monitorPanel().querySelectorAll('[data-behavior="total"]')
|
|
118
135
|
}
|
|
119
136
|
|
|
120
137
|
function panelCurrent() {
|
|
121
138
|
return monitorPanel()
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
?.querySelector('[data-behavior="monitor-current"]')
|
|
140
|
+
?.querySelector('[data-behavior="completed"]')
|
|
124
141
|
}
|
|
125
142
|
|
|
126
143
|
function progressBar() {
|
|
127
|
-
return monitorPanel()
|
|
144
|
+
return monitorPanel()?.querySelector(".progress-bar")
|
|
128
145
|
}
|
|
129
146
|
|
|
130
147
|
function panelErrorMessage() {
|
|
131
|
-
return monitorPanel()
|
|
148
|
+
return monitorPanel()?.querySelector('[data-behavior="monitor-error"]')
|
|
132
149
|
}
|
|
133
150
|
|
|
134
151
|
function setPanelCompleted(finished) {
|
|
135
|
-
var panel = monitorPanel()
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
panel.hide()
|
|
141
|
-
}
|
|
152
|
+
var panel = monitorPanel()?.querySelector(
|
|
153
|
+
'[data-behavior="monitor-completed"]',
|
|
154
|
+
)
|
|
155
|
+
if (!panel) return
|
|
156
|
+
panel.style.display = finished ? "" : "none"
|
|
142
157
|
}
|
|
143
158
|
|
|
144
159
|
return this
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export default class {
|
|
2
2
|
connect() {
|
|
3
3
|
// Don't allow unchecking of checkboxes with the data-readonly attribute
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
document
|
|
5
|
+
.querySelectorAll("input[type='checkbox'][data-readonly]")
|
|
6
|
+
.forEach(function (el) {
|
|
7
|
+
el.addEventListener("click", function (event) {
|
|
8
|
+
event.preventDefault()
|
|
9
|
+
})
|
|
10
|
+
})
|
|
7
11
|
}
|
|
8
12
|
}
|