added title/author links for holds
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Jul 2005 12:40:31 +0000 (12:40 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Jul 2005 12:40:31 +0000 (12:40 +0000)
other minor tweaks

git-svn-id: svn://svn.open-ils.org/ILS/trunk@1137 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/javascript/opac/AbstractRecordResultPage.js
Open-ILS/src/javascript/opac/LoginDialog.js
Open-ILS/src/javascript/opac/MRResultPage.js
Open-ILS/src/javascript/opac/MyOPACSPage.js
Open-ILS/src/javascript/util/Cookie.js
Open-ILS/src/javascript/util/RemoteRequest.js
Open-ILS/src/javascript/util/UserSession.js
Open-ILS/src/javascript/util/ils_utils.js
Open-ILS/src/javascript/util/webutils.js
Open-ILS/src/javascript/widgets/PopupBox.js

index e9fe26a..6d14653 100644 (file)
@@ -311,40 +311,44 @@ AbstractRecordResultPage.prototype.displayRecord =
 
        }
 
-       var holds = elem( "a", 
-       { 
-               href:"javascript:void(0)", 
-               style: "text-decoration:underline" 
-       }, {}, "Place Hold" );
-
-
-       var type = "M";
-       if(instanceOf(this, RecordResultPage))
-               type = "T";
-
-       var win;
-       var user = UserSession.instance();
-       if(user.verifySession()) {
-               win = new HoldsWindow(record.doc_id(), 
-                       type, user.userObject, user.userObject, user.session_id);
-       } else {
-               win = new HoldsWindow(record.doc_id(), 
-                       type, null, null, null);
-       }
+       var holddiv = null;
+       if(instanceOf(this, RecordResultPage)) {
 
+               var holds = elem( "a", 
+               { 
+                       href:"javascript:void(0)", 
+                       style: "text-decoration:underline" 
+               }, {}, "Place Hold" );
+       
+       
+               var type = "M";
+               if(instanceOf(this, RecordResultPage))
+                       type = "T";
+       
+               var win;
+               var user = UserSession.instance();
+               if(user.verifySession()) {
+                       win = new HoldsWindow(record.doc_id(), 
+                               type, user.userObject, user.userObject, user.session_id);
+               } else {
+                       win = new HoldsWindow(record.doc_id(), 
+                               type, null, null, null);
+               }
+       
+               
+               holds.onclick = function() { win.toggle(holds); }
+               holddiv = elem("div");
+       
+               //if(instanceOf(this,RecordResultPage))
+               holddiv.setAttribute("style", "float:right");
+       
+               holddiv.appendChild(holds);
+               //var space = elem("span", {style:"padding:5px"},null, " ");
+               //c.appendChild(space)
+               //c.appendChild(mktext(" "))
+               //c.appendChild(holddiv)
+       }
        
-       holds.onclick = function() { win.toggle(holds); }
-       var holddiv = elem("div");
-
-       //if(instanceOf(this,RecordResultPage))
-       holddiv.setAttribute("style", "float:right");
-
-       holddiv.appendChild(holds);
-       //var space = elem("span", {style:"padding:5px"},null, " ");
-       //c.appendChild(space)
-       //c.appendChild(mktext(" "))
-       //c.appendChild(holddiv)
-
        var tab = elem("table",{style:"float:right"});
        var tr = tab.insertRow(0);
        var tc = tr.insertCell(0);
@@ -353,9 +357,10 @@ AbstractRecordResultPage.prototype.displayRecord =
        tc.setAttribute("nowrap", "nowrap");
        tc3.setAttribute("nowrap", "nowrap");
 
-       tc.appendChild(marcd);
+       if(holddiv) tc.appendChild(holddiv);
        tc2.appendChild(mktext(" "));
-       tc3.appendChild(holddiv);
+       tc3.appendChild(marcd);
+
        c.appendChild(tab);
 
 
index 6556cac..edca0f0 100644 (file)
@@ -1,8 +1,13 @@
+var PopupBoxId = 0;
+
+
 function LoginDialog(logged_in_callback) {
        this.callback = logged_in_callback;
-       this.rand = Math.random();
+       this.rand = PopupBoxId++;
 }
 
+
+
 /* node is the element the dialog should popup under */
 LoginDialog.prototype.display = function(node) {
 
index 65c927d..50f9009 100644 (file)
@@ -366,6 +366,19 @@ MRResultPage.prototype.checkSpelling = function() {
        }
 }
 
