LP#1685840 Activate Google Preview "extras" bar on load
authorDan Scott <dscott@laurentian.ca>
Tue, 2 May 2017 04:37:17 +0000 (00:37 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 4 May 2017 14:31:32 +0000 (10:31 -0400)
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 <dscott@laurentian.ca>
Signed-off-by: Ben Shum <ben@evergreener.net>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/web/js/ui/default/opac/ac_google_books.js

index 6c9aa00..861bdf4 100644 (file)
@@ -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';
     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.
       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();