spotlight-frontend 3.5.0-beta.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 (153) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +114 -0
  3. package/app/assets/images/blacklight/arrow-alt-circle-left.svg +1 -0
  4. package/app/assets/images/blacklight/arrow-alt-circle-right.svg +1 -0
  5. package/app/assets/images/blacklight/arrow_back_ios.svg +1 -0
  6. package/app/assets/images/blacklight/arrow_forward_ios.svg +1 -0
  7. package/app/assets/images/blacklight/check.svg +1 -0
  8. package/app/assets/images/blacklight/check_circle.svg +1 -0
  9. package/app/assets/images/blacklight/chevron_right.svg +1 -0
  10. package/app/assets/images/blacklight/close.svg +1 -0
  11. package/app/assets/images/blacklight/edit.svg +1 -0
  12. package/app/assets/images/blacklight/error.svg +1 -0
  13. package/app/assets/images/blacklight/highlight_off.svg +1 -0
  14. package/app/assets/images/blacklight/info.svg +1 -0
  15. package/app/assets/images/blacklight/warning.svg +1 -0
  16. package/app/assets/images/blacklight/zoom_in.svg +1 -0
  17. package/app/assets/images/blacklight/zoom_out.svg +1 -0
  18. package/app/assets/images/spotlight/.keep +0 -0
  19. package/app/assets/images/spotlight/blocks/sir-trevor-icons.svg +320 -0
  20. package/app/assets/images/spotlight/default_browse_thumbnail.jpg +0 -0
  21. package/app/assets/images/spotlight/default_thumbnail.jpg +0 -0
  22. package/app/assets/images/spotlight/fallback/default.png +0 -0
  23. package/app/assets/javascripts/spotlight/admin/add_another.js +22 -0
  24. package/app/assets/javascripts/spotlight/admin/add_new_button.js +81 -0
  25. package/app/assets/javascripts/spotlight/admin/appearance.js +24 -0
  26. package/app/assets/javascripts/spotlight/admin/attachments.js +2 -0
  27. package/app/assets/javascripts/spotlight/admin/blacklight_configuration.js +63 -0
  28. package/app/assets/javascripts/spotlight/admin/block_mixins/autocompleteable.js +72 -0
  29. package/app/assets/javascripts/spotlight/admin/block_mixins/formable.js +78 -0
  30. package/app/assets/javascripts/spotlight/admin/block_mixins/plustextable.js +57 -0
  31. package/app/assets/javascripts/spotlight/admin/blocks/block.js +23 -0
  32. package/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +87 -0
  33. package/app/assets/javascripts/spotlight/admin/blocks/browse_group_categories_block.js +88 -0
  34. package/app/assets/javascripts/spotlight/admin/blocks/iframe_block.js +34 -0
  35. package/app/assets/javascripts/spotlight/admin/blocks/link_to_search_block.js +16 -0
  36. package/app/assets/javascripts/spotlight/admin/blocks/oembed_block.js +40 -0
  37. package/app/assets/javascripts/spotlight/admin/blocks/pages_block.js +22 -0
  38. package/app/assets/javascripts/spotlight/admin/blocks/resources_block.js +145 -0
  39. package/app/assets/javascripts/spotlight/admin/blocks/rule_block.js +25 -0
  40. package/app/assets/javascripts/spotlight/admin/blocks/search_result_block.js +44 -0
  41. package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_base_block.js +108 -0
  42. package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_block.js +25 -0
  43. package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_carousel_block.js +103 -0
  44. package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_embed_block.js +17 -0
  45. package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_features_block.js +41 -0
  46. package/app/assets/javascripts/spotlight/admin/blocks/solr_documents_grid_block.js +14 -0
  47. package/app/assets/javascripts/spotlight/admin/blocks/uploaded_items_block.js +145 -0
  48. package/app/assets/javascripts/spotlight/admin/catalog_edit.js +16 -0
  49. package/app/assets/javascripts/spotlight/admin/copy_email_addresses.js +9 -0
  50. package/app/assets/javascripts/spotlight/admin/crop.es6 +310 -0
  51. package/app/assets/javascripts/spotlight/admin/croppable.js +25 -0
  52. package/app/assets/javascripts/spotlight/admin/edit_in_place.js +54 -0
  53. package/app/assets/javascripts/spotlight/admin/exhibit_tag_autocomplete.js +37 -0
  54. package/app/assets/javascripts/spotlight/admin/exhibits.js +58 -0
  55. package/app/assets/javascripts/spotlight/admin/form_observer.js +86 -0
  56. package/app/assets/javascripts/spotlight/admin/iiif.es6 +54 -0
  57. package/app/assets/javascripts/spotlight/admin/index.js +16 -0
  58. package/app/assets/javascripts/spotlight/admin/locks.js +12 -0
  59. package/app/assets/javascripts/spotlight/admin/multi_image_selector.js +158 -0
  60. package/app/assets/javascripts/spotlight/admin/pages.js.erb +40 -0
  61. package/app/assets/javascripts/spotlight/admin/progress_monitor.js +148 -0
  62. package/app/assets/javascripts/spotlight/admin/readonly_checkbox.js +6 -0
  63. package/app/assets/javascripts/spotlight/admin/search_typeahead.js +108 -0
  64. package/app/assets/javascripts/spotlight/admin/select_related_input.js +34 -0
  65. package/app/assets/javascripts/spotlight/admin/sir-trevor/block_controls.js +120 -0
  66. package/app/assets/javascripts/spotlight/admin/sir-trevor/block_limits.js +37 -0
  67. package/app/assets/javascripts/spotlight/admin/sir-trevor/locales.js +120 -0
  68. package/app/assets/javascripts/spotlight/admin/spotlight_nestable.js +72 -0
  69. package/app/assets/javascripts/spotlight/admin/tabs.js +6 -0
  70. package/app/assets/javascripts/spotlight/admin/translation_progress.js +23 -0
  71. package/app/assets/javascripts/spotlight/admin/users.js +79 -0
  72. package/app/assets/javascripts/spotlight/application.js +14 -0
  73. package/app/assets/javascripts/spotlight/spotlight.js +23 -0
  74. package/app/assets/javascripts/spotlight/user/analytics.js +9 -0
  75. package/app/assets/javascripts/spotlight/user/browse_group_categories.js +59 -0
  76. package/app/assets/javascripts/spotlight/user/carousel.js +3 -0
  77. package/app/assets/javascripts/spotlight/user/clear_form_button.js +27 -0
  78. package/app/assets/javascripts/spotlight/user/index.js +8 -0
  79. package/app/assets/javascripts/spotlight/user/report_a_problem.js +39 -0
  80. package/app/assets/javascripts/spotlight/user/zpr_links.js.erb +45 -0
  81. package/app/assets/stylesheets/spotlight/_accessibility.scss +8 -0
  82. package/app/assets/stylesheets/spotlight/_attachments.css +4 -0
  83. package/app/assets/stylesheets/spotlight/_blacklight_configuration.scss +82 -0
  84. package/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +21 -0
  85. package/app/assets/stylesheets/spotlight/_bootstrap_overrides.scss +105 -0
  86. package/app/assets/stylesheets/spotlight/_breadcrumbs.scss +6 -0
  87. package/app/assets/stylesheets/spotlight/_browse.scss +158 -0
  88. package/app/assets/stylesheets/spotlight/_catalog.scss +161 -0
  89. package/app/assets/stylesheets/spotlight/_collapse_toggle.scss +14 -0
  90. package/app/assets/stylesheets/spotlight/_croppable.scss +4 -0
  91. package/app/assets/stylesheets/spotlight/_curation.scss +224 -0
  92. package/app/assets/stylesheets/spotlight/_edit_in_place.scss +9 -0
  93. package/app/assets/stylesheets/spotlight/_exhibit_admin.scss +81 -0
  94. package/app/assets/stylesheets/spotlight/_exhibit_navbar.scss +10 -0
  95. package/app/assets/stylesheets/spotlight/_exhibits_index.scss +147 -0
  96. package/app/assets/stylesheets/spotlight/_featured_browse_categories_block.scss +269 -0
  97. package/app/assets/stylesheets/spotlight/_footer.scss +12 -0
  98. package/app/assets/stylesheets/spotlight/_header.scss +155 -0
  99. package/app/assets/stylesheets/spotlight/_item_text_block.scss +50 -0
  100. package/app/assets/stylesheets/spotlight/_mixins.scss +17 -0
  101. package/app/assets/stylesheets/spotlight/_modals.scss +3 -0
  102. package/app/assets/stylesheets/spotlight/_multi_image_selector.scss +22 -0
  103. package/app/assets/stylesheets/spotlight/_multi_up_item_grid.scss +63 -0
  104. package/app/assets/stylesheets/spotlight/_nestable.scss +124 -0
  105. package/app/assets/stylesheets/spotlight/_pages.scss +282 -0
  106. package/app/assets/stylesheets/spotlight/_report_a_problem.scss +14 -0
  107. package/app/assets/stylesheets/spotlight/_sir-trevor_overrides.scss +87 -0
  108. package/app/assets/stylesheets/spotlight/_slideshow_block.scss +87 -0
  109. package/app/assets/stylesheets/spotlight/_spotlight.scss +49 -0
  110. package/app/assets/stylesheets/spotlight/_translations.scss +86 -0
  111. package/app/assets/stylesheets/spotlight/_upload.scss +0 -0
  112. package/app/assets/stylesheets/spotlight/_uploaded_items_block.scss +7 -0
  113. package/app/assets/stylesheets/spotlight/_utilities.scss +7 -0
  114. package/app/assets/stylesheets/spotlight/_variables.scss +42 -0
  115. package/app/assets/stylesheets/spotlight/_variables_bootstrap.scss +7 -0
  116. package/app/assets/stylesheets/spotlight/_view_larger.scss +22 -0
  117. package/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +92 -0
  118. package/app/assets/stylesheets/spotlight/typeahead.css +77 -0
  119. package/package.json +29 -0
  120. package/vendor/assets/images/sir-trevor-icons.svg +263 -0
  121. package/vendor/assets/javascripts/Leaflet.Editable.js +1917 -0
  122. package/vendor/assets/javascripts/MutationObserver.js +625 -0
  123. package/vendor/assets/javascripts/Path.Drag.js +137 -0
  124. package/vendor/assets/javascripts/bootstrap-tagsinput.js +530 -0
  125. package/vendor/assets/javascripts/eventable.js +205 -0
  126. package/vendor/assets/javascripts/jquery.serializejson.js +234 -0
  127. package/vendor/assets/javascripts/jquery.waitforimages.min.js +2 -0
  128. package/vendor/assets/javascripts/leaflet-iiif.js +323 -0
  129. package/vendor/assets/javascripts/nestable.js +645 -0
  130. package/vendor/assets/javascripts/parameterize.js +137 -0
  131. package/vendor/assets/javascripts/polyfill.min.js +4 -0
  132. package/vendor/assets/javascripts/sir-trevor.js +21639 -0
  133. package/vendor/assets/javascripts/tiny-slider.js +3218 -0
  134. package/vendor/assets/javascripts/typeahead.bundle.min.js +7 -0
  135. package/vendor/assets/stylesheets/bootstrap-tagsinput.css +46 -0
  136. package/vendor/assets/stylesheets/leaflet-areaselect.css +15 -0
  137. package/vendor/assets/stylesheets/sir-trevor/_icons.scss +6 -0
  138. package/vendor/assets/stylesheets/sir-trevor/_variables.scss +22 -0
  139. package/vendor/assets/stylesheets/sir-trevor/base.scss +17 -0
  140. package/vendor/assets/stylesheets/sir-trevor/block-addition-top.scss +95 -0
  141. package/vendor/assets/stylesheets/sir-trevor/block-addition.scss +72 -0
  142. package/vendor/assets/stylesheets/sir-trevor/block-controls.scss +34 -0
  143. package/vendor/assets/stylesheets/sir-trevor/block-positioner.scss +34 -0
  144. package/vendor/assets/stylesheets/sir-trevor/block-replacer.scss +43 -0
  145. package/vendor/assets/stylesheets/sir-trevor/block-ui.scss +120 -0
  146. package/vendor/assets/stylesheets/sir-trevor/block.scss +300 -0
  147. package/vendor/assets/stylesheets/sir-trevor/errors.scss +21 -0
  148. package/vendor/assets/stylesheets/sir-trevor/format-bar.scss +65 -0
  149. package/vendor/assets/stylesheets/sir-trevor/inputs.scss +45 -0
  150. package/vendor/assets/stylesheets/sir-trevor/main.scss +24 -0
  151. package/vendor/assets/stylesheets/sir-trevor/patterns/ui-popup.scss +38 -0
  152. package/vendor/assets/stylesheets/sir-trevor/utils.scss +10 -0
  153. package/vendor/assets/stylesheets/tiny-slider.css +1 -0
