blacklight-spotlight 5.3.0 → 5.3.2

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 (154) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -1
  3. data/app/assets/javascripts/spotlight/spotlight.esm.js +1696 -1229
  4. data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
  5. data/app/assets/javascripts/spotlight/spotlight.js +1718 -1232
  6. data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
  7. data/app/assets/stylesheets/spotlight/_multi_up_item_grid.scss +1 -10
  8. data/app/assets/stylesheets/spotlight/_nestable.scss +18 -1
  9. data/app/assets/stylesheets/spotlight/_pages.scss +3 -3
  10. data/app/components/spotlight/analytics/aggregation_component.html.erb +1 -1
  11. data/app/components/spotlight/document_admin_table_component.html.erb +2 -2
  12. data/app/components/spotlight/edit_view_links_component.html.erb +1 -1
  13. data/app/components/spotlight/header_component.html.erb +1 -1
  14. data/app/components/spotlight/tag_list_form_component.html.erb +1 -1
  15. data/app/components/spotlight/tag_selector_component.html.erb +2 -2
  16. data/app/components/spotlight/translations/subheading_component.html.erb +1 -1
  17. data/app/controllers/spotlight/resources_controller.rb +1 -1
  18. data/app/javascript/spotlight/admin/add_another.js +22 -15
  19. data/app/javascript/spotlight/admin/add_image_selector.js +27 -25
  20. data/app/javascript/spotlight/admin/add_new_button.js +47 -43
  21. data/app/javascript/spotlight/admin/blacklight_configuration.js +52 -38
  22. data/app/javascript/spotlight/admin/block_mixins/autocompleteable.js +68 -60
  23. data/app/javascript/spotlight/admin/block_mixins/formable.js +55 -47
  24. data/app/javascript/spotlight/admin/block_mixins/plustextable.js +19 -20
  25. data/app/javascript/spotlight/admin/blocks/block.js +20 -16
  26. data/app/javascript/spotlight/admin/blocks/browse_block.js +42 -37
  27. data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +33 -31
  28. data/app/javascript/spotlight/admin/blocks/iframe_block.js +14 -11
  29. data/app/javascript/spotlight/admin/blocks/link_to_search_block.js +4 -7
  30. data/app/javascript/spotlight/admin/blocks/oembed_block.js +13 -10
  31. data/app/javascript/spotlight/admin/blocks/pages_block.js +20 -13
  32. data/app/javascript/spotlight/admin/blocks/resources_block.js +150 -117
  33. data/app/javascript/spotlight/admin/blocks/rule_block.js +11 -10
  34. data/app/javascript/spotlight/admin/blocks/search_result_block.js +16 -17
  35. data/app/javascript/spotlight/admin/blocks/solr_documents_base_block.js +123 -64
  36. data/app/javascript/spotlight/admin/blocks/solr_documents_block.js +8 -8
  37. data/app/javascript/spotlight/admin/blocks/solr_documents_carousel_block.js +63 -43
  38. data/app/javascript/spotlight/admin/blocks/solr_documents_embed_block.js +9 -9
  39. data/app/javascript/spotlight/admin/blocks/solr_documents_features_block.js +17 -16
  40. data/app/javascript/spotlight/admin/blocks/solr_documents_grid_block.js +6 -7
  41. data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +84 -64
  42. data/app/javascript/spotlight/admin/crop.js +203 -156
  43. data/app/javascript/spotlight/admin/croppable.js +4 -4
  44. data/app/javascript/spotlight/admin/croppable_modal.js +59 -37
  45. data/app/javascript/spotlight/admin/edit_in_place.js +50 -47
  46. data/app/javascript/spotlight/admin/exhibits.js +52 -41
  47. data/app/javascript/spotlight/admin/form_observer.js +59 -53
  48. data/app/javascript/spotlight/admin/iiif.js +26 -25
  49. data/app/javascript/spotlight/admin/index.js +44 -47
  50. data/app/javascript/spotlight/admin/locks.js +14 -14
  51. data/app/javascript/spotlight/admin/multi_image_selector.js +127 -111
  52. data/app/javascript/spotlight/admin/pages.js +21 -21
  53. data/app/javascript/spotlight/admin/progress_monitor.js +67 -65
  54. data/app/javascript/spotlight/admin/readonly_checkbox.js +3 -3
  55. data/app/javascript/spotlight/admin/search_typeahead.js +55 -43
  56. data/app/javascript/spotlight/admin/select_related_input.js +17 -17
  57. data/app/javascript/spotlight/admin/sir-trevor/block_controls.js +100 -84
  58. data/app/javascript/spotlight/admin/sir-trevor/block_limits.js +36 -31
  59. data/app/javascript/spotlight/admin/sir-trevor/locales.js +52 -39
  60. data/app/javascript/spotlight/admin/spotlight_nestable.js +126 -91
  61. data/app/javascript/spotlight/admin/tabs.js +19 -3
  62. data/app/javascript/spotlight/admin/translation_progress.js +13 -7
  63. data/app/javascript/spotlight/admin/users.js +41 -41
  64. data/app/javascript/spotlight/admin/visibility_toggle.js +4 -4
  65. data/app/javascript/spotlight/controllers/clipboard_controller.js +14 -0
  66. data/app/javascript/spotlight/controllers/index.js +4 -2
  67. data/app/javascript/spotlight/controllers/tag_selector_controller.js +116 -79
  68. data/app/javascript/spotlight/core.js +18 -15
  69. data/app/javascript/spotlight/index.js +4 -4
  70. data/app/javascript/spotlight/user/browse_group_categories.js +24 -22
  71. data/app/javascript/spotlight/user/carousel.js +23 -19
  72. data/app/javascript/spotlight/user/clear_form_button.js +15 -15
  73. data/app/javascript/spotlight/user/index.js +4 -4
  74. data/app/javascript/spotlight/user/zpr_links.js +18 -18
  75. data/app/models/spotlight/analytics/ga.rb +0 -1
  76. data/app/models/spotlight/resources/iiif_manifest_v3.rb +2 -2
  77. data/app/services/spotlight/exhibit_import_export_service.rb +0 -2
  78. data/app/views/blacklight/nav/_bookmark.html.erb +1 -1
  79. data/app/views/catalog/_remove_tags.html.erb +1 -1
  80. data/app/views/layouts/spotlight/base.html.erb +1 -1
  81. data/app/views/shared/_header_navbar.html.erb +1 -1
  82. data/app/views/shared/_masthead.html.erb +2 -2
  83. data/app/views/shared/_site_sidebar.html.erb +1 -1
  84. data/app/views/shared/_user_util_links.html.erb +2 -2
  85. data/app/views/spotlight/about_pages/_contacts.html.erb +1 -1
  86. data/app/views/spotlight/accessibility/alt_text.html.erb +1 -1
  87. data/app/views/spotlight/admin_users/index.html.erb +11 -9
  88. data/app/views/spotlight/appearances/edit.html.erb +1 -1
  89. data/app/views/spotlight/browse/_search_box.html.erb +1 -1
  90. data/app/views/spotlight/bulk_updates/_download.html.erb +1 -1
  91. data/app/views/spotlight/bulk_updates/_progress_panel.html.erb +6 -6
  92. data/app/views/spotlight/bulk_updates/edit.html.erb +1 -1
  93. data/app/views/spotlight/catalog/_admin_header.html.erb +1 -1
  94. data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +1 -1
  95. data/app/views/spotlight/catalog/_curation_mode_toggle_default.html.erb +1 -1
  96. data/app/views/spotlight/catalog/_document.html.erb +2 -2
  97. data/app/views/spotlight/catalog/_document_admin_table.html.erb +1 -1
  98. data/app/views/spotlight/catalog/_edit_sidecar.html.erb +1 -1
  99. data/app/views/spotlight/catalog/_index_compact_default.html.erb +1 -1
  100. data/app/views/spotlight/catalog/_reindex_progress_panel.html.erb +6 -6
  101. data/app/views/spotlight/catalog/select_image.html.erb +1 -1
  102. data/app/views/spotlight/contact_mailer/report_problem.html.erb +2 -2
  103. data/app/views/spotlight/exhibits/_contact.html.erb +2 -2
  104. data/app/views/spotlight/exhibits/_delete.html.erb +2 -2
  105. data/app/views/spotlight/exhibits/_exhibit_card.html.erb +1 -1
  106. data/app/views/spotlight/exhibits/_export.html.erb +1 -1
  107. data/app/views/spotlight/exhibits/_form.html.erb +2 -2
  108. data/app/views/spotlight/exhibits/_languages.html.erb +7 -7
  109. data/app/views/spotlight/exhibits/_missing_exhibits.html.erb +1 -1
  110. data/app/views/spotlight/locks/_lock.html.erb +2 -2
  111. data/app/views/spotlight/metadata_configurations/edit.html.erb +1 -1
  112. data/app/views/spotlight/pages/_order_pages.html.erb +3 -3
  113. data/app/views/spotlight/pages/preview.html.erb +1 -1
  114. data/app/views/spotlight/pages/show.html.erb +2 -2
  115. data/app/views/spotlight/resources/_form.html.erb +1 -1
  116. data/app/views/spotlight/resources/csv_upload/_form.html.erb +1 -1
  117. data/app/views/spotlight/resources/upload/_form.html.erb +1 -1
  118. data/app/views/spotlight/roles/index.html.erb +5 -5
  119. data/app/views/spotlight/search_configurations/_search_fields.html.erb +1 -1
  120. data/app/views/spotlight/search_configurations/edit.html.erb +1 -1
  121. data/app/views/spotlight/searches/index.html.erb +2 -2
  122. data/app/views/spotlight/shared/_configuration_sidebar.html.erb +1 -1
  123. data/app/views/spotlight/shared/_curation_sidebar.html.erb +1 -1
  124. data/app/views/spotlight/shared/_dd3_item.html.erb +1 -1
  125. data/app/views/spotlight/sir_trevor/_sir_trevor_block_array.html.erb +1 -1
  126. data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +1 -1
  127. data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +1 -1
  128. data/app/views/spotlight/sir_trevor/blocks/_featured_pages_block.html.erb +2 -2
  129. data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +1 -1
  130. data/app/views/spotlight/sir_trevor/blocks/_rule_block.html.erb +1 -1
  131. data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +1 -1
  132. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +1 -1
  133. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +1 -1
  134. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +1 -1
  135. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +1 -1
  136. data/app/views/spotlight/sites/edit_exhibits.html.erb +3 -3
  137. data/app/views/spotlight/translations/_browse_categories.html.erb +2 -2
  138. data/app/views/spotlight/translations/_general.html.erb +21 -21
  139. data/app/views/spotlight/translations/_groups.html.erb +1 -1
  140. data/app/views/spotlight/translations/_metadata.html.erb +8 -8
  141. data/app/views/spotlight/translations/_pages_table.html.erb +2 -2
  142. data/app/views/spotlight/translations/_search_fields.html.erb +13 -13
  143. data/app/views/spotlight/translations/edit.html.erb +5 -5
  144. data/config/importmap.rb +0 -1
  145. data/lib/generators/spotlight/assets/propshaft_generator.rb +0 -1
  146. data/lib/generators/spotlight/templates/solr/conf/admin-extra.html +31 -31
  147. data/lib/spotlight/version.rb +1 -1
  148. data/spec/factories/contact_images.rb +1 -1
  149. data/spec/factories/exhibit_thumbnails.rb +1 -1
  150. data/spec/factories/featured_images.rb +1 -1
  151. data/spec/support/features/test_features_helpers.rb +41 -1
  152. metadata +4 -61
  153. data/app/javascript/spotlight/admin/copy_email_addresses.js +0 -7
  154. data/vendor/assets/javascripts/jquery.waitforimages.min.js +0 -2
