Add a basic option for avoiding holds on available items
authordbs <dbs@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 12 Apr 2009 20:16:34 +0000 (20:16 +0000)
committerdbs <dbs@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 12 Apr 2009 20:16:34 +0000 (20:16 +0000)
Also bring Google Book Previews into sync with trunk

git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@322 6d9bc8c9-1ec2-4278-b937-99fde70a366f

web/opac/skin/default/js/rdetail.js

index 254270a..bb7d691 100644 (file)
@@ -26,6 +26,7 @@ var _statusPositions = {};
 var rdetailShowLocal = true;
 var rdetailShowCopyLocation = true;
 var googleBookPreview = true;
+var enableHoldsOnAvailable = false;
 
 
 var nextContainerIndex;
@@ -197,6 +198,13 @@ function _rdetailDraw(r) {
        }
        G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
 
+       if (enableHoldsOnAvailable) {
+               unHideMe($('rdetail_place_hold'));      
+       } else {
+               hideMe($('rdetail_place_hold'));        
+               rdetailCheckAvailable();
+       }
+
        try{
                if(record.isbn()) {
                        if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) {
@@ -281,6 +289,20 @@ function _rdetailDraw(r) {
 }
 
 
+function rdetailCheckAvailable() {
+       var loc = getLocation();
+       var rid = getRid();
+       var req = new Request( 'open-ils.search:open-ils.search.biblio.record.copy_count', loc, rid );
+       req.callback(rdetailEnableHold); 
+       req.send();
+}
+
+function rdetailEnableHold(r) {
+       var ccDepths = r.getResultObject();
+       if ((ccDepths[(ccDepths.length - 1)].available) > 0) {
+               unHideMe($('rdetail_place_hold'));
+       }
+}
 
 function rdetailCheckDeleted(r) {
        var br = r.getResultObject()[0];
@@ -819,17 +841,11 @@ function _rdetailSortStatuses(a, b) {
 }
 
 /**
- * XXX Need to adopt a more typical approach to showing loading status
+ * Check for a Google Book preview 
  */
 function rdetailCheckForGBPreview() {
-
        if (!googleBookPreview) return;
-       var GBPp = document.createElement('p');
-       GBPp.appendChild( document.createTextNode('Loading... ' ) );
-       GBPp.id = 'loading';
-       $('rdetail_preview_div').appendChild(GBPp);
        searchForGBPreview( cleanISBN(record.isbn()) );
-
 }
 
 /**
@@ -869,7 +885,6 @@ function searchForGBPreview( isbn ) {
  * @param {JSON} booksInfo is the JSON object pulled from the Google books service.
  */
 function GBPreviewCallback(GBPBookInfo) {
-       // Clear any old data to prepare to display the Loading... message.
        var GBPreviewDiv = document.getElementById("rdetail_preview_div");
        var GBPBook;
 
@@ -883,22 +898,23 @@ function GBPreviewCallback(GBPBookInfo) {
 
        if ( GBPBook.preview != "noview" ) {
                if ( GBPBook.preview == 'full' ) {
-                       setText( $('rdetail_preview_link'), 'Full Text' );
-                       $('rdetail_preview_link_a').title = 'See the full text of this book.';      
+                       setText( $('rdetail_preview_link'), $('rdetail_preview_full_text').innerHTML );
+                       $('rdetail_preview_link_a').title = $('rdetail_preview_title').innerHTML;      
                }
 
                // Add a button below the book cover image to load the preview.
                GBPBadge = document.createElement( 'img' );
                GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif';
-               GBPBadge.title = 'Show a preview of this book from Google Book Search';
+               GBPBadge.title = $('rdetail_preview_badge').innerHTML;
                GBPBadge.style.border = 0;
                GBPBadgelink = document.createElement( 'a' );
                GBPBadgelink.href = 'javascript:rdetailShowExtra("preview");';
                GBPBadgelink.appendChild( GBPBadge );
                $('rdetail_image_cell').appendChild( GBPBadgelink );
+               $('rdetail_preview_div').style.height = 600;
 
+               /* Display the "Preview" tab in the Extras section */
                unHideMe( $('rdetail_preview_link' ) );
-               $('rdetail_preview_div').style.height = 600;
        }
 }
 
@@ -909,6 +925,7 @@ function GBPreviewCallback(GBPBookInfo) {
  * XXX I18N of Google Book Preview language attribute needed
  */
 function rdetailDisplayGBPreview() {
+       unHideMe($('rdetail_extras_loading'));
        GBPreviewPane = $('rdetail_preview_div');
        if ( GBPreviewPane.getAttribute('loaded') == null ||
                GBPreviewPane.getAttribute('loaded') == "false" ) {
@@ -918,6 +935,7 @@ function rdetailDisplayGBPreview() {
 }
 
 function rdetailGBPViewerLoadCallback() {
+       hideMe($('rdetail_extras_loading'));
        var GBPViewer = new google.books.DefaultViewer(document.getElementById('rdetail_preview_div'));
        GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) );