+/* expand search if results are too low... */
+MRResultPage.prototype.buildExpandSearchLinks = function() {
+
+       /*
+       var string                      = paramObj.__mr_search_query;
+       var stype                       = paramObj.__mr_search_type;
+       var location            = paramObj.__mr_search_location;
+       var depth                       = paramObj.__mr_search_depth;
+       */
+       
+       var div = elem("div");
+}
+
 
 MRResultPage.prototype.doMRSearch = function() {
 
@@ -411,12 +424,48 @@ MRResultPage.prototype.doMRSearch = function() {
 
 MRResultPage.prototype.collectRecords = function() {
 
+       debug("Collecting records...");
        var i = this.searchOffset;
 
        var row = getById("hourglass_row");
        if(row)
                row.parentNode.removeChild(row);
 
+       /* ------------------------------------------------- */
+
+       /*
+       var ids = new Array();
+       while( i < (this.searchOffset + this.hitsPerPage) ) 
+               ids.push(this.recordIDs[i++]);
+
+       debug("Retrieving IDs " + ids);
+
+       var request = new RemoteRequest( "open-ils.search",
+               "open-ils.search.biblio.metarecord.mods_slim.batch.retrieve", ids );
+       this.requestBatch.add(request);
+       var obj = this;
+
+
+       request.setCompleteCallback(
+               function(req) {
+                       var records = req.getResultObject();
+                       //alert(records);
+
+                       for(var i = 0; i!= records.length; i++) {
+                               var rec = records[i];
+                               debug("Displaying recocord " + rec.doc_id());
+                               obj.displayRecord( rec, obj.searchOffset, i );
+                               obj.doCopyCount( rec, obj.searchOffset, i );
+                       }
+                       obj.requestBatch.remove(request);
+               }
+       );              
+       request.send();
+       return;
+       */
+       /* ------------------------------------------------- */
+
+
        while( i < (this.searchOffset + this.hitsPerPage) ) {
                var id = this.recordIDs[i];
 
index 6dfcd1f..97d0e78 100644 (file)
@@ -556,7 +556,6 @@ MyOPACSPage.prototype.updateEmail = function(){
 
 MyOPACSPage.prototype._drawHolds = function() {
 
-       var holds = this.grabHolds();
        var table = this.infoTable;
        var row = table.insertRow(table.rows.length);
 
@@ -584,9 +583,20 @@ MyOPACSPage.prototype._drawHolds = function() {
        add_css_class(cell, "my_opac_info_table_header");
        cell.appendChild(mktext("Cancel"));
 
+       /* ---------------------------------------- */
+       row = table.insertRow(table.rows.length);
+       cell = row.insertCell(row.cells.length);
+       cell.appendChild(mktext("Retrieving holds..."));
+       /* ---------------------------------------- */
+
+       var holds = this.grabHolds();
+       table.firstChild.removeChild(table.firstChild.childNodes[1]);
+
        for( var idx = 0; idx != holds.length; idx++ ) {
+               debug("Displaying hold " + holds[idx].id());
                _doCallbackDance(table, holds[idx]);
        }
+
 }
 
 function _doCallbackDance(table, hold) {
@@ -603,7 +613,6 @@ function _doCallbackDance(table, hold) {
 }
 
 
-
 function _drawHoldsRow(table, hold, record) {
 
        if(record == null || record.length == 0) return;
@@ -614,10 +623,26 @@ function _drawHoldsRow(table, hold, record) {
 
        add_css_class(cell, "my_opac_profile_cell");
        cell.style.width = "35%";
-       cell.appendChild(mktext(record.title()));
+
+       var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath;
+       var tl = elem("a",
+                       {href:prefix + "?sub_frame=1&target=record_detail&record="+encodeURIComponent(record.doc_id())},
+                       null, record.title());
+       tl.setAttribute("target","_top");
+       //cell.appendChild(mktext(record.title()));
+       cell.appendChild(tl);
+
        cell = row.insertCell(row.cells.length);
+       var al = elem("a",
+                       {href:prefix + "?sub_frame=1&target=mr_result"+
+                               "&mr_search_query="+encodeURIComponent(record.author())+
+                               "&mr_search_type=author"},
+                       null, record.author());
+       al.setAttribute("target","_top");
        add_css_class(cell, "my_opac_profile_cell");
-       cell.appendChild(mktext(record.author()));
+
+       //cell.appendChild(mktext(record.author()));
+       cell.appendChild(al);
 
        cell = row.insertCell(row.cells.length);
        add_css_class(cell, "my_opac_profile_cell");
index 6f3ed33..8401cdf 100644 (file)
@@ -60,12 +60,14 @@ if (i >=0) {
 
 function ucFieldPut (fieldname, fieldval) {
 var i = this.namepos(fieldname)
-if (i >=0) {
-  this.fields[i] = fieldval
-  return true
-} else {
-  return false
+
+if(i < 0) {
+       i = this.fieldnames.length;
+       this.fieldnames[i] = fieldname;
 }
+
+this.fields[i] = fieldval
+return true
 }
 
 function ucNamePos(fieldname) {
@@ -119,6 +121,7 @@ if (this.fields.length == 1) {
 function ucRead() {
   var search = this.name + "="                       
   var CookieString = document.cookie            
+  if(CookieString == null) CookieString = "";
   this.rawValue = null
   this.found = false     
   if (CookieString.length > 0) {                
index 1720abc..6e21b71 100644 (file)
@@ -110,6 +110,7 @@ function RemoteRequest( service, method ) {
        while(i < arguments.length) {
                var object = js2JSON(arguments[i++]);
                this.params += "&param=" + encodeURIComponent(object);
+               debug("Remote Request adding param => " + object);
        }
 
        if(!this.params) { this.params = ""; }
@@ -264,7 +265,7 @@ RemoteRequest.prototype.send = function(blocking) {
                                'application/x-www-form-urlencoded');
        }
 
-       debug("Remote Request sending..." + data);
+       //alert("Sending from " + location.href + " to " + url + " data [" + data + "]");
        this.xmlhttp.send( data );
        this.sendCount += 1;
        debug("Remote Request done sending");
index 30a839e..0740959 100644 (file)
@@ -163,14 +163,14 @@ UserSession.prototype.grabOrgUnit = function(org) {
        if(org) this.orgUnit = org;
        else this.orgUnit = findOrgUnit(this.userObject.home_ou());
 
-       if(!paramObj.__depth)
+       if(!paramObj.__depth && this.orgUnit)
                globalSelectedDepth = findOrgDepth(this.orgUnit.ou_type());
-       if(!paramObj.__location)
+       if(!paramObj.__location && this.orgUnit)
                globalPage.updateSelectedLocation(this.orgUnit);
+
        globalPage.updateCurrentLocation(this.orgUnit);
 
        return;
-
 }
 
 
index 98f54bf..e4082d1 100644 (file)
@@ -214,6 +214,7 @@ function MARCFormatToMods(format) {
 /* if callback exists, call is asynchronous and 
        the returned item is passed to the callback... */
 function fetchRecord(id, callback) {
+
        var req = new RemoteRequest(
                "open-ils.search",
                "open-ils.search.biblio.record.mods_slim.retrieve",
index 81df9b5..9c866c0 100644 (file)
@@ -722,12 +722,7 @@ function getXYOffsets(target, object) {
        var offsety = y + height;
        var offsetx = xpos; 
        
-/*
-       if(IE) { 
-               offsety = parseInt(offsety) + 15;
-               offsetx = parseInt(offsetx) + 8;
-       }
-*/
+       if(IE) offsety += 15; 
 
        debug("getXYOffset y: " + offsety + " x: " + offsetx );
        return [offsetx, offsety];
@@ -746,10 +741,28 @@ function userPressedEnter(evt) {
 
 /* return [ x, y ] for the window */
 function getWindowSize() {
+
        var doc = getDocument();
        var win = getWindow();
-       if (IE) 
-               return [doc.body.offsetWidth, doc.body.offsetHeight ];
-       return [        win.innerWidth, win.innerHeight ];
+       var x, y;
+
+       if (IE) {
+
+               if(doc.documentElement.offsetWidth != null) { /* IE 6 standards compliant */
+                       x = doc.documentElement.offsetWidth;
+                       y = doc.documentElement.offsetHeight;
+
+               } else {
+                       x = doc.body.offsetWidth; 
+                       y = doc.body.offsetHeight;
+               }
+
+       } else {
+               x = win.innerWidth;
+               y = win.innerHeight;
+       }
+       return [x, y];
 }
 
+
+
index 6ef8dd7..c3268fe 100644 (file)
@@ -63,7 +63,6 @@ PopupBox.prototype.show = function() {
        var wx = W[0];
        var wy = W[1];
 
-
        var x =  getObjectWidth(this.div);
        var y =  getObjectHeight(this.div);