spotlight-frontend 5.1.0 → 5.2.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.
@@ -3266,7 +3266,37 @@
3266
3266
  class Carousel {
3267
3267
  connect() {
3268
3268
  if ($.fn.carousel) {
3269
- $('.carousel').carousel();
3269
+ const $carousel = $('.carousel');
3270
+
3271
+ // updates the aria-describedby on the next and prev btns
3272
+ const updateAriaDescribedBy = function ($carousel) {
3273
+ const $activeItem = $carousel.find('.carousel-item.active');
3274
+ const $items = $carousel.find('.carousel-item');
3275
+ const curIndex = $items.index($activeItem);
3276
+ const prevIndex = (curIndex - 1 + $items.length) % $items.length;
3277
+ const nextIndex = (curIndex + 1) % $items.length;
3278
+
3279
+ const prevDataId = $items.eq(prevIndex).data('id');
3280
+ const nextDataId = $items.eq(nextIndex).data('id');
3281
+ if (prevDataId) {
3282
+ $carousel.find('.carousel-control-prev').attr('aria-describedby', 'carousel-caption-' + prevDataId);
3283
+ }
3284
+ if (nextDataId) {
3285
+ $carousel.find('.carousel-control-next').attr('aria-describedby', 'carousel-caption-' + nextDataId);
3286
+ }
3287
+ };
3288
+
3289
+ // on initial page load, set the aria-describedby on the btns for each carousel
3290
+ $carousel.each(function () {
3291
+ const $this = $(this);
3292
+ $this.carousel();
3293
+ updateAriaDescribedBy($this);
3294
+ });
3295
+
3296
+ // on slide change
3297
+ $carousel.on('slid.bs.carousel', function () {
3298
+ updateAriaDescribedBy($(this));
3299
+ });
3270
3300
  }
3271
3301
  }
3272
3302
  }
@@ -3925,7 +3955,7 @@
3925
3955
  url: url, //Server script to process data
3926
3956
  type: 'POST',
3927
3957
  success: (data, stat, xhr) => this.successHandler(data, stat, xhr),
3928
- // error: errorHandler,
3958
+ error: (xhr, stat, error) => this.errorHandler(xhr, stat, error),
3929
3959
  // Form data
3930
3960
  data: this.getData(),
3931
3961
  headers: {
@@ -3941,6 +3971,39 @@
3941
3971
  successHandler(data, stat, xhr) {
3942
3972
  this.setIiifFields({ tilesource: data.tilesource });
3943
3973
  this.setUploadId(data.id);
3974
+ this.clearUploadErrors();
3975
+ }
3976
+
3977
+ errorHandler(xhr, stat, error) {
3978
+ let errorMessage = "Upload failed";
3979
+ if (xhr.responseJSON) {
3980
+ if (xhr.responseJSON.errors) {
3981
+ errorMessage = xhr.responseJSON.errors.join(', ');
3982
+ } else if (xhr.responseJSON.error) {
3983
+ errorMessage = xhr.responseJSON.error;
3984
+ }
3985
+ }
3986
+ this.showUploadError(errorMessage);
3987
+ }
3988
+
3989
+ getUploadErrorsElement() {
3990
+ return this.cropTool.find(".featured-image.invalid-feedback")
3991
+ }
3992
+
3993
+ showUploadError(errorMessage) {
3994
+ const errorsElement = this.getUploadErrorsElement();
3995
+ if (errorsElement) {
3996
+ errorsElement.text(errorMessage).show();
3997
+ } else {
3998
+ console.error("uploadFile", error, errorMessage);
3999
+ }
4000
+ }
4001
+
4002
+ clearUploadErrors() {
4003
+ const errorsElement = this.getUploadErrorsElement();
4004
+ if (errorsElement) {
4005
+ errorsElement.text("").hide();
4006
+ }
3944
4007
  }
3945
4008
 
3946
4009
  setUploadId(id) {
@@ -5999,6 +6062,8 @@
5999
6062
 
6000
6063
  icon_name: "pages",
6001
6064
 
6065
+ show_image_selection: false,
6066
+
6002
6067
  autocomplete_url: function() { return document.getElementById(this.instanceID).closest('form[data-autocomplete-exhibit-pages-path]').dataset.autocompleteExhibitPagesPath; },
6003
6068
  autocomplete_fetch: function(url) {
6004
6069
  return this.fetchOnceAndFilterLocalResults(url);
@@ -6037,8 +6102,6 @@
6037
6102
  });
6038
6103
  })();
6039
6104
 
6040
- //= require spotlight/admin/blocks/browse_block
6041
-
6042
6105
  SirTrevor.Blocks.SearchResults = (function(){
6043
6106
 
6044
6107
  return SirTrevor.Blocks.Browse.extend({
@@ -6199,8 +6262,6 @@
6199
6262
 
6200
6263
  })();
6201
6264
 
6202
- //= require spotlight/admin/blocks/solr_documents_base_block
6203
-
6204
6265
  SirTrevor.Blocks.SolrDocuments = (function(){
6205
6266
 
6206
6267
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -6225,8 +6286,6 @@
6225
6286
 
6226
6287
  })();
6227
6288
 
6228
- //= require spotlight/admin/blocks/solr_documents_base_block
6229
-
6230
6289
  SirTrevor.Blocks.SolrDocumentsCarousel = (function(){
6231
6290
 
6232
6291
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -6326,8 +6385,6 @@
6326
6385
 
6327
6386
  })();
6328
6387
 
6329
- //= require spotlight/admin/blocks/solr_documents_base_block
6330
-
6331
6388
  SirTrevor.Blocks.SolrDocumentsEmbed = (function(){
6332
6389
 
6333
6390
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -6344,8 +6401,6 @@
6344
6401
 
6345
6402
  })();
6346
6403
 
6347
- //= require spotlight/admin/blocks/solr_documents_base_block
6348
-
6349
6404
  SirTrevor.Blocks.SolrDocumentsFeatures = (function(){
6350
6405
 
6351
6406
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -6385,8 +6440,6 @@
6385
6440
 
6386
6441
  })();
6387
6442
 
6388
- //= require spotlight/admin/blocks/solr_documents_base_block
6389
-
6390
6443
  SirTrevor.Blocks.SolrDocumentsGrid = (function(){
6391
6444
 
6392
6445
  return SirTrevor.Blocks.SolrDocumentsBase.extend({