blacklight-spotlight 3.5.0.1 → 3.6.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -0
  3. data/Rakefile +6 -7
  4. data/app/assets/config/spotlight/manifest.js +1 -0
  5. data/app/assets/javascripts/spotlight/application.js +14 -14
  6. data/app/assets/javascripts/spotlight/spotlight.esm.js +7148 -0
  7. data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -0
  8. data/app/assets/javascripts/spotlight/spotlight.js +7148 -15
  9. data/app/assets/javascripts/spotlight/spotlight.js.map +1 -0
  10. data/app/assets/stylesheets/spotlight/_catalog.scss +16 -0
  11. data/app/controllers/concerns/spotlight/base.rb +2 -1
  12. data/app/controllers/concerns/spotlight/controller.rb +10 -0
  13. data/app/controllers/spotlight/admin_users_controller.rb +4 -4
  14. data/app/controllers/spotlight/appearances_controller.rb +6 -6
  15. data/app/controllers/spotlight/browse_controller.rb +1 -1
  16. data/app/controllers/spotlight/catalog_controller.rb +20 -15
  17. data/app/controllers/spotlight/concerns/application_controller.rb +1 -0
  18. data/app/controllers/spotlight/concerns/catalog_search_context.rb +2 -2
  19. data/app/controllers/spotlight/contacts_controller.rb +6 -6
  20. data/app/controllers/spotlight/dashboards_controller.rb +2 -2
  21. data/app/controllers/spotlight/exhibits_controller.rb +19 -19
  22. data/app/controllers/spotlight/featured_images_controller.rb +1 -1
  23. data/app/controllers/spotlight/home_pages_controller.rb +7 -7
  24. data/app/controllers/spotlight/lock_controller.rb +1 -1
  25. data/app/controllers/spotlight/metadata_configurations_controller.rb +2 -2
  26. data/app/controllers/spotlight/pages_controller.rb +4 -3
  27. data/app/controllers/spotlight/search_configurations_controller.rb +6 -6
  28. data/app/controllers/spotlight/searches_controller.rb +22 -22
  29. data/app/controllers/spotlight/solr_controller.rb +1 -1
  30. data/app/controllers/spotlight/translations_controller.rb +8 -10
  31. data/app/controllers/spotlight/versions_controller.rb +2 -1
  32. data/app/helpers/spotlight/application_helper.rb +33 -17
  33. data/app/helpers/spotlight/crud_link_helpers.rb +12 -2
  34. data/app/helpers/spotlight/pages_helper.rb +1 -1
  35. data/app/helpers/spotlight/roles_helper.rb +2 -2
  36. data/app/helpers/spotlight/title_helper.rb +1 -1
  37. data/app/helpers/spotlight/translations_helper.rb +1 -3
  38. data/app/javascript/spotlight/admin/add_another.es6 +24 -0
  39. data/app/javascript/spotlight/admin/add_image_selector.es6 +38 -0
  40. data/app/javascript/spotlight/admin/add_new_button.es6 +77 -0
  41. data/app/javascript/spotlight/admin/appearance.es6 +22 -0
  42. data/app/javascript/spotlight/admin/blacklight_configuration.es6 +65 -0
  43. data/app/{assets/javascripts → javascript}/spotlight/admin/block_mixins/autocompleteable.js +8 -8
  44. data/app/{assets/javascripts → javascript}/spotlight/admin/block_mixins/formable.js +1 -1
  45. data/app/javascript/spotlight/admin/block_mixins/plustextable.js +58 -0
  46. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/block.js +2 -1
  47. data/app/javascript/spotlight/admin/blocks/browse_block.js +86 -0
  48. data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +88 -0
  49. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/iframe_block.js +7 -11
  50. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/link_to_search_block.js +0 -2
  51. data/app/javascript/spotlight/admin/blocks/oembed_block.js +41 -0
  52. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/pages_block.js +1 -1
  53. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/resources_block.js +45 -42
  54. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/rule_block.js +2 -4
  55. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/search_result_block.js +7 -9
  56. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_base_block.js +22 -22
  57. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_block.js +7 -7
  58. data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_carousel_block.js +14 -15
  59. data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +147 -0
  60. data/app/javascript/spotlight/admin/checkbox_submit.es6 +75 -0
  61. data/app/javascript/spotlight/admin/copy_email_addresses.es6 +5 -0
  62. data/app/{assets/javascripts/spotlight/admin/crop.es6 → javascript/spotlight/admin/crop.js} +5 -4
  63. data/app/javascript/spotlight/admin/croppable.es6 +10 -0
  64. data/app/{assets/javascripts/spotlight/admin/edit_in_place.js → javascript/spotlight/admin/edit_in_place.es6} +6 -13
  65. data/app/javascript/spotlight/admin/exhibit_tag_autocomplete.es6 +39 -0
  66. data/app/javascript/spotlight/admin/exhibits.es6 +59 -0
  67. data/app/{assets/javascripts/spotlight/admin/form_observer.js → javascript/spotlight/admin/form_observer.es6} +23 -21
  68. data/app/javascript/spotlight/admin/index.js +85 -0
  69. data/app/javascript/spotlight/admin/locks.es6 +12 -0
  70. data/app/{assets/javascripts → javascript}/spotlight/admin/multi_image_selector.js +2 -1
  71. data/app/javascript/spotlight/admin/pages.es6 +42 -0
  72. data/app/{assets/javascripts/spotlight/admin/progress_monitor.js → javascript/spotlight/admin/progress_monitor.es6} +5 -9
  73. data/app/javascript/spotlight/admin/readonly_checkbox.es6 +8 -0
  74. data/app/{assets/javascripts → javascript}/spotlight/admin/search_typeahead.js +3 -46
  75. data/app/{assets/javascripts/spotlight/admin/select_related_input.js → javascript/spotlight/admin/select_related_input.es6} +6 -3
  76. data/app/{assets/javascripts → javascript}/spotlight/admin/sir-trevor/block_controls.js +6 -4
  77. data/app/{assets/javascripts → javascript}/spotlight/admin/sir-trevor/block_limits.js +2 -0
  78. data/app/{assets/javascripts → javascript}/spotlight/admin/spotlight_nestable.js +4 -8
  79. data/app/javascript/spotlight/admin/tabs.es6 +8 -0
  80. data/app/{assets/javascripts/spotlight/admin/translation_progress.js → javascript/spotlight/admin/translation_progress.es6} +6 -13
  81. data/app/{assets/javascripts/spotlight/admin/users.js → javascript/spotlight/admin/users.es6} +7 -17
  82. data/app/javascript/spotlight/admin/visibility_toggle.es6 +23 -0
  83. data/app/javascript/spotlight/index.js +10 -0
  84. data/app/javascript/spotlight/spotlight.js +32 -0
  85. data/app/{assets/javascripts/spotlight/user/analytics.js → javascript/spotlight/user/analytics.es6} +4 -4
  86. data/app/{assets/javascripts/spotlight/user/browse_group_categories.js → javascript/spotlight/user/browse_group_categories.es6} +4 -13
  87. data/app/javascript/spotlight/user/carousel.es6 +5 -0
  88. data/app/{assets/javascripts/spotlight/user/clear_form_button.js → javascript/spotlight/user/clear_form_button.es6} +5 -9
  89. data/app/javascript/spotlight/user/index.js +17 -0
  90. data/app/{assets/javascripts/spotlight/user/report_a_problem.js → javascript/spotlight/user/report_a_problem.es6} +6 -15
  91. data/app/javascript/spotlight/user/zpr_links.es6 +44 -0
  92. data/app/jobs/spotlight/add_uploads_from_csv.rb +1 -2
  93. data/app/models/concerns/spotlight/browse_category_search_builder.rb +7 -3
  94. data/app/models/concerns/spotlight/exhibit_defaults.rb +1 -1
  95. data/app/models/concerns/spotlight/exhibit_documents.rb +2 -2
  96. data/app/models/concerns/spotlight/resources/web.rb +1 -1
  97. data/app/models/concerns/spotlight/solr_document/atomic_updates.rb +1 -1
  98. data/app/models/concerns/spotlight/solr_document/finder.rb +2 -2
  99. data/app/models/concerns/spotlight/solr_document.rb +2 -2
  100. data/app/models/concerns/spotlight/translatables.rb +1 -1
  101. data/app/models/sir_trevor_rails/blocks/displayable.rb +2 -2
  102. data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +17 -6
  103. data/app/models/spotlight/analytics/ga.rb +5 -5
  104. data/app/models/spotlight/blacklight_configuration.rb +12 -12
  105. data/app/models/spotlight/bulk_update.rb +1 -0
  106. data/app/models/spotlight/contact_email.rb +1 -1
  107. data/app/models/spotlight/contact_form.rb +1 -1
  108. data/app/models/spotlight/exhibit.rb +1 -1
  109. data/app/models/spotlight/featured_image.rb +1 -2
  110. data/app/models/spotlight/lock.rb +1 -1
  111. data/app/models/spotlight/main_navigation.rb +1 -5
  112. data/app/models/spotlight/page.rb +1 -1
  113. data/app/models/spotlight/resources/iiif_manifest.rb +4 -4
  114. data/app/models/spotlight/resources/iiif_service.rb +1 -1
  115. data/app/models/spotlight/resources/upload.rb +3 -6
  116. data/app/models/spotlight/search.rb +6 -2
  117. data/app/models/translation.rb +2 -0
  118. data/app/presenters/spotlight/iiif_manifest_presenter.rb +2 -1
  119. data/app/services/spotlight/iiif_resource_resolver.rb +10 -10
  120. data/app/uploaders/spotlight/bulk_updates_uploader.rb +1 -0
  121. data/app/views/layouts/spotlight/base.html.erb +1 -0
  122. data/app/views/shared/_exhibit_navbar.html.erb +6 -1
  123. data/app/views/spotlight/admin_users/index.html.erb +9 -3
  124. data/app/views/spotlight/browse/show.html.erb +2 -2
  125. data/app/views/spotlight/catalog/_admin_header.html.erb +3 -1
  126. data/app/views/spotlight/catalog/_document_visibility_control.html.erb +21 -2
  127. data/app/views/spotlight/catalog/_index_compact_default.html.erb +1 -1
  128. data/app/views/spotlight/exhibits/_confirmation_status.html.erb +3 -1
  129. data/app/views/spotlight/exhibits/_contact.html.erb +5 -1
  130. data/app/views/spotlight/shared/_exhibit_sidebar.html.erb +2 -0
  131. data/app/views/spotlight/shared/_report_a_problem.html.erb +1 -1
  132. data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +2 -2
  133. data/app/views/spotlight/translations/_page.html.erb +6 -1
  134. data/config/locales/spotlight.en.yml +3 -8
  135. data/lib/generators/spotlight/install_generator.rb +15 -23
  136. data/lib/generators/spotlight/scaffold_resource_generator.rb +12 -12
  137. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +3 -0
  138. data/lib/generators/spotlight/templates/solr/conf/_rest_managed.json +3 -0
  139. data/lib/generators/spotlight/templates/solr/conf/admin-extra.html +31 -0
  140. data/lib/generators/spotlight/templates/solr/conf/elevate.xml +36 -0
  141. data/lib/generators/spotlight/templates/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  142. data/lib/generators/spotlight/templates/solr/conf/protwords.txt +21 -0
  143. data/lib/generators/spotlight/templates/solr/{config → conf}/schema.xml +17 -0
  144. data/lib/generators/spotlight/templates/solr/conf/scripts.conf +24 -0
  145. data/lib/generators/spotlight/templates/solr/{config → conf}/solrconfig.xml +55 -24
  146. data/lib/generators/spotlight/templates/solr/conf/spellings.txt +2 -0
  147. data/lib/generators/spotlight/templates/solr/conf/stopwords.txt +58 -0
  148. data/lib/generators/spotlight/templates/solr/conf/stopwords_en.txt +58 -0
  149. data/lib/generators/spotlight/templates/solr/conf/synonyms.txt +31 -0
  150. data/lib/generators/spotlight/templates/solr/conf/xslt/example.xsl +132 -0
  151. data/lib/generators/spotlight/templates/solr/conf/xslt/example_atom.xsl +67 -0
  152. data/lib/generators/spotlight/templates/solr/conf/xslt/example_rss.xsl +66 -0
  153. data/lib/generators/spotlight/templates/solr/conf/xslt/luke.xsl +337 -0
  154. data/lib/generators/spotlight/templates/spotlight.js +1 -1
  155. data/lib/migration/iiif.rb +3 -7
  156. data/lib/spotlight/engine.rb +18 -16
  157. data/lib/spotlight/riiif_service.rb +31 -0
  158. data/lib/spotlight/search_state.rb +19 -0
  159. data/lib/spotlight/upload_field_config.rb +1 -1
  160. data/lib/spotlight/version.rb +1 -1
  161. data/lib/tasks/spotlight_tasks.rake +1 -1
  162. data/spec/fixtures/iiif_responses.rb +64 -64
  163. data/vendor/assets/javascripts/nestable.js +1 -1
  164. data/vendor/assets/javascripts/parameterize.js +2 -2
  165. data/vendor/assets/javascripts/sir-trevor.js +22460 -20591
  166. data/vendor/assets/stylesheets/sir-trevor/_icons.scss +0 -0
  167. data/vendor/assets/stylesheets/sir-trevor/_variables.scss +16 -18
  168. data/vendor/assets/stylesheets/sir-trevor/base.scss +11 -0
  169. data/vendor/assets/stylesheets/sir-trevor/block-addition-top.scss +4 -1
  170. data/vendor/assets/stylesheets/sir-trevor/block-addition.scss +3 -2
  171. data/vendor/assets/stylesheets/sir-trevor/block-controls.scss +4 -0
  172. data/vendor/assets/stylesheets/sir-trevor/block-positioner.scss +0 -0
  173. data/vendor/assets/stylesheets/sir-trevor/block-replacer.scss +0 -0
  174. data/vendor/assets/stylesheets/sir-trevor/block-ui.scss +10 -0
  175. data/vendor/assets/stylesheets/sir-trevor/block.scss +19 -5
  176. data/vendor/assets/stylesheets/sir-trevor/errors.scss +0 -0
  177. data/vendor/assets/stylesheets/sir-trevor/format-bar.scss +0 -0
  178. data/vendor/assets/stylesheets/sir-trevor/inputs.scss +0 -0
  179. data/vendor/assets/stylesheets/sir-trevor/main.scss +0 -0
  180. data/vendor/assets/stylesheets/sir-trevor/patterns/ui-popup.scss +0 -0
  181. data/vendor/assets/stylesheets/sir-trevor/utils.scss +0 -0
  182. metadata +104 -117
  183. data/app/assets/javascripts/spotlight/admin/add_another.js +0 -22
  184. data/app/assets/javascripts/spotlight/admin/add_new_button.js +0 -81
  185. data/app/assets/javascripts/spotlight/admin/appearance.js +0 -24
  186. data/app/assets/javascripts/spotlight/admin/attachments.js +0 -2
  187. data/app/assets/javascripts/spotlight/admin/blacklight_configuration.js +0 -63
  188. data/app/assets/javascripts/spotlight/admin/block_mixins/plustextable.js +0 -57
  189. data/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +0 -87
  190. data/app/assets/javascripts/spotlight/admin/blocks/browse_group_categories_block.js +0 -88
  191. data/app/assets/javascripts/spotlight/admin/blocks/oembed_block.js +0 -40
  192. data/app/assets/javascripts/spotlight/admin/blocks/uploaded_items_block.js +0 -145
  193. data/app/assets/javascripts/spotlight/admin/catalog_edit.js +0 -16
  194. data/app/assets/javascripts/spotlight/admin/copy_email_addresses.js +0 -9
  195. data/app/assets/javascripts/spotlight/admin/croppable.js +0 -25
  196. data/app/assets/javascripts/spotlight/admin/exhibit_tag_autocomplete.js +0 -37
  197. data/app/assets/javascripts/spotlight/admin/exhibits.js +0 -58
  198. data/app/assets/javascripts/spotlight/admin/index.js +0 -16
  199. data/app/assets/javascripts/spotlight/admin/locks.js +0 -12
  200. data/app/assets/javascripts/spotlight/admin/pages.js.erb +0 -40
  201. data/app/assets/javascripts/spotlight/admin/readonly_checkbox.js +0 -6
  202. data/app/assets/javascripts/spotlight/admin/tabs.js +0 -6
  203. data/app/assets/javascripts/spotlight/user/carousel.js +0 -3
  204. data/app/assets/javascripts/spotlight/user/index.js +0 -8
  205. data/app/assets/javascripts/spotlight/user/zpr_links.js.erb +0 -45
  206. data/vendor/assets/javascripts/MutationObserver.js +0 -625
  207. data/vendor/assets/javascripts/eventable.js +0 -205
  208. data/vendor/assets/javascripts/polyfill.min.js +0 -4
  209. /data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_embed_block.js +0 -0
  210. /data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_features_block.js +0 -0
  211. /data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_grid_block.js +0 -0
  212. /data/app/{assets/javascripts/spotlight/admin/iiif.es6 → javascript/spotlight/admin/iiif.js} +0 -0
  213. /data/app/{assets/javascripts → javascript}/spotlight/admin/sir-trevor/locales.js +0 -0
