Skip to content

Commit

Permalink
WIP - Curators can upload multiple images for an item
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisrlc committed Oct 1, 2024
1 parent 262c08a commit a26bc80
Show file tree
Hide file tree
Showing 31 changed files with 1,397 additions and 75 deletions.
50 changes: 50 additions & 0 deletions app/assets/javascripts/openseadragon/jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Overrides openseadragon/jquery.js from openseadragon-rails gem to add custom page binding for pagination

(function($) {
$.fn.openseadragon = function() {
var __osd_counter = 0;
function generateOsdId() {
__osd_counter++;

return "Openseadragon" + __osd_counter;
}

$(this).each(function() {
var $picture = $(this);
$picture.addClass('openseadragon-viewer');

if (typeof $picture.attr('id') === "undefined") {
$picture.attr('id', generateOsdId());
}

var collectionOptions = $picture.data('openseadragon');

var sources = $picture.find('source[media="openseadragon"]');

var tilesources = $.map(sources, function(e) {
if ($(e).data('openseadragon')) {
return $(e).data('openseadragon');
} else {
return $(e).attr('src');
}
});

$picture.css('height', $picture.css('height'));

// BEGIN CUSTOMIZATION
var viewer = OpenSeadragon(
$.extend({ id: $picture.attr('id') }, collectionOptions, { tileSources: tilesources })
);

viewer.addHandler('page', function (data) {
$picture.siblings().find('[id*="currentpage"]')[0].innerHTML = ( data.page + 1 );
});

$picture.data('osdViewer', viewer);
// END CUSTOMIZATION

});

return this;
};
})(jQuery);
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Replaces _itemPanel from https://github.com/projectblacklight/spotlight/blob/v3.5.0.2/app/assets/javascripts/spotlight/admin/blocks/resources_block.js
// Adds optional "Alt text" input for resource image display
// Adds optional "Alt text" input for resource image display
// Replaces afterPanelRender from https://github.com/projectblacklight/spotlight/blob/v3.5.0.4/app/assets/javascripts/spotlight/admin/blocks/solr_documents_base_block.js
// Passes iiif tilesource to multiImageSelector instead of imageid

SirTrevor.Blocks.SolrDocumentsBase = (function(){

Expand Down Expand Up @@ -73,6 +75,38 @@ SirTrevor.Blocks.SolrDocumentsBase = (function(){
this.afterPanelRender(data, panel);

return panel;
},
afterPanelRender: function(data, panel) {
var context = this;
var manifestUrl = data.iiif_manifest || data.iiif_manifest_url;

if (!manifestUrl) {
$(panel).find('[name$="[thumbnail_image_url]"]').val(data.thumbnail_image_url || data.thumbnail);
$(panel).find('[name$="[full_image_url]"]').val(data.full_image_url);

return;
}

$.ajax(manifestUrl).done(
function(manifest) {
var Iiif = spotlightAdminIiif;
var iiifManifest = new Iiif(manifestUrl, manifest);

var thumbs = iiifManifest.imagesArray();

// BEGIN CUSTOMIZATION
if (!data.iiif_tilesource) {
context.setIiifFields(panel, thumbs[0], !!data.iiif_manifest_url);
}

if(thumbs.length > 1) {
panel.multiImageSelector(thumbs, function(selectorImage) {
context.setIiifFields(panel, selectorImage, false);
}, data.iiif_tilesource);
}
// END CUSTOMIZATION
}
);
}

});
Expand Down
Loading

0 comments on commit a26bc80

Please sign in to comment.