From 90e11363cc4cee40ff44d7431d4ebef8e04685f0 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 12 Jul 2005 12:40:31 +0000 Subject: [PATCH] added title/author links for holds other minor tweaks git-svn-id: svn://svn.open-ils.org/ILS/trunk@1137 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../javascript/opac/AbstractRecordResultPage.js | 73 ++++++++++++---------- Open-ILS/src/javascript/opac/LoginDialog.js | 7 ++- Open-ILS/src/javascript/opac/MRResultPage.js | 49 +++++++++++++++ Open-ILS/src/javascript/opac/MyOPACSPage.js | 33 ++++++++-- Open-ILS/src/javascript/util/Cookie.js | 13 ++-- Open-ILS/src/javascript/util/RemoteRequest.js | 3 +- Open-ILS/src/javascript/util/UserSession.js | 6 +- Open-ILS/src/javascript/util/ils_utils.js | 1 + Open-ILS/src/javascript/util/webutils.js | 31 ++++++--- Open-ILS/src/javascript/widgets/PopupBox.js | 1 - 10 files changed, 159 insertions(+), 58 deletions(-) diff --git a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js index e9fe26ab81..6d14653e8f 100644 --- a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js +++ b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js @@ -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); diff --git a/Open-ILS/src/javascript/opac/LoginDialog.js b/Open-ILS/src/javascript/opac/LoginDialog.js index 6556cac31d..edca0f013c 100644 --- a/Open-ILS/src/javascript/opac/LoginDialog.js +++ b/Open-ILS/src/javascript/opac/LoginDialog.js @@ -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) { diff --git a/Open-ILS/src/javascript/opac/MRResultPage.js b/Open-ILS/src/javascript/opac/MRResultPage.js index 65c927ddad..50f9009b33 100644 --- a/Open-ILS/src/javascript/opac/MRResultPage.js +++ b/Open-ILS/src/javascript/opac/MRResultPage.js @@ -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]; diff --git a/Open-ILS/src/javascript/opac/MyOPACSPage.js b/Open-ILS/src/javascript/opac/MyOPACSPage.js index 6dfcd1ffed..97d0e78302 100644 --- a/Open-ILS/src/javascript/opac/MyOPACSPage.js +++ b/Open-ILS/src/javascript/opac/MyOPACSPage.js @@ -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"); diff --git a/Open-ILS/src/javascript/util/Cookie.js b/Open-ILS/src/javascript/util/Cookie.js index 6f3ed33ac8..8401cdfd4a 100644 --- a/Open-ILS/src/javascript/util/Cookie.js +++ b/Open-ILS/src/javascript/util/Cookie.js @@ -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) { diff --git a/Open-ILS/src/javascript/util/RemoteRequest.js b/Open-ILS/src/javascript/util/RemoteRequest.js index 1720abcbf8..6e21b71d8e 100644 --- a/Open-ILS/src/javascript/util/RemoteRequest.js +++ b/Open-ILS/src/javascript/util/RemoteRequest.js @@ -110,6 +110,7 @@ function RemoteRequest( service, method ) { while(i < arguments.length) { var object = js2JSON(arguments[i++]); this.params += "¶m=" + 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"); diff --git a/Open-ILS/src/javascript/util/UserSession.js b/Open-ILS/src/javascript/util/UserSession.js index 30a839e967..0740959910 100644 --- a/Open-ILS/src/javascript/util/UserSession.js +++ b/Open-ILS/src/javascript/util/UserSession.js @@ -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; - } diff --git a/Open-ILS/src/javascript/util/ils_utils.js b/Open-ILS/src/javascript/util/ils_utils.js index 98f54bf379..e4082d15c0 100644 --- a/Open-ILS/src/javascript/util/ils_utils.js +++ b/Open-ILS/src/javascript/util/ils_utils.js @@ -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", diff --git a/Open-ILS/src/javascript/util/webutils.js b/Open-ILS/src/javascript/util/webutils.js index 81df9b5f73..9c866c05ab 100644 --- a/Open-ILS/src/javascript/util/webutils.js +++ b/Open-ILS/src/javascript/util/webutils.js @@ -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]; } + + diff --git a/Open-ILS/src/javascript/widgets/PopupBox.js b/Open-ILS/src/javascript/widgets/PopupBox.js index 6ef8dd7812..c3268fe19c 100644 --- a/Open-ILS/src/javascript/widgets/PopupBox.js +++ b/Open-ILS/src/javascript/widgets/PopupBox.js @@ -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); -- 2.11.0