@@ -0,0 +1,75 @@
1
+ /*
2
+ NOTE: this is copied & adapted from BL8's checkbox_submit.js in order to have
3
+ it accessible in a BL7-based spotlight. Once we drop support for BL7, this file
4
+ can be deleted and we can change visibility_toggle.es6 to import CheckboxSubmit
5
+ from Blacklight.
6
+
7
+ See https://github.com/projectblacklight/blacklight/blob/main/app/javascript/blacklight/checkbox_submit.js
8
+ */
9
+ export default class CheckboxSubmit {
10
+ constructor(form) {
11
+ this.form = form
12
+ }
13
+
14
+ async clicked(evt) {
15
+ this.spanTarget.innerHTML = this.form.getAttribute('data-inprogress')
16
+ this.labelTarget.setAttribute('disabled', 'disabled');
17
+ this.checkboxTarget.setAttribute('disabled', 'disabled');
18
+ const csrfMeta = document.querySelector('meta[name=csrf-token]')
19
+ const response = await fetch(this.formTarget.getAttribute('action'), {
20
+ body: new FormData(this.formTarget),
21
+ method: this.formTarget.getAttribute('method').toUpperCase(),
22
+ headers: {
23
+ 'Accept': 'application/json',
24
+ 'X-Requested-With': 'XMLHttpRequest',
25
+ 'X-CSRF-Token': csrfMeta ? csrfMeta.content : ''
26
+ }
27
+ })
28
+ this.labelTarget.removeAttribute('disabled')
29
+ this.checkboxTarget.removeAttribute('disabled')
30
+ if (response.ok) {
31
+ this.updateStateFor(!this.checked)
32
+ // Not used for our case in Spotlight (visibility toggle)
33
+ // const json = await response.json()
34
+ // document.querySelector('[data-role=bookmark-counter]').innerHTML = json.bookmarks.count
35
+ } else {
36
+ alert('Error')
37
+ }
38
+ }
39
+
40
+ get checked() {
41
+ return (this.form.querySelectorAll('input[name=_method][value=delete]').length != 0)
42
+ }
43
+
44
+ get formTarget() {
45
+ return this.form
46
+ }
47
+
48
+ get labelTarget() {
49
+ return this.form.querySelector('[data-checkboxsubmit-target="label"]')
50
+ }
51
+
52
+ get checkboxTarget() {
53
+ return this.form.querySelector('[data-checkboxsubmit-target="checkbox"]')
54
+ }
55
+
56
+ get spanTarget() {
57
+ return this.form.querySelector('[data-checkboxsubmit-target="span"]')
58
+ }
59
+
60
+ updateStateFor(state) {
61
+ this.checkboxTarget.checked = state
62
+
63
+ if (state) {
64
+ this.labelTarget.classList.add('checked')
65
+ //Set the Rails hidden field that fakes an HTTP verb
66
+ //properly for current state action.
67
+ this.formTarget.querySelector('input[name=_method]').value = 'delete'
68
+ this.spanTarget.innerHTML = this.form.getAttribute('data-present')
69
+ } else {
70
+ this.labelTarget.classList.remove('checked')
71
+ this.formTarget.querySelector('input[name=_method]').value = 'put'
72
+ this.spanTarget.innerHTML = this.form.getAttribute('data-absent')
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,5 @@
1
+ export default class {
2
+ connect() {
3
+ new Clipboard('.copy-email-addresses');
4
+ }
5
+ }
@@ -1,3 +1,6 @@
1
+ import { addImageSelector } from 'add_image_selector'
2
+ import Spotlight from 'spotlight'
3
+
1
4
  export default class Crop {
2
5
  constructor(cropArea) {
3
6
  this.cropArea = cropArea;
@@ -226,7 +229,7 @@ export default class Crop {
226
229
 
227
230
  var input = $('[data-behavior="autocomplete"]', this.cropTool);
228
231
  var panel = $(input.data('target-panel'));
229
- // This is defined in search_typeahead.js
232
+
230
233
  addImageSelector(input, panel, this.iiifManifestField.val(), !this.iiifImageField.val());
231
234
  }
232
235
 
@@ -251,8 +254,6 @@ export default class Crop {
251
254
  }
252
255
 
253
256
  uploadFile() {
254
- // Set a ujs adapter to support both rails-ujs and jquery-ujs
255
- var ujs = typeof Rails === 'undefined' ? $.rails : Rails;
256
257
  var url = this.fileInput.data('endpoint')
257
258
  // Every post creates a new image/masthead.
258
259
  // Because they create IIIF urls which are heavily cached.
@@ -264,7 +265,7 @@ export default class Crop {
264
265
  // Form data
265
266
  data: this.getData(),
266
267
  headers: {
267
- 'X-CSRF-Token': ujs.csrfToken() || ''
268
+ 'X-CSRF-Token': Spotlight.csrfToken() || ''
268
269
  },
269
270
  //Options to tell jQuery not to process data or worry about content-type.
270
271
  cache: false,
@@ -0,0 +1,10 @@
1
+ import Crop from 'crop';
2
+
3
+ export default class {
4
+ connect() {
5
+ $('[data-behavior="iiif-cropper"]').each(function() {
6
+ var cropElement = $(this)
7
+ new Crop(cropElement).render()
8
+ })
9
+ }
10
+ }
@@ -1,14 +1,9 @@
1
- Spotlight.onLoad(function() {
2
- $('[data-in-place-edit-target]').spotlightEditInPlace();
3
- });
4
1
  /*
5
2
  Simple plugin add edit-in-place behavior
6
3
  */
7
- (function($) {
8
- $.fn.spotlightEditInPlace = function() {
9
- var clickElements = this;
10
-
11
- $(clickElements).each(function() {
4
+ export default class {
5
+ connect() {
6
+ $('[data-in-place-edit-target]').each(function() {
12
7
  $(this).on('click.inplaceedit', function() {
13
8
  var $label = $(this).find($(this).data('in-place-edit-target'));
14
9
  var $input = $(this).find($(this).data('in-place-edit-field-target'));
@@ -47,8 +42,6 @@ Spotlight.onLoad(function() {
47
42
 
48
43
  return false;
49
44
  });
50
- });
51
-
52
- return this;
53
- };
54
- })(jQuery);
45
+ })
46
+ }
47
+ }
@@ -0,0 +1,39 @@
1
+ export default class {
2
+ connect() {
3
+ $('[data-autocomplete-tag="true"]').each(function(_i, el) {
4
+ var $el = $(el);
5
+ // By default tags input binds on page ready to [data-role=tagsinput],
6
+ // however, that doesn't work with Turbolinks. So we init manually:
7
+ $el.tagsinput();
8
+
9
+ var tags = new Bloodhound({
10
+ datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.name); },
11
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
12
+ limit: 100,
13
+ prefetch: {
14
+ url: $el.data('autocomplete-url'),
15
+ ttl: 1,
16
+ filter: function(list) {
17
+ // Let the dom know that the response has been returned
18
+ $el.attr('data-autocomplete-fetched', true);
19
+ return $.map(list, function(tag) { return { name: tag }; });
20
+ }
21
+ }
22
+ });
23
+
24
+ tags.initialize();
25
+
26
+ $el.tagsinput('input').typeahead({highlight: true, hint: false}, {
27
+ name: 'tags',
28
+ displayKey: 'name',
29
+ source: tags.ttAdapter()
30
+ }).bind('typeahead:selected', $.proxy(function (obj, datum) {
31
+ $el.tagsinput('add', datum.name);
32
+ $el.tagsinput('input').typeahead('val', '');
33
+ })).bind('blur', function() {
34
+ $el.tagsinput('add', $el.tagsinput('input').typeahead('val'));
35
+ $el.tagsinput('input').typeahead('val', '');
36
+ })
37
+ })
38
+ }
39
+ }
@@ -0,0 +1,59 @@
1
+ export default class {
2
+ connect() {
3
+ // auto-fill the exhibit slug on the new exhibit form
4
+ $('#new_exhibit').each(function() {
5
+ $('#exhibit_title').on('change keyup', function() {
6
+ $('#exhibit_slug').attr('placeholder', URLify($(this).val(), $(this).val().length));
7
+ });
8
+
9
+ $('#exhibit_slug').on('focus', function() {
10
+ if ($(this).val() === '') {
11
+ $(this).val($(this).attr('placeholder'));
12
+ }
13
+ });
14
+ });
15
+
16
+ $("#another-email").on("click", function(e) {
17
+ e.preventDefault();
18
+
19
+ var container = $(this).closest('.form-group');
20
+ var contacts = container.find('.contact');
21
+ var inputContainer = contacts.first().clone();
22
+
23
+ // wipe out any values from the inputs
24
+ inputContainer.find('input').each(function() {
25
+ $(this).val('');
26
+ $(this).attr('id', $(this).attr('id').replace('0', contacts.length));
27
+ $(this).attr('name', $(this).attr('name').replace('0', contacts.length));
28
+ if ($(this).attr('aria-label')) {
29
+ $(this).attr('aria-label', $(this).attr('aria-label').replace('1', contacts.length + 1));
30
+ }
31
+ });
32
+
33
+ inputContainer.find('.contact-email-delete-wrapper').remove();
34
+ inputContainer.find('.confirmation-status').remove();
35
+
36
+ // bootstrap does not render input-groups with only one value in them correctly.
37
+ inputContainer.find('.input-group input:only-child').closest('.input-group').removeClass('input-group');
38
+
39
+ $(inputContainer).insertAfter(contacts.last());
40
+ });
41
+
42
+ $('.contact-email-delete').on('ajax:success', function() {
43
+ $(this).closest('.contact').fadeOut(250, function() { $(this).remove(); });
44
+ });
45
+
46
+ $('.contact-email-delete').on('ajax:error', function(event, _xhr, _status, error) {
47
+ var errSpan = $(this).closest('.contact').find('.contact-email-delete-error');
48
+ errSpan.show();
49
+ errSpan.find('.error-msg').first().text(error || event.detail[1]);
50
+ });
51
+
52
+ $('.btn-with-tooltip').tooltip();
53
+
54
+ // Put focus in saved search title input when Save this search modal is shown
55
+ $('#save-modal').on('shown.bs.modal', function () {
56
+ $('#search_title').focus();
57
+ });
58
+ }
59
+ }
@@ -1,24 +1,3 @@
1
- Spotlight.onLoad(function() {
2
- // Instantiate the singleton SerializedForm plugin
3
- var serializedForm = $.SerializedForm();
4
- $(window).on('beforeunload page:before-change turbolinks:before-visit', function(event) {
5
- // Don't handle the same event twice #turbolinks
6
- if (event.handled !== true) {
7
- if ( serializedForm.observedFormsStatusHasChanged() ) {
8
- event.handled = true;
9
- var message = "You have unsaved changes. Are you sure you want to leave this page?";
10
- // There are variations in how Webkit browsers may handle this:
11
- // https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload
12
- if ( event.type == "beforeunload" ) {
13
- return message;
14
- }else{
15
-
16
- return confirm(message)
17
- }
18
- }
19
- }
20
- });
21
- });
22
1
 
23
2
  (function($, undefined) {
24
3
  'use strict';
@@ -84,3 +63,26 @@ Spotlight.onLoad(function() {
84
63
  return plugin;
85
64
  };
86
65
  })(jQuery);
66
+
67
+ export default class {
68
+ connect() {
69
+ // Instantiate the singleton SerializedForm plugin
70
+ var serializedForm = $.SerializedForm();
71
+ $(window).on('beforeunload page:before-change turbolinks:before-visit', function(event) {
72
+ // Don't handle the same event twice #turbolinks
73
+ if (event.handled !== true) {
74
+ if ( serializedForm.observedFormsStatusHasChanged() ) {
75
+ event.handled = true;
76
+ var message = "You have unsaved changes. Are you sure you want to leave this page?";
77
+ // There are variations in how Webkit browsers may handle this:
78
+ // https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload
79
+ if ( event.type == "beforeunload" ) {
80
+ return message;
81
+ } else {
82
+ return confirm(message)
83
+ }
84
+ }
85
+ }
86
+ });
87
+ }
88
+ }
@@ -0,0 +1,85 @@
1
+ // import '../../../../vendor/assets/javascripts/sir-trevor'
2
+ import '../../../../vendor/assets/javascripts/nestable'
3
+ import '../../../../vendor/assets/javascripts/parameterize'
4
+ import '../../../../vendor/assets/javascripts/bootstrap-tagsinput'
5
+ import '../../../../vendor/assets/javascripts/jquery.serializejson'
6
+ // import '../../../../vendor/assets/javascripts/clipboard'
7
+ // import '../../../../vendor/assets/javascripts/leaflet'
8
+ import '../../../../vendor/assets/javascripts/leaflet-iiif'
9
+ import '../../../../vendor/assets/javascripts/Leaflet.Editable'
10
+ import '../../../../vendor/assets/javascripts/Path.Drag'
11
+
12
+ import AddAnother from 'add_another'
13
+ import AddNewButton from 'add_new_button'
14
+ import Appearance from 'appearance'
15
+ import BlacklightConfiguration from 'blacklight_configuration'
16
+ import CopyEmailAddress from 'copy_email_addresses'
17
+ import Croppable from 'croppable'
18
+ import EditInPlace from 'edit_in_place'
19
+ import ExhibitTagAutocomplete from 'exhibit_tag_autocomplete'
20
+ import Exhibits from 'exhibits'
21
+ import FormObserver from 'form_observer'
22
+ import Locks from 'locks'
23
+ import 'multi_image_selector'
24
+ import Pages from 'pages'
25
+ import ProgressMonitor from 'progress_monitor'
26
+ import ReadonlyCheckbox from 'readonly_checkbox'
27
+ import { addAutocompletetoFeaturedImage } from 'search_typeahead'
28
+ import SelectRelatedInput from 'select_related_input'
29
+ import SpotlightNestable from 'spotlight_nestable'
30
+ import Tabs from 'tabs'
31
+ import TranslationProgress from 'translation_progress'
32
+ import 'visibility_toggle'
33
+ import Users from 'users'
34
+
35
+ import 'block_mixins/autocompleteable'
36
+ import 'block_mixins/formable'
37
+ import 'block_mixins/plustextable'
38
+
39
+ import 'blocks/block'
40
+ import 'blocks/resources_block' // This is a base class of several other blocks, so must come first
41
+ import 'blocks/browse_block'
42
+ import 'blocks/browse_group_categories_block'
43
+ import 'blocks/iframe_block'
44
+ import 'blocks/link_to_search_block'
45
+ import 'blocks/oembed_block'
46
+ import 'blocks/pages_block'
47
+ import 'blocks/rule_block'
48
+ import 'blocks/search_result_block'
49
+ import 'blocks/solr_documents_base_block'
50
+ import 'blocks/solr_documents_block'
51
+ import 'blocks/solr_documents_carousel_block'
52
+ import 'blocks/solr_documents_embed_block'
53
+ import 'blocks/solr_documents_features_block'
54
+ import 'blocks/solr_documents_grid_block'
55
+ import 'blocks/uploaded_items_block'
56
+
57
+ import 'sir-trevor/block_controls'
58
+ import 'sir-trevor/block_limits'
59
+ import 'sir-trevor/locales'
60
+
61
+
62
+ export default class {
63
+ connect() {
64
+ new AddAnother().connect()
65
+ new AddNewButton().connect()
66
+ new Appearance().connect()
67
+ new CopyEmailAddress().connect()
68
+ new Croppable().connect()
69
+ new EditInPlace().connect()
70
+ new ExhibitTagAutocomplete().connect()
71
+ new Exhibits().connect()
72
+ new FormObserver().connect()
73
+ new Locks().connect()
74
+ new BlacklightConfiguration().connect()
75
+ new Pages().connect()
76
+ new ProgressMonitor().connect()
77
+ new ReadonlyCheckbox().connect()
78
+ new SelectRelatedInput().connect()
79
+ new Tabs().connect()
80
+ new TranslationProgress().connect()
81
+ new Users().connect()
82
+ addAutocompletetoFeaturedImage()
83
+ SpotlightNestable.init();
84
+ }
85
+ }
@@ -0,0 +1,12 @@
1
+ export default class {
2
+ delete_lock(el) {
3
+ $.ajax({ url: $(el).data('lock'), type: 'POST', data: { _method: "delete" }, async: false});
4
+ $(el).removeAttr('data-lock');
5
+ }
6
+
7
+ connect() {
8
+ $('[data-lock]').on('click', (e) => {
9
+ this.delete_lock(e.target);
10
+ })
11
+ }
12
+ }
@@ -36,7 +36,8 @@
36
36
  }
37
37
 
38
38
  function indexOf(thumb){
39
- if( (index = imageIds.indexOf(thumb)) > -1 ){
39
+ const index = imageIds.indexOf(thumb)
40
+ if (index > -1) {
40
41
  return index + 1;
41
42
  } else {
42
43
  return 1;
@@ -0,0 +1,42 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
3
+ import Spotlight from 'spotlight'
4
+
5
+ export default class {
6
+ connect(){
7
+ SirTrevor.setDefaults({
8
+ iconUrl: Spotlight.sirTrevorIcon,
9
+ uploadUrl: $('[data-attachment-endpoint]').data('attachment-endpoint'),
10
+ ajaxOptions: {
11
+ headers: {
12
+ 'X-CSRF-Token': Spotlight.csrfToken() || ''
13
+ },
14
+ credentials: 'same-origin'
15
+ }
16
+ });
17
+
18
+ SirTrevor.Blocks.Heading.prototype.toolbarEnabled = true;
19
+ SirTrevor.Blocks.Quote.prototype.toolbarEnabled = true;
20
+ SirTrevor.Blocks.Text.prototype.toolbarEnabled = true;
21
+
22
+ var instance = $('.js-st-instance').first();
23
+
24
+ if (instance.length) {
25
+ var editor = new SirTrevor.Editor({
26
+ el: instance[0],
27
+ blockTypes: instance.data('blockTypes'),
28
+ defaultType:["Text"],
29
+ onEditorRender: function() {
30
+ $.SerializedForm();
31
+ },
32
+ blockTypeLimits: {
33
+ "SearchResults": 1
34
+ }
35
+ });
36
+
37
+ editor.blockControls = Spotlight.BlockControls.create(editor);
38
+
39
+ new Spotlight.BlockLimits(editor).enforceLimits(editor);
40
+ }
41
+ }
42
+ }
@@ -1,10 +1,6 @@
1
- Spotlight.onLoad(function() {
2
- $('[data-behavior="progress-panel"]').progressMonitor();
3
- });
4
-
5
- (function($) {
6
- $.fn.progressMonitor = function() {
7
- var monitorElements = this;
1
+ export default class {
2
+ connect() {
3
+ var monitorElements = $('[data-behavior="progress-panel"]');
8
4
  var defaultRefreshRate = 3000;
9
5
  var panelContainer;
10
6
  var pollers = [];
@@ -144,5 +140,5 @@ Spotlight.onLoad(function() {
144
140
  }
145
141
 
146
142
  return this;
147
- };
148
- })(jQuery);
143
+ }
144
+ }
@@ -0,0 +1,8 @@
1
+ export default class {
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();
6
+ })
7
+ }
8
+ }
@@ -1,5 +1,4 @@
1
- //= require typeahead.bundle.min.js
2
- //= require handlebars
1
+ import { addImageSelector } from 'add_image_selector'
3
2
 
4
3
  (function($){
5
4
  $.fn.spotlightSearchTypeAhead = function( options ) {
@@ -52,7 +51,7 @@ function itemsTemplate() {
52
51
  return '<div class="autocomplete-item{{#if private}} blacklight-private{{/if}}">{{#if thumbnail}}<div class="document-thumbnail"><img class="img-thumbnail" src="{{thumbnail}}" /></div>{{/if}}<span class="autocomplete-title">{{title}}</span><br/><small>&nbsp;&nbsp;{{description}}</small></div>';
53
52
  }
54
53
 
55
- function addAutocompletetoFeaturedImage(){
54
+ export function addAutocompletetoFeaturedImage(){
56
55
  if($('[data-featured-image-typeahead]').length > 0) {
57
56
  $('[data-featured-image-typeahead]').spotlightSearchTypeAhead({bloodhound: itemsBloodhound(), template: itemsTemplate()}).on('click', function() {
58
57
  $(this).select();
@@ -63,46 +62,4 @@ function addAutocompletetoFeaturedImage(){
63
62
  $(this).attr('type', 'text');
64
63
  });
65
64
  }
66
- }
67
-
68
- function addImageSelector(input, panel, manifestUrl, initialize) {
69
- if (!manifestUrl) {
70
- showNonIiifAlert(input);
71
- return;
72
- }
73
- var cropper = input.data('iiifCropper');
74
- $.ajax(manifestUrl).done(
75
- function(manifest) {
76
- var Iiif = spotlightAdminIiif;
77
- var iiifManifest = new Iiif(manifestUrl, manifest);
78
-
79
- var thumbs = iiifManifest.imagesArray();
80
-
81
- hideNonIiifAlert(input);
82
-
83
- if (initialize) {
84
- cropper.setIiifFields(thumbs[0]);
85
- panel.multiImageSelector(); // Clears out existing selector
86
- }
87
-
88
- if(thumbs.length > 1) {
89
- panel.show();
90
- panel.multiImageSelector(thumbs, function(selectorImage) {
91
- cropper.setIiifFields(selectorImage);
92
- }, cropper.iiifImageField.val());
93
- }
94
- }
95
- );
96
- }
97
-
98
- function showNonIiifAlert(input){
99
- input.parent().prev('[data-behavior="non-iiif-alert"]').show();
100
- }
101
-
102
- function hideNonIiifAlert(input){
103
- input.parent().prev('[data-behavior="non-iiif-alert"]').hide();
104
- }
105
-
106
- Spotlight.onLoad(function(){
107
- addAutocompletetoFeaturedImage();
108
- });
65
+ }
@@ -1,6 +1,3 @@
1
- Spotlight.onLoad(function() {
2
- $('[data-input-select-target]').selectRelatedInput();
3
- });
4
1
  /*
5
2
  Simple plugin to select form elements
6
3
  when other elements are clicked.
@@ -32,3 +29,9 @@ Spotlight.onLoad(function() {
32
29
  return this;
33
30
  };
34
31
  })(jQuery);
32
+
33
+ export default class {
34
+ connect() {
35
+ $('[data-input-select-target]').selectRelatedInput();
36
+ }
37
+ }
@@ -1,4 +1,6 @@
1
- (function(global) {
1
+ import Spotlight from 'spotlight'
2
+
3
+ (function() {
2
4
  var BLOCK_REPLACER_CONTROL_TEMPLATE = function(block) {
3
5
  var el = document.createElement('button');
4
6
  el.className = "st-block-controls__button";
@@ -75,8 +77,8 @@
75
77
  return elButtons;
76
78
  }
77
79
 
78
- global.Spotlight.BlockControls = function() { };
79
- global.Spotlight.BlockControls.create = function(editor) {
80
+ Spotlight.BlockControls = function() { };
81
+ Spotlight.BlockControls.create = function(editor) {
80
82
  // REFACTOR - should probably not know about blockManager
81
83
  var el = render(SirTrevor.Blocks, editor.blockManager.blockTypes);
82
84
 
@@ -117,4 +119,4 @@
117
119
  destroy: destroy
118
120
  };
119
121
  };
120
- })(this);
122
+ })();
@@ -1,3 +1,5 @@
1
+ import Spotlight from 'spotlight'
2
+
1
3
  Spotlight.BlockLimits = function(editor) {
2
4
  this.editor = editor;
3
5
  };
@@ -1,6 +1,4 @@
1
-
2
- (function( global ) {
3
- var Module = (function() {
1
+ const Module = (function() {
4
2
  var nestableSelector = '[data-behavior="nestable"]';
5
3
  return {
6
4
  init: function(selector){
@@ -23,7 +21,7 @@
23
21
  var weight = 0;
24
22
  for(var i in data){
25
23
  var parent_id = data[i]['id'];
26
- parent_node = findNode(parent_id, container);
24
+ const parent_node = findNode(parent_id, container);
27
25
  setWeight(parent_node, weight++);
28
26
  if(data[i]['children']){
29
27
  var children = data[i]['children'];
@@ -65,8 +63,6 @@
65
63
  function find_property(node, property) {
66
64
  return node.find("input[data-property=" + property + "]");
67
65
  }
68
- })();
69
-
70
- global.SpotlightNestable = Module;
66
+ })();
71
67
 
72
- })( this );
68
+ export default Module
@@ -0,0 +1,8 @@
1
+ export default class {
2
+ connect() {
3
+ if ($('[role=tabpanel]').length > 0 && window.location.hash) {
4
+ var tabpanel = $(window.location.hash).closest('[role=tabpanel]');
5
+ $('a[role=tab][href="#'+tabpanel.attr('id')+'"]').tab('show');
6
+ }
7
+ }
8
+ }