Skip to content

Commit

Permalink
🎁 change clover iiif about > homepage label
Browse files Browse the repository at this point in the history
This commit updates the About section text label from `"Homepage"` to
`"Link to item"`. Since this label comes from the clover iiif
JavaScript, it was necessary to create a custom function that finds the
label and overrides it.

There was also a bug that opened the entire page inside the iframe
window. The custom iiif clover override function also added a target
parent to the link to prevent this issue.

Ref:
- #659
  • Loading branch information
sjproctor committed Jul 31, 2024
1 parent cffe715 commit f12c70b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@
//= require flot/jquery.flot.selection.js
//= require bootstrap-slider
//= require_tree ./blacklight_range_limit
//= require clover_iiif_custom
21 changes: 21 additions & 0 deletions app/assets/javascripts/clover_iiif_custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$(function() {
function updateIframeContent() {
var iframeContent = $('#clover-iiif-iframe').contents();
iframeContent.find(".manifest-property-title:contains('Homepage')").text('List of items');
iframeContent.find("a:not([target])").attr('target', '_parent');
}

function observeIframe() {
var iframe = $('#clover-iiif-iframe')[0];
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var observer = new MutationObserver(function(mutations) {
updateIframeContent();
});
observer.observe(iframeDocument, { childList: true, subtree: true });
updateIframeContent();
}

$('#clover-iiif-iframe').on('load', function() {
observeIframe();
});
});

0 comments on commit f12c70b

Please sign in to comment.