<script type="text/javascript">
var GBisbns = Array();
+var GBPreviewShowing = false;
/**
*
GBPBadge.src = 'https://www.google.com/intl/[% ctx.locale.substr(0,2) %]/googlebooks/images/gbs_preview_button1.gif';
GBPBadge.title = dojo.byId('rdetail_title').innerHTML;
GBPBadge.style.border = 0;
- GBPBadge.style.margin = '0.5em 0 0 0';
+ GBPBadge.style.verticalAlign = 'middle';
GBPBadgelink = document.createElement('a');
- GBPBadgelink.href = 'javascript:GBDisplayPreview();';
+ GBPBadgelink.id = 'gbptoggle';
GBPBadgelink.appendChild( GBPBadge );
- dojo.byId('rdetail_title_div').appendChild( GBPBadgelink );
+ GBPBadgelink.href = 'javascript:GBDisplayPreview();';
+ GBPBadgelink.appendChild( document.createTextNode(' [% l('Show Preview') %]') );
+ dojo.byId('canvas_main').insertBefore(GBPBadgelink, dojo.byId('rdetail_record_details'));
}
}
var GBPViewer = new google.books.DefaultViewer(dojo.byId('rdetail_preview_div'));
GBPViewer.load('ISBN:' + GBisbns[0]);
GBPViewer.resize();
- dojo.byId('gbpbadge').style.display = 'none';
+ var GBPBadgelink = dojo.byId('gbptoggle');
+ GBPBadgelink.href = 'javascript:GBShowHidePreview();';
+ GBShowHidePreview(GBPBadgelink);
+}
+
+function GBShowHidePreview(toggle) {
+ if (!toggle) {
+ toggle = dojo.byId('gbptoggle');
+ }
+ if (!GBPreviewShowing) {
+ dojo.byId('rdetail_preview_div').style.display = 'inherit';
+ toggle.lastChild.nodeValue = ' [% l('Hide Preview') %]';
+ GBPreviewShowing = true;
+ } else {
+ dojo.byId('rdetail_preview_div').style.display = 'none';
+ toggle.lastChild.nodeValue = ' [% l('Show Preview') %]';
+ GBPreviewShowing = false;
+ }
}
dojo.addOnLoad(function() {
Setting `ctx.google_books_preview` to `1` in the TPAC `config.tt2`
configuration file will cause the TPAC to check to see, as part of the record
details view, if Google Books has an online preview available. If it does,
-then a preview button will be displayed in the book cover image location.
-If the user then clicks the preview button, the preview will load below the
-title of the book in the record details page.
+then a preview button will be displayed below the list of copies. If the user
+then clicks the preview button, the preview will load below the button. At that
+point, the button will then will act as a toggle to turn the viewer on and off.
By default, this functionality is disabled to protect the privacy of users
who might not want to share their browsing behaviour with Google.