@@ -0,0 +1,86 @@
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
+
23
+ (function($, undefined) {
24
+ 'use strict';
25
+
26
+ /*
27
+ * SerializedForm is built as a singleton jQuery plugin. It needs to be able to
28
+ * handle instantiation from multiple sources, and use the [data-form-observer]
29
+ * as global state object.
30
+ */
31
+ $.SerializedForm = function () {
32
+ var $serializedForm;
33
+ var plugin = this;
34
+
35
+ // Store form serialization in data attribute
36
+ function serializeFormStatus () {
37
+ $serializedForm.data('serialized-form', formSerialization($serializedForm));
38
+ }
39
+
40
+ // Do custom serialization of the sir-trevor form data. This needs to be a
41
+ // passed in argument for comparison later on.
42
+ function formSerialization (form) {
43
+ var content_editable = [];
44
+ var i = 0;
45
+ $("[contenteditable='true']", form).each(function(){
46
+ content_editable.push('&contenteditable_' + i + '=' + $(this).text());
47
+ });
48
+ return form.serialize() + content_editable.join();
49
+ }
50
+
51
+ // Unbind observing form on submit (which we have to do because of turbolinks)
52
+ function unbindObservedFormSubmit () {
53
+ $serializedForm.on('submit', function () {
54
+ $(this).data('being-submitted', true);
55
+ });
56
+ }
57
+
58
+ // Get the stored serialized form status
59
+ function serializedFormStatus () {
60
+ return $serializedForm.data('serialized-form');
61
+ }
62
+
63
+ // Check all observed forms on page for status change
64
+ plugin.observedFormsStatusHasChanged = function () {
65
+ var unsaved_changes = false;
66
+ $('[data-form-observer]').each(function (){
67
+ if ( !$(this).data("being-submitted") ) {
68
+ if (serializedFormStatus() != formSerialization($(this))) {
69
+ unsaved_changes = true;
70
+ }
71
+ }
72
+ });
73
+ return unsaved_changes;
74
+ }
75
+
76
+ function init () {
77
+ $serializedForm = $('[data-form-observer]');
78
+ serializeFormStatus();
79
+ unbindObservedFormSubmit();
80
+ }
81
+
82
+ init();
83
+
84
+ return plugin;
85
+ };
86
+ })(jQuery);
@@ -0,0 +1,54 @@
1
+ export default class Iiif {
2
+ constructor(manifestUrl, manifest) {
3
+ this.manifestUrl = manifestUrl;
4
+ this.manifest = manifest;
5
+ }
6
+
7
+ sequences() {
8
+ var it = {};
9
+ var context = this;
10
+ it[Symbol.iterator] = function*() {
11
+ for (let sequence of context.manifest.sequences) {
12
+ yield sequence;
13
+ };
14
+ }
15
+ return it;
16
+ }
17
+
18
+ canvases() {
19
+ var it = {};
20
+ var context = this;
21
+ it[Symbol.iterator] = function*() {
22
+ for (let sequence of context.sequences()) {
23
+ for (let canvas of sequence.canvases) {
24
+ yield canvas;
25
+ }
26
+ }
27
+ }
28
+ return it;
29
+ }
30
+
31
+ images() {
32
+ var it = {};
33
+ var context = this;
34
+ it[Symbol.iterator] = function*() {
35
+ for (let canvas of context.canvases()) {
36
+ for (let image of canvas.images) {
37
+ var iiifService = image.resource.service['@id'];
38
+ yield {
39
+ 'thumb': iiifService + '/full/!100,100/0/default.jpg',
40
+ 'tilesource': iiifService + '/info.json',
41
+ 'manifest': context.manifestUrl,
42
+ 'canvasId': canvas['@id'],
43
+ 'imageId': image['@id']
44
+ };
45
+ }
46
+ }
47
+ }
48
+ return it;
49
+ }
50
+
51
+ imagesArray() {
52
+ return Array.from(this.images())
53
+ }
54
+ }
@@ -0,0 +1,16 @@
1
+ //= require underscore
2
+ //= require eventable
3
+ //= require sir-trevor
4
+ //= require nestable
5
+ //= require parameterize
6
+ //= require bootstrap-tagsinput
7
+ //= require jquery.serializejson
8
+ //= require clipboard
9
+ //= require leaflet
10
+ //= require leaflet-iiif
11
+ //= require Leaflet.Editable
12
+ //= require Path.Drag
13
+ //= require MutationObserver
14
+
15
+ //= require polyfill.min.js
16
+ //= require_tree .
@@ -0,0 +1,12 @@
1
+ Spotlight.onLoad(function(){
2
+
3
+
4
+ function delete_lock(el) {
5
+ $.ajax({ url: $(el).data('lock'), type: 'POST', data: { _method: "delete" }, async: false});
6
+ $(el).removeAttr('data-lock');
7
+ }
8
+
9
+ $('[data-lock]').on('click', function(e) {
10
+ delete_lock(this);
11
+ });
12
+ });
@@ -0,0 +1,158 @@
1
+ // Module to add multi-image selector to widget panels
2
+
3
+ (function(){
4
+ $.fn.multiImageSelector = function(image_versions, clickCallback, activeImageId) {
5
+ var changeLink = $("<a href='javascript:;'>Change</a>"),
6
+ thumbsListContainer = $("<div class='thumbs-list' style='display:none'></div>"),
7
+ thumbList = $("<ul></ul>"),
8
+ panel;
9
+
10
+ var imageIds = $.map(image_versions, function(e) { return e['imageId']; });
11
+
12
+ return init(this);
13
+
14
+ function init(el) {
15
+ panel = el;
16
+
17
+ destroyExistingImageSelector();
18
+ if(image_versions && image_versions.length > 1) {
19
+ addChangeLink();
20
+ addThumbsList();
21
+ }
22
+ }
23
+ function addChangeLink() {
24
+ $('[data-panel-image-pagination]', panel)
25
+ .html("Image <span data-current-image='true'>" + indexOf(activeImageId) + "</span> of " + image_versions.length)
26
+ .show()
27
+ .append(" ")
28
+ .append(changeLink);
29
+ addChangeLinkBehavior();
30
+ }
31
+
32
+ function destroyExistingImageSelector() {
33
+ var pagination = $('[data-panel-image-pagination]', panel);
34
+ pagination.html('');
35
+ pagination.next('.' + thumbsListContainer.attr('class')).remove();
36
+ }
37
+
38
+ function indexOf(thumb){
39
+ if( (index = imageIds.indexOf(thumb)) > -1 ){
40
+ return index + 1;
41
+ } else {
42
+ return 1;
43
+ }
44
+ }
45
+ function addChangeLinkBehavior() {
46
+ changeLink.on('click', function(){
47
+ thumbsListContainer.slideToggle();
48
+ updateThumbListWidth();
49
+ addScrollBehavior();
50
+ scrollToActiveThumb();
51
+ loadVisibleThumbs();
52
+ swapChangeLinkText($(this));
53
+ });
54
+ }
55
+ function updateThumbListWidth() {
56
+ var width = 0;
57
+ $('li', thumbList).each(function(){
58
+ width += $(this).outerWidth();
59
+ });
60
+ thumbList.width(width + 5);
61
+ }
62
+ function loadVisibleThumbs(){
63
+ var viewportWidth = thumbsListContainer.width();
64
+ var width = 0;
65
+ $('li', thumbList).each(function(){
66
+ var thisThumb = $(this),
67
+ image = $('img', thisThumb),
68
+ totalWidth = width += thisThumb.width();
69
+ position = (thumbList.position().left + totalWidth) - thisThumb.width();
70
+
71
+ if(position >= 0 && position < viewportWidth) {
72
+ image.prop('src', image.data('src'));
73
+ }
74
+ });
75
+ }
76
+ function addScrollBehavior(){
77
+ thumbsListContainer.scrollStop(function(){
78
+ loadVisibleThumbs();
79
+ });
80
+ }
81
+ function scrollToActiveThumb(){
82
+ var halfContainerWidth = (thumbsListContainer.width() / 2),
83
+ activeThumbLeftPosition = ($('.active', thumbList).position() || $('li', thumbList).first().position()).left,
84
+ halfActiveThumbWidth = ($('.active', thumbList).width() / 2);
85
+ thumbsListContainer.scrollLeft(
86
+ (activeThumbLeftPosition - halfContainerWidth) + halfActiveThumbWidth
87
+ );
88
+ }
89
+ function addThumbsList() {
90
+ addThumbsToList();
91
+ updateActiveThumb();
92
+ $('.card-header', panel).append(
93
+ thumbsListContainer.append(
94
+ thumbList
95
+ )
96
+ );
97
+ }
98
+ function updateActiveThumb(){
99
+ $('li', thumbList).each(function(){
100
+ var item = $(this);
101
+ if($('img', item).data('image-id') == activeImageId){
102
+ item.addClass('active');
103
+ }
104
+ });
105
+ }
106
+ function swapChangeLinkText(link){
107
+ link.text(
108
+ link.text() == 'Change' ? 'Close' : 'Change'
109
+ )
110
+ }
111
+
112
+ function addThumbsToList(){
113
+ $.each(image_versions, function(i){
114
+ var listItem = $('<li data-index="' + i + '"><a href="javascript:;"><img src="' + image_versions[i]['thumb'] +'" data-image-id="' + image_versions[i]['imageId'] +'" /></a></li>');
115
+ listItem.on('click', function(){
116
+ // get the current image id
117
+ var imageid = $('img', $(this)).data('image-id');
118
+ var src = $('img', $(this)).attr('src');
119
+
120
+ if (typeof clickCallback === 'function' ) {
121
+ clickCallback(image_versions[i]);
122
+ }
123
+
124
+ // mark the current selection as active
125
+ $('li.active', thumbList).removeClass('active');
126
+ $(this).addClass('active');
127
+
128
+ // update the multi-image selector image
129
+ $(".pic img.img-thumbnail", panel).attr("src", src);
130
+
131
+ $('[data-panel-image-pagination] [data-current-image]', panel).text(
132
+ $('li', thumbList).index($(this)) + 1
133
+ );
134
+ scrollToActiveThumb();
135
+ });
136
+ $("img", listItem).on('load', function() {
137
+ updateThumbListWidth();
138
+ });
139
+ thumbList.append(listItem);
140
+ });
141
+ }
142
+ };
143
+
144
+ })(jQuery);
145
+
146
+ // source: http://stackoverflow.com/questions/14035083/jquery-bind-event-on-scroll-stops
147
+ jQuery.fn.scrollStop = function(callback) {
148
+ $(this).scroll(function() {
149
+ var self = this,
150
+ $this = $(self);
151
+
152
+ if ($this.data('scrollTimeout')) {
153
+ clearTimeout($this.data('scrollTimeout'));
154
+ }
155
+
156
+ $this.data('scrollTimeout', setTimeout(callback, 250, self));
157
+ });
158
+ };
@@ -0,0 +1,40 @@
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
+ Spotlight.onLoad(function(){
4
+ // Set a ujs adapter to support both rails-ujs and jquery-ujs
5
+ var ujs = typeof Rails === 'undefined' ? $.rails : Rails;
6
+ SirTrevor.setDefaults({
7
+ iconUrl: <%= asset_path('spotlight/blocks/sir-trevor-icons.svg').to_json %>,
8
+ uploadUrl: $('[data-attachment-endpoint]').data('attachment-endpoint'),
9
+ ajaxOptions: {
10
+ headers: {
11
+ 'X-CSRF-Token': ujs.csrfToken() || ''
12
+ },
13
+ credentials: 'same-origin'
14
+ }
15
+ });
16
+
17
+ SirTrevor.Blocks.Heading.prototype.toolbarEnabled = true;
18
+ SirTrevor.Blocks.Quote.prototype.toolbarEnabled = true;
19
+ SirTrevor.Blocks.Text.prototype.toolbarEnabled = true;
20
+
21
+ var instance = $('.js-st-instance').first();
22
+
23
+ if (instance.length) {
24
+ var editor = new SirTrevor.Editor({
25
+ el: instance[0],
26
+ blockTypes: instance.data('blockTypes'),
27
+ defaultType:["Text"],
28
+ onEditorRender: function() {
29
+ $.SerializedForm();
30
+ },
31
+ blockTypeLimits: {
32
+ "SearchResults": 1
33
+ }
34
+ });
35
+
36
+ editor.blockControls = Spotlight.BlockControls.create(editor);
37
+
38
+ new Spotlight.BlockLimits(editor).enforceLimits(editor);
39
+ }
40
+ });
@@ -0,0 +1,148 @@
1
+ Spotlight.onLoad(function() {
2
+ $('[data-behavior="progress-panel"]').progressMonitor();
3
+ });
4
+
5
+ (function($) {
6
+ $.fn.progressMonitor = function() {
7
+ var monitorElements = this;
8
+ var defaultRefreshRate = 3000;
9
+ var panelContainer;
10
+ var pollers = [];
11
+
12
+ $(monitorElements).each(function() {
13
+ panelContainer = $(this);
14
+ panelContainer.hide();
15
+ var monitorUrl = panelContainer.data('monitorUrl');
16
+ var refreshRate = panelContainer.data('refreshRate') || defaultRefreshRate;
17
+ pollers.push(
18
+ setInterval(function() {
19
+ checkMonitorUrl(monitorUrl);
20
+ }, refreshRate)
21
+ );
22
+ });
23
+
24
+ // Clear the intervals on turbolink:click event (e.g. when the user navigates away from the page)
25
+ $(document).on('turbolinks:click', function() {
26
+ if (pollers.length > 0) {
27
+ $.each(pollers, function() {
28
+ clearInterval(this);
29
+ });
30
+ pollers = [];
31
+ }
32
+ });
33
+
34
+ function checkMonitorUrl(url) {
35
+ $.ajax(url).done(success).fail(fail);
36
+ }
37
+
38
+ function success(data) {
39
+ if (data.recently_in_progress) {
40
+ updateMonitorPanel(data);
41
+ monitorPanel().show();
42
+ } else {
43
+ monitorPanel().hide();
44
+ }
45
+ }
46
+
47
+ function fail() { monitorPanel().hide(); }
48
+
49
+ function updateMonitorPanel(data) {
50
+ panelStartDate().text(data.started_at);
51
+ panelCurrentDate().text(data.updated_at);
52
+ panelCompletedDate().text(data.updated_at);
53
+ panelCurrent().text(data.completed);
54
+ setPanelCompleted(data.finished);
55
+ updatePanelTotals(data);
56
+ updatePanelErrorMessage(data);
57
+ updateProgressBar(data);
58
+
59
+ panelContainer.show();
60
+ }
61
+
62
+ function updateProgressBar(data) {
63
+ var percentage = calculatePercentage(data);
64
+ progressBar()
65
+ .attr('aria-valuemax', data.total)
66
+ .attr('aria-valuenow', percentage)
67
+ .css('width', percentage + '%')
68
+ .text(percentage + '%');
69
+
70
+ if (data.finished) {
71
+ progressBar().removeClass('active').removeClass('progress-bar-striped');
72
+ }
73
+ }
74
+
75
+ function updatePanelErrorMessage(data) {
76
+ // We currently do not store this state,
77
+ // but with this code we can in the future.
78
+ if ( data.errored ) {
79
+ panelErrorMessage().show();
80
+ } else {
81
+ panelErrorMessage().hide();
82
+ }
83
+ }
84
+
85
+ function updatePanelTotals(data) {
86
+ panelTotals().each(function() {
87
+ $(this).text(data.total);
88
+ });
89
+ }
90
+
91
+ function calculatePercentage(data) {
92
+ if (data.total == 0) return 0;
93
+ return Math.floor((data.completed / data.total) * 100);
94
+ }
95
+
96
+ function monitorPanel() {
97
+ return panelContainer.find('.index-status');
98
+ }
99
+
100
+ function panelStartDate() {
101
+ return monitorPanel()
102
+ .find('[data-behavior="monitor-start"]')
103
+ .find('[data-behavior="date"]');
104
+ }
105
+
106
+ function panelCurrentDate() {
107
+ return monitorPanel()
108
+ .find('[data-behavior="monitor-current"]')
109
+ .find('[data-behavior="date"]');
110
+ }
111
+
112
+ function panelCompletedDate() {
113
+ return monitorPanel()
114
+ .find('[data-behavior="monitor-completed"]')
115
+ .find('[data-behavior="date"]');
116
+ }
117
+
118
+ function panelTotals() {
119
+ return monitorPanel().find('[data-behavior="total"]');
120
+ }
121
+
122
+ function panelCurrent() {
123
+ return monitorPanel()
124
+ .find('[data-behavior="monitor-current"]')
125
+ .find('[data-behavior="completed"]');
126
+ }
127
+
128
+ function progressBar() {
129
+ return monitorPanel().find('.progress-bar');
130
+ }
131
+
132
+ function panelErrorMessage() {
133
+ return monitorPanel().find('[data-behavior="monitor-error"]');
134
+ }
135
+
136
+ function setPanelCompleted(finished) {
137
+ var panel = monitorPanel().find('[data-behavior="monitor-completed"]');
138
+
139
+ if (finished) {
140
+ panel.show();
141
+ } else {
142
+ panel.hide();
143
+ }
144
+ }
145
+
146
+ return this;
147
+ };
148
+ })(jQuery);
@@ -0,0 +1,6 @@
1
+ Spotlight.onLoad(function() {
2
+ // Don't allow unchecking of checkboxes with the data-readonly attribute
3
+ $("input[type='checkbox'][data-readonly]").on("click", function(event) {
4
+ event.preventDefault();
5
+ });
6
+ });
@@ -0,0 +1,108 @@
1
+ //= require typeahead.bundle.min.js
2
+ //= require handlebars
3
+
4
+ (function($){
5
+ $.fn.spotlightSearchTypeAhead = function( options ) {
6
+ $.each(this, function(){
7
+ addAutocompleteBehavior($(this));
8
+ });
9
+
10
+ function addAutocompleteBehavior( typeAheadInput, settings ) {
11
+ var settings = $.extend({
12
+ displayKey: 'title',
13
+ minLength: 0,
14
+ highlight: (typeAheadInput.data('autocomplete-highlight') || true),
15
+ hint: (typeAheadInput.data('autocomplete-hint') || false),
16
+ autoselect: (typeAheadInput.data('autocomplete-autoselect') || true)
17
+ }, options);
18
+
19
+ typeAheadInput.typeahead(settings, {
20
+ displayKey: settings.displayKey,
21
+ source: settings.bloodhound.ttAdapter(),
22
+ templates: {
23
+ suggestion: Handlebars.compile(settings.template)
24
+ }
25
+ })
26
+ }
27
+ return this;
28
+ }
29
+ })( jQuery );
30
+
31
+ function itemsBloodhound() {
32
+ var results = new Bloodhound({
33
+ datumTokenizer: function(d) {
34
+ return Bloodhound.tokenizers.whitespace(d.title);
35
+ },
36
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
37
+ limit: 100,
38
+ remote: {
39
+ url: $('form[data-autocomplete-exhibit-catalog-path]').data('autocomplete-exhibit-catalog-path').replace("%25QUERY", "%QUERY"),
40
+ filter: function(response) {
41
+ return $.map(response['docs'], function(doc) {
42
+ return doc;
43
+ })
44
+ }
45
+ }
46
+ });
47
+ results.initialize();
48
+ return results;
49
+ };
50
+
51
+ function itemsTemplate() {
52
+ 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
+ }
54
+
55
+ function addAutocompletetoFeaturedImage(){
56
+ if($('[data-featured-image-typeahead]').length > 0) {
57
+ $('[data-featured-image-typeahead]').spotlightSearchTypeAhead({bloodhound: itemsBloodhound(), template: itemsTemplate()}).on('click', function() {
58
+ $(this).select();
59
+ }).on('typeahead:selected typeahead:autocompleted', function(e, data) {
60
+ var panel = $($(this).data('target-panel'));
61
+ addImageSelector($(this), panel, data.iiif_manifest, true);
62
+ $($(this).data('id-field')).val(data['global_id']);
63
+ $(this).attr('type', 'text');
64
+ });
65
+ }
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
+ });
@@ -0,0 +1,34 @@
1
+ Spotlight.onLoad(function() {
2
+ $('[data-input-select-target]').selectRelatedInput();
3
+ });
4
+ /*
5
+ Simple plugin to select form elements
6
+ when other elements are clicked.
7
+ */
8
+ (function($) {
9
+ $.fn.selectRelatedInput = function() {
10
+ var clickElements = this;
11
+
12
+ $(clickElements).each(function() {
13
+ var target = $($(this).data('input-select-target'));
14
+
15
+ var event;
16
+
17
+ if ($(this).is("select")) {
18
+ event = 'change';
19
+ } else {
20
+ event = 'click';
21
+ }
22
+
23
+ $(this).on(event, function() {
24
+ if (target.is(":checkbox") || target.is(":radio")) {
25
+ target.prop('checked', true);
26
+ } else {
27
+ target.focus();
28
+ }
29
+ });
30
+ });
31
+
32
+ return this;
33
+ };
34
+ })(jQuery);