blacklight-spotlight 5.2.4 → 5.3.1

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 (165) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -5
  3. data/app/assets/javascripts/spotlight/spotlight.esm.js +1679 -1228
  4. data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
  5. data/app/assets/javascripts/spotlight/spotlight.js +1682 -1231
  6. data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
  7. data/app/assets/stylesheets/spotlight/_spotlight.scss +0 -2
  8. data/app/components/spotlight/analytics/aggregation_component.html.erb +1 -1
  9. data/app/components/spotlight/document_admin_table_component.html.erb +2 -2
  10. data/app/components/spotlight/edit_view_links_component.html.erb +1 -1
  11. data/app/components/spotlight/header_component.html.erb +1 -1
  12. data/app/components/spotlight/tag_list_form_component.html.erb +1 -1
  13. data/app/components/spotlight/tag_selector_component.html.erb +2 -2
  14. data/app/components/spotlight/translations/subheading_component.html.erb +1 -1
  15. data/app/controllers/spotlight/bulk_actions_controller.rb +2 -2
  16. data/app/controllers/spotlight/bulk_updates_controller.rb +2 -2
  17. data/app/controllers/spotlight/catalog_controller.rb +2 -2
  18. data/app/controllers/spotlight/contact_forms_controller.rb +1 -1
  19. data/app/controllers/spotlight/exhibits_controller.rb +1 -1
  20. data/app/controllers/spotlight/featured_images_controller.rb +1 -1
  21. data/app/controllers/spotlight/pages_controller.rb +1 -1
  22. data/app/controllers/spotlight/resources_controller.rb +1 -1
  23. data/app/controllers/spotlight/searches_controller.rb +3 -4
  24. data/app/controllers/spotlight/solr_controller.rb +1 -1
  25. data/app/controllers/spotlight/tags_controller.rb +1 -1
  26. data/app/controllers/spotlight/versions_controller.rb +1 -1
  27. data/app/javascript/spotlight/admin/add_another.js +22 -15
  28. data/app/javascript/spotlight/admin/add_image_selector.js +27 -25
  29. data/app/javascript/spotlight/admin/add_new_button.js +47 -43
  30. data/app/javascript/spotlight/admin/blacklight_configuration.js +52 -38
  31. data/app/javascript/spotlight/admin/block_mixins/autocompleteable.js +68 -60
  32. data/app/javascript/spotlight/admin/block_mixins/formable.js +55 -47
  33. data/app/javascript/spotlight/admin/block_mixins/plustextable.js +19 -20
  34. data/app/javascript/spotlight/admin/blocks/block.js +20 -16
  35. data/app/javascript/spotlight/admin/blocks/browse_block.js +42 -37
  36. data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +33 -31
  37. data/app/javascript/spotlight/admin/blocks/iframe_block.js +14 -11
  38. data/app/javascript/spotlight/admin/blocks/link_to_search_block.js +4 -7
  39. data/app/javascript/spotlight/admin/blocks/oembed_block.js +13 -10
  40. data/app/javascript/spotlight/admin/blocks/pages_block.js +20 -13
  41. data/app/javascript/spotlight/admin/blocks/resources_block.js +150 -117
  42. data/app/javascript/spotlight/admin/blocks/rule_block.js +11 -10
  43. data/app/javascript/spotlight/admin/blocks/search_result_block.js +16 -17
  44. data/app/javascript/spotlight/admin/blocks/solr_documents_base_block.js +123 -64
  45. data/app/javascript/spotlight/admin/blocks/solr_documents_block.js +8 -8
  46. data/app/javascript/spotlight/admin/blocks/solr_documents_carousel_block.js +63 -43
  47. data/app/javascript/spotlight/admin/blocks/solr_documents_embed_block.js +9 -9
  48. data/app/javascript/spotlight/admin/blocks/solr_documents_features_block.js +17 -16
  49. data/app/javascript/spotlight/admin/blocks/solr_documents_grid_block.js +6 -7
  50. data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +84 -64
  51. data/app/javascript/spotlight/admin/crop.js +203 -156
  52. data/app/javascript/spotlight/admin/croppable.js +4 -4
  53. data/app/javascript/spotlight/admin/croppable_modal.js +59 -37
  54. data/app/javascript/spotlight/admin/edit_in_place.js +50 -47
  55. data/app/javascript/spotlight/admin/exhibits.js +52 -41
  56. data/app/javascript/spotlight/admin/form_observer.js +59 -53
  57. data/app/javascript/spotlight/admin/iiif.js +26 -25
  58. data/app/javascript/spotlight/admin/index.js +44 -47
  59. data/app/javascript/spotlight/admin/locks.js +14 -14
  60. data/app/javascript/spotlight/admin/multi_image_selector.js +127 -111
  61. data/app/javascript/spotlight/admin/pages.js +21 -21
  62. data/app/javascript/spotlight/admin/progress_monitor.js +67 -65
  63. data/app/javascript/spotlight/admin/readonly_checkbox.js +3 -3
  64. data/app/javascript/spotlight/admin/search_typeahead.js +55 -43
  65. data/app/javascript/spotlight/admin/select_related_input.js +17 -17
  66. data/app/javascript/spotlight/admin/sir-trevor/block_controls.js +100 -84
  67. data/app/javascript/spotlight/admin/sir-trevor/block_limits.js +36 -31
  68. data/app/javascript/spotlight/admin/sir-trevor/locales.js +52 -39
  69. data/app/javascript/spotlight/admin/spotlight_nestable.js +112 -90
  70. data/app/javascript/spotlight/admin/tabs.js +16 -3
  71. data/app/javascript/spotlight/admin/translation_progress.js +13 -7
  72. data/app/javascript/spotlight/admin/users.js +41 -41
  73. data/app/javascript/spotlight/admin/visibility_toggle.js +4 -4
  74. data/app/javascript/spotlight/controllers/clipboard_controller.js +14 -0
  75. data/app/javascript/spotlight/controllers/index.js +4 -2
  76. data/app/javascript/spotlight/controllers/tag_selector_controller.js +116 -79
  77. data/app/javascript/spotlight/core.js +18 -15
  78. data/app/javascript/spotlight/index.js +4 -4
  79. data/app/javascript/spotlight/user/browse_group_categories.js +24 -22
  80. data/app/javascript/spotlight/user/carousel.js +23 -19
  81. data/app/javascript/spotlight/user/clear_form_button.js +15 -15
  82. data/app/javascript/spotlight/user/index.js +4 -4
  83. data/app/javascript/spotlight/user/zpr_links.js +18 -18
  84. data/app/models/spotlight/analytics/ga.rb +0 -1
  85. data/app/models/spotlight/custom_field.rb +1 -1
  86. data/app/models/spotlight/resources/iiif_manifest_v3.rb +2 -2
  87. data/app/services/spotlight/exhibit_import_export_service.rb +0 -2
  88. data/app/views/blacklight/nav/_bookmark.html.erb +1 -1
  89. data/app/views/catalog/_remove_tags.html.erb +1 -1
  90. data/app/views/layouts/spotlight/base.html.erb +1 -1
  91. data/app/views/shared/_header_navbar.html.erb +1 -1
  92. data/app/views/shared/_masthead.html.erb +2 -2
  93. data/app/views/shared/_site_sidebar.html.erb +1 -1
  94. data/app/views/shared/_user_util_links.html.erb +2 -2
  95. data/app/views/spotlight/about_pages/_contacts.html.erb +1 -1
  96. data/app/views/spotlight/accessibility/alt_text.html.erb +1 -1
  97. data/app/views/spotlight/admin_users/index.html.erb +11 -9
  98. data/app/views/spotlight/appearances/edit.html.erb +1 -1
  99. data/app/views/spotlight/browse/_search_box.html.erb +1 -1
  100. data/app/views/spotlight/bulk_updates/_download.html.erb +1 -1
  101. data/app/views/spotlight/bulk_updates/_progress_panel.html.erb +6 -6
  102. data/app/views/spotlight/bulk_updates/edit.html.erb +1 -1
  103. data/app/views/spotlight/catalog/_admin_header.html.erb +1 -1
  104. data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +1 -1
  105. data/app/views/spotlight/catalog/_curation_mode_toggle_default.html.erb +1 -1
  106. data/app/views/spotlight/catalog/_document.html.erb +2 -2
  107. data/app/views/spotlight/catalog/_document_admin_table.html.erb +1 -1
  108. data/app/views/spotlight/catalog/_edit_sidecar.html.erb +1 -1
  109. data/app/views/spotlight/catalog/_index_compact_default.html.erb +1 -1
  110. data/app/views/spotlight/catalog/_reindex_progress_panel.html.erb +6 -6
  111. data/app/views/spotlight/catalog/select_image.html.erb +1 -1
  112. data/app/views/spotlight/contact_mailer/report_problem.html.erb +2 -2
  113. data/app/views/spotlight/exhibits/_contact.html.erb +2 -2
  114. data/app/views/spotlight/exhibits/_delete.html.erb +2 -2
  115. data/app/views/spotlight/exhibits/_exhibit_card.html.erb +1 -1
  116. data/app/views/spotlight/exhibits/_export.html.erb +1 -1
  117. data/app/views/spotlight/exhibits/_form.html.erb +2 -2
  118. data/app/views/spotlight/exhibits/_languages.html.erb +7 -7
  119. data/app/views/spotlight/exhibits/_missing_exhibits.html.erb +1 -1
  120. data/app/views/spotlight/locks/_lock.html.erb +2 -2
  121. data/app/views/spotlight/metadata_configurations/edit.html.erb +1 -1
  122. data/app/views/spotlight/pages/_order_pages.html.erb +3 -3
  123. data/app/views/spotlight/pages/preview.html.erb +1 -1
  124. data/app/views/spotlight/pages/show.html.erb +2 -2
  125. data/app/views/spotlight/resources/_form.html.erb +1 -1
  126. data/app/views/spotlight/resources/csv_upload/_form.html.erb +1 -1
  127. data/app/views/spotlight/resources/upload/_form.html.erb +1 -1
  128. data/app/views/spotlight/roles/index.html.erb +5 -5
  129. data/app/views/spotlight/search_configurations/_search_fields.html.erb +1 -1
  130. data/app/views/spotlight/search_configurations/edit.html.erb +1 -1
  131. data/app/views/spotlight/searches/index.html.erb +2 -2
  132. data/app/views/spotlight/shared/_configuration_sidebar.html.erb +1 -1
  133. data/app/views/spotlight/shared/_curation_sidebar.html.erb +1 -1
  134. data/app/views/spotlight/shared/_dd3_item.html.erb +1 -1
  135. data/app/views/spotlight/sir_trevor/_sir_trevor_block_array.html.erb +1 -1
  136. data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +1 -1
  137. data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +1 -1
  138. data/app/views/spotlight/sir_trevor/blocks/_featured_pages_block.html.erb +2 -2
  139. data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +1 -1
  140. data/app/views/spotlight/sir_trevor/blocks/_rule_block.html.erb +1 -1
  141. data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +1 -1
  142. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +1 -1
  143. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +1 -1
  144. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +1 -1
  145. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +1 -1
  146. data/app/views/spotlight/sites/edit_exhibits.html.erb +3 -3
  147. data/app/views/spotlight/translations/_browse_categories.html.erb +2 -2
  148. data/app/views/spotlight/translations/_general.html.erb +21 -21
  149. data/app/views/spotlight/translations/_groups.html.erb +1 -1
  150. data/app/views/spotlight/translations/_metadata.html.erb +8 -8
  151. data/app/views/spotlight/translations/_pages_table.html.erb +2 -2
  152. data/app/views/spotlight/translations/_search_fields.html.erb +13 -13
  153. data/app/views/spotlight/translations/edit.html.erb +5 -5
  154. data/config/importmap.rb +0 -1
  155. data/lib/generators/spotlight/assets/propshaft_generator.rb +0 -1
  156. data/lib/generators/spotlight/templates/solr/conf/admin-extra.html +31 -31
  157. data/lib/spotlight/version.rb +1 -1
  158. data/spec/factories/contact_images.rb +1 -1
  159. data/spec/factories/exhibit_thumbnails.rb +1 -1
  160. data/spec/factories/featured_images.rb +1 -1
  161. data/spec/support/features/test_features_helpers.rb +12 -3
  162. metadata +12 -64
  163. data/app/assets/stylesheets/spotlight/typeahead.scss +0 -77
  164. data/app/javascript/spotlight/admin/copy_email_addresses.js +0 -7
  165. data/vendor/assets/javascripts/jquery.waitforimages.min.js +0 -2
