Teach OPAC (jspac) jacket images by record id
authorJeff Godin <jgodin@tadl.org>
Sat, 28 Apr 2012 22:18:34 +0000 (18:18 -0400)
committerBen Shum <bshum@biblio.org>
Thu, 26 Sep 2013 17:56:21 +0000 (13:56 -0400)
Teach the Javascript OPAC how to retrieve jacket images by
record id.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/web/opac/common/js/added_content.js
Open-ILS/web/opac/skin/default/js/cn_browse.js
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/js/result_common.js

index 4240b4f..68f5529 100644 (file)
@@ -11,6 +11,17 @@ function buildISBNSrc(isbn, size) {
        return '../../../../extras/ac/jacket/'+size+'/'+isbn;
 }      
 
+/**
+* This function should return a URL which points to the book cover image based on record ID.
+*/
+
+function buildJacketSrc(rec_id, size) {
+size = (size) ? size : 'small';
+       var protocol = (OILS_OPAC_STATIC_PROTOCOL) ? OILS_OPAC_STATIC_PROTOCOL + ':' : location.protocol;
+       if(OILS_OPAC_IMAGES_HOST)
+               return protocol + '//' + OILS_OPAC_IMAGES_HOST + size + '/r/' + rec_id;
+       return '../../../../extras/ac/jacket/'+size+'/r/'+rec_id;
+}
 
 function acMakeURL(type, key) {
        return '../../../../extras/ac/' + type + '/html/' + key;
index 94b8c8b..4d1f59f 100644 (file)
@@ -133,7 +133,7 @@ function cnBrowseDrawTitle(mods, title_td, author_td, pic_td) {
 
        buildTitleDetailLink(mods, title_td); 
        buildSearchLink(STYPE_AUTHOR, mods.author(), author_td);
-       pic_td.setAttribute("src", buildISBNSrc(cleanISBN(mods.isbn())));
+       pic_td.setAttribute("src", buildJacketSrc(mods.doc_id()));
 
        var args = {};
        args.page = RDETAIL;
index 3446574..596c0c2 100644 (file)
@@ -508,8 +508,10 @@ function _rdetailDraw(r) {
                        rdetailCheckForGBPreview();
 
                } else {
-                       hideMe($("rdetail.jacket_attrib_div"));
-                       hideMe($("rdetail_img_link"));
+                       if(!record.doc_id()) {
+                               hideMe($("rdetail.jacket_attrib_div"));
+                               hideMe($("rdetail_img_link"));
+                       }
                }
        } catch(E) {}
 
@@ -599,8 +601,8 @@ function _rdetailDraw(r) {
                unHideMe($('rdetail_exp_refworks_span'));
        }
 
-       $('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
-       G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
+       $('rdetail_img_link').setAttribute('href', buildJacketSrc(record.doc_id()), 'large'));
+       G.ui.rdetail.image.setAttribute("src", buildJacketSrc(record.doc_id()));
        runEvt("rdetail", "recordDrawn");
        recordsCache.push(record);
 
index d5052d3..061bf6f 100644 (file)
@@ -531,8 +531,8 @@ function resultDisplayRecord(rec, pos, is_mr) {
 */
 
     var pic = $n(r, config.names.result.item_jacket);
-    if (currentISBN) {
-        pic.setAttribute("src", buildISBNSrc(currentISBN));
+    if (rec.doc_id()) {
+        pic.setAttribute("src", buildJacketSrc(rec.doc_id()));
     } else {
         pic.setAttribute("src", "/opac/images/blank.png");
     }