@@ -1,144 +1,146 @@
1
1
  export default class {
2
2
  connect() {
3
- var monitorElements = $('[data-behavior="progress-panel"]');
4
- var defaultRefreshRate = 3000;
5
- var panelContainer;
6
- var pollers = [];
7
-
8
- $(monitorElements).each(function() {
9
- panelContainer = $(this);
10
- panelContainer.hide();
11
- var monitorUrl = panelContainer.data('monitorUrl');
12
- var refreshRate = panelContainer.data('refreshRate') || defaultRefreshRate;
3
+ var monitorElements = $('[data-behavior="progress-panel"]')
4
+ var defaultRefreshRate = 3000
5
+ var panelContainer
6
+ var pollers = []
7
+
8
+ $(monitorElements).each(function () {
9
+ panelContainer = $(this)
10
+ panelContainer.hide()
11
+ var monitorUrl = panelContainer.data("monitorUrl")
12
+ var refreshRate = panelContainer.data("refreshRate") || defaultRefreshRate
13
13
  pollers.push(
14
- setInterval(function() {
15
- checkMonitorUrl(monitorUrl);
16
- }, refreshRate)
17
- );
18
- });
14
+ setInterval(function () {
15
+ checkMonitorUrl(monitorUrl)
16
+ }, refreshRate),
17
+ )
18
+ })
19
19
 
20
20
  // Clear the intervals on turbolink:click event (e.g. when the user navigates away from the page)
21
- $(document).on('turbolinks:click', function() {
21
+ $(document).on("turbolinks:click", function () {
22
22
  if (pollers.length > 0) {
23
- $.each(pollers, function() {
24
- clearInterval(this);
25
- });
26
- pollers = [];
23
+ $.each(pollers, function () {
24
+ clearInterval(this)
25
+ })
26
+ pollers = []
27
27
  }
28
- });
28
+ })
29
29
 
30
30
  function checkMonitorUrl(url) {
31
- $.ajax(url).done(success).fail(fail);
31
+ $.ajax(url).done(success).fail(fail)
32
32
  }
33
33
 
34
34
  function success(data) {
35
35
  if (data.recently_in_progress) {
36
- updateMonitorPanel(data);
37
- monitorPanel().show();
36
+ updateMonitorPanel(data)
37
+ monitorPanel().show()
38
38
  } else {
39
- monitorPanel().hide();
39
+ monitorPanel().hide()
40
40
  }
41
41
  }
42
42
 
43
- function fail() { monitorPanel().hide(); }
43
+ function fail() {
44
+ monitorPanel().hide()
45
+ }
44
46
 
45
47
  function updateMonitorPanel(data) {
46
- panelStartDate().text(data.started_at);
47
- panelCurrentDate().text(data.updated_at);
48
- panelCompletedDate().text(data.updated_at);
49
- panelCurrent().text(data.completed);
50
- setPanelCompleted(data.finished);
51
- updatePanelTotals(data);
52
- updatePanelErrorMessage(data);
53
- updateProgressBar(data);
48
+ panelStartDate().text(data.started_at)
49
+ panelCurrentDate().text(data.updated_at)
50
+ panelCompletedDate().text(data.updated_at)
51
+ panelCurrent().text(data.completed)
52
+ setPanelCompleted(data.finished)
53
+ updatePanelTotals(data)
54
+ updatePanelErrorMessage(data)
55
+ updateProgressBar(data)
54
56
 
55
- panelContainer.show();
57
+ panelContainer.show()
56
58
  }
57
59
 
58
60
  function updateProgressBar(data) {
59
- var percentage = calculatePercentage(data);
61
+ var percentage = calculatePercentage(data)
60
62
  progressBar()
61
- .attr('aria-valuemax', data.total)
62
- .attr('aria-valuenow', percentage)
63
- .css('width', percentage + '%')
64
- .text(percentage + '%');
63
+ .attr("aria-valuemax", data.total)
64
+ .attr("aria-valuenow", percentage)
65
+ .css("width", percentage + "%")
66
+ .text(percentage + "%")
65
67
 
66
68
  if (data.finished) {
67
- progressBar().removeClass('active').removeClass('progress-bar-striped');
69
+ progressBar().removeClass("active").removeClass("progress-bar-striped")
68
70
  }
69
71
  }
70
72
 
71
73
  function updatePanelErrorMessage(data) {
72
74
  // We currently do not store this state,
73
75
  // but with this code we can in the future.
74
- if ( data.errored ) {
75
- panelErrorMessage().show();
76
+ if (data.errored) {
77
+ panelErrorMessage().show()
76
78
  } else {
77
- panelErrorMessage().hide();
79
+ panelErrorMessage().hide()
78
80
  }
79
81
  }
80
82
 
81
83
  function updatePanelTotals(data) {
82
- panelTotals().each(function() {
83
- $(this).text(data.total);
84
- });
84
+ panelTotals().each(function () {
85
+ $(this).text(data.total)
86
+ })
85
87
  }
86
88
 
87
89
  function calculatePercentage(data) {
88
- if (data.total == 0) return 0;
89
- return Math.floor((data.completed / data.total) * 100);
90
+ if (data.total == 0) return 0
91
+ return Math.floor((data.completed / data.total) * 100)
90
92
  }
91
93
 
92
94
  function monitorPanel() {
93
- return panelContainer.find('.index-status');
95
+ return panelContainer.find(".index-status")
94
96
  }
95
97
 
96
98
  function panelStartDate() {
97
99
  return monitorPanel()
98
- .find('[data-behavior="monitor-start"]')
99
- .find('[data-behavior="date"]');
100
+ .find('[data-behavior="monitor-start"]')
101
+ .find('[data-behavior="date"]')
100
102
  }
101
103
 
102
104
  function panelCurrentDate() {
103
105
  return monitorPanel()
104
- .find('[data-behavior="monitor-current"]')
105
- .find('[data-behavior="date"]');
106
+ .find('[data-behavior="monitor-current"]')
107
+ .find('[data-behavior="date"]')
106
108
  }
107
109
 
108
110
  function panelCompletedDate() {
109
111
  return monitorPanel()
110
- .find('[data-behavior="monitor-completed"]')
111
- .find('[data-behavior="date"]');
112
+ .find('[data-behavior="monitor-completed"]')
113
+ .find('[data-behavior="date"]')
112
114
  }
113
115
 
114
116
  function panelTotals() {
115
- return monitorPanel().find('[data-behavior="total"]');
117
+ return monitorPanel().find('[data-behavior="total"]')
116
118
  }
117
119
 
118
120
  function panelCurrent() {
119
121
  return monitorPanel()
120
- .find('[data-behavior="monitor-current"]')
121
- .find('[data-behavior="completed"]');
122
+ .find('[data-behavior="monitor-current"]')
123
+ .find('[data-behavior="completed"]')
122
124
  }
123
125
 
124
126
  function progressBar() {
125
- return monitorPanel().find('.progress-bar');
127
+ return monitorPanel().find(".progress-bar")
126
128
  }
127
129
 
128
130
  function panelErrorMessage() {
129
- return monitorPanel().find('[data-behavior="monitor-error"]');
131
+ return monitorPanel().find('[data-behavior="monitor-error"]')
130
132
  }
131
133
 
132
134
  function setPanelCompleted(finished) {
133
- var panel = monitorPanel().find('[data-behavior="monitor-completed"]');
135
+ var panel = monitorPanel().find('[data-behavior="monitor-completed"]')
134
136
 
135
137
  if (finished) {
136
- panel.show();
138
+ panel.show()
137
139
  } else {
138
- panel.hide();
140
+ panel.hide()
139
141
  }
140
142
  }
141
143
 
142
- return this;
144
+ return this
143
145
  }
144
146
  }
