syncing js files
authorartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Fri, 10 Sep 2010 21:02:17 +0000 (21:02 +0000)
committerartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Fri, 10 Sep 2010 21:02:17 +0000 (21:02 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_1_6_1@983 6d9bc8c9-1ec2-4278-b937-99fde70a366f

web/opac/skin/uwin/js/adv_global.js
web/opac/skin/uwin/js/copy_details.js
web/opac/skin/uwin/js/depth_selector.js
web/opac/skin/uwin/js/myopac.js
web/opac/skin/uwin/js/rdetail.js
web/opac/skin/uwin/js/result_common.js
web/opac/skin/uwin/js/rresult.js
web/opac/skin/uwin/js/search_bar.js

index a8a0a14..74edd3f 100644 (file)
@@ -121,6 +121,10 @@ function initSearchBoxes() {
 
     var types = getObjectKeys(search.searches);
 
+    // if we have browser cached data, clear it before populating from cookie
+    if (search.searches[types[0]].term)
+        clearSearchBoxes();
+
     /* pre-add the needed rows */
     while($('adv_global_tbody').getElementsByTagName('tr').length - 1 < types.length)
         advAddGblRow();
@@ -307,7 +311,7 @@ function advBuildSearchBlob() {
             string = string.replace(/\s*$/,'');
                        //searches[stype].term = string;
             if(searches) searches += ' ';
-            searches += stype + ':'+ string;
+            searches += stype + ': '+ string;
                }
        }
 
index 762b13e..9d3b407 100644 (file)
@@ -2,8 +2,15 @@ var cpdTemplate;
 var cpdCounter = 0;
 var cpdNodes = {};
 
+/* showDueDate will show the due date in the OPAC */
+var showDueDate = false;
+/* showDueTime will show the due time (hours and minutes) in the OPAC;
+   if showDueDate is false, then showDueTime has no effect
+*/
+var showDueTime = false;
+
 function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, copy_location ) {
-var i = cpdCheckExisting(contextRow);
+       var i = cpdCheckExisting(contextRow);
        if(i) return i;
 
        var counter = cpdCounter++;
@@ -25,6 +32,9 @@ var i = cpdCheckExisting(contextRow);
                unHideMe($n(templateRow, 'age_protect_label'));
                unHideMe($n(templateRow, 'create_date_label'));
                unHideMe($n(templateRow, 'holdable_label'));
+       }
+
+       if (isXUL() || showDueDate) {
                unHideMe($n(templateRow, 'due_date_label'));
        }
 
@@ -177,6 +187,9 @@ function cpdDrawCopies(r) {
                unHideMe($n(copyrow, 'age_protect_value'));
                unHideMe($n(copyrow, 'create_date_value'));
                unHideMe($n(copyrow, 'copy_holdable_td'));
+       }
+
+       if(isXUL() || showDueDate) {
                unHideMe($n(copyrow, 'copy_due_date_td'));
        }
 
@@ -219,6 +232,30 @@ function cpdDrawCopy(r) {
                        );
                }
 
+               /* show the book now link */
+               l = $n(row, 'copy_reserve_link');
+               unHideMe(l);
+               l.onclick = function() {
+                       // XXX FIXME this duplicates things in cat/util.js
+                       // Also needs i18n
+                       dojo.require("fieldmapper.Fieldmapper");
+                       var r = fieldmapper.standardRequest(
+                               ["open-ils.booking",
+                                       "open-ils.booking.resources.create_from_copies"],
+                               [G.user.session, [copy.id()]]
+                       );
+                       if (!r) {
+                               alert("No response from server!");
+                       } else if (r.ilsevent != undefined) {
+                               alert("Error from server:\n" + js2JSON(r));
+                       } else {
+                               xulG.auth = {"session": {"key": G.user.session}};
+                               xulG.bresv_interface_opts = {"booking_results": r};
+                               location.href = "/eg/booking/reservation";
+                       }
+               }
+
+
                if( copy.age_protect() ) 
                        appendClear($n(row, 'age_protect_value'), text(copy.age_protect().name()));
 
@@ -236,15 +273,21 @@ function cpdDrawCopy(r) {
                } else {
                        $n(row, 'copy_is_holdable').appendChild(text(no));      
                }
+       }
 
