From 437bc8289464b8bf184e70fbee7fe21ce9c5b72c Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 2 May 2017 00:37:17 -0400 Subject: [PATCH] LP#1685840 Activate Google Preview "extras" bar on load Thanks to Ben Shum for pointing out that users might expect the Google Preview extras bar near the bottom of the screen to trigger loading the preview as well. Another event listener handles this accordingly. Signed-off-by: Dan Scott Signed-off-by: Ben Shum Signed-off-by: Galen Charlton --- Open-ILS/web/js/ui/default/opac/ac_google_books.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/js/ui/default/opac/ac_google_books.js b/Open-ILS/web/js/ui/default/opac/ac_google_books.js index 6c9aa00b8f..861bdf4c79 100644 --- a/Open-ILS/web/js/ui/default/opac/ac_google_books.js +++ b/Open-ILS/web/js/ui/default/opac/ac_google_books.js @@ -49,6 +49,7 @@ GBPBadgelink = document.createElement('a'); GBPBadgelink.id = 'gbpbadge_link'; GBPBadgelink.addEventListener('click', GBDisplayPreview); + GBExtrasActivate(true); GBPBadgelink.appendChild(GBPBadge); document.getElementById('rdetail_title_div').appendChild(GBPBadgelink); document.getElementById('gbp_extra').style.display = 'block'; @@ -64,6 +65,18 @@ GBPBadgelink.addEventListener('click', GBShowHidePreview); } + function GBExtrasActivate (init) { + var extras = document.getElementById('gbp_extra_links').getElementsByTagName('a'); + for (var i = 0; i < extras.length; i++) { + if (init) { + extras[i].addEventListener('click', GBDisplayPreview); + } else { + extras[i].removeEventListener('click', GBDisplayPreview); + extras[i].addEventListener('click', GBShowHidePreview); + } + } + } + /** * This is called when the user clicks on the 'Preview' link. We assume * a preview is available from Google if this link was made visible. @@ -82,10 +95,6 @@ document.getElementById('gbp_extra_container').appendChild(GBClear); google.books.load({'language': lang}); window.setTimeout(GBPViewerLoadCallback, 750); - var extras = document.getElementById('gbp_extra_links').getElementsByTagName('a'); - for (var i = 0; i < extras.length; i++) { - extras[i].addEventListener('click', GBShowHidePreview); - } GBPreviewPane.loaded = 'true'; } GBShowHidePreview(); -- 2.11.0