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.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -4
  3. data/Rakefile +1 -2
  4. data/app/assets/javascripts/spotlight/spotlight.esm.js +2168 -4560
  5. data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
  6. data/app/assets/javascripts/spotlight/spotlight.js +2167 -4559
  7. data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
  8. data/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +4 -0
  9. data/app/assets/stylesheets/spotlight/_browse.scss +0 -4
  10. data/app/assets/stylesheets/spotlight/{_collapse_toggle.scss → _collapse_toggle.css} +2 -2
  11. data/app/assets/stylesheets/spotlight/_exhibit_admin.scss +8 -0
  12. data/app/assets/stylesheets/spotlight/_exhibits_index.scss +2 -1
  13. data/app/assets/stylesheets/spotlight/_footer.scss +2 -2
  14. data/app/assets/stylesheets/spotlight/_header.scss +8 -8
  15. data/app/assets/stylesheets/spotlight/_pages.scss +1 -1
  16. data/app/assets/stylesheets/spotlight/_slideshow_block.scss +15 -0
  17. data/app/assets/stylesheets/spotlight/_spotlight.scss +1 -1
  18. data/app/assets/stylesheets/spotlight/_translations.scss +3 -3
  19. data/app/assets/stylesheets/spotlight/_uploaded_items_block.css +7 -0
  20. data/app/assets/stylesheets/spotlight/_variables.css +15 -0
  21. data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +0 -76
  22. data/app/components/blacklight/icons/pause_component.rb +15 -0
  23. data/app/components/blacklight/icons/play_arrow_component.rb +15 -0
  24. data/app/components/spotlight/analytics/dashboard_component.html.erb +1 -1
  25. data/app/components/spotlight/custom_field_form_group_component.rb +40 -0
  26. data/app/components/spotlight/document_admin_table_component.html.erb +2 -2
  27. data/app/components/spotlight/edit_sidecar_component.html.erb +18 -0
  28. data/app/components/spotlight/edit_sidecar_component.rb +41 -0
  29. data/app/components/spotlight/masthead_component.html.erb +18 -0
  30. data/app/components/spotlight/masthead_component.rb +46 -0
  31. data/app/components/spotlight/save_search_component.html.erb +1 -1
  32. data/app/components/spotlight/sidecar_form_field_component.html.erb +18 -0
  33. data/app/components/spotlight/sidecar_form_field_component.rb +71 -0
  34. data/app/components/spotlight/solr_document_legacy_embed_component.html.erb +0 -4
  35. data/app/components/spotlight/solr_document_legacy_embed_component.rb +2 -2
  36. data/app/components/spotlight/tag_selector_component.html.erb +1 -1
  37. data/app/components/spotlight/tag_selector_component.rb +3 -2
  38. data/app/components/spotlight/upload_field_form_group_component.rb +33 -0
  39. data/app/controllers/concerns/spotlight/controller.rb +15 -14
  40. data/app/controllers/concerns/spotlight/search_helper.rb +2 -5
  41. data/app/controllers/spotlight/browse_controller.rb +1 -6
  42. data/app/controllers/spotlight/catalog_controller.rb +2 -3
  43. data/app/controllers/spotlight/concerns/application_controller.rb +4 -6
  44. data/app/controllers/spotlight/exhibits_controller.rb +22 -10
  45. data/app/controllers/spotlight/lock_controller.rb +1 -1
  46. data/app/controllers/spotlight/pages_controller.rb +11 -11
  47. data/app/controllers/spotlight/resources/upload_controller.rb +1 -1
  48. data/app/controllers/spotlight/resources_controller.rb +1 -1
  49. data/app/controllers/spotlight/solr_controller.rb +5 -1
  50. data/app/helpers/spotlight/application_helper.rb +14 -26
  51. data/app/helpers/spotlight/crud_link_helpers.rb +0 -12
  52. data/app/helpers/spotlight/main_app_helpers.rb +2 -2
  53. data/app/javascript/spotlight/admin/add_another.js +37 -25
  54. data/app/javascript/spotlight/admin/add_image_selector.js +43 -26
  55. data/app/javascript/spotlight/admin/add_new_button.js +51 -36
  56. data/app/javascript/spotlight/admin/blacklight_configuration.js +76 -54
  57. data/app/javascript/spotlight/admin/block_mixins/autocompleteable.js +102 -101
  58. data/app/javascript/spotlight/admin/block_mixins/formable.js +91 -75
  59. data/app/javascript/spotlight/admin/block_mixins/plustextable.js +46 -48
  60. data/app/javascript/spotlight/admin/blocks/block.js +27 -28
  61. data/app/javascript/spotlight/admin/blocks/browse_block.js +14 -10
  62. data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +14 -10
  63. data/app/javascript/spotlight/admin/blocks/pages_block.js +5 -4
  64. data/app/javascript/spotlight/admin/blocks/resources_block.js +61 -41
  65. data/app/javascript/spotlight/admin/blocks/search_result_block.js +24 -7
  66. data/app/javascript/spotlight/admin/blocks/solr_documents_base_block.js +103 -50
  67. data/app/javascript/spotlight/admin/blocks/solr_documents_carousel_block.js +50 -26
  68. data/app/javascript/spotlight/admin/blocks/solr_documents_features_block.js +47 -23
  69. data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +35 -19
  70. data/app/javascript/spotlight/admin/crop.js +146 -66
  71. data/app/javascript/spotlight/admin/croppable.js +5 -4
  72. data/app/javascript/spotlight/admin/croppable_modal.js +67 -32
  73. data/app/javascript/spotlight/admin/edit_in_place.js +69 -54
  74. data/app/javascript/spotlight/admin/exhibits.js +92 -45
  75. data/app/javascript/spotlight/admin/form_observer.js +92 -78
  76. data/app/javascript/spotlight/admin/multi_image_selector.js +201 -153
  77. data/app/javascript/spotlight/admin/pages.js +13 -7
  78. data/app/javascript/spotlight/admin/progress_monitor.js +65 -50
  79. data/app/javascript/spotlight/admin/readonly_checkbox.js +7 -3
  80. data/app/javascript/spotlight/admin/search_typeahead.js +20 -11
  81. data/app/javascript/spotlight/admin/select_related_input.js +23 -23
  82. data/app/javascript/spotlight/admin/serialize_json.js +120 -0
  83. data/app/javascript/spotlight/admin/sir-trevor/block_controls.js +24 -11
  84. data/app/javascript/spotlight/admin/sir-trevor/block_limits.js +9 -6
  85. data/app/javascript/spotlight/admin/sir-trevor/locales.js +2 -2
  86. data/app/javascript/spotlight/admin/spotlight_nestable.js +2 -5
  87. data/app/javascript/spotlight/admin/translation_progress.js +18 -13
  88. data/app/javascript/spotlight/admin/users.js +151 -64
  89. data/app/javascript/spotlight/user/carousel.js +104 -32
  90. data/app/javascript/spotlight/user/clear_form_button.js +24 -14
  91. data/app/javascript/spotlight/user/index.js +0 -2
  92. data/app/javascript/spotlight/user/zpr_links.js +99 -40
  93. data/app/jobs/concerns/spotlight/gather_documents.rb +1 -1
  94. data/app/jobs/spotlight/add_uploads_from_csv.rb +31 -8
  95. data/app/jobs/spotlight/cleanup_job_trackers_job.rb +5 -3
  96. data/app/models/concerns/spotlight/access_controls_enforcement_search_builder.rb +13 -2
  97. data/app/models/concerns/spotlight/browse_category_search_builder.rb +3 -3
  98. data/app/models/concerns/spotlight/exhibit_documents.rb +2 -2
  99. data/app/models/concerns/spotlight/sitemap.rb +2 -2
  100. data/app/models/concerns/spotlight/solr_document/finder.rb +2 -2
  101. data/app/models/concerns/spotlight/solr_document.rb +1 -47
  102. data/app/models/sir_trevor_rails/blocks/browse_block.rb +0 -4
  103. data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +2 -1
  104. data/app/models/spotlight/blacklight_configuration.rb +5 -3
  105. data/app/models/spotlight/contact_email.rb +2 -2
  106. data/app/models/spotlight/custom_field.rb +17 -0
  107. data/app/models/spotlight/exhibit.rb +28 -0
  108. data/app/models/spotlight/featured_image.rb +1 -1
  109. data/app/models/spotlight/field_metadata.rb +10 -5
  110. data/app/models/spotlight/job_tracker.rb +0 -18
  111. data/app/models/spotlight/main_navigation.rb +2 -2
  112. data/app/models/spotlight/page.rb +3 -3
  113. data/app/models/spotlight/resources/iiif_harvester.rb +7 -4
  114. data/app/models/spotlight/resources/iiif_manifest.rb +0 -4
  115. data/app/models/spotlight/resources/iiif_manifest_metadata.rb +1 -3
  116. data/app/models/spotlight/resources/iiif_service.rb +21 -6
  117. data/app/models/spotlight/resources/upload.rb +6 -0
  118. data/app/models/spotlight/search.rb +5 -9
  119. data/app/models/spotlight/solr_document_sidecar.rb +18 -0
  120. data/app/services/spotlight/bulk_updates_csv_template_service.rb +1 -1
  121. data/app/services/spotlight/etl/pipeline.rb +2 -2
  122. data/app/services/spotlight/etl/step.rb +2 -2
  123. data/app/views/catalog/_remove_tags.html.erb +2 -2
  124. data/app/views/layouts/spotlight/base.html.erb +3 -6
  125. data/app/views/layouts/spotlight/spotlight.html.erb +2 -2
  126. data/app/views/shared/_analytics.html.erb +4 -3
  127. data/app/views/shared/_masthead.html.erb +2 -18
  128. data/app/views/spotlight/about_pages/_empty.html.erb +1 -1
  129. data/app/views/spotlight/about_pages/_sidebar.html.erb +10 -8
  130. data/app/views/spotlight/browse/_search.html.erb +2 -2
  131. data/app/views/spotlight/browse/_search_box.html.erb +6 -14
  132. data/app/views/spotlight/browse/index.html.erb +1 -1
  133. data/app/views/spotlight/browse/show.html.erb +1 -1
  134. data/app/views/spotlight/catalog/_document_admin_table.html.erb +1 -1
  135. data/app/views/spotlight/catalog/_edit_default.html.erb +1 -1
  136. data/app/views/spotlight/catalog/edit.html.erb +1 -1
  137. data/app/views/spotlight/dashboards/_page.html.erb +1 -1
  138. data/app/views/spotlight/exhibits/_exhibit_card.html.erb +3 -1
  139. data/app/views/spotlight/exhibits/_export.html.erb +17 -1
  140. data/app/views/spotlight/exhibits/_form.html.erb +20 -4
  141. data/app/views/spotlight/exhibits/_missing_exhibits.html.erb +3 -3
  142. data/app/views/spotlight/exhibits/index.html.erb +21 -8
  143. data/app/views/spotlight/feature_pages/_empty.html.erb +1 -1
  144. data/app/views/spotlight/feature_pages/_sidebar.html.erb +17 -15
  145. data/app/views/spotlight/home_pages/_empty.html.erb +7 -7
  146. data/app/views/spotlight/pages/show.html.erb +1 -0
  147. data/app/views/spotlight/resources/upload/_form.html.erb +2 -2
  148. data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +5 -16
  149. data/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb +3 -5
  150. data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +1 -1
  151. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +11 -2
  152. data/app/views/spotlight/sites/_exhibit.html.erb +1 -1
  153. data/config/i18n-tasks.yml +1 -1
  154. data/config/locales/spotlight.ar.yml +1 -2
  155. data/config/locales/spotlight.de.yml +1 -2
  156. data/config/locales/spotlight.en.yml +39 -10
  157. data/config/locales/spotlight.es.yml +1 -2
  158. data/config/locales/spotlight.fr.yml +1 -2
  159. data/config/locales/spotlight.it.yml +1 -2
  160. data/config/locales/spotlight.ja.yml +39 -0
  161. data/config/locales/spotlight.zh.yml +1 -2
  162. data/db/migrate/20261007133748_add_discovery_enabled_to_spotlight_exhibits.rb +5 -0
  163. data/lib/generators/spotlight/assets/importmap_generator.rb +2 -10
  164. data/lib/generators/spotlight/assets/propshaft_generator.rb +5 -4
  165. data/lib/generators/spotlight/install_generator.rb +2 -4
  166. data/lib/generators/spotlight/templates/catalog_controller.rb +0 -1
  167. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +26 -4
  168. data/lib/generators/spotlight/templates/solr/conf/schema.xml +4 -3
  169. data/lib/generators/spotlight/templates/solr/conf/solrconfig.xml +3 -8
  170. data/lib/migration/page_language.rb +0 -2
  171. data/lib/spotlight/engine.rb +28 -9
  172. data/lib/spotlight/search_state.rb +7 -11
  173. data/lib/spotlight/upload_field_config.rb +19 -1
  174. data/lib/spotlight/version.rb +1 -1
  175. data/lib/spotlight.rb +1 -1
  176. data/spec/support/features/capybara_wait_metadata_helper.rb +3 -1
  177. data/spec/support/features/test_features_helpers.rb +24 -1
  178. data/spec/support/iiif_manifest_fixtures.rb +33 -0
  179. data/spec/support/stub_dns_resolution.rb +12 -0
  180. metadata +50 -80
  181. data/app/assets/stylesheets/spotlight/_uploaded_items_block.scss +0 -7
  182. data/app/assets/stylesheets/spotlight/_variables.scss +0 -13
  183. data/app/components/blacklight/icons/arrow_alt_circle_left_component.rb +0 -15
  184. data/app/components/blacklight/icons/arrow_alt_circle_right_component.rb +0 -15
  185. data/app/components/blacklight/icons/info_component.rb +0 -15
  186. data/app/components/blacklight/icons/zoom_in_component.rb +0 -15
  187. data/app/components/blacklight/icons/zoom_out_component.rb +0 -15
  188. data/app/components/spotlight/icon_component.rb +0 -13
  189. data/app/javascript/spotlight/user/browse_group_categories.js +0 -54
  190. data/app/mailers/spotlight/invitation_mailer.rb +0 -21
  191. data/app/models/concerns/spotlight/resources/web.rb +0 -38
  192. data/app/services/spotlight/iiif_resource_resolver.rb +0 -78
  193. data/app/views/catalog/_image_default.html.erb +0 -6
  194. data/app/views/shared/_exhibit_navbar.html.erb +0 -2
  195. data/app/views/shared/_header_navbar.html.erb +0 -6
  196. data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +0 -23
  197. data/app/views/spotlight/catalog/_admin_thumbnail_default.html.erb +0 -7
  198. data/app/views/spotlight/catalog/_curation_mode_toggle_default.html.erb +0 -1
  199. data/app/views/spotlight/catalog/_document_row.html.erb +0 -2
  200. data/app/views/spotlight/catalog/_edit_sidecar.html.erb +0 -24
  201. data/app/views/spotlight/catalog/_index_compact_default.html.erb +0 -21
  202. data/app/views/spotlight/custom_fields/form_group/_text.html.erb +0 -23
  203. data/app/views/spotlight/custom_fields/form_group/_vocab.html.erb +0 -23
  204. data/app/views/spotlight/invitation_mailer/exhibit_invitation_notification.html.erb +0 -12
  205. data/lib/generators/spotlight/templates/javascript/jquery-shim.js +0 -1
  206. data/vendor/assets/javascripts/tiny-slider.js +0 -3221
  207. data/vendor/assets/stylesheets/tiny-slider.css +0 -1
  208. /data/app/assets/stylesheets/spotlight/{_breadcrumbs.scss → _breadcrumbs.css} +0 -0
  209. /data/app/assets/stylesheets/spotlight/{_croppable.scss → _croppable.css} +0 -0
  210. /data/app/assets/stylesheets/spotlight/{_modals.scss → _modals.css} +0 -0
  211. /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