@@ -1,69 +1,69 @@
1
1
  export default class {
2
2
  connect() {
3
- var container;
3
+ var container
4
4
  function edit_user(event) {
5
- event.preventDefault();
6
- $(this).closest('tr').hide();
7
- const id = $(this).attr('data-target');
8
- const edit_view = $("[data-edit-for='"+id+"']", container).show();
9
- $.each(edit_view.find('input[type="text"], select'), function() {
5
+ event.preventDefault()
6
+ $(this).closest("tr").hide()
7
+ const id = $(this).attr("data-target")
8
+ const edit_view = $("[data-edit-for='" + id + "']", container).show()
9
+ $.each(edit_view.find('input[type="text"], select'), function () {
10
10
  // Cache original values incase editing is canceled
11
- $(this).data('orig', $(this).val());
12
- });
11
+ $(this).data("orig", $(this).val())
12
+ })
13
13
  }
14
14
 
15
15
  function cancel_edit(event) {
16
- event.preventDefault();
17
- const id = $(this).closest('tr').attr('data-edit-for');
18
- const edit_view = $("[data-edit-for='"+id+"']", container).hide();
19
- clear_errors(edit_view);
20
- rollback_changes(edit_view);
21
- $("[data-show-for='"+id+"']", container).show();
16
+ event.preventDefault()
17
+ const id = $(this).closest("tr").attr("data-edit-for")
18
+ const edit_view = $("[data-edit-for='" + id + "']", container).hide()
19
+ clear_errors(edit_view)
20
+ rollback_changes(edit_view)
21
+ $("[data-show-for='" + id + "']", container).show()
22
22
  }
23
23
 
24
24
  function clear_errors(element) {
25
- element.find('.has-error')
26
- .removeClass('has-error')
27
- .find('.form-text')
28
- .remove(); // Remove the error messages
25
+ element
26
+ .find(".has-error")
27
+ .removeClass("has-error")
28
+ .find(".form-text")
29
+ .remove() // Remove the error messages
29
30
  }
30
31
 
31
32
  function rollback_changes(element) {
32
- $.each(element.find('input[type="text"], select'), function() {
33
- $(this).val($(this).data('orig')).trigger('change');
34
- });
33
+ $.each(element.find('input[type="text"], select'), function () {
34
+ $(this).val($(this).data("orig")).trigger("change")
35
+ })
35
36
  }
36
37
 
37
- function destroy_user(event) {
38
- const id = $(this).attr('data-target');
39
- $("[data-destroy-for='"+id+"']", container).val('1');
38
+ function destroy_user(_event) {
39
+ const id = $(this).attr("data-target")
40
+ $("[data-destroy-for='" + id + "']", container).val("1")
40
41
  }
41
42
 
42
43
  function new_user(event) {
43
- event.preventDefault();
44
- const edit_view = $("[data-edit-for='new']", container).show();
45
- $.each(edit_view.find('input[type="text"], select'), function() {
44
+ event.preventDefault()
45
+ const edit_view = $("[data-edit-for='new']", container).show()
46
+ $.each(edit_view.find('input[type="text"], select'), function () {
46
47
  // Cache original values incase editing is canceled
47
- $(this).data('orig', $(this).val());
48
- });
48
+ $(this).data("orig", $(this).val())
49
+ })
49
50
  }
50
51
 
51
52
  function open_errors() {
52
- const edit_row = container.find('.has-error').closest('[data-edit-for]');
53
- edit_row.show();
53
+ const edit_row = container.find(".has-error").closest("[data-edit-for]")
54
+ edit_row.show()
54
55
  // The following row has the controls, so show it too.
55
- edit_row.next().show();
56
+ edit_row.next().show()
56
57
  }
57
58
 
58
- $('.edit_exhibit, .admin-users').each(function() {
59
-
60
- container = $(this);
61
- $('[data-edit-for]', container).hide();
62
- open_errors();
63
- $("[data-behavior='edit-user']", container).on('click', edit_user);
64
- $("[data-behavior='cancel-edit']", container).on('click', cancel_edit);
65
- $("[data-behavior='destroy-user']", container).on('click', destroy_user);
66
- $("[data-behavior='new-user']", container).on('click', new_user);
59
+ $(".edit_exhibit, .admin-users").each(function () {
60
+ container = $(this)
61
+ $("[data-edit-for]", container).hide()
62
+ open_errors()
63
+ $("[data-behavior='edit-user']", container).on("click", edit_user)
64
+ $("[data-behavior='cancel-edit']", container).on("click", cancel_edit)
65
+ $("[data-behavior='destroy-user']", container).on("click", destroy_user)
66
+ $("[data-behavior='new-user']", container).on("click", new_user)
67
67
  })
68
68
  }
69
69
  }
@@ -1,13 +1,13 @@
1
1
  // Blacklight's BookmarkToggle is doing the real work, this only adds/removes the "blacklight-private" class.
2
2
  const VisibilityToggle = (e) => {
3
3
  if (e.target.matches('[data-checkboxsubmit-target="checkbox"]')) {
4
- const form = e.target.closest('form')
4
+ const form = e.target.closest("form")
5
5
  if (form) {
6
6
  // Add/remove the "private" label to the document row when visibility is toggled
7
- const docRow = form.closest('tr')
8
- if (docRow) docRow.classList.toggle('blacklight-private')
7
+ const docRow = form.closest("tr")
8
+ if (docRow) docRow.classList.toggle("blacklight-private")
9
9
  }
10
10
  }
11
11
  }
12
- document.addEventListener('click', VisibilityToggle)
12
+ document.addEventListener("click", VisibilityToggle)
13
13
  export default VisibilityToggle
@@ -0,0 +1,14 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Connects to data-controller="clipboard"
4
+ export default class extends Controller {
5
+ static targets = ["text"]
6
+
7
+ async copy() {
8
+ try {
9
+ await navigator.clipboard.writeText(this.textTarget.innerText)
10
+ } catch (err) {
11
+ console.error("Clipboard controller failed to copy with error:", err)
12
+ }
13
+ }
14
+ }
@@ -1,8 +1,10 @@
1
- import TagSelectorController from 'spotlight/controllers/tag_selector_controller'
1
+ import ClipboardController from "spotlight/controllers/clipboard_controller"
2
+ import TagSelectorController from "spotlight/controllers/tag_selector_controller"
2
3
 
3
4
  export default class {
4
5
  connect() {
5
6
  if (typeof Stimulus === "undefined") return
6
- Stimulus.register('tag-selector', TagSelectorController)
7
+ Stimulus.register("clipboard", ClipboardController)
8
+ Stimulus.register("tag-selector", TagSelectorController)
7
9
  }
8
10
  }
@@ -1,60 +1,61 @@
1
- import { Controller } from '@hotwired/stimulus'
1
+ import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
-
5
4
  static targets = [
6
- 'addNewTagWrapper',
7
- 'dropdownContent',
8
- 'initialTags',
9
- 'newTag',
10
- 'searchResultTags',
11
- 'selectedTags',
12
- 'tagControlWrapper',
13
- 'tagSearch',
14
- 'tagsField',
15
- 'tagSearchDropdown',
16
- 'tagSearchInputWrapper'
5
+ "addNewTagWrapper",
6
+ "dropdownContent",
7
+ "initialTags",
8
+ "newTag",
9
+ "searchResultTags",
10
+ "selectedTags",
11
+ "tagControlWrapper",
12
+ "tagSearch",
13
+ "tagsField",
14
+ "tagSearchDropdown",
15
+ "tagSearchInputWrapper",
17
16
  ]
18
17
 
19
18
  static values = {
20
19
  tags: Array,
21
- translations: Object
20
+ translations: Object,
22
21
  }
23
22
 
24
- tagDropdown (event) {
25
- this.dropdownContentTarget.classList.toggle('d-none')
23
+ tagDropdown(_event) {
24
+ this.dropdownContentTarget.classList.toggle("d-none")
26
25
  }
27
26
 
28
- clickOutside (event) {
29
- const isShown = !this.dropdownContentTarget.classList.contains('d-none')
30
- const inSelected = event.target.classList.contains('pill-close')
27
+ clickOutside(event) {
28
+ const isShown = !this.dropdownContentTarget.classList.contains("d-none")
29
+ const inSelected = event.target.classList.contains("pill-close")
31
30
  const inContainer = this.tagControlWrapperTarget.contains(event.target)
32
31
  if (!inContainer && !inSelected && isShown) {
33
32
  this.tagDropdown(event)
34
33
  }
35
34
  }
36
35
 
37
- handleKeydown (event) {
38
- if (event.key === 'Enter') {
36
+ handleKeydown(event) {
37
+ if (event.key === "Enter") {
39
38
  event.preventDefault()
40
- const hidden = this.dropdownContentTarget.classList.contains('d-none')
41
- if (hidden) return;
39
+ const hidden = this.dropdownContentTarget.classList.contains("d-none")
40
+ if (hidden) return
42
41
 
43
- const tagElementToAdd = this.dropdownContentTarget.querySelector('.active')?.firstElementChild
42
+ const tagElementToAdd =
43
+ this.dropdownContentTarget.querySelector(".active")?.firstElementChild
44
44
  if (tagElementToAdd) tagElementToAdd.click()
45
45
  }
46
46
 
47
- if (event.key === ',') {
47
+ if (event.key === ",") {
48
48
  event.preventDefault()
49
49
  if (this.tagSearchTarget.value.length === 0) return
50
50
 
51
- if (!this.addNewTagWrapperTarget.classList.contains('d-none')) {
51
+ if (!this.addNewTagWrapperTarget.classList.contains("d-none")) {
52
52
  this.addNewTagWrapperTarget.click()
53
53
  this.tagSearchTarget.focus()
54
54
  return
55
55
  }
56
56
 
57
- const exactMatch = this.dropdownContentTarget.querySelector('.active')?.firstElementChild
57
+ const exactMatch =
58
+ this.dropdownContentTarget.querySelector(".active")?.firstElementChild
58
59
  if (exactMatch?.checked === false) {
59
60
  exactMatch.click()
60
61
  this.resetSearch()
@@ -63,8 +64,11 @@ export default class extends Controller {
63
64
  }
64
65
  }
65
66
 
66
- addNewTag (event) {
67
- if (this.addNewTagWrapperTarget.classList.contains('d-none') || this.newTagTarget.dataset.tag.length === 0) {
67
+ addNewTag(_event) {
68
+ if (
69
+ this.addNewTagWrapperTarget.classList.contains("d-none") ||
70
+ this.newTagTarget.dataset.tag.length === 0
71
+ ) {
68
72
  return
69
73
  }
70
74
 
@@ -73,118 +77,150 @@ export default class extends Controller {
73
77
  }
74
78
 
75
79
  resetSearch() {
76
- this.tagSearchTarget.value = ''
77
- this.newTagTarget.innerHTML = ''
78
- this.newTagTarget.dataset.tag = ''
80
+ this.tagSearchTarget.value = ""
81
+ this.newTagTarget.innerHTML = ""
82
+ this.newTagTarget.dataset.tag = ""
79
83
  this.newTagTarget.disabled = true
80
- this.addNewTagWrapperTarget.classList.add('d-none')
81
- this.searchResultTagsTargets.forEach(target => this.showElement(target.parentElement))
84
+ this.addNewTagWrapperTarget.classList.add("d-none")
85
+ this.searchResultTagsTargets.forEach((target) =>
86
+ this.showElement(target.parentElement),
87
+ )
82
88
  }
83
89
 
84
- tagUpdate (event) {
90
+ tagUpdate(event) {
85
91
  const target = event.target ? event.target : event
86
92
  if (target.checked) {
87
93
  this.tagsValue = this.tagsValue.concat([target.dataset.tag])
88
94
  } else {
89
- this.tagsValue = this.tagsValue.filter(tag => tag !== target.dataset.tag)
95
+ this.tagsValue = this.tagsValue.filter(
96
+ (tag) => tag !== target.dataset.tag,
97
+ )
90
98
  }
91
99
  }
92
100
 
93
- updateSearchResultsPlaceholder(event) {
94
- const placeholderElement = this.dropdownContentTarget.querySelector('.no-results')
101
+ updateSearchResultsPlaceholder(_event) {
102
+ const placeholderElement =
103
+ this.dropdownContentTarget.querySelector(".no-results")
95
104
  if (!placeholderElement) return
96
105
 
97
- const hasVisibleTags = this.dropdownContentTarget.querySelector('label:not(.d-none):not(.no-results)')
98
- placeholderElement.classList.toggle('d-none', hasVisibleTags)
106
+ const hasVisibleTags = this.dropdownContentTarget.querySelector(
107
+ "label:not(.d-none):not(.no-results)",
108
+ )
109
+ placeholderElement.classList.toggle("d-none", hasVisibleTags)
99
110
  }
100
111
 
101
112
  tagCreate(event) {
102
113
  event.preventDefault()
103
- const newTagCheckbox = document.createElement('label')
114
+ const newTagCheckbox = document.createElement("label")
104
115
  newTagCheckbox.innerHTML = `<input type="checkbox" checked data-action="click->${this.identifier}#tagUpdate" data-tag-selector-target="searchResultTags" data-tag="${this.newTagTarget.dataset.tag}"> ${this.newTagTarget.dataset.tag}`
105
- const existingTags = Array.from(this.dropdownContentTarget.querySelectorAll('label:not(#add-new-tag-wrapper)'))
106
- const insertPosition = existingTags.findIndex(tag => tag.textContent.trim().localeCompare(this.newTagTarget.dataset.tag) > 0)
116
+ const existingTags = Array.from(
117
+ this.dropdownContentTarget.querySelectorAll(
118
+ "label:not(#add-new-tag-wrapper)",
119
+ ),
120
+ )
121
+ const insertPosition = existingTags.findIndex(
122
+ (tag) =>
123
+ tag.textContent.trim().localeCompare(this.newTagTarget.dataset.tag) > 0,
124
+ )
107
125
  if (insertPosition === -1) {
108
- this.addNewTagWrapperTarget.insertAdjacentElement('beforebegin', newTagCheckbox)
126
+ this.addNewTagWrapperTarget.insertAdjacentElement(
127
+ "beforebegin",
128
+ newTagCheckbox,
129
+ )
109
130
  } else {
110
- existingTags[insertPosition].insertAdjacentElement('beforebegin', newTagCheckbox)
131
+ existingTags[insertPosition].insertAdjacentElement(
132
+ "beforebegin",
133
+ newTagCheckbox,
134
+ )
111
135
  }
112
136
 
113
137
  this.tagsValue = this.tagsValue.concat([this.newTagTarget.dataset.tag])
114
- this.tagSearchTarget.value = ''
115
- this.tagSearchTarget.dispatchEvent(new Event('input'))
138
+ this.tagSearchTarget.value = ""
139
+ this.tagSearchTarget.dispatchEvent(new Event("input"))
116
140
  }
117
141
 
118
-
119
142
  tagsValueChanged() {
120
143
  const isEmpty = this.tagsValue.length === 0
121
144
 
122
- this.selectedTagsTarget.classList.toggle('d-none', isEmpty)
123
- this.tagSearchInputWrapperTarget.classList.toggle('rounded', isEmpty)
124
- this.tagSearchInputWrapperTarget.classList.toggle('rounded-bottom', !isEmpty)
145
+ this.selectedTagsTarget.classList.toggle("d-none", isEmpty)
146
+ this.tagSearchInputWrapperTarget.classList.toggle("rounded", isEmpty)
147
+ this.tagSearchInputWrapperTarget.classList.toggle(
148
+ "rounded-bottom",
149
+ !isEmpty,
150
+ )
125
151
 
126
152
  if (!isEmpty) {
127
153
  this.selectedTagsTarget.innerHTML = `<ul class="list-unstyled border rounded-top mb-0 p-1 px-2">${this.renderTagPills()}</ul>`
128
154
  }
129
155
 
130
- const newValue = this.tagsValue.join(', ')
156
+ const newValue = this.tagsValue.join(", ")
131
157
  if (this.tagsFieldTarget.value !== newValue) {
132
158
  this.tagsFieldTarget.value = newValue
133
159
  }
134
160
  }
135
161
 
136
- normalizeTag (tag) {
162
+ normalizeTag(tag) {
137
163
  const normalizeRegex = /[^\w\s]/gi
138
- return tag.replace(normalizeRegex, '').toLowerCase().trim()
164
+ return tag.replace(normalizeRegex, "").toLowerCase().trim()
139
165
  }
140
166
 
141
- showElement (element) {
142
- element.classList.add('d-block')
143
- element.classList.remove('d-none')
167
+ showElement(element) {
168
+ element.classList.add("d-block")
169
+ element.classList.remove("d-none")
144
170
  }
145
171
 
146
- hideElement (element) {
147
- element.classList.remove('d-block')
148
- element.classList.add('d-none')
172
+ hideElement(element) {
173
+ element.classList.remove("d-block")
174
+ element.classList.add("d-none")
149
175
  }
150
176
 
151
177
  search(event) {
152
178
  const searchTerm = this.normalizeTag(event.target.value)
153
- this.dropdownContentTarget.classList.remove('d-none')
179
+ this.dropdownContentTarget.classList.remove("d-none")
154
180
 
155
- const exactMatch = this.searchResultTagsTargets.some(target => {
181
+ const exactMatch = this.searchResultTagsTargets.some((target) => {
156
182
  const compareTerm = this.normalizeTag(target.dataset.tag)
157
183
  const isMatch = compareTerm.includes(searchTerm)
158
- target.parentElement.classList.remove('active')
159
- this[isMatch ? 'showElement' : 'hideElement'](target.parentElement)
184
+ target.parentElement.classList.remove("active")
185
+ this[isMatch ? "showElement" : "hideElement"](target.parentElement)
160
186
  return compareTerm === searchTerm
161
187
  })
162
188
 
163
- this[searchTerm.length > 0 && !exactMatch ? 'showElement' : 'hideElement'](this.addNewTagWrapperTarget)
164
- this.addNewTagWrapperTarget.classList.remove('active')
165
- this.dropdownContentTarget.querySelector('label:not(.d-none)')?.classList.add('active')
189
+ this[searchTerm.length > 0 && !exactMatch ? "showElement" : "hideElement"](
190
+ this.addNewTagWrapperTarget,
191
+ )
192
+ this.addNewTagWrapperTarget.classList.remove("active")
193
+ this.dropdownContentTarget
194
+ .querySelector("label:not(.d-none)")
195
+ ?.classList.add("active")
166
196
  }
167
197
 
168
- updateTagToAdd (event) {
169
- const tagAlreadyAdded = this.tagsValue.some(tag =>
170
- this.normalizeTag(tag) === this.normalizeTag(event.target.value)
198
+ updateTagToAdd(event) {
199
+ const tagAlreadyAdded = this.tagsValue.some(
200
+ (tag) => this.normalizeTag(tag) === this.normalizeTag(event.target.value),
171
201
  )
172
202
  this.newTagTarget.dataset.tag = event.target.value.trim()
173
203
  this.newTagTarget.nextSibling.textContent = ` ${this.translationsValue.add_new_tag}: ${event.target.value}`
174
- this.newTagTarget.disabled = !this.newTagTarget.dataset.tag.length || tagAlreadyAdded
204
+ this.newTagTarget.disabled =
205
+ !this.newTagTarget.dataset.tag.length || tagAlreadyAdded
175
206
  }
176
207
 
177
- deselect (event) {
208
+ deselect(event) {
178
209
  event.preventDefault()
179
210
 
180
- const clickedTag = event.target.closest('button').dataset.tag
181
- const target = this.searchResultTagsTargets.find((tag) => tag.dataset.tag === clickedTag)
182
- target ? target.click() : this.tagsValue = this.tagsValue.filter(tag => tag !== clickedTag)
211
+ const clickedTag = event.target.closest("button").dataset.tag
212
+ const target = this.searchResultTagsTargets.find(
213
+ (tag) => tag.dataset.tag === clickedTag,
214
+ )
215
+ target
216
+ ? target.click()
217
+ : (this.tagsValue = this.tagsValue.filter((tag) => tag !== clickedTag))
183
218
  }
184
219
 
185
- renderTagPills () {
186
- return this.tagsValue.map((tag) => {
187
- return `
220
+ renderTagPills() {
221
+ return this.tagsValue
222
+ .map((tag) => {
223
+ return `
188
224
  <li class="d-inline-flex gap-2 align-items-center my-2">
189
225
  <span class="bg-light badge rounded-pill border selected-item d-inline-flex align-items-center text-dark">
190
226
  <span class="selected-item-label d-inline-flex">${tag}</span>
@@ -198,6 +234,7 @@ export default class extends Controller {
198
234
  </span>
199
235
  </li>
200
236
  `
201
- }).join('')
237
+ })
238
+ .join("")
202
239
  }
203
240
  }
@@ -1,28 +1,31 @@
1
1
  import SirTrevor from "sir-trevor"
2
2
 
3
- const Spotlight = function() {
4
- var buffer = [];
3
+ const Spotlight = (function () {
4
+ var buffer = []
5
5
  return {
6
- onLoad: function(func) {
7
- buffer.push(func);
6
+ onLoad: function (func) {
7
+ buffer.push(func)
8
8
  },
9
9
 
10
- activate: function() {
11
- this.sirTrevorIcon = window.sirTrevorIcon;
12
- for(var i = 0; i < buffer.length; i++) {
13
- buffer[i].call();
10
+ activate: function () {
11
+ this.sirTrevorIcon = window.sirTrevorIcon
12
+ for (var i = 0; i < buffer.length; i++) {
13
+ buffer[i].call()
14
14
  }
15
15
  },
16
16
  csrfToken: function () {
17
- return document.querySelector('meta[name=csrf-token]')?.content
17
+ return document.querySelector("meta[name=csrf-token]")?.content
18
18
  },
19
19
  ZprLinks: {
20
- close: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\"><path d=\"M0 0h24v24H0V0z\" fill=\"none\"/><path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z\"/></svg>",
21
- zoomIn: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\"><path d=\"M0 0h24v24H0V0z\" fill=\"none\"/><path d=\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2z\"/></svg>\n",
22
- zoomOut: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\"><path d=\"M0 0h24v24H0V0z\" fill=\"none\"/><path d=\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7V9z\"/></svg>\n"
23
- }
24
- };
25
- }();
20
+ close:
21
+ '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg>',
22
+ zoomIn:
23
+ '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2z"/></svg>\n',
24
+ zoomOut:
25
+ '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7V9z"/></svg>\n',
26
+ },
27
+ }
28
+ })()
26
29
 
27
30
  // This allows us to configure Spotlight in app/views/layouts/base.html.erb
28
31
  window.Spotlight = Spotlight
@@ -1,7 +1,7 @@
1
- import UserIndex from 'spotlight/user'
2
- import AdminIndex from 'spotlight/admin'
3
- import Core from 'spotlight/core'
4
- import SpotlightControllers from 'spotlight/controllers'
1
+ import UserIndex from "spotlight/user"
2
+ import AdminIndex from "spotlight/admin"
3
+ import Core from "spotlight/core"
4
+ import SpotlightControllers from "spotlight/controllers"
5
5
 
6
6
  Core.onLoad(() => {
7
7
  new SpotlightControllers().connect()
@@ -1,15 +1,17 @@
1
- import tns from 'tiny-slider'
1
+ import tns from "tiny-slider"
2
2
 
3
3
  export default class {
4
4
  connect() {
5
- var $container, slider;
5
+ var $container, slider
6
6
 
7
7
  function init() {
8
- var data = $container.data();
9
- var sidebar = $container.data().sidebar;
10
- var items = data.browseGroupCategoriesCount;
11
- var dir = $('html').attr('dir');
12
- var controls = $container.parent().find('.browse-group-categories-controls')[0];
8
+ var data = $container.data()
9
+ var sidebar = $container.data().sidebar
10
+ var items = data.browseGroupCategoriesCount
11
+ var dir = $("html").attr("dir")
12
+ var controls = $container
13
+ .parent()
14
+ .find(".browse-group-categories-controls")[0]
13
15
 
14
16
  slider = tns({
15
17
  container: $container[0],
@@ -17,36 +19,36 @@ export default class {
17
19
  loop: false,
18
20
  nav: false,
19
21
  items: 1,
20
- slideBy: 'page',
22
+ slideBy: "page",
21
23
  textDirection: dir,
22
24
  responsive: {
23
25
  576: {
24
- items: itemCount(items, sidebar)
25
- }
26
- }
27
- });
26
+ items: itemCount(items, sidebar),
27
+ },
28
+ },
29
+ })
28
30
  }
29
31
 
30
32
  // Destroy the slider instance, as tns will change the dom elements, causing some issues with turbolinks
31
33
  function setupDestroy() {
32
- document.addEventListener('turbolinks:before-cache', function() {
34
+ document.addEventListener("turbolinks:before-cache", function () {
33
35
  if (slider && slider.destroy) {
34
- slider.destroy();
36
+ slider.destroy()
35
37
  }
36
- });
38
+ })
37
39
  }
38
40
 
39
41
  function itemCount(items, sidebar) {
40
42
  if (items < 3) {
41
- return items;
43
+ return items
42
44
  }
43
- return sidebar ? 3 : 4;
45
+ return sidebar ? 3 : 4
44
46
  }
45
47
 
46
- return $('[data-browse-group-categories-carousel]').each(function() {
47
- $container = $(this);
48
- init();
49
- setupDestroy();
50
- });
48
+ return $("[data-browse-group-categories-carousel]").each(function () {
49
+ $container = $(this)
50
+ init()
51
+ setupDestroy()
52
+ })
51
53
  }
52
54
  }