spotlight-frontend 4.2.0 → 4.3.4

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.
package/README.md CHANGED
@@ -78,9 +78,9 @@ See more detailed instructions for development environment setup at ["Contributi
78
78
  ## With Docker
79
79
 
80
80
  ```sh
81
- # because of how docker-compose handles named images, running `docker-compose up --build` will error when the Rails images have not been built locally
82
- docker-compose build
83
- docker-compose up
81
+ # because of how docker compose handles named images, running `docker compose up --build` will error when the Rails images have not been built locally
82
+ docker compose build
83
+ docker compose up
84
84
  ```
85
85
 
86
86
  ## Tests
@@ -5927,10 +5927,24 @@ Spotlight$1.Block.Resources = (function(){
5927
5927
  formable: true,
5928
5928
  autocompleteable: true,
5929
5929
  show_heading: true,
5930
+ show_alt_text: true,
5930
5931
 
5931
5932
  title: function() { return i18n.t("blocks:" + this.type + ":title"); },
5932
5933
  description: function() { return i18n.t("blocks:" + this.type + ":description"); },
5933
-
5934
+ alt_text_guidelines: function() {
5935
+ if (this.show_alt_text) {
5936
+ return i18n.t("blocks:alt_text_guidelines:intro");
5937
+ }
5938
+ return "";
5939
+ },
5940
+ alt_text_guidelines_link: function() {
5941
+ if (this.show_alt_text) {
5942
+ var link_url = i18n.t("blocks:alt_text_guidelines:link_url");
5943
+ var link_label = i18n.t("blocks:alt_text_guidelines:link_label");
5944
+ return '<a target="_blank" href="' + link_url + '">' + link_label + '</a>';
5945
+ }
5946
+ return "";
5947
+ },
5934
5948
  icon_name: "resources",
5935
5949
  blockGroup: function() { return i18n.t("blocks:group:items") },
5936
5950
 
@@ -5940,6 +5954,8 @@ Spotlight$1.Block.Resources = (function(){
5940
5954
  show_secondary_field_key: "show-secondary-caption",
5941
5955
 
5942
5956
  display_checkbox: "display-checkbox",
5957
+ decorative_checkbox: "decorative-checkbox",
5958
+ alt_text_textarea: "alt-text-textarea",
5943
5959
 
5944
5960
  globalIndex: 0,
5945
5961
 
@@ -5947,6 +5963,13 @@ Spotlight$1.Block.Resources = (function(){
5947
5963
  return [];
5948
5964
  },
5949
5965
 
5966
+ _altTextFieldsHTML: function(index, data) {
5967
+ if (this.show_alt_text) {
5968
+ return this.altTextHTML(index, data);
5969
+ }
5970
+ return "";
5971
+ },
5972
+
5950
5973
  _itemPanel: function(data) {
5951
5974
  var index = "item_" + this.globalIndex++;
5952
5975
  var checked;
@@ -5977,6 +6000,7 @@ Spotlight$1.Block.Resources = (function(){
5977
6000
  <div class="main">
5978
6001
  <div class="title card-title">${data.title}</div>
5979
6002
  <div>${(data.slug || data.id)}</div>
6003
+ ${this._altTextFieldsHTML(index, data)}
5980
6004
  </div>
5981
6005
  <div class="remove float-right float-end">
5982
6006
  <a data-item-grid-panel-remove="true" href="#">${i18n.t("blocks:resources:panel:remove")}</a>
@@ -6013,6 +6037,7 @@ Spotlight$1.Block.Resources = (function(){
6013
6037
 
6014
6038
  createItemPanel: function(data) {
6015
6039
  var panel = this._itemPanel(data);
6040
+ this.attachAltTextHandlers(panel);
6016
6041
  $(panel).appendTo($('.panels > ol', this.inner));
6017
6042
  $('[data-behavior="nestable"]', this.inner).trigger('change');
6018
6043
  },
@@ -6045,11 +6070,67 @@ Spotlight$1.Block.Resources = (function(){
6045
6070
  return `<div class="form resources-admin clearfix">
6046
6071
  <div class="widget-header">
6047
6072
  ${this.description()}
6073
+ ${this.alt_text_guidelines()}
6074
+ ${this.alt_text_guidelines_link()}
6048
6075
  </div>
6049
6076
  ${this.content()}
6050
6077
  </div>`
6051
6078
  },
6052
6079
 
6080
+ _altTextData: function(data) {
6081
+ const isDecorative = data.decorative;
6082
+ const altText = isDecorative ? '' : (data.alt_text || '');
6083
+ const altTextBackup = data.alt_text_backup || '';
6084
+ const placeholderAttr = isDecorative ? '' : `placeholder="${i18n.t("blocks:resources:alt_text:placeholder")}"`;
6085
+ const disabledAttr = isDecorative ? 'disabled' : '';
6086
+
6087
+ return { isDecorative, altText, altTextBackup, placeholderAttr, disabledAttr };
6088
+ },
6089
+
6090
+ altTextHTML: function(index, data) {
6091
+ const { isDecorative, altText, altTextBackup, placeholderAttr, disabledAttr } = this._altTextData(data);
6092
+ return `<div class="mt-2 pt-2 d-flex">
6093
+ <div class="me-2 mr-2">
6094
+ <label class="col-form-label pb-0 pt-1" for="${this.formId(this.alt_text_textarea + '_' + data.id)}">${i18n.t("blocks:resources:alt_text:alternative_text")}</label>
6095
+ <div class="form-check mb-1 justify-content-end">
6096
+ <input class="form-check-input" type="checkbox"
6097
+ id="${this.formId(this.decorative_checkbox + '_' + data.id)}" name="item[${index}][decorative]" ${isDecorative ? 'checked' : ''}>
6098
+ <label class="form-check-label" for="${this.formId(this.decorative_checkbox + '_' + data.id)}">${i18n.t("blocks:resources:alt_text:decorative")}</label>
6099
+ </div>
6100
+ </div>
6101
+ <div class="flex-grow-1 flex-fill d-flex">
6102
+ <input type="hidden" name="item[${index}][alt_text_backup]" value="${altTextBackup}" />
6103
+ <textarea class="form-control w-100" rows="2" ${placeholderAttr}
6104
+ id="${this.formId(this.alt_text_textarea + '_' + data.id)}" name="item[${index}][alt_text]" ${disabledAttr}>${altText}</textarea>
6105
+ </div>
6106
+ </div>`
6107
+ },
6108
+
6109
+ attachAltTextHandlers: function(panel) {
6110
+ if (this.show_alt_text) {
6111
+ const decorativeCheckbox = $('input[name$="[decorative]"]', panel);
6112
+ const altTextInput = $('textarea[name$="[alt_text]"]', panel);
6113
+ const altTextBackupInput = $('input[name$="[alt_text_backup]"]', panel);
6114
+
6115
+ decorativeCheckbox.on('change', function() {
6116
+ const isDecorative = this.checked;
6117
+ if (isDecorative) {
6118
+ altTextBackupInput.val(altTextInput.val());
6119
+ altTextInput.val('');
6120
+ } else {
6121
+ altTextInput.val(altTextBackupInput.val());
6122
+ }
6123
+ altTextInput
6124
+ .prop('disabled', isDecorative)
6125
+ .attr('placeholder', isDecorative ? '' : i18n.t("blocks:resources:alt_text:placeholder"));
6126
+ });
6127
+
6128
+ altTextInput.on('input', function() {
6129
+ $(this).data('lastValue', $(this).val());
6130
+ });
6131
+ }
6132
+ },
6133
+
6053
6134
  onBlockRender: function() {
6054
6135
  Module.init($('[data-behavior="nestable"]', this.inner));
6055
6136
 
@@ -6239,7 +6320,7 @@ SirTrevor.Blocks.BrowseGroupCategories = (function(){
6239
6320
  },
6240
6321
 
6241
6322
  item_options: function() { return `
6242
- '<label>
6323
+ <label>
6243
6324
  <input type="hidden" name="display-item-counts" value="false" />
6244
6325
  <input type="checkbox" name="display-item-counts" value="true" checked />
6245
6326
  ${i18n.t("blocks:browse_group_categories:item_counts")}
@@ -6674,7 +6755,7 @@ SirTrevor.Blocks.SolrDocumentsEmbed = (function(){
6674
6755
 
6675
6756
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
6676
6757
  type: "solr_documents_embed",
6677
-
6758
+ show_alt_text: false,
6678
6759
  icon_name: "item_embed",
6679
6760
 
6680
6761
  item_options: function() { return "" },
@@ -6838,6 +6919,7 @@ SirTrevor.Blocks.UploadedItems = (function(){
6838
6919
  <label for="${this.formId('link_' + dataId)}" class="col-form-label col-md-3">${i18n.t("blocks:uploaded_items:link")}</label>
6839
6920
  <input type="text" class="form-control col" id="${this.formId('link_' + dataId)}" name="item[${index}][link]" data-field="link"/>
6840
6921
  </div>
6922
+ ${this._altTextFieldsHTML(index, data)}
6841
6923
  </div>
6842
6924
  <div class="remove float-right float-end">
6843
6925
  <a data-item-grid-panel-remove="true" href="#">${i18n.t("blocks:resources:panel:remove")}</a>
@@ -6865,6 +6947,8 @@ SirTrevor.Blocks.UploadedItems = (function(){
6865
6947
  return `<div class="form oembed-text-admin clearfix">
6866
6948
  <div class="widget-header">
6867
6949
  ${this.description()}
6950
+ ${this.alt_text_guidelines()}
6951
+ ${this.alt_text_guidelines_link()}
6868
6952
  </div>
6869
6953
  <div class="row">
6870
6954
  <div class="form-group mb-3 col-md-8">
@@ -6884,6 +6968,24 @@ SirTrevor.Blocks.UploadedItems = (function(){
6884
6968
  </div>`
6885
6969
  },
6886
6970
 
6971
+ altTextHTML: function(index, data) {
6972
+ const { isDecorative, altText, altTextBackup, placeholderAttr, disabledAttr } = this._altTextData(data);
6973
+ return `
6974
+ <div class="field row mr-3 me-3">
6975
+ <div class="col-lg-3 ps-md-2 pl-md-2">
6976
+ <label class="col-form-label text-nowrap pb-0 pt-1 justify-content-md-start justify-content-lg-end d-flex" for="${this.formId(this.alt_text_textarea + '_' + data.id)}">${i18n.t("blocks:resources:alt_text:alternative_text")}</label>
6977
+ <div class="form-check d-flex justify-content-md-start justify-content-lg-end">
6978
+ <input class="form-check-input" type="checkbox"
6979
+ id="${this.formId(this.decorative_checkbox + '_' + data.id)}" name="item[${index}][decorative]" ${isDecorative ? 'checked' : ''}>
6980
+ <label class="form-check-label" for="${this.formId(this.decorative_checkbox + '_' + data.id)}">${i18n.t("blocks:resources:alt_text:decorative")}</label>
6981
+ </div>
6982
+ </div>
6983
+ <input type="hidden" name="item[${index}][alt_text_backup]" value="${altTextBackup}" />
6984
+ <textarea class="col-lg-9" rows="2" ${placeholderAttr}
6985
+ id="${this.formId(this.alt_text_textarea + '_' + data.id)}" name="item[${index}][alt_text]" ${disabledAttr}>${altText}</textarea>
6986
+ </div>`
6987
+ },
6988
+
6887
6989
  zpr_key: 'zpr_link'
6888
6990
  });
6889
6991
  })();
@@ -7094,6 +7196,11 @@ SirTrevor.Locales.en.blocks = $.extend(SirTrevor.Locales.en.blocks, {
7094
7196
  drag: "Drag",
7095
7197
  display: "Display?",
7096
7198
  remove: "Remove"
7199
+ },
7200
+ alt_text: {
7201
+ decorative: "Decorative",
7202
+ alternative_text: "Alternative text",
7203
+ placeholder: "Enter alt text for this item..."
7097
7204
  }
7098
7205
  },
7099
7206
 
@@ -7159,6 +7266,12 @@ SirTrevor.Locales.en.blocks = $.extend(SirTrevor.Locales.en.blocks, {
7159
7266
  group: {
7160
7267
  undefined: "Standard widgets",
7161
7268
  items: "Exhibit item widgets"
7269
+ },
7270
+
7271
+ alt_text_guidelines: {
7272
+ intro: 'For each item, please enter alternative text or appropriately check the decorative box. ',
7273
+ link_label: 'Guidelines for writing alt text.',
7274
+ link_url: 'https://www.w3.org/WAI/tutorials/images/'
7162
7275
  }
7163
7276
  });
7164
7277