- ;(function () {
4
- $.fn.multiImageSelector = function (
5
- image_versions,
6
- clickCallback,
7
- activeImageId,
8
- ) {
9
- var changeLink = $("<a href='javascript:;'>Change</a>"),
10
- thumbsListContainer = $(
11
- "<div class='thumbs-list' style='display:none'></div>",
12
- ),
13
- thumbList = $("<ul></ul>"),
14
- panel
15
-
16
- var imageIds = $.map(image_versions, function (e) {
17
- return e["imageId"]
18
- })
19
-
20
- return init(this)
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
- function init(el) {
23
- panel = el
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
- destroyExistingImageSelector()
26
- if (image_versions && image_versions.length > 1) {
27
- addChangeLink()
28
- addThumbsList()
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
- function addChangeLink() {
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
- function destroyExistingImageSelector() {
46
- var pagination = $("[data-panel-image-pagination]", panel)
47
- pagination.html("")
48
- pagination.next("." + thumbsListContainer.attr("class")).remove()
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
- function indexOf(thumb) {
52
- const index = imageIds.indexOf(thumb)
53
- if (index > -1) {
54
- return index + 1
66
+ function addChangeLinkBehavior() {
67
+ changeLink.addEventListener("click", () => {
68
+ if (thumbsListContainer.style.display === "none") {
69
+ thumbsListContainer.style.display = ""
55
70
  } else {
56
- return 1
71
+ thumbsListContainer.style.display = "none"
57
72
  }
58
- }
59
- function addChangeLinkBehavior() {
60
- changeLink.on("click", function () {
61
- thumbsListContainer.slideToggle()
62
- updateThumbListWidth()
63
- addScrollBehavior()
64
- scrollToActiveThumb()
65
- loadVisibleThumbs()
66
- swapChangeLinkText($(this))
67
- })
68
- }
69
- function updateThumbListWidth() {
70
- var width = 0
71
- $("li", thumbList).each(function () {
72
- width += $(this).outerWidth()
73
- })
74
- thumbList.width(width + 5)
75
- }
76
- function loadVisibleThumbs() {
77
- var viewportWidth = thumbsListContainer.width()
78
- var width = 0
79
- $("li", thumbList).each(function () {
80
- var thisThumb = $(this),
81
- image = $("img", thisThumb),
82
- totalWidth = (width += thisThumb.width()),
83
- position = thumbList.position().left + totalWidth - thisThumb.width()
84
-
85
- if (position >= 0 && position < viewportWidth) {
86
- image.prop("src", image.data("src"))
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
- function addScrollBehavior() {
91
- thumbsListContainer.scrollStop(function () {
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
- function scrollToActiveThumb() {
96
- var halfContainerWidth = thumbsListContainer.width() / 2,
97
- activeThumbLeftPosition = (
98
- $(".active", thumbList).position() ||
99
- $("li", thumbList).first().position()
100
- ).left,
101
- halfActiveThumbWidth = $(".active", thumbList).width() / 2
102
- thumbsListContainer.scrollLeft(
103
- activeThumbLeftPosition - halfContainerWidth + halfActiveThumbWidth,
104
- )
105
- }
106
- function addThumbsList() {
107
- addThumbsToList()
108
- updateActiveThumb()
109
- $(".card-header", panel).append(thumbsListContainer.append(thumbList))
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
- function updateActiveThumb() {
112
- $("li", thumbList).each(function () {
113
- var item = $(this)
114
- if ($("img", item).data("image-id") == activeImageId) {
115
- item.addClass("active")
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
- function addThumbsToList() {
124
- $.each(image_versions, function (i) {
125
- var listItem = $(
126
- '<li data-index="' +
127
- i +
128
- '"><a href="javascript:;"><img src="' +
129
- image_versions[i]["thumb"] +
130
- '" data-image-id="' +
131
- image_versions[i]["imageId"] +
132
- '" /></a></li>',
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
- listItem.on("click", function () {
135
- // get the current image id
136
- var src = $("img", $(this)).attr("src")
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
- // source: http://stackoverflow.com/questions/14035083/jquery-bind-event-on-scroll-stops
164
- jQuery.fn.scrollStop = function (callback) {
165
- $(this).scroll(function () {
166
- var self = this,
167
- $this = $(self)
205
+ img.addEventListener("load", () => {
206
+ updateThumbListWidth()
207
+ })
168
208
 
169
- if ($this.data("scrollTimeout")) {
170
- clearTimeout($this.data("scrollTimeout"))
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
- $this.data("scrollTimeout", setTimeout(callback, 250, self))
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: $("[data-attachment-endpoint]").data("attachment-endpoint"),
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 = $(".js-st-instance").first()
28
+ var instance = document.querySelector(".js-st-instance")
23
29
 
24
- if (instance.length) {
30
+ if (instance) {
25
31
  var editor = new SirTrevor.Editor({
26
- el: instance[0],
27
- blockTypes: instance.data("blockTypes"),
28
- altTextSettings: instance.data("altTextSettings"),
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
- $.SerializedForm()
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 = $('[data-behavior="progress-panel"]')
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
- $(monitorElements).each(function () {
9
- panelContainer = $(this)
10
- panelContainer.hide()
11
- var monitorUrl = panelContainer.data("monitorUrl")
12
- var refreshRate = panelContainer.data("refreshRate") || defaultRefreshRate
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
- $(document).on("turbolinks:click", function () {
23
+ document.addEventListener("turbolinks:click", function () {
22
24
  if (pollers.length > 0) {
23
- $.each(pollers, function () {
24
- clearInterval(this)
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
- $.ajax(url).done(success).fail(fail)
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
- monitorPanel().show()
49
+ panel.style.display = ""
38
50
  } else {
39
- monitorPanel().hide()
51
+ panel.style.display = "none"
40
52
  }
41
53
  }
42
54
 
43
55
  function fail() {
44
- monitorPanel().hide()
56
+ var panel = monitorPanel()
57
+ if (panel) panel.style.display = "none"
45
58
  }
46
59
 
47
60
  function updateMonitorPanel(data) {
48
- panelStartDate().text(data.started_at)
49
- panelCurrentDate().text(data.updated_at)
50
- panelCompletedDate().text(data.updated_at)
51
- panelCurrent().text(data.completed)
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.show()
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
- .attr("aria-valuemax", data.total)
64
- .attr("aria-valuenow", percentage)
65
- .css("width", percentage + "%")
66
- .text(percentage + "%")
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
- progressBar().removeClass("active").removeClass("progress-bar-striped")
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
- if (data.errored) {
77
- panelErrorMessage().show()
78
- } else {
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().each(function () {
85
- $(this).text(data.total)
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.find(".index-status")
112
+ return panelContainer.querySelector(".index-status")
96
113
  }
97
114
 
98
115
  function panelStartDate() {
99
116
  return monitorPanel()
100
- .find('[data-behavior="monitor-start"]')
101
- .find('[data-behavior="date"]')
117
+ ?.querySelector('[data-behavior="monitor-start"]')
118
+ ?.querySelector('[data-behavior="date"]')
102
119
  }
103
120
 
104
121
  function panelCurrentDate() {
105
122
  return monitorPanel()
106
- .find('[data-behavior="monitor-current"]')
107
- .find('[data-behavior="date"]')
123
+ ?.querySelector('[data-behavior="monitor-current"]')
124
+ ?.querySelector('[data-behavior="date"]')
108
125
  }
109
126
 
110
127
  function panelCompletedDate() {
111
128
  return monitorPanel()
112
- .find('[data-behavior="monitor-completed"]')
113
- .find('[data-behavior="date"]')
129
+ ?.querySelector('[data-behavior="monitor-completed"]')
130
+ ?.querySelector('[data-behavior="date"]')
114
131
  }
115
132
 
116
133
  function panelTotals() {
117
- return monitorPanel().find('[data-behavior="total"]')
134
+ return monitorPanel().querySelectorAll('[data-behavior="total"]')
118
135
  }
119
136
 
120
137
  function panelCurrent() {
121
138
  return monitorPanel()
122
- .find('[data-behavior="monitor-current"]')
123
- .find('[data-behavior="completed"]')
139
+ ?.querySelector('[data-behavior="monitor-current"]')
140
+ ?.querySelector('[data-behavior="completed"]')
124
141
  }
125
142
 
126
143
  function progressBar() {
127
- return monitorPanel().find(".progress-bar")
144
+ return monitorPanel()?.querySelector(".progress-bar")
128
145
  }
129
146
 
130
147
  function panelErrorMessage() {
131
- return monitorPanel().find('[data-behavior="monitor-error"]')
148
+ return monitorPanel()?.querySelector('[data-behavior="monitor-error"]')
132
149
  }
133
150
 
134
151
  function setPanelCompleted(finished) {
135
- var panel = monitorPanel().find('[data-behavior="monitor-completed"]')
136
-
137
- if (finished) {
138
- panel.show()
139
- } else {
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
- $("input[type='checkbox'][data-readonly]").on("click", function (event) {
5
- event.preventDefault()
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
  }