[open-ils-commits] [GIT] Evergreen ILS branch master updated. 33351bae24fd680d06aa0a4e9265de2ec74870af
Evergreen Git
git at git.evergreen-ils.org
Thu May 4 12:01:55 EDT 2017
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via 33351bae24fd680d06aa0a4e9265de2ec74870af (commit)
via 437bc8289464b8bf184e70fbee7fe21ce9c5b72c (commit)
via 55aa6265712b38eb746aa69c5ea93702d1b6950c (commit)
via e16178021742b7aa83b83152c874c62f769b006c (commit)
via b6e3ad033f98bf75a0d03021907103ed313ab475 (commit)
via 07466251f2c0d60a5c6aaebb23c87d5cf26c7f02 (commit)
via a968d72e91e40adfe42c28462f4c257c3d1688d5 (commit)
from 825f4aaf8e407a42ddd30ce558303696aa7ecd47 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 33351bae24fd680d06aa0a4e9265de2ec74870af
Author: Dan Scott <dscott at laurentian.ca>
Date: Tue May 2 23:02:17 2017 -0400
LP#1685840 Release notes for Google Books Preview rewrite
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
diff --git a/docs/RELEASE_NOTES_NEXT/OPAC/google_books_preview_no_dojo.adoc b/docs/RELEASE_NOTES_NEXT/OPAC/google_books_preview_no_dojo.adoc
new file mode 100644
index 0000000..e96e5ea
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/OPAC/google_books_preview_no_dojo.adoc
@@ -0,0 +1,20 @@
+Google Books Preview rewrite
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The Google Books Preview functionality in record detail pages has been
+rewritten to modernize its style and optimize its performance:
+
+* The Dojo JavaScript framework is no longer used, saving approximately
+ 150K of JavaScript and CSS and four network requests per page load.
+* The Embedded Viewer is not loaded unless a possible preview is found,
+ saving more network and memory overhead.
+* The Google Books Loader is used to load the Embedded Viewer instead of the
+ https://productforums.google.com/forum/#!topic/books-api/lZrq5cWKrTo;context-place=forum/books-api[deprecated
+ Google Loader].
+* All variables are self-contained and do not pollute the global namespace.
+* Event listeners are registered to handle clicks, rather than attaching
+ `href="javascript:function()"` to <a> elements.
+* Book previews are displayed in a panel sized according to the viewport
+ of the browser, improving its appearance on both mobile and desktop
+ browsers.
+* The rewritten code is now served up directly from
+ `/js/ui/default/opac/ac_google_books.js` rather than as a TT2 template.
commit 437bc8289464b8bf184e70fbee7fe21ce9c5b72c
Author: Dan Scott <dscott at laurentian.ca>
Date: Tue May 2 00:37:17 2017 -0400
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 <dscott at laurentian.ca>
Signed-off-by: Ben Shum <ben at evergreener.net>
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
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 6c9aa00..861bdf4 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();
commit 55aa6265712b38eb746aa69c5ea93702d1b6950c
Author: Dan Scott <dscott at laurentian.ca>
Date: Mon Apr 24 12:18:12 2017 -0400
LP#1685840: Dojoless Google Books Preview as external script
Rather than including the JavaScript inline in each page, load the
JavaScript as a regular external JavaScript file so that browsers
can take advantage of caching, reduce network bandwidth, and reduce the
amount of TT2 processing required. Every little bit helps.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Ben Shum <ben at evergreener.net>
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
diff --git a/Open-ILS/src/templates/opac/parts/js.tt2 b/Open-ILS/src/templates/opac/parts/js.tt2
index 1deac91..f7fc737 100644
--- a/Open-ILS/src/templates/opac/parts/js.tt2
+++ b/Open-ILS/src/templates/opac/parts/js.tt2
@@ -59,7 +59,9 @@
IF CGI.https; url = url.replace('^http:', 'https:'); END; %]
<script type='text/javascript' id='EIT' src='[% url %]'></script>
[%- END %]
-[% INCLUDE "opac/parts/ac_google_books.tt2" IF ctx.page == 'record' AND ctx.google_books_preview %]
+[%- IF ctx.page == 'record' AND ctx.google_books_preview %]
+<script src='[% ctx.media_prefix %]/js/ui/default/opac/ac_google_books.js' async defer></script>
+[%- END %]
[%- IF want_dojo; -%]
<script type="text/javascript">
var djConfig = {
diff --git a/Open-ILS/src/templates/opac/parts/ac_google_books.tt2 b/Open-ILS/web/js/ui/default/opac/ac_google_books.js
similarity index 99%
rename from Open-ILS/src/templates/opac/parts/ac_google_books.tt2
rename to Open-ILS/web/js/ui/default/opac/ac_google_books.js
index 22f6963..6c9aa00 100644
--- a/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
+++ b/Open-ILS/web/js/ui/default/opac/ac_google_books.js
@@ -1,4 +1,3 @@
-<script>
;(function () {
var GBisbns = [];
var GBPBadgelink;
@@ -161,4 +160,3 @@
window.addEventListener('load', GBLoader, false);
}
})()
-</script>
commit e16178021742b7aa83b83152c874c62f769b006c
Author: Dan Scott <dscott at laurentian.ca>
Date: Mon Apr 24 11:53:24 2017 -0400
LP#1685840: Dojoless Google Books Preview: remove TT2 dependency
Rather than process the template with TT2 to specify the language in
which the Google Books Preview should be displayed, use the @lang
attribute on the <html> element--and fall back to 'en' if for some
reason that attribute has been removed from the template.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Ben Shum <ben at evergreener.net>
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
diff --git a/Open-ILS/src/templates/opac/parts/ac_google_books.tt2 b/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
index 5632395..22f6963 100644
--- a/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
+++ b/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
@@ -4,7 +4,10 @@
var GBPBadgelink;
var GBPreviewLink = '';
var GBPreviewShowing = false;
- var lang = '[% ctx.locale.substr(0,2) %]';
+ var lang = 'en';
+ if (document.documentElement.lang) {
+ lang = document.documentElement.lang.substr(0,2) || 'en';
+ }
var head = document.getElementsByTagName('head')[0];
/**
commit b6e3ad033f98bf75a0d03021907103ed313ab475
Author: Dan Scott <dscott at laurentian.ca>
Date: Mon Apr 24 11:29:37 2017 -0400
LP#1685840: Google Books Preview: responsive sizing
Use the viewport's actual height and width to display the book preview,
rather than hard-coding 600px x 800px. On a very wide screen, the book
will be centred; on a small screen such as a mobile device, the book
will not scroll indiscriminately off to the side, but instead stays
within the bounds of the viewport.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Ben Shum <ben at evergreener.net>
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
diff --git a/Open-ILS/src/templates/opac/parts/ac_google_books.tt2 b/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
index c5a1303..5632395 100644
--- a/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
+++ b/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
@@ -71,8 +71,8 @@
if (GBPreviewPane === null || typeof GBPreviewPane.loaded === 'undefined' || GBPreviewPane.loaded === 'false') {
GBPreviewPane = document.createElement('div');
GBPreviewPane.id = 'rdetail_preview_div';
- GBPreviewPane.style.height = '800px';
- GBPreviewPane.style.width = '600px';
+ GBPreviewPane.style.height = document.documentElement.clientHeight + 'px';
+ GBPreviewPane.style.width = document.documentElement.clientWidth + 'px';
GBPreviewPane.style.display = 'block';
var GBClear = document.createElement('div');
GBClear.style.padding = '1em';
commit 07466251f2c0d60a5c6aaebb23c87d5cf26c7f02
Author: Dan Scott <dscott at laurentian.ca>
Date: Mon Apr 17 18:42:11 2017 -0400
LP#1685840: Dojoless Google Books Preview does not need want_dojo
Now that Dojo is no longer needed for Google Books Preview, we can load
the associated JavaScript without having to enable want_dojo.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Ben Shum <ben at evergreener.net>
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
diff --git a/Open-ILS/src/templates/opac/parts/header.tt2 b/Open-ILS/src/templates/opac/parts/header.tt2
index 5b34c16..a0ffcb8 100644
--- a/Open-ILS/src/templates/opac/parts/header.tt2
+++ b/Open-ILS/src/templates/opac/parts/header.tt2
@@ -116,10 +116,6 @@
want_dojo = 1;
END;
- IF ctx.google_books_preview;
- want_dojo = 1;
- END;
-
IF ENV.OILS_NOVELIST_URL;
want_dojo = 1;
END;
diff --git a/Open-ILS/src/templates/opac/parts/js.tt2 b/Open-ILS/src/templates/opac/parts/js.tt2
index 4d5b400..1deac91 100644
--- a/Open-ILS/src/templates/opac/parts/js.tt2
+++ b/Open-ILS/src/templates/opac/parts/js.tt2
@@ -59,6 +59,7 @@
IF CGI.https; url = url.replace('^http:', 'https:'); END; %]
<script type='text/javascript' id='EIT' src='[% url %]'></script>
[%- END %]
+[% INCLUDE "opac/parts/ac_google_books.tt2" IF ctx.page == 'record' AND ctx.google_books_preview %]
[%- IF want_dojo; -%]
<script type="text/javascript">
var djConfig = {
@@ -101,7 +102,6 @@
[% END; # use_autosuggest %]
[% INCLUDE "opac/parts/acjs.tt2" IF ctx.page == 'record' %]
-[% INCLUDE "opac/parts/ac_google_books.tt2" IF ctx.page == 'record' AND ctx.google_books_preview %]
[% IF ctx.page == 'advanced' %]
<script type="text/javascript"
src="[% ctx.media_prefix %]/js/ui/default/opac/copyloc.js"></script>
commit a968d72e91e40adfe42c28462f4c257c3d1688d5
Author: Dan Scott <dan at coffeecode.net>
Date: Sun Apr 16 22:27:52 2017 -0400
LP#1685840: Dojoless Google Books Preview
Avoid polluting the global namespace by wrapping the code in (function() {})().
Add event listeners to the DOM elements rather than the crufty
href=javascript:function approach.
Optimization: do not load the Google Books JSAPI unless there is a matching
embedded ISBN.
Use display style directly, rather than munging class names with hide_me
Supports IE 10/11, which does not handle responseType = 'json', through
the fallback to XHR responseText.
IE9 for now; it seems the new Google Books Loader wipes out the DOM in
IE9 instead of loading nicely in the <head>. Could go back to the old
Google JS loader, which still works, but is deprecated, so could
disappear at any point.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Ben Shum <ben at evergreener.net>
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
diff --git a/Open-ILS/src/templates/opac/css/style.css.tt2 b/Open-ILS/src/templates/opac/css/style.css.tt2
index aba12de..3daeb49 100644
--- a/Open-ILS/src/templates/opac/css/style.css.tt2
+++ b/Open-ILS/src/templates/opac/css/style.css.tt2
@@ -774,6 +774,10 @@ div.format_icon {
margin:0;
}
+#gbp_extra, #gbp_arrow_down_link {
+ display: none;
+}
+
.almost-content-wrapper {
background: [% css_colors.background %];
}
diff --git a/Open-ILS/src/templates/opac/parts/ac_google_books.tt2 b/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
index a03bfb9..c5a1303 100644
--- a/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
+++ b/Open-ILS/src/templates/opac/parts/ac_google_books.tt2
@@ -1,132 +1,161 @@
-<script type="text/javascript">
-var GBisbns = Array();
-var GBPreviewLink = '';
-var GBPreviewShowing = false;
+<script>
+;(function () {
+ var GBisbns = [];
+ var GBPBadgelink;
+ var GBPreviewLink = '';
+ var GBPreviewShowing = false;
+ var lang = '[% ctx.locale.substr(0,2) %]';
+ var head = document.getElementsByTagName('head')[0];
/**
- *
- * @param {DOM object} isbn The form element containing the input parameters "isbns"
- */
-function searchForGBPreview( isbn ) {
- dojo.require("dojo.io.script");
- dojo.io.script.get({"url": "https://www.google.com/jsapi"});
- dojo.io.script.get({"url": "https://www.googleapis.com/books/v1/volumes", "content": { "q": "isbn:" + isbn, "callback": "GBPreviewCallback"}});
-}
-
-/**
- * This function is the call-back function for the JSON scripts which
+ * This function is the call-back function for the JSON scripts which
* executes a Google book search response.
*
* @param {JSON} GBPBookInfo is the JSON object pulled from the Google books service.
*/
-function GBPreviewCallback(GBPBookInfo) {
- if (GBPBookInfo.totalItems < 1) return;
+ function GBPreviewCallback (GBPBookInfo) {
+ if (GBPBookInfo.totalItems < 1) {
+ return;
+ }
- var accessInfo = GBPBookInfo.items[0].accessInfo;
- if ( !accessInfo ) {
- return;
- }
+ var accessInfo = GBPBookInfo.items[0].accessInfo;
+ if (!accessInfo) {
+ return;
+ }
- if ( accessInfo.embeddable ) {
- GPPreviewLink = GBPBookInfo.items[0].volumeInfo.previewLink;
- if ( !GPPreviewLink) {
+ if (accessInfo.embeddable) {
+ GBPreviewLink = GBPBookInfo.items[0].volumeInfo.previewLink;
+ if (!GBPreviewLink) {
return;
- }
+ }
+ if (document.location.protocol === 'https:') {
+ GBPreviewLink = GBPreviewLink.replace(/^http:/, 'https:');
+ }
+ var gbsrc = '//www.google.com/books/jsapi.js';
+ if (!head.querySelector('script[src="' + gbsrc + '"]')) {
+ var GBjsapi = document.createElement('script');
+ GBjsapi.src = gbsrc;
+ head.appendChild(GBjsapi);
+ }
/* Add a button below the book cover image to load the preview. */
- var GBPBadge = document.createElement( 'img' );
- GBPBadge.id = 'gbpbadge';
- 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';
- GBPBadgelink = document.createElement('a');
- GBPBadgelink.id = 'gbpbadge_link';
- GBPBadgelink.href = 'javascript:GBDisplayPreview(true);';
- GBPBadgelink.appendChild( GBPBadge );
- dojo.byId('rdetail_title_div').appendChild( GBPBadgelink );
- unHideMe(dojo.byId('gbp_extra'));
+ var GBPBadge = document.createElement('img');
+ GBPBadge.id = 'gbpbadge';
+ GBPBadge.src = 'https://www.google.com/intl/' + lang + '/googlebooks/images/gbs_preview_button1.gif';
+ GBPBadge.title = document.getElementById('rdetail_title').innerHTML;
+ GBPBadge.style.border = 0;
+ GBPBadge.style.margin = '0.5em 0 0 0';
+ GBPBadgelink = document.createElement('a');
+ GBPBadgelink.id = 'gbpbadge_link';
+ GBPBadgelink.addEventListener('click', GBDisplayPreview);
+ GBPBadgelink.appendChild(GBPBadge);
+ document.getElementById('rdetail_title_div').appendChild(GBPBadgelink);
+ document.getElementById('gbp_extra').style.display = 'block';
+ }
+ }
+
+ function GBPViewerLoadCallback () {
+ var GBPViewer = new google.books.DefaultViewer(document.getElementById('rdetail_preview_div'));
+ GBPViewer.load(GBPreviewLink);
+ GBPViewer.resize();
+ GBPBadgelink = document.getElementById('gbpbadge_link');
+ GBPBadgelink.removeEventListener('click', GBDisplayPreview);
+ GBPBadgelink.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.
*/
-function GBDisplayPreview(scroll_to_div) {
- var GBPreviewPane = document.createElement('div');
- GBPreviewPane.id = 'rdetail_preview_div';
- GBPreviewPane.style.height = '800px';
- GBPreviewPane.style.width = '600px';
- GBPreviewPane.style.display = 'block';
- var GBClear = document.createElement('div');
- GBClear.style.padding = '1em';
- dojo.byId('gbp_extra_container').appendChild(GBPreviewPane);
- dojo.byId('gbp_extra_container').appendChild(GBClear);
- if (GBPreviewPane.getAttribute('loaded') == null || GBPreviewPane.getAttribute('loaded') == "false" ) {
- google.load("books", "0", {"callback" : GBPViewerLoadCallback, "language": "[% ctx.locale.substr(0,2) %]"} );
- GBPreviewPane.setAttribute('loaded', 'true');
+ function GBDisplayPreview () {
+ var GBPreviewPane = document.getElementById('rdetail_preview_div');
+ if (GBPreviewPane === null || typeof GBPreviewPane.loaded === 'undefined' || GBPreviewPane.loaded === 'false') {
+ GBPreviewPane = document.createElement('div');
+ GBPreviewPane.id = 'rdetail_preview_div';
+ GBPreviewPane.style.height = '800px';
+ GBPreviewPane.style.width = '600px';
+ GBPreviewPane.style.display = 'block';
+ var GBClear = document.createElement('div');
+ GBClear.style.padding = '1em';
+ document.getElementById('gbp_extra_container').appendChild(GBPreviewPane);
+ 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();
+ document.location.hash = '#gbp_extra';
}
- if (scroll_to_div) document.location.hash = '#gbp_extra';
-}
-function GBPViewerLoadCallback() {
- var GBPViewer = new google.books.DefaultViewer(dojo.byId('rdetail_preview_div'));
- GBPViewer.load(GPPreviewLink);
- GBPViewer.resize();
- var GBPBadgelink = dojo.byId('gbpbadge_link');
- GBPBadgelink.href = 'javascript:GBShowHidePreview(true);';
- dojo.forEach(
- dojo.byId('gbp_extra_links').getElementsByTagName('a'),
- function(link) {
- link.href = 'javascript:GBShowHidePreview();';
+ function GBShowHidePreview () {
+ if (!GBPreviewShowing) {
+ document.getElementById('gbp_extra_container').style.display = 'inherit';
+ document.getElementById('gbp_arrow_link').style.display = 'none';
+ document.getElementById('gbp_arrow_down_link').style.display = 'inline';
+ GBPreviewShowing = true;
+ document.location.hash = '#gbp_extra';
+ } else { // button can open, but shouldn't close
+ document.getElementById('gbp_extra_container').style.display = 'none';
+ document.getElementById('gbp_arrow_link').style.display = 'inline';
+ document.getElementById('gbp_arrow_down_link').style.display = 'none';
+ GBPreviewShowing = false;
+ document.location.hash = 'rdetail_title';
}
- );
- hideMe(dojo.byId('gbp_arrow_link'));
- unHideMe(dojo.byId('gbp_arrow_down_link'));
- GBPreviewShowing = true;
-}
-
-function GBShowHidePreview(from_button) {
- if (!GBPreviewShowing) {
- dojo.byId('gbp_extra_container').style.display = 'inherit';
- hideMe(dojo.byId('gbp_arrow_link'));
- unHideMe(dojo.byId('gbp_arrow_down_link'));
- GBPreviewShowing = true;
- } else if (!from_button) { // button can open, but shouldn't close
- dojo.byId('gbp_extra_container').style.display = 'none';
- unHideMe(dojo.byId('gbp_arrow_link'));
- hideMe(dojo.byId('gbp_arrow_down_link'));
- GBPreviewShowing = false;
}
- // button should always scroll
- if (from_button) document.location.hash = '#gbp_extra';
-}
-dojo.addOnLoad(function() {
- var spans = dojo.query('li.rdetail_isbns span.rdetail_value');
- for (var i = 0; i < spans.length; i++) {
- var prop = spans[i].getAttribute('property');
- if (!prop) {
- continue;
+ function GBLoader () {
+ var spans = document.body.querySelectorAll('li.rdetail_isbns span.rdetail_value');
+ for (var i = 0; i < spans.length; i++) {
+ var prop = spans[i].getAttribute('property');
+ if (!prop) {
+ continue;
+ }
+ var isbn = spans[i].textContent || spans[i].innerText
+ if (!isbn) {
+ continue;
+ }
+ isbn = isbn.toString().replace(/^\s+/, '');
+ var idx = isbn.indexOf(' ');
+ if (idx > -1) {
+ isbn = isbn.substring(0, idx);
+ }
+ isbn = isbn.toString().replace(/-/g, '');
+ if (!isbn) {
+ continue;
+ }
+ GBisbns.push(isbn);
}
- var isbn = spans[i].textContent || spans[i].innerText;
- if (!isbn) {
- continue;
- }
- isbn = isbn.toString().replace(/^\s+/,"");
- var idx = isbn.indexOf(" ");
- if (idx > -1) {
- isbn = isbn.substring(0, idx);
- }
- isbn = isbn.toString().replace(/-/g,"");
- if (!isbn) {
- continue;
+
+ if (GBisbns.length) {
+ var req = new window.XMLHttpRequest();
+ var qisbn = encodeURIComponent('isbn:' + GBisbns[0]);
+ req.open('GET', 'https://www.googleapis.com/books/v1/volumes?q=' + qisbn + '&prettyPrint=false');
+ if (req.responseType && (req.responseType = 'json')) {
+ req.onload = function (evt) {
+ var result = req.response;
+ if (result) {
+ GBPreviewCallback(result);
+ }
+ }
+ } else {
+ // IE 10/11
+ req.onload = function (evt) {
+ var result = JSON.parse(req.responseText);
+ if (result) {
+ GBPreviewCallback(result);
+ }
+ }
+ }
+ req.send();
}
- GBisbns.push(isbn);
- }
+ };
- if (GBisbns.length) {
- searchForGBPreview(GBisbns[0]);
+ // Skips IE9
+ if (window.addEventListener && !window.XDomainRequest) {
+ window.addEventListener('load', GBLoader, false);
}
-});
+})()
</script>
diff --git a/Open-ILS/src/templates/opac/parts/record/extras.tt2 b/Open-ILS/src/templates/opac/parts/record/extras.tt2
index 04cdd14..b35cf54 100644
--- a/Open-ILS/src/templates/opac/parts/record/extras.tt2
+++ b/Open-ILS/src/templates/opac/parts/record/extras.tt2
@@ -8,14 +8,13 @@
IF ctx.google_books_preview;
label = l('Google Preview');
name = 'google_preview';
- href = 'javascript:GBDisplayPreview();';
%]
- <div id="gbp_extra" class="rdetail_extras hide_me">
+ <div id="gbp_extra" class="rdetail_extras">
<div class="rdetail_extras_hr"></div>
<div id="gbp_extra_links" class="rdetail_extras_link">
- <a id='gbp_arrow_link' name='[% name %]' href='[% href %]' class='rdetail_extras_lbl'>[% arrow_right %]</a>
- <a id='gbp_arrow_down_link' name='[% name %]' href='[% href %]' class='rdetail_extras_lbl hide_me'>[% arrow_down %]</a>
- <a name='[% name %]_lbl' href='[% href %]' class="rdetail_extras_lbl">[% label %]</a></div>
+ <a id='gbp_arrow_link' name='[% name %]' class='rdetail_extras_lbl'>[% arrow_right %]</a>
+ <a id='gbp_arrow_down_link' name='[% name %]' class='rdetail_extras_lbl'>[% arrow_down %]</a>
+ <a name='[% name %]_lbl' class="rdetail_extras_lbl">[% label %]</a></div>
</div>
<div id="gbp_extra_container" class='rdetail_extras_div'></div>
[% END %]
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/templates/opac/css/style.css.tt2 | 4 +
.../src/templates/opac/parts/ac_google_books.tt2 | 132 ---------------
Open-ILS/src/templates/opac/parts/header.tt2 | 4 -
Open-ILS/src/templates/opac/parts/js.tt2 | 4 +-
.../src/templates/opac/parts/record/extras.tt2 | 9 +-
Open-ILS/web/js/ui/default/opac/ac_google_books.js | 171 ++++++++++++++++++++
.../OPAC/google_books_preview_no_dojo.adoc | 20 +++
7 files changed, 202 insertions(+), 142 deletions(-)
delete mode 100644 Open-ILS/src/templates/opac/parts/ac_google_books.tt2
create mode 100644 Open-ILS/web/js/ui/default/opac/ac_google_books.js
create mode 100644 docs/RELEASE_NOTES_NEXT/OPAC/google_books_preview_no_dojo.adoc
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list