@@ -1,8 +1,8 @@
1
1
  export default class {
2
2
  connect() {
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();
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
6
  })
7
7
  }
8
8
  }
@@ -1,73 +1,85 @@
1
- import { addImageSelector } from 'spotlight/admin/add_image_selector'
1
+ import { addImageSelector } from "spotlight/admin/add_image_selector"
2
2
 
3
- const docStore = new Map();
3
+ const docStore = new Map()
4
4
 
5
5
  function highlight(value, query) {
6
- if (query.trim() === '') return value;
7
- const queryValue = query.trim();
8
- return queryValue ? value.replace(new RegExp(queryValue, 'gi'), '<strong>$&</strong>') : value;
6
+ if (query.trim() === "") return value
7
+ const queryValue = query.trim()
8
+ return queryValue
9
+ ? value.replace(new RegExp(queryValue, "gi"), "<strong>$&</strong>")
10
+ : value
9
11
  }
10
12
 
11
13
  function templateFunc(obj, query) {
12
- const thumbnail = obj.thumbnail ? `<div class="document-thumbnail"><img class="img-thumbnail" src="${obj.thumbnail}" /></div>` : '';
13
- const privateClass = obj.private ? ' blacklight-private' : '';
14
- const title = highlight(obj.title, query);
15
- const description = obj.description ? `<small>&nbsp;&nbsp;${highlight(obj.description, query)}</small>` : '';
14
+ const thumbnail = obj.thumbnail
15
+ ? `<div class="document-thumbnail"><img class="img-thumbnail" src="${obj.thumbnail}" /></div>`
16
+ : ""
17
+ const privateClass = obj.private ? " blacklight-private" : ""
18
+ const title = highlight(obj.title, query)
19
+ const description = obj.description
20
+ ? `<small>&nbsp;&nbsp;${highlight(obj.description, query)}</small>`
21
+ : ""
16
22
  return `<div class="autocomplete-item${privateClass}">${thumbnail}
17
23
  <span class="autocomplete-title">${title}</span><br/>${description}
18
- </div>`;
24
+ </div>`
19
25
  }
20
26
 
21
27
  function autoCompleteElementTemplate(obj, query) {
22
- return `<li role="option" data-autocomplete-value="${obj.id}">${templateFunc(obj, query)}</li>`;
28
+ return `<li role="option" data-autocomplete-value="${obj.id}">${templateFunc(obj, query)}</li>`
23
29
  }
24
30
 
25
31
  function getAutoCompleteElementDataMap(autoCompleteElement) {
26
32
  if (!docStore.has(autoCompleteElement.id)) {
27
- docStore.set(autoCompleteElement.id, new Map());
33
+ docStore.set(autoCompleteElement.id, new Map())
28
34
  }
29
- return docStore.get(autoCompleteElement.id);
35
+ return docStore.get(autoCompleteElement.id)
30
36
  }
31
37
 
32
38
  async function fetchResult(url) {
33
- const result = await fetchAutocompleteJSON(url);
34
- const docs = result.docs || [];
35
- const query = this.querySelector('input').value || '';
36
- const autoCompleteElementDataMap = getAutoCompleteElementDataMap(this);
37
- return docs.map(doc => {
38
- autoCompleteElementDataMap.set(doc.id, doc);
39
- return autoCompleteElementTemplate(doc, query);
40
- }).join('');
39
+ const result = await fetchAutocompleteJSON(url)
40
+ const docs = result.docs || []
41
+ const query = this.querySelector("input").value || ""
42
+ const autoCompleteElementDataMap = getAutoCompleteElementDataMap(this)
43
+ return docs
44
+ .map((doc) => {
45
+ autoCompleteElementDataMap.set(doc.id, doc)
46
+ return autoCompleteElementTemplate(doc, query)
47
+ })
48
+ .join("")
41
49
  }
42
50
 
43
- export function addAutocompletetoFeaturedImage(){
44
- const autocompletePath = $('form[data-autocomplete-exhibit-catalog-path]').data('autocomplete-exhibit-catalog-path');
45
- const featuredImageTypeaheads = $('[data-featured-image-typeahead]');
46
- if (featuredImageTypeaheads.length === 0) return;
51
+ export function addAutocompletetoFeaturedImage() {
52
+ const autocompletePath = $(
53
+ "form[data-autocomplete-exhibit-catalog-path]",
54
+ ).data("autocomplete-exhibit-catalog-path")
55
+ const featuredImageTypeaheads = $("[data-featured-image-typeahead]")
56
+ if (featuredImageTypeaheads.length === 0) return
47
57
 
48
- $.each(featuredImageTypeaheads, function(index, autoCompleteInput) {
49
- const autoCompleteElement = autoCompleteInput.closest('auto-complete');
58
+ $.each(featuredImageTypeaheads, function (index, autoCompleteInput) {
59
+ const autoCompleteElement = autoCompleteInput.closest("auto-complete")
50
60
 
51
- autoCompleteElement.setAttribute('src', autocompletePath);
52
- autoCompleteElement.fetchResult = fetchResult;
53
- autoCompleteElement.addEventListener('auto-complete-change', e => {
54
- const data = getAutoCompleteElementDataMap(autoCompleteElement).get(e.relatedTarget.value);
55
- if (!data) return;
61
+ autoCompleteElement.setAttribute("src", autocompletePath)
62
+ autoCompleteElement.fetchResult = fetchResult
63
+ autoCompleteElement.addEventListener("auto-complete-change", (e) => {
64
+ const data = getAutoCompleteElementDataMap(autoCompleteElement).get(
65
+ e.relatedTarget.value,
66
+ )
67
+ if (!data) return
56
68
 
57
- const inputElement = $(e.relatedTarget);
58
- const panel = document.querySelector(e.relatedTarget.dataset.targetPanel);
59
- e.relatedTarget.value = data.title;
60
- addImageSelector(inputElement, $(panel), data.iiif_manifest, true);
61
- $(inputElement.data('id-field')).val(data['global_id']);
62
- inputElement.attr('type', 'text');
63
- });
64
- });
69
+ const inputElement = $(e.relatedTarget)
70
+ const panel = document.querySelector(e.relatedTarget.dataset.targetPanel)
71
+ e.relatedTarget.value = data.title
72
+ addImageSelector(inputElement, $(panel), data.iiif_manifest, true)
73
+ $(inputElement.data("id-field")).val(data["global_id"])
74
+ inputElement.attr("type", "text")
75
+ })
76
+ })
65
77
  }
66
78
 
67
79
  export async function fetchAutocompleteJSON(url) {
68
- const res = await(fetch(url.toString()));
80
+ const res = await fetch(url.toString())
69
81
  if (!res.ok) {
70
- throw new Error(await res.text());
82
+ throw new Error(await res.text())
71
83
  }
72
- return await res.json();
84
+ return await res.json()
73
85
  }
@@ -2,36 +2,36 @@
2
2
  Simple plugin to select form elements
3
3
  when other elements are clicked.
4
4
  */
5
- (function($) {
6
- $.fn.selectRelatedInput = function() {
7
- var clickElements = this;
5
+ ;(function ($) {
6
+ $.fn.selectRelatedInput = function () {
7
+ var clickElements = this
8
8
 
9
- $(clickElements).each(function() {
10
- var target = $($(this).data('input-select-target'));
9
+ $(clickElements).each(function () {
10
+ var target = $($(this).data("input-select-target"))
11
11
 
12
- var event;
12
+ var event
13
13
 
14
14
  if ($(this).is("select")) {
15
- event = 'change';
15
+ event = "change"
16
16
  } else {
17
- event = 'click';
17
+ event = "click"
18
18
  }
19
19
 
20
- $(this).on(event, function() {
20
+ $(this).on(event, function () {
21
21
  if (target.is(":checkbox") || target.is(":radio")) {
22
- target.prop('checked', true);
22
+ target.prop("checked", true)
23
23
  } else {
24
- target.focus();
24
+ target.focus()
25
25
  }
26
- });
27
- });
26
+ })
27
+ })
28
28
 
29
- return this;
30
- };
31
- })(jQuery);
29
+ return this
30
+ }
31
+ })(jQuery)
32
32
 
33
33
  export default class {
34
34
  connect() {
35
- $('[data-input-select-target]').selectRelatedInput();
35
+ $("[data-input-select-target]").selectRelatedInput()
36
36
  }
37
37
  }
@@ -1,122 +1,138 @@
1
- import Core from 'spotlight/core'
2
-
3
- (function() {
4
- var BLOCK_REPLACER_CONTROL_TEMPLATE = function(block) {
5
- var el = document.createElement('button');
6
- el.className = "st-block-controls__button";
7
- el.setAttribute('data-type', block.type);
8
- el.type = "button";
9
-
10
- var img = document.createElement('svg');
11
- img.className = "st-icon";
12
- img.setAttribute('role', 'img');
13
-
14
- var use = document.createElement('use');
15
- use.setAttributeNS('https://www.w3.org/1999/xlink', 'href', SirTrevor.config.defaults.iconUrl + "#" + block.icon_name);
16
- img.appendChild(use);
17
- el.appendChild(img);
18
- el.appendChild(document.createTextNode(block.title()));
19
-
20
- return el.outerHTML;
21
- };
1
+ import Core from "spotlight/core"
2
+ ;(function () {
3
+ var BLOCK_REPLACER_CONTROL_TEMPLATE = function (block) {
4
+ var el = document.createElement("button")
5
+ el.className = "st-block-controls__button"
6
+ el.setAttribute("data-type", block.type)
7
+ el.type = "button"
8
+
9
+ var img = document.createElement("svg")
10
+ img.className = "st-icon"
11
+ img.setAttribute("role", "img")
12
+
13
+ var use = document.createElement("use")
14
+ use.setAttributeNS(
15
+ "https://www.w3.org/1999/xlink",
16
+ "href",
17
+ SirTrevor.config.defaults.iconUrl + "#" + block.icon_name,
18
+ )
19
+ img.appendChild(use)
20
+ el.appendChild(img)
21
+ el.appendChild(document.createTextNode(block.title()))
22
+
23
+ return el.outerHTML
24
+ }
22
25
 
23
26
  function generateBlocksHTML(Blocks, availableTypes) {
24
- var groups = {};
25
- for(var i in availableTypes) {
26
- var type = availableTypes[i];
27
- if (Blocks.hasOwnProperty(type) && Blocks[type].prototype.toolbarEnabled) {
28
- var blockGroup;
27
+ var groups = {}
28
+ for (var i in availableTypes) {
29
+ var type = availableTypes[i]
30
+ if (
31
+ Object.prototype.hasOwnProperty.call(Blocks, type) &&
32
+ Blocks[type].prototype.toolbarEnabled
33
+ ) {
34
+ var blockGroup
29
35
 
30
36
  if ($.isFunction(Blocks[type].prototype.blockGroup)) {
31
- blockGroup = Blocks[type].prototype.blockGroup();
37
+ blockGroup = Blocks[type].prototype.blockGroup()
32
38
  } else {
33
- blockGroup = Blocks[type].prototype.blockGroup;
39
+ blockGroup = Blocks[type].prototype.blockGroup
34
40
  }
35
41
 
36
- if (blockGroup == 'undefined' || blockGroup === undefined) {
37
- blockGroup = i18n.t("blocks:group:undefined");
42
+ if (blockGroup == "undefined" || blockGroup === undefined) {
43
+ blockGroup = i18n.t("blocks:group:undefined")
38
44
  }
39
45
 
40
- groups[blockGroup] = groups[blockGroup] || [];
41
- groups[blockGroup].push(BLOCK_REPLACER_CONTROL_TEMPLATE(Blocks[type].prototype));
46
+ groups[blockGroup] = groups[blockGroup] || []
47
+ groups[blockGroup].push(
48
+ BLOCK_REPLACER_CONTROL_TEMPLATE(Blocks[type].prototype),
49
+ )
42
50
  }
43
51
  }
44
52
 
45
53
  function generateBlock(groups, key) {
46
- var group = groups[key];
47
- var groupEl = $("<div class='st-controls-group'><div class='st-group-col-form-label'>" + key + "</div></div>");
48
- var buttons = group.reduce(function(memo, btn) {
49
- return memo += btn;
50
- }, "");
51
- groupEl.append(buttons);
52
- return groupEl[0].outerHTML;
54
+ var group = groups[key]
55
+ var groupEl = $(
56
+ "<div class='st-controls-group'><div class='st-group-col-form-label'>" +
57
+ key +
58
+ "</div></div>",
59
+ )
60
+ var buttons = group.reduce(function (memo, btn) {
61
+ return memo + btn
62
+ }, "")
63
+ groupEl.append(buttons)
64
+ return groupEl[0].outerHTML
53
65
  }
54
66
 
55
- var standardWidgets = generateBlock(groups, i18n.t("blocks:group:undefined"));
67
+ var standardWidgets = generateBlock(
68
+ groups,
69
+ i18n.t("blocks:group:undefined"),
70
+ )
56
71
 
57
- var exhibitWidgets = Object.keys(groups).map(function(key) {
58
- if (key !== i18n.t("blocks:group:undefined")) {
59
- return generateBlock(groups, key);
60
- }
61
- }).filter(function (element) {
62
- return element != null;
63
- });
72
+ var exhibitWidgets = Object.keys(groups)
73
+ .map(function (key) {
74
+ if (key !== i18n.t("blocks:group:undefined")) {
75
+ return generateBlock(groups, key)
76
+ }
77
+ })
78
+ .filter(function (element) {
79
+ return element != null
80
+ })
64
81
 
65
- var blocks = [standardWidgets].concat(exhibitWidgets).join("<hr />");
66
- return blocks;
82
+ var blocks = [standardWidgets].concat(exhibitWidgets).join("<hr />")
83
+ return blocks
67
84
  }
68
85
 
69
- function render(Blocks, availableTypes) {
70
- var el = document.createElement('div');
71
- el.className = "st-block-controls__buttons";
72
- el.innerHTML = generateBlocksHTML.apply(null, arguments);
86
+ function render(_Blocks, _availableTypes) {
87
+ var el = document.createElement("div")
88
+ el.className = "st-block-controls__buttons"
89
+ el.innerHTML = generateBlocksHTML.apply(null, arguments)
73
90
 
74
- var elButtons = document.createElement('div');
75
- elButtons.className = "spotlight-block-controls";
76
- elButtons.appendChild(el);
77
- return elButtons;
91
+ var elButtons = document.createElement("div")
92
+ elButtons.className = "spotlight-block-controls"
93
+ elButtons.appendChild(el)
94
+ return elButtons
78
95
  }
79
96
 
80
- Core.BlockControls = function() { };
81
- Core.BlockControls.create = function(editor) {
97
+ Core.BlockControls = function () {}
98
+ Core.BlockControls.create = function (editor) {
82
99
  // REFACTOR - should probably not know about blockManager
83
- var el = render(SirTrevor.Blocks, editor.blockManager.blockTypes);
100
+ var el = render(SirTrevor.Blocks, editor.blockManager.blockTypes)
84
101
 
85
102
  function hide() {
86
- var parent = el.parentNode;
87
- if (!parent) { return; }
88
- parent.removeChild(el);
89
- parent.classList.remove("st-block--controls-active");
90
- return parent;
103
+ var parent = el.parentNode
104
+ if (!parent) {
105
+ return
106
+ }
107
+ parent.removeChild(el)
108
+ parent.classList.remove("st-block--controls-active")
109
+ return parent
91
110
  }
92
111
 
93
112
  function destroy() {
94
- SirTrevor = null;
95
- el = null;
113
+ // eslint-disable-next-line no-global-assign
114
+ SirTrevor = null
115
+ el = null
96
116
  }
97
117
 
98
118
  function insert(e) {
99
- e.stopPropagation();
100
-
101
- var parent = this.parentNode;
102
- if (!parent || hide() === parent) { return; }
103
- $('.st-block__inner', parent).after(el);
104
- parent.classList.add("st-block--controls-active");
105
- }
119
+ e.stopPropagation()
106
120
 
107
- function replaceBlock() {
108
- SirTrevor.mediator.trigger(
109
- "block:replace", el.parentNode, this.getAttribute('data-type')
110
- );
121
+ var parent = this.parentNode
122
+ if (!parent || hide() === parent) {
123
+ return
124
+ }
125
+ $(".st-block__inner", parent).after(el)
126
+ parent.classList.add("st-block--controls-active")
111
127
  }
112
128
 
113
- $(editor.wrapper).delegate(".st-block-replacer", "click", insert);
114
- $(editor.wrapper).delegate(".st-block-controls__button", "click", insert);
129
+ $(editor.wrapper).delegate(".st-block-replacer", "click", insert)
130
+ $(editor.wrapper).delegate(".st-block-controls__button", "click", insert)
115
131
 
116
132
  return {
117
133
  el: el,
118
134
  hide: hide,
119
- destroy: destroy
120
- };
121
- };
122
- })();
135
+ destroy: destroy,
136
+ }
137
+ }
138
+ })()