From f12c70b224ba7e8f313e5c1338c15fb234bef6e5 Mon Sep 17 00:00:00 2001 From: Sarah Proctor Date: Wed, 31 Jul 2024 10:14:56 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=81=20change=20clover=20iiif=20about?= =?UTF-8?q?=20>=20homepage=20label?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: - https://github.com/scientist-softserv/utk-hyku/issues/659 --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/clover_iiif_custom.js | 21 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 app/assets/javascripts/clover_iiif_custom.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4299c34f..2e22c1b2 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -61,3 +61,4 @@ //= require flot/jquery.flot.selection.js //= require bootstrap-slider //= require_tree ./blacklight_range_limit +//= require clover_iiif_custom diff --git a/app/assets/javascripts/clover_iiif_custom.js b/app/assets/javascripts/clover_iiif_custom.js new file mode 100644 index 00000000..282a24a7 --- /dev/null +++ b/app/assets/javascripts/clover_iiif_custom.js @@ -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(); + }); +});