+       if (isXUL() || showDueDate) {
                var circ;
                if( copy.circulations() ) {
                        circ = copy.circulations()[0];
                        if( circ ) {
-                               $n(row, 'copy_due_date').appendChild(text(circ.due_date().replace(/[T ].*/,'')));
+                                var due_time = dojo.date.stamp.fromISOString(circ.due_date().replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3"));
+                                if( showDueTime ) {
+                                        $n(row, 'copy_due_date').appendChild(text(dojo.date.locale.format(due_time, {"formatLength": "medium"})));
+                                } else {
+                                        $n(row, 'copy_due_date').appendChild(text(dojo.date.locale.format(due_time, {"selector": "date", "formatLength": "medium"})));
+                                }
                        }
                }
-
        }
 
        r.args.copy = copy;
index 1bd983e..6bd4b0e 100644 (file)
@@ -78,6 +78,7 @@ function buildLocationSelector(newLoc) {
        var type;
        if (location) type = findOrgType(location.ou_type());
 
+       var orgHiding = checkOrgHiding();
        while( type && location ) {
                var n = node.cloneNode(true);   
                n.setAttribute("value", type.depth());
@@ -85,8 +86,14 @@ function buildLocationSelector(newLoc) {
                n.appendChild(text(type.opac_label()));
                selector.appendChild(n);
                location = findOrgUnit(location.parent_ou());
-               if(location) type = findOrgType(location.ou_type());
-               else type = null;
+               if(location) {
+                       type = findOrgType(location.ou_type());
+                       if (orgHiding && orgHiding.depth > type.depth()) {
+                               type = null;
+                       }
+               } else {
+                       type = null;
+               }
        }
 
        selector.appendChild(node);
index 3eccb25..3e4ca8a 100644 (file)
@@ -8,6 +8,10 @@ var fleshedContainers = {};
 var holdCache = {};
 var holdStatusCache = {};
 var allowPendingAddr = false;
+var preventRenewOverdue = false;
+var myopacEnableRefWorks = true;
+var myopacRefWorksHost = 'http://refworks.scholarsportal.info';
+
 
 function clearNodes( node, keepArray ) {
        if(!node) return;
@@ -165,19 +169,42 @@ function myOPACDrawCheckedOutSlim(r) {
                return;
        }
 
+    var totalAsync = checked.overdue.length + checked.out.length;
+    var fetchedCircs = [];
+    var collectCircs = function(r) {
+        var circ = r.getResultObject();
+        circ._od = r.od;
+        fetchedCircs.push(circ);
+        if(fetchedCircs.length < totalAsync) return;
+
+        // sort by due date, oldest to newest
+        fetchedCircs = fetchedCircs.sort(
+            function(a, b) {
+                if(a.due_date() > b.due_date()) return 1;
+                return -1;
+            }
+        )
+
+        dojo.forEach(fetchedCircs, 
+            function(circ) { 
+                myOPACDrawCheckedItem(circ, tbody);
+            }
+        );
+    }
+
        for( var i = 0; i < checked.overdue.length; i++ ) {
                var req = new Request(FETCH_CIRC_BY_ID, G.user.session, checked.overdue[i]);
-               req.request.tbody = tbody;
+               //req.request.tbody = tbody;
                req.request.od = true;
-               req.callback(myOPACDrawCheckedItem);
+               req.callback(collectCircs);
                req.send();
        }
 
 
        for( var i = 0; i < checked.out.length; i++ ) {
                var req = new Request(FETCH_CIRC_BY_ID, G.user.session, checked.out[i]);
-               req.request.tbody = tbody;
-               req.callback(myOPACDrawCheckedItem);
+               //req.request.tbody = tbody;
+               req.callback(collectCircs);
                req.send();
        }
 
@@ -193,13 +220,14 @@ function myOPACDrawCheckedOutSlim(r) {
 }
 
 
-function myOPACDrawCheckedItem(r) {
+//function myOPACDrawCheckedItem(r) {
+function myOPACDrawCheckedItem(circ, tbody) {
 
-       var circ = r.getResultObject();
-       var tbody = r.tbody;
+       //var circ = r.getResultObject();
+       //var tbody = r.tbody;
        var row = checkedRowTemplate.cloneNode(true);
        row.id = 'myopac_checked_row_ ' + circ.id();
-   row.setAttribute('circid', circ.id());
+    row.setAttribute('circid', circ.id());
 
        var due = _trimTime(circ.due_date());
 
@@ -208,7 +236,7 @@ function myOPACDrawCheckedItem(r) {
        //var rnlink = $n( row, "myopac_checked_renew_link" );
 
        //if( r.od ) due = elem('b', {style:'color:red;font-size:110%'},due);
-       if( r.od ) {
+       if( circ._od ) {
       due = elem('b', null, due);
       addCSSClass(due, 'overdue');
    } else {
@@ -221,7 +249,8 @@ function myOPACDrawCheckedItem(r) {
        //rnlink.setAttribute('href', 'javascript:myOPACRenewCirc("'+circ.id()+'");');
        circsCache.push(circ);
 
-       if( circ.renewal_remaining() < 1 ) {
+   // Disable renewals if no renewals left or item already overdue
+   if( circ.renewal_remaining() < 1 || (preventRenewOverdue && circ._od)) {
       $n(row, 'selectme').disabled = true;
       if(!__can_renew_one)
          $('mo_renew_button').disabled = true;
@@ -370,7 +399,7 @@ function myOPACDrawHolds(r) {
 
         var exp_date;
         if(h.expire_time()) {
-            exp_date = dojo.date.stamp.fromISOString(h.expire_time());
+            exp_date = dojo.date.stamp.fromISOString(h.expire_time().replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3"));
             $n(row, 'myopac_hold_expire_time').appendChild(
                 text(dojo.date.locale.format(exp_date, {selector:'date'})));
         }
@@ -560,6 +589,7 @@ function _finesFormatNumber(num) {
 //function _trimTime(time) { if(!time) return ""; return time.replace(/\ .*/,""); }
 function _trimTime(time) { 
        if(!time) return ""; 
+    time = time.replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3");
     var d = dojo.date.stamp.fromISOString(time);
     if(!d) return ""; /* date parse failed */
     return d.iso8601Format('YMD');
@@ -567,7 +597,7 @@ function _trimTime(time) {
 
 function _trimSeconds(time) { 
     if(!time) return ""; 
-    var d = dojo.date.stamp.fromISOString(time);
+    var d = dojo.date.stamp.fromISOString(time.replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3"));
     if(!d) return ""; /* date parse failed */
     return d.iso8601Format('YMDHM',null,true,true);
 }
@@ -665,8 +695,7 @@ function myOPACShowCircTransaction(trans, record, circ) {
 
        $n(row,'myopac_circ_trans_start').
                appendChild(text(_trimTime(trans.xact_start())));
-
-   var due = _trimTime(circ.due_date());
+       var due = _trimTime(circ.due_date());
        var checkin = _trimTime(circ.stop_fines_time());
 
        $n(row,'myopac_circ_trans_due').appendChild(text(due))
@@ -1063,7 +1092,7 @@ function myOPACUpdateEmail() {
        var req = new Request(UPDATE_EMAIL, G.user.session, email );
        req.send(true);
        if(req.result()) {
-               G.user.usrname(email);
+               G.user.email(email);
                hideMe($('myopac_update_email_row'));
                userShown = false;
                alertId('myopac_email_success');
@@ -1147,7 +1176,23 @@ function myOPACShowBookbags(force) {
                        link = $n(row, 'myopac_bb_make_unpublished');
                        link.setAttribute('href', 'javascript:myOPACMakeBBPublished("'+cont.id()+'", true);');
                        unHideMe(link);
-
+                        
+                       var RW = $n(row, 'myopac_bb_exp_refworks');
+                       if (RW && myopacEnableRefWorks) {
+                               var here = (findOrgUnit(getLocation())).name();
+                               var org_name = here.replace(" ", "+");
+                               var cgi = new CGI();
+
+                               RW.setAttribute('href',
+                               myopacRefWorksHost + '/express/expressimport.asp?vendor='
+                                       + org_name
+                                       + '&filter=MARC+Format&database=All+MARC+Formats&encoding=65001&url=http%3A%2F%2F'
+                                       + cgi.server_name + '/opac/extras/feed/bookbag/marctxt-full/'
+                                       + cont.id()
+                               );
+                               RW.setAttribute('target', 'RefWorksMain');
+                               unHideMe($n(row, 'myopac_bb_exp_refworks'));
+                       }
                } else { 
                        unHideMe($n(row, 'myopac_bb_published_no')); 
                        var link = $n(row, 'myopac_bb_make_published');
@@ -1347,7 +1392,7 @@ function myOPACDrawNonCatCirc(r) {
        duration = parseInt(duration + '000');
 
        var dtf = circ.circ_time();
-    var start = dojo.date.stamp.fromISOString(circ.circ_time());
+       var start = dojo.date.stamp.fromISOString(circ.circ_time().replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3"));
        var due = new Date(  start.getTime() + duration );
        appendClear($n(row, 'circ_time'), text(due.iso8601Format('YMDHM', null, true, true)));
 }
@@ -1391,120 +1436,36 @@ var __renew_circs = [];
 /* true if 1 renewal succeeded */
 var __success_count = 0;
 
-/*
-       holdBlock - checking for holds before allowing renewals
+/* renews all selected circulations */
+function myOPACRenewSelected() {
+   var rows = myopacGetCheckedOutRows();
+       if(!confirm($('myopac_renew_confirm').innerHTML)) return;
+   __success_count = 0;
 
-*/
-function holdBlock(r) {
-       var rec = r.getResultObject();
-       var circ = r.circ;
-                               
-       //this may be inefficient, but go this route to snag needed title id
-       var new_req = new Request( FETCH_BIB_ID_BY_BARCODE, rec.barcode() );
-       new_req.send(true);
-                               
-       if (new_req) {
-               var record = new_req.result();
-                               
-               if (record){
-                       //alert(HOLDSU + ' start for ' + circ.id() + ' - ' + rec.barcode());
-                       /*
-                       var init_request = new Request( LOGIN_INIT, HOLDSU );
-                       init_request.send(true);
-                       var seed = init_request.result();
-
-                       var args = {
-                               password : hex_md5(seed + hex_md5(HOLDSP)),
-                               type            : "opac",
-                               org             : getOrigLocation(),
-                               username : HOLDSU
-                       };
-
-                       var auth_request = new Request( LOGIN_COMPLETE, args );
-
-                       auth_request.request.alertEvent = false;
-                       auth_request.send(true);
-                       var auth_result = auth_request.result();
-
-                               if(!auth_result) {
-                               alertId('problem with renewing');
-                               return null;
-                       }
-
-                       var temp_session = auth_result.payload.authtoken;
-                       */
-                               
-                       //if you needed a special session for this, would use the above
-                       //and pass it in the call, however, this doesn't seem to matter
-                       //for this call
-                       /*
-                       new_req = new Request( "open-ils.circ:open-ils.circ.open_holds.retrieve", 
-                               temp_session, record, 'T', getOrigLocation() );
-                       */
-
-                       //make the call with user's credentials
-                       new_req = new Request( "open-ils.circ:open-ils.circ.open_holds.retrieve", 
-                               G.user.session, record, 'T', getOrigLocation() );
-                               
-                       new_req.send(true);
-
-                       //we would clean up session right away if we had created one
-                       /*
-                       var sess_req = new Request(LOGIN_DELETE, temp_session);
-                       sess_req.send(true);
-                       try { sess_req.result(); } catch(E){}
-                       */
-                               
-                       if (new_req) {
-                               record = new_req.result();
-                               if (record.length > 0) {
-                                       var renewTitle = __circ_titles[circ.id()];
-                                       if (renewTitle) {
-                                               alert('Sorry, someone has requested \"' + renewTitle +
-                                                       '\", it can not be renewed, please return this title to the library.');
-                                       }//if renewTitle
-                                       return null;
-                               } else {
-                                       //alert('renew for ' + circ.id());
-                                       moRenewCirc( circ.target_copy(), G.user.id(), circ );
-                               }//if record
-                       }//if new_req
-               
-               }//if record
-       }//if new_req
-
-}//holdBlock
+   for( var i = 0; i < rows.length; i++ ) {
 
+      var row = rows[i];
+      if( ! $n(row, 'selectme').checked ) continue;
+      var circ_id = row.getAttribute('circid');
 
-/* renews all selected circulations */
-function myOPACRenewSelected() {
+          var circ;
+          for( var j = 0; j != circsCache.length; j++ ) 
+                  if(circsCache[j].id() == circ_id)
+                          circ = circsCache[j];
 
-       var rows = myopacGetCheckedOutRows();
-       if(!confirm($('myopac_renew_confirm').innerHTML)) return;
-       __success_count = 0;
-
-       for( var i = 0; i < rows.length; i++ ) {
-
-               var row = rows[i];
-               if( ! $n(row, 'selectme').checked ) continue;
-               var circ_id = row.getAttribute('circid');
-
-               var circ;
-               for( var j = 0; j != circsCache.length; j++ ) {
-                       if(circsCache[j].id() == circ_id) {
-                               circ = circsCache[j];
-                               var cp =  circ.target_copy();
-                               if (cp) {
-                                       var hold_req = new Request(FETCH_FLESHED_COPY, 
-                                               circ.target_copy() );
-                                       hold_req.request.circ = circ;
-                                       hold_req.callback(holdBlock);
-                                       hold_req.send();
-                               }//if cp
-                       }//if circsCache
-               }//for j
-       }//for i
-}//myOPACRenewSelected
+      __renew_circs.push(circ);
+   }
+
+    if( __renew_circs.length == 0 ) return;
+
+    unHideMe($('my_renewing'));
+    moClearCheckedTable();
+
+    for( var i = 0; i < __renew_circs.length; i++ ) {
+        var circ = __renew_circs[i];
+        moRenewCirc( circ.target_copy(), G.user.id(), circ );
+    }
+}
 
 
 /* renews a single circulation */
index e75eed5..7f59e6d 100644 (file)
@@ -10,15 +10,11 @@ attachEvt("rdetail", "recordDrawn", rdetailGetPageIds);
 var rdetailLocalOnly = true;
 var rdetailShowLocal = true;
 var rdetailShowCopyLocation = true;
-var rdetailGoogleBookPreview = false;
+var rdetailGoogleBookPreview = true;
 var rdetailDisplaySerialHoldings = true;
-var rdetailEnableRefWorks = true;
+var rdetailEnableRefWorks = false;
 var rdetailRefWorksHost = 'http://refworks.scholarsportal.info';
-
-/* threshold for paging */
-var rdetailBreakUpLargeSets = true; //flag for paging support
-var pgThreshold = 15; //the number of items to invoke paging
-var pgDisplay = 10; //number of items to display at a time
+var enableHoldsOnAvailable = false;
 
 /* vars vars vars */
 var record = null;
@@ -49,6 +45,8 @@ var rdetailEnd = null;
 
 /* serials are currently the only use of Dojo strings in the OPAC */
 if (rdetailDisplaySerialHoldings) {
+       dojo.require("dijit.Menu");
+       dojo.require("dijit.form.Button");
        dojo.requireLocalization("openils.opac", "opac");
        opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
 }
@@ -134,6 +132,17 @@ function rdetailDraw() {
                var req = new Request(FETCH_MFHD_SUMMARY, getRid());
                req.callback(_holdingsDraw);
                req.send();
+               if (isXUL()) {
+                       var here = findOrgUnit(getLocation());
+                       dojo.place("<div id='mfhd_ad_menu></div>", "rdetail_details_table", "after");
+                       var mfhd_add = new dijit.Menu({style:"float: right;"});
+                       new dijit.MenuItem({onClick:function(){
+                               var req = new Request(CREATE_MFHD_RECORD, G.user.session, 1, here.id(), getRid());
+                               var res = req.send();
+                               alert(dojo.string.substitute(opac_strings.CREATED_MFHD_RECORD, [here.name()]));
+                       }, label:opac_strings.CREATE_MFHD}).placeAt(mfhd_add);
+                       mfhd_add.placeAt(mfhd_ad_menu);
+               }
        }
 
        detachAllEvt("result", "idsReceived");
@@ -231,9 +240,11 @@ function _holdingsDraw(h) {
        if (!holdings) { return null; }
 
        dojo.forEach(holdings, _holdingsDrawMFHD);
+
 }
 
 function _holdingsDrawMFHD(holdings, entryNum) {
+
         var here = findOrgUnit(getLocation());
         if (getDepth() > 0 || getDepth === 0 ) {
                 while (getDepth() < findOrgDepth(here))
@@ -256,12 +267,22 @@ function _holdingsDrawMFHD(holdings, entryNum) {
 
        if (    hh.length == 0 && hch.length == 0 && hs.length == 0 &&
                hcs.length == 0 && hi.length == 0 && hci.length == 0 &&
-               ho.length == 0 && hm.length == 0 && hinc.length == 0 && !isXUL()
+               ho.length == 0 && hm.length == 0 && hinc.length == 0
        ) {
-               return null;
+
+               if (isXUL()) {
+                       /* 
+                        * If we have a record, but nothing to show for it, then the
+                        * record is likely empty or corrupt. This gives cataloguers a
+                        * chance to add holdings or correct the record
+                        */
+                       hh = 'PLACEHOLDER';
+               } else {
+                       return null;
+               }
        }
 
-       dojo.place("<table style='width: 100%;'><caption id='mfhdHoldingsCaption' class='rdetail_header color_1'>" +
+       dojo.place("<table style='width: 100%;'><caption id='mfhdHoldingsCaption" + entryNum + "' class='rdetail_header color_1'>" +
                dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [hloc]) +
                "</caption><tbody id='rdetail_holdings_tbody_" + entryNum +
                "'></tbody></table>", "rdetail_details_table", "after"
@@ -279,10 +300,20 @@ function _holdingsDrawMFHD(holdings, entryNum) {
        if (isXUL()) {
                dojo.require('openils.Event');
                dojo.require('openils.PermaCrud');
-               dojo.place("<span> - </span><a class='classic_link' href='javascript:loadMarcEditor(" +
-                       holdings.id() + ")'>" + opac_strings.EDIT_LABEL + "</a>", 
-                       "mfhdHoldingsCaption", "last"
-               );
+               var mfhd_edit = new dijit.Menu({});
+               new dijit.MenuItem({onClick: function(){loadMarcEditor(holdings.id())}, label:opac_strings.EDIT_MFHD_RECORD}).placeAt(mfhd_edit, "first");
+               new dijit.MenuItem({onClick:function(){
+                       var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
+                       var mfhd_rec = pcrud.retrieve("sre", holdings.id());
+                       if (mfhd_rec) {
+                               pcrud.eliminate(mfhd_rec);
+                               alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.id()]));
+                       }
+               }, label:opac_strings.DELETE_MFHD}).placeAt(mfhd_edit, "last");
+               // new dijit.MenuItem({onClick:function(){alert("Edit properties " + holdings.id());}, label:opac_strings.EDIT_PROPERTIES}).placeAt(mfhd_edit, "last");
+               var mfhd_mb = new dijit.form.DropDownButton({dropDown: mfhd_edit, label:opac_strings.EDIT_MFHD_MENU, style:"float:right"});
+               mfhd_mb.placeAt("mfhdHoldingsCaption" + entryNum, "last");
+               mfhd_edit.startup();
        }
 }
 
@@ -298,14 +329,7 @@ function _rdetailDraw(r) {
 
        G.ui.rdetail.title.appendChild(text(record.title()));
        buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author);
-//     G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
-       var isbnText= text(cleanISBN(record.isbn()));
-       if (isbnText != null){
-               if (isbnText.length > 0){
-               G.ui.rdetail.isbn.appendChild(isbnText);
-               unHideMe($('rdetail_isbn_row'));                
-               }
-       }
+       G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
        G.ui.rdetail.edition.appendChild(text(record.edition()));
        G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
        G.ui.rdetail.publisher.appendChild(text(record.publisher()));
@@ -317,6 +341,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) {
@@ -359,7 +390,10 @@ function _rdetailDraw(r) {
                                        displayLabel = note;
                                }
                        }
-                       $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
+            // IE in quirks mode doesn't render CSS styling for links where the class attribute
+            // comes after the href attribute, apparently; we can use Dojo to ensure the class
+            // attribute comes first
+            dojo.place('<a class="search_link" href="' + href + '">' + displayLabel + '</a>', dojo.byId('rdetail_online'));
                        if (note && note != displayLabel) {
                                $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
                        }
@@ -398,6 +432,7 @@ function _rdetailDraw(r) {
               );
 
                RW.setAttribute('target', 'RefWorksMain');
+
                unHideMe($('rdetail_exp_refworks_span'));
        }
 
@@ -410,6 +445,7 @@ function _rdetailDraw(r) {
        runEvt("rdetail", "recordDrawn");
        recordsCache.push(record);
 
+
        var breq = new Request(FETCH_BRE, [getRid()]);
        breq.callback( rdetailCheckDeleted );
        breq.send();
@@ -420,11 +456,32 @@ function _rdetailDraw(r) {
 
        // grab added content 
        acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
-       
-       rdetailShowCustomizedMARCs ();
 }
 
+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();
+}
 
+/*
+ * Display the "Place Hold" link if:
+ *   * the current location holds at least one copy and 
+ *   * none of those copies are available
+ */
+function rdetailEnableHold(r) {
+       var ccDepths = r.getResultObject();
+       if (
+               ((ccDepths[(ccDepths.length - 1)].available) > 0) ||
+               ((ccDepths[(ccDepths.length - 1)].count) == 0)
+       ) {
+               hideMe($('rdetail_place_hold'));
+       } else {
+               unHideMe($('rdetail_place_hold'));
+       }
+}
 
 function rdetailCheckDeleted(r) {
        var br = r.getResultObject()[0];
@@ -675,58 +732,21 @@ function rdetailShowTOC(r) {
        }
 }
 
-function sortOutCopies(loc_id, rec_id, form_id) {
-        var copies = 0;
-        var recreq = new Request(FETCH_R_COPY_COUNTS, loc_id, rec_id, form_id);
-        recreq.send(true);
-        if (recreq) {
-                var copy_info =  recreq.result();
-                for (var i in copy_info) {
-                        //alert(loc_id + ' - ' + i + ' - ' + copy_info[i].available);
-                        if (loc_id == copy_info[i].org_unit)
-                                return copy_info[i].available;
-                }//for
-        }//if
-
-        return copies;
-}
-
-
 function rdetailBuildInfoRows() {
        var req;
        var method = FETCH_COPY_COUNTS_SUMMARY;
-       var cpCnt = 0;
-
-       //we figure out the number of copies
-       if (rdetailBreakUpLargeSets) 
-               cpCnt = sortOutCopies(getLocation(), getRid(), getForm());
-
-       if (rdetailShowCopyLocation && cpCnt < pgThreshold)
+       if (rdetailShowCopyLocation)
                method = FETCH_COPY_LOCATION_COUNTS_SUMMARY;
 
        if( rdetailShowLocal ) 
                req = new Request(method, record.doc_id(), getLocation(), getDepth())
        else
                req = new Request(method, record.doc_id());
-
-       if (rdetailBreakUpLargeSets && cpCnt >= pgThreshold) {
-               rdetailLocalOnly = true;
-               req.request.rec_id = record.doc_id();
-               req.request.cpCnt = cpCnt;
-               //remove the location options for paged sets
-               try {
-                       /*
-                       hideMe(G.ui.rdetail.cp_info_local);
-                        hideMe(G.ui.rdetail.cp_info_all);
-                       */
-                } catch(e) { }
-                req.callback(_rdetailBuildInfoPagedRows);
-        } else
-                req.callback(_rdetailBuildInfoRows);
+       req.callback(_rdetailBuildInfoRows);
        req.send();
 }
 
-function _rdetailRows(node, summaryStart, pgSize, summarySize, tot_copies) {
+function _rdetailRows(node) {
 
        if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) {
                var loc = findOrgUnit(getLocation());
@@ -755,7 +775,6 @@ function _rdetailRows(node, summaryStart, pgSize, summarySize, tot_copies) {
 
                var row = copyRow.cloneNode(true);
                row.id = "cp_info_" + node.id();
-               //alert(row.id);
 
                var libtd = findNodeByName( row, config.names.rdetail.lib_cell );
                var cntd  = findNodeByName( row, config.names.rdetail.cn_cell );
@@ -764,7 +783,6 @@ function _rdetailRows(node, summaryStart, pgSize, summarySize, tot_copies) {
 
                var p = libtd.getElementsByTagName('a')[0];
                libtd.insertBefore(text(node.name()), p);
-               
                libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1)  * 9) + "px;");
 
                if(!findOrgType(node.ou_type()).can_have_vols()) {
@@ -777,19 +795,14 @@ function _rdetailRows(node, summaryStart, pgSize, summarySize, tot_copies) {
                        libtd.setAttribute("colspan", numStatuses + 3 );
                        libtd.colSpan = numStatuses + 3;
                        addCSSClass(row, 'copy_info_region_row');
-                       if (summaryStart!= undefined &&  pgSize!=undefined &&
-                               summarySize != undefined && tot_copies != undefined) 
-                       {
-                               fillOutLinks(libtd, summaryStart, pgSize, summarySize, tot_copies);
-                       } //if summaryStart
-               }//if 
+               } 
 
                copyRowParent.appendChild(row);
 
        } else { node = globalOrgTree; }
 
        for( var c in node.children() ) 
-               _rdetailRows(node.children()[c], summaryStart, pgSize, summarySize, tot_copies);
+               _rdetailRows(node.children()[c]);
 }
 
 function rdetailCNPrint(orgid, cn) {
@@ -802,216 +815,6 @@ function rdetailCNPrint(orgid, cn) {
 
 var localCNFound = false;
 var ctr = 0;
-function _rdetailCL(r) {
-        if (!r) return;
-        var cl = r.getResultObject();
-        if (cl) {
-                //alert(r.arrVal + " - " + cl.location().name());
-                rdetailApplyStatuses(r.rowNode, r.cpc_temp, r.statuses);
-
-                var isLocal = false;
-                if( orgIsMine( findOrgUnit(getLocation()), r.thisOrg ) ) {
-                        isLocal = true;
-                        if(!localCNFound) {
-                                localCNFound = true;
-                                defaultCN = r.arrVal;
-                        }
-                }
-
-                //if(isLocal) unHideMe(rowNode);
-                unHideMe(r.rowNode);
-
-                rdetailSetPath( r.thisOrg, isLocal);
-                rdetailBuildBrowseInfo( r.rowNode, r.arrVal, isLocal, r.thisOrg,
-                        cl.location().name());
-        }//cl
-}
-function _rdetailFL(r) {
-        if (!r) return;
-        var fl = r.getResultObject();
-        if (fl) {
-                var cp_request = new Request(FETCH_FLESHED_COPY, fl);
-
-                cp_request.request.rowNode = r.rowNode;
-                cp_request.request.cpc_temp = r.cpc_temp;
-                cp_request.request.statuses = r.statuses;
-                cp_request.request.arrVal = r.arrVal;
-                cp_request.request.thisOrg = r.thisOrg;
-                cp_request.callback(_rdetailCL);
-                cp_request.send();
-        }//fl
-}
-
-/*
-        callsortfn - sorting an array of call numbers
-
-        This probably won't work for every instance, but assumes last
-        number is a year. Anyway, this is how to get into the
-        array values, it could be refined, though a better way
-        will be to set up a special opensrf that can apply
-        postgres goodness to this.
-*/
-function callsortfn(a,b) {
-        var callno1 = a[1];
-        var callno2 = b[1];
-        var callnum1 = 0;
-        var callnum2 = 0;
-
-        var marker = callno1.lastIndexOf(' ');
-        if (marker != -1)
-                callnum1 = parseInt(callno1.substring(marker));
-        marker = callno2.lastIndexOf(' ');
-        if (marker != -1)
-                callnum2 = parseInt(callno2.substring(marker));
-
-        //window.status = 'comparing ' + callnum1 + ' to ' + callnum2;
-
-        if (callnum1 < callnum2) return -1;
-        if (callnum1 > callnum2) return 1;
-        return 0;
-}
-
-function fillOutLinks(node, cpstart, cpsize, ssize, pieces) {
-        if (node) {
-                var theLink = document.location + "";
-                var marker = theLink.indexOf("&cstart");
-                if (marker > 0)
-                        theLink = theLink.substring(0,marker);
-
-                var summaryStmt = '(' + (cpstart + 1) + ' to ' + ssize + ' of ' + pieces;
-                node.appendChild(document.createTextNode(summaryStmt));
-                if ((cpstart + 1) > cpsize) {
-                        node.appendChild(document.createTextNode(' '));
-                        var pglink = document.createElement("a");
-                        pglink.appendChild(document.createTextNode('Start'));
-                        pglink.setAttribute('href',theLink + '&cstart=0' +
-                                '&csize=' + cpsize);
-                        pglink.setAttribute('class','classic_link');
-                        node.appendChild(pglink);
-                        node.appendChild(document.createTextNode(' '));
-                        var pglink = document.createElement("a");
-                        pglink.appendChild(document.createTextNode('<<'));
-                        pglink.setAttribute('href',theLink + '&cstart=' +
-                                (cpstart - cpsize) + '&csize=' + cpsize);
-                        pglink.setAttribute('class','classic_link');
-                        node.appendChild(pglink);
-                        node.appendChild(document.createTextNode(' '));
-                        /*
-                        */
-                }
-                if (ssize < pieces) {
-                        node.appendChild(document.createTextNode(' '));
-                        var pglink = document.createElement("a");
-                        pglink.appendChild(document.createTextNode('>>'));
-                        pglink.setAttribute('href',theLink + '&cstart=' +
-                                ssize + '&csize=' + cpsize);
-                        pglink.setAttribute('class','classic_link');
-                        node.appendChild(pglink);
-                        node.appendChild(document.createTextNode(' '));
-                        var pglink = document.createElement("a");
-                        pglink.appendChild(document.createTextNode('End'));
-                        pglink.setAttribute('href',theLink + '&cstart=' +
-                                (pieces - cpsize) + '&csize=' + cpsize);
-                        pglink.setAttribute('class','classic_link');
-                        node.appendChild(pglink);
-                        /*
-                        */
-                }
-                node.appendChild(document.createTextNode(')'));
-                /*
-                */
-        }//if node
-}
-
-function _rdetailBuildInfoPagedRows(r) {
-
-        //alert(r.getText());
-        if (!r) return;
-        /*
-        */
-        var summary = r.getResultObject();
-        if(!summary) return;
-
-        summary.sort(callsortfn);
-        if (rdetailShowCopyLocation)
-                unHideMe( $n( $('rdetail_copy_info_table'), 'rdetail_copylocation_header' ) );
-
-        removeChildren(copyRowParent);
-
-        var rec_id = r.rec_id;
-        //var tot_copies = r.cpCnt;
-        var tot_copies = summary.length;
-        var cgi = new CGI();
-        var parm = cgi.param("cstart");
-        if (parm == undefined)
-                parm = 0;
-        var summaryStart = parseInt(parm);
-        parm = cgi.param("csize");
-        if (parm == undefined)
-                parm = pgDisplay;
-        var summarySize = parseInt(parm) + summaryStart;
-        if (summarySize > tot_copies)
-                summarySize = tot_copies;
-        var pgSize = parseInt(parm);
-
-        _rdetailRows(null,summaryStart, pgSize, summarySize, tot_copies);
-        var found = false;
-
-        for( var i = summaryStart; i < summary.length && i < summarySize; i++ ) {
-                var arr = summary[i];
-                globalCNCache[arr[1]] = 1;
-                var thisOrg = findOrgUnit(arr[0]);
-                var rowNode = $("cp_info_" + thisOrg.id());
-                if(!rowNode) continue;
-
-                if(rowNode.getAttribute("used")) {
-
-                        if( rowNode.nextSibling ) {
-                                sib = rowNode.nextSibling;
-                                o ='cp_info_'+thisOrg.id()+'_';
-                                /* push the new row on as the last row for this org unit */
-                                while( sib && sib.id.match(o) ) {
-                                        sib = sib.nextSibling;
-                                }
-                                if(sib)
-                                        rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), sib);
-                                else
-                                        rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
-                        } else {
-                                rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
-                        }
-
-                        var n = findNodeByName( rowNode, config.names.rdetail.lib_cell );
-                        n.appendChild(text(thisOrg.name()));
-                        n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1)  * 9) + "px;");
-                        rowNode.id = "cp_info_" + thisOrg.id() + '_' + (++ctr);
-
-                } else {
-                        rowNode.setAttribute("used", "1");
-                }
-
-                var cpc_temp = rowNode.removeChild(
-                                findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
-
-                var statuses = arr[2];
-                var cl = '';
-
-                var recreq = new Request( FETCH_COPIES_FROM_VOLUME, rec_id, arr[1], arr[0]);
-                recreq.request.rowNode = rowNode;
-                recreq.request.cpc_temp = cpc_temp;
-                recreq.request.statuses = statuses;
-                recreq.request.arrVal = arr[1];
-                recreq.request.thisOrg = thisOrg;
-                recreq.callback(_rdetailFL);
-                recreq.send();
-
-
-                if( i == summary.length - 1 && !defaultCN) defaultCN = arr[1];
-        }
-
-        if(!found) unHideMe(G.ui.rdetail.cp_info_none);
-}
-
 function _rdetailBuildInfoRows(r) {
 
        if (rdetailShowCopyLocation)
@@ -1023,19 +826,9 @@ function _rdetailBuildInfoRows(r) {
 
        var summary = r.getResultObject();
        if(!summary) return;
-        var cgi = new CGI();
-        var parm = cgi.param("cstart");
-        if (parm == undefined)
-                parm = 0;
-        var summaryStart = parseInt(parm);
-        parm = cgi.param("csize");
-        if (parm == undefined)
-                parm = 25;
-        var summarySize = parseInt(parm);
 
        var found = false;
-       //for( var i = 0; i < summary.length; i++ ) {
-        for( var i = summaryStart; i < summary.length && i < summarySize; i++ ) {
+       for( var i = 0; i < summary.length; i++ ) {
 
                var arr = summary[i];
                globalCNCache[arr[1]] = 1;
@@ -1126,9 +919,9 @@ function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) {
        _debug('setting action clicks for cn ' + cn);
 
        var dHref = 'javascript:rdetailVolumeDetails('+
-                       '{copy_location : "'+cl+'", rowid : "'+row.id+'", cn :"'+cn+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
+                       '{copy_location : "'+cl.replace(/\"/g, '\\"')+'", rowid : "'+row.id+'", cn :"'+cn.replace(/\"/g, '\\"')+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
 
-       var bHref = 'javascript:rdetailShowCNBrowse("' + cn + '", '+orgNode.id()+', "'+depth+'");'; 
+       var bHref = 'javascript:rdetailShowCNBrowse("' + cn.replace(/\"/g, '\\"') + '", '+orgNode.id()+', "'+depth+'");'; 
 
        unHideMe( $n(row, 'details') )
                $n(row, 'details').setAttribute('href', dHref);
@@ -1154,7 +947,6 @@ function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) {
 function rdetailSetPath(org, local) {
        if( findOrgDepth(org) == 0 ) return;
        var row = $("cp_info_" + org.id());
-       //alert("cp_info_" + org.id() + " - " + row.id + " - " + row.innerHTML);
        row.setAttribute("hasinfo", "1");
        unHideMe(row);
        rdetailSetPath(findOrgUnit(org.parent_ou()), local);
@@ -1275,15 +1067,15 @@ function GBPreviewCallback(GBPBookInfo) {
                }
 
                // 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 = $('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;
+               GBPBadge = document.createElement( 'img' );
+               GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif';
+               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' ) );
index 65faf8f..56411ef 100644 (file)
@@ -5,6 +5,27 @@ var lowHitCount = 4;
 var isbnList = '';
 var googleBooksLink = false;
 var enableHoldsOnAvailable = false;
+var enableExtraSearchesLowHits = false;
+var localProxyPrefix = '';
+
+/* an array of the extra services to which we want to direct people, in order of priority:
+Properties:
+  url: will be proxied via localProxyPrefix
+  description: will be used in the OPAC display
+  termTransform: a function name that transforms Evergreen compiled searches to the target search format
+*/
+var externalSearchServices = [
+    {   
+        "url": "http://books.scholarsportal.info/search.html?searchField=All+Fields&limit=full_text&sortBy=relevance&collection=all&searchTerm=",
+        "description": "Search ScholarsPortal ebooks",
+        "termTransform": "allKeywords"
+    },
+    {   
+        "url": "http://scholar.google.com/scholar?q=",
+        "description": "Search Google Scholar",
+        "termTransform": "allKeywords"
+    }
+];
 
 var resultFetchAllRecords = false;
 var resultCompiledSearch = null;
@@ -12,7 +33,8 @@ var resultCompiledSearch = null;
 /* set up the event handlers */
 if( findCurrentPage() == MRESULT || findCurrentPage() == RRESULT ) {
        G.evt.result.hitCountReceived.push(resultSetHitInfo);
-       G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
+       //G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
+       G.evt.result.recordReceived.push(resultDisplayRecord);
        G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
        G.evt.result.allRecordsReceived.push(resultBuildCaches, resultDrawSubjects, 
       resultDrawAuthors, resultDrawSeries, function(){unHideMe($('result_info_2'))},
@@ -211,6 +233,10 @@ function resultLowHits() {
 
        resultSuggestSearchClass();
 
+    if (enableExtraSearchesLowHits) {
+        resultSuggestExtraSearches();
+    }
+
        if(getTerm()) resultExpandSearch(); /* advanced search */
 }
 
@@ -250,12 +276,15 @@ function resultZeroHits() {
        showCanvas();
        unHideMe($('result_low_hits'));
        unHideMe($('result_zero_hits_msg'));
+
        //if(getTerm()) resultExpandSearch(); /* advanced search */
 }
 
 function resultExpandSearch() {
        var top = findOrgDepth(globalOrgTree);
-       if(getDepth() == top) return;
+
+    /* We don't want to expand the scope to Everywhere in Conifer, that's just confusing */
+       if(getDepth() == top || getDepth() - 1 == top) return;
        unHideMe($('low_hits_expand_range'));
        var par = $('low_hits_expand_link').parentNode;
        var template = par.removeChild($('low_hits_expand_link'));
@@ -272,6 +301,33 @@ function resultExpandSearch() {
        }
 }
 
+/* Generate links to our extra search services */
+function resultSuggestExtraSearches() {
+    dojo.forEach(externalSearchServices, function(esItem) {
+        var extraSearchStuff = this[esItem.termTransform].apply(this, [esItem.url]);
+        dojo.place("<div style='text-align: center; width: 100%; margin-left: auto; margin-right: auto;'><strong>" +
+            esItem.description + "</strong>: <a class='classic_link' href='" +
+            extraSearchStuff.searchTerms + "'>" + extraSearchStuff.displayTerms + "</a><div>", "result_low_hits", "child"
+        );
+    });
+}
+
+/* Transform everything in the Evergreen search to plain old keywords */
+function allKeywords(esUrl) {
+    var ebook_search = localProxyPrefix + esUrl;
+    var ebook_terms = '';
+    for (var key in resultCompiledSearch.searches) {
+        ebook_search += resultCompiledSearch.searches[key].term + '+';
+        ebook_terms += resultCompiledSearch.searches[key].term + ' ';
+    }
+    ebook_search = ebook_search.replace(/ /g, '+');
+    ebook_search = ebook_search.replace(/\%20/g, '+');
+    ebook_search = ebook_search.replace(/\+$/g, '');
+    ebook_terms = ebook_terms.replace(/ $/g, '');
+    var extraSuggestion = {"displayTerms": ebook_terms, "searchTerms": ebook_search};
+    return extraSuggestion;
+}
+
 function resultSuggestSearchClass() {
        var stype = getStype();
        if(stype == STYPE_KEYWORD) return;
@@ -430,6 +486,23 @@ function unhideGoogleBooksLink (data) {
     }
 }
 
+/* riff on buildTitleDetailLink from opac_utils */
+function buildResultTitleDetailLink(rec, link) {
+        if(!rec) return;
+        link.appendChild(text(normalize(truncate(rec.title(), 500))));
+        var args = {};
+        args.page = RDETAIL;
+        args[PARAM_RID] = rec.doc_id();
+    // in IE, if the link text contains a '@', it replaces the innerHTML text
+    // with the value of the href attribute.  Wait, what?  Yes.  Capture the
+    // innerHTML and put it back into place after the href is set
+    var linkText = link.innerHTML; // IE
+        link.setAttribute("href", buildOPACLink(args));
+    link.innerHTML = linkText; // IE
+}
+
+
+
 /* display the record info in the record display table 'pos' is the 
                zero based position the record should have in the display table */
 function resultDisplayRecord(rec, pos, is_mr) {
@@ -498,19 +571,36 @@ function resultDisplayRecord(rec, pos, is_mr) {
        } else {
                buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id());
 
-               buildTitleDetailLink(rec, title_link); 
+               buildResultTitleDetailLink(rec, title_link); 
                var args = {};
                args.page = RDETAIL;
                args[PARAM_OFFSET] = 0;
                args[PARAM_RID] = rec.doc_id();
                pic.parentNode.setAttribute("href", buildOPACLink(args));
 
+               //don't bother with holds at this point
+               /*
                if (enableHoldsOnAvailable) {
                        unHideMe($n(r,'place_hold_span'));
                }
 
                $n(r,'place_hold_link').setAttribute(
                        'href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"T"});');
+               */
+                // Stolen from trunk - (and stolen again from lul :-))
+                var here = findOrgUnit(getLocation());
+                dojo.require('openils.BibTemplate');
+                var l_cn_list = $n(r,'local_callnumber_list');
+                var onlyrec = rec.doc_id();
+
+                dojo.addOnLoad(function () {
+                        new openils.BibTemplate({
+                                root : l_cn_list,
+                                record : '' + onlyrec,
+                                org_unit : here.shortname()
+                        }).render();
+                        unHideMe(l_cn_list);
+                });
        }
 
        buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
@@ -651,7 +741,8 @@ function resultAddCopyCounts(rec, pagePosition) {
                ccheadcell =  ccrow.removeChild($n(ccrow, "result_thead_ccell"));
                var t = ccheadcell.cloneNode(true);
                lastheadcell = t;
-               t.appendChild(text(type.opac_label()));
+               //t.appendChild(text(type.opac_label()));
+               t.appendChild(text(" "));
                ccrow.appendChild(t);
                resultCCHeaderApplied = true;
        }
@@ -738,8 +829,20 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
        while(copy_counts[i] != null) {
                var cell = $("copy_count_cell_" + i +"_" + pagePosition);
                var cts = copy_counts[i];
-               cell.appendChild(text(cts.available + " / " + cts.count));
 
+                var availMess = "Available";
+                if (cts.count >= cts.available && cts.available > 1)
+                        availMess = cts.available + " of " + cts.count + " Available";
+                if (cts.count > cts.available && cts.available == 0)
+                        availMess = "Checked Out";
+                if (cts.count == 0 && cts.available == 0)
+                        availMess = "Online";
+
+               //cell.appendChild(text(cts.available + " / " + cts.count));
+               cell.appendChild(text(availMess));
+
+               //don't bother with holds at this point
+               /*
                if (!enableHoldsOnAvailable && (i == (copy_counts.length - 1))) {
                        var resultTBody = findParentByNodeName(cell, 'TBODY');
                        if (cts.available == 0 && cts.count > 0 && !metarecords) {
@@ -748,12 +851,13 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
                                dojo.query('[name="place_hold_span"]', resultTBody).addClass('hide_me');
                        }
                }
+               */
 
                if(isXUL()) {
                        /* here we style opac-invisible records for xul */
 
                        if( cts.depth == 0 ) {
-                               if(!cts.transcendant && !cts.unshadow) {
+                               if(cts.transcendant == null && cts.unshadow == 0) {
                                        _debug("found an opac-shadowed record: " + rec.doc_id());
                                        var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode; 
                                        if( cts.count == 0 ) 
@@ -767,4 +871,3 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
        }
 }
 
-
index d93aa45..4a7fb35 100644 (file)
@@ -30,7 +30,11 @@ function rresultDoSearch() {
 function rresultCollectIds() {
        var ids;
 
-       switch(getRtype()) {
+    var rtype = getRtype();
+    if (rtype.indexOf('|') > -1)
+        rtype = rtype.substring(0,rtype.indexOf('|'));
+
+       switch(rtype) {
 
                case RTYPE_COOKIE:
                        ids = JSON2js(cookieManager.read(COOKIE_RIDS));
index 37dc49e..67369f3 100644 (file)
@@ -34,6 +34,11 @@ function searchBarInit() {
        setSelector(_ts,        getStype());
        setSelector(_fs,        getForm());
 
+    /* If searching for journal title, set it to journal title */
+    if (getStype() == 'title' && getBibLevel() == 's') {
+        dojo.byId('jtitle').selected = true;
+    }
+
        depthSelInit();
 
 
@@ -74,6 +79,12 @@ function searchBarSubmit(isFilterSort) {
        args[PARAM_DEPTH]               = d;
        args[PARAM_FORM]                = _fs.options[_fs.selectedIndex].value;
 
+    /* Set the bib level to 's' for serials if the magic "Journal title" has ben chosen */
+    if (_ts.options[_ts.selectedIndex].id == 'jtitle') {
+        args[PARAM_BIBLEVEL] = 's';
+    }
+
+
     if($('opac.result.limit2avail')) {
         args[PARAM_AVAIL] = ($('opac.result.limit2avail').checked) ? 1 : '';
         if( (val = getSelectorVal($('opac.result.sort'))) ) {