From 636a1e91063ce47599ca244d9bc397c55da817c0 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 24 Jun 2005 17:35:00 +0000 Subject: [PATCH] moving some of the nav components around to sidebars and stuff git-svn-id: svn://svn.open-ils.org/ILS/trunk@923 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../javascript/opac/AbstractRecordResultPage.js | 56 ++++++++-------- Open-ILS/src/javascript/opac/GlobalInit.js | 1 + Open-ILS/src/javascript/opac/LocationTree.js | 3 + Open-ILS/src/javascript/opac/Page.js | 75 ++++++++++++++++++++-- Open-ILS/src/javascript/opac/RecordDetailPage.js | 4 +- Open-ILS/src/javascript/opac/RecordResultPage.js | 8 +++ Open-ILS/src/javascript/util/RemoteRequest.js | 20 ++++-- Open-ILS/src/javascript/util/webutils.js | 27 +++++++- 8 files changed, 154 insertions(+), 40 deletions(-) diff --git a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js index 82237943b0..85c8533cb4 100644 --- a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js +++ b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js @@ -33,6 +33,8 @@ AbstractRecordResultPage.prototype.init = function() { this.sidebarBox = getById("record_sidebar_box"); + this.sidebarBox.appendChild(this.buildNavBox()); + this.sidebarBox.appendChild(elem("br")); if(!this.hitsPerPage) this.hitsPerPage = 10; /* how many hits are displayed per page */ @@ -300,7 +302,10 @@ AbstractRecordResultPage.prototype.displayRecord = var marcd = elem( "div", { style: "float:right" } ); marcd.appendChild(marcb); - author_cell.appendChild(marcd); + //author_cell.appendChild(marcd); + //misc_row.insertCell(misc_row.cells.length).appendChild(marcd); + c.appendChild(marcd); + } @@ -510,7 +515,7 @@ AbstractRecordResultPage.prototype.displayCopyCounts = AbstractRecordResultPage.prototype.noHits = function() { var hcell = getById("hit_count_cell"); - hcell.appendChild(createAppElement("br")); + //hcell.appendChild(createAppElement("br")); hcell.appendChild(createAppTextNode("0 hits were returned for you search")); } @@ -559,32 +564,29 @@ AbstractRecordResultPage.prototype.buildNextLinks = function() { var hcell2 = getById("hit_count_cell_2"); hideMe(hcell2); - var ident = "Titles"; - if(instanceOf(this, MRResultPage)) - ident = "Title Groups"; - - hcell.appendChild( - createAppTextNode( "Displaying " + ident + " " + - ( parseInt(i) + 1 ) + " to " + max + " of " + this.hitCount)); - - hcell.appendChild(createAppTextNode(" ")); - hcell.appendChild(createAppTextNode(" ")); - hcell.appendChild(createAppTextNode(" ")); + if(hcell) { - /* - var div = createAppElement("div"); - div.appendChild(createAppTextNode(".")); - div.setAttribute("style", "color:#FFF;float:left;width:10px;border:1px solid black;position:relative"); - hcell.appendChild(div); - */ - - hcell.appendChild(prev); - var span = createAppElement("span"); - span.appendChild(createAppTextNode(" ... ")); - hcell.appendChild(span); - hcell.appendChild(next); - - hcell2.innerHTML = hcell.innerHTML; + var ident = "Titles"; + if(instanceOf(this, MRResultPage)) + ident = "Title Groups"; + + hcell.appendChild( + createAppTextNode( "Displaying " + ident + " " + + ( parseInt(i) + 1 ) + " to " + max + " of " + this.hitCount)); + + hcell.appendChild(createAppTextNode(" ")); + hcell.appendChild(createAppTextNode(" ")); + hcell.appendChild(createAppTextNode(" ")); + + hcell.appendChild(prev); + var span = createAppElement("span"); + span.appendChild(createAppTextNode(" ... ")); + hcell.appendChild(span); + hcell.appendChild(next); + + hcell2.innerHTML = hcell.innerHTML; + + } } diff --git a/Open-ILS/src/javascript/opac/GlobalInit.js b/Open-ILS/src/javascript/opac/GlobalInit.js index dd4c24a294..cbcdf111fd 100644 --- a/Open-ILS/src/javascript/opac/GlobalInit.js +++ b/Open-ILS/src/javascript/opac/GlobalInit.js @@ -51,6 +51,7 @@ function globalInit() { if( isXUL() && globalAppFrame ) globalAppFrame.document.body.style.background = "#FFF"; + getDocument().body.onunload = cleanIEMemory; var page_name = globalPageTarget; diff --git a/Open-ILS/src/javascript/opac/LocationTree.js b/Open-ILS/src/javascript/opac/LocationTree.js index fd6b0da012..3456a7ec3a 100644 --- a/Open-ILS/src/javascript/opac/LocationTree.js +++ b/Open-ILS/src/javascript/opac/LocationTree.js @@ -111,6 +111,9 @@ LocationTree.prototype.toggle = function(button_div, offsetx, offsety, relative) offsetx = parseInt(offsetx) + 8; } + + debug("TREE OFFSET y: " + offsety + " x: " + offsetx ); + this.treeContainerBox.style.position = "absolute"; this.treeContainerBox.style.top = offsety; this.treeContainerBox.style.left = offsetx; diff --git a/Open-ILS/src/javascript/opac/Page.js b/Open-ILS/src/javascript/opac/Page.js index 88573084be..ae5c897a54 100644 --- a/Open-ILS/src/javascript/opac/Page.js +++ b/Open-ILS/src/javascript/opac/Page.js @@ -45,6 +45,15 @@ Page.prototype.setLocDisplay = function(name) { orgunit = globalSelectedLocation; else { orgunit = globalLocation; } + this.searchingCell.innerHTML = + "Now Searching " + orgunit.name() + ""; + + this.resetRange(); + return; + + + + var arr = orgNodeTrail(orgunit); this.searchingCell.innerHTML = ""; @@ -97,7 +106,8 @@ Page.prototype.resetRange = function() { } this.searchRange.selectedIndex = selectedOption; - this.searchRange.options[selectedOption].selected = true; + var opt = this.searchRange.options[selectedOption]; + if(opt) opt.selected = true; if(this.searchRange.options.length == 1 ) hideMe(this.searchRange.parentNode); @@ -112,6 +122,8 @@ Page.prototype.resetRange = function() { var obj = this; debug("Setting onclick for selector"); + + var obj = this; this.searchRange.onchange = function() { var location = globalSelectedLocation; @@ -174,28 +186,79 @@ Page.prototype.buildDivider = function() { Page.prototype.buildNavBox = function() { Page.navBox = new Box(); Page.navBox.init("Navigate", false, false); - var table = elem("table", {className:"main_nav_table"}); + var table = elem("table"); + add_css_class(table, "main_nav_table"); - var arr = new Array(); + var arr = []; + + /* location tree */ + var loc = elem("a", + {id:"location_nav_link", href:"javascript:void(0);"}, null, "Change Search Location"); + + loc.onclick = function(evt) { + globalPage.locationTree.toggle(getById("location_nav_link")); + } + arr.push(loc); + + arr.push(elem("a", {href:'?target=advanced_search'}, null, "Advanced Search")); + arr.push(elem("a", {href:'?target=my_opac'}, null, "My OPAC")); + arr.push(elem("a", {href:'?target=about'}, null, "About PINES")); + arr.push(this.buildDeepLink()); + + if(UserSession.instance().verifySession()) { + arr.push(elem("a", {href:"?target=logout"}, null, "Logout")); + } - arr.push(elem("a", {href:'?target=advanced_search'}, "Advanced Search")); - arr.push(elem("a", {href:'?target=my_opac'}, "My OPAC")); - arr.push(elem("a", {href:'?target=about'}, "About PINES")); for( var i in arr ) { var row = table.insertRow(table.rows.length); add_css_class(row, "main_nav_row"); var cell = row.insertCell(row.cells.length); add_css_class(cell, "main_nav_cell"); + cell.appendChild(arr[i]); } /* append to the page */ Page.navBox.addItem(table); + Page.navBox.finalize(); + var location = getById("main_page_nav_box"); if(location) location.appendChild(Page.navBox.getNode()); + + return Page.navBox.getNode(); } +Page.prototype.buildDeepLink = function() { + try { + if(!globalAppFrame) + return elem("div"); + } catch(E) { return elem("div"); } + + var org = globalSelectedLocation; + if(org == null) + org = globalLocation; + org = org.id(); + + var depth = globalSearchDepth; + + var string =globalAppFrame.location.href; + if(!string.match(/sub_frame/)) + string += "&sub_frame=1" + if(!string.match(/location/)) + string += "&location=" + org; + if(!string.match(/depth/)) + string += "&depth=" + depth; + + debug("Redirecting deep link to " + string ); + + var a = elem("a", + { href: string }, null, "Link to this page" + ); + + a.setAttribute("target", "_blank"); + return a; +} diff --git a/Open-ILS/src/javascript/opac/RecordDetailPage.js b/Open-ILS/src/javascript/opac/RecordDetailPage.js index ba8436594a..023eaf464b 100644 --- a/Open-ILS/src/javascript/opac/RecordDetailPage.js +++ b/Open-ILS/src/javascript/opac/RecordDetailPage.js @@ -106,6 +106,8 @@ RecordDetailPage.prototype.draw = function() { this.fetchRecord(paramObj.__record); /* sets this.record */ this.viewMarc = getById("record_detail_view_marc"); + + this.buildNavBox(); } @@ -113,7 +115,6 @@ RecordDetailPage.prototype.draw = function() { function buildCustomOrgTree(org_node, root) { - debug("performing custom org tree build"); var item; if(root) { @@ -132,7 +133,6 @@ function buildCustomOrgTree(org_node, root) { for( var index in org_node.children()) { var childorg = org_node.children()[index]; if( childorg != null ) { - debug("Adding " + childorg.name() + " to org tree"); var tree_node = buildCustomOrgTree(childorg); if(tree_node != null) item.add(tree_node); diff --git a/Open-ILS/src/javascript/opac/RecordResultPage.js b/Open-ILS/src/javascript/opac/RecordResultPage.js index 027452339b..2411a8a1bf 100644 --- a/Open-ILS/src/javascript/opac/RecordResultPage.js +++ b/Open-ILS/src/javascript/opac/RecordResultPage.js @@ -205,6 +205,13 @@ RecordResultPage.prototype.isNewSearch = function() { /* performs a new search */ RecordResultPage.prototype.doSearch = function() { + if(recordResultRedirect) { + /* if the user is just hitting the 'back' button */ + recordResultRedirect = false; + history.back(); + return; + } + debug( "Key Value Array \n" + js2JSON( paramObj ) ); this.page = parseInt(paramObj.__page); @@ -344,6 +351,7 @@ RecordResultPage.prototype.mrSearch = function(mrid) { } } else { recordResultRedirect = false; + history.back(); } obj.collectRecords(); diff --git a/Open-ILS/src/javascript/util/RemoteRequest.js b/Open-ILS/src/javascript/util/RemoteRequest.js index 3748f42373..61e44f5a23 100644 --- a/Open-ILS/src/javascript/util/RemoteRequest.js +++ b/Open-ILS/src/javascript/util/RemoteRequest.js @@ -30,8 +30,13 @@ RemoteRequest.prunePending = function(id) { var tmpArray = new Array(); for( var x in RemoteRequest.pending ) { if( RemoteRequest.pending[x] != null ) { - if( RemoteRequest.pending[x].id != id ) - tmpArray.push(RemoteRequest.pending[x]); + var req = RemoteRequest.pending[x]; + if( req.id != id ) + tmpArray.push(req); + else { + debug("Cleaning " + req.id ); + req.clean(); + } } } RemoteRequest.pending = tmpArray; @@ -46,7 +51,9 @@ RemoteRequest.cancelAll = function() { for( var x in RemoteRequest.pending ) { if( RemoteRequest.pending[x] != null ) { debug("Cancelling request..."); - RemoteRequest.pending[x].cancelled = true; + var req = RemoteRequest.pending[x]; + req.cancelled = true; + req.clean(); } } } @@ -117,6 +124,11 @@ function RemoteRequest( service, method ) { alert("NEWER BROWSER"); } +RemoteRequest.prototype.clean = function() { + this.xmlhttp.onreadystatechange = function(){}; + this.callback = null; +} + /* constructs our XMLHTTPRequest object */ RemoteRequest.prototype.buildXMLRequest = function() { @@ -190,7 +202,7 @@ RemoteRequest.prototype.setCompleteCallback = function(callback) { //alert("Exception: " + E); throw E; } - } + } /* on success, remove the request from the pending cache */ RemoteRequest.prunePending(object.id); diff --git a/Open-ILS/src/javascript/util/webutils.js b/Open-ILS/src/javascript/util/webutils.js index 0e9a8d0d81..b7d49debd2 100644 --- a/Open-ILS/src/javascript/util/webutils.js +++ b/Open-ILS/src/javascript/util/webutils.js @@ -1,3 +1,22 @@ +function cleanIEMemory() { + var a = [ "a", "div", "span", "select", "option", "img", "body", "iframe", "frame"]; + for( var index in a ) { + var nodes = getDocument().getElementsByTagName(a[index]); + for( var n = 0; n!= nodes.length; n++ ) { + var node = nodes[n]; + node.onclick = null; + node.onchange = null; + node.onselect = null; + } + } +} + + + + + + + function hideMe(obj) { if(!obj) return; @@ -70,7 +89,7 @@ function normalize(val) { if(!val) return ""; var newVal = ''; - val = val.split(' '); + try {val = val.split(' ');} catch(E) {return val;} var reg = /\w/; for( var c = 0; c < val.length; c++) { @@ -555,6 +574,12 @@ function getDocument() { return document; } +function getWindow() { + if(globalAppFrame) + return globalAppFrame; + return window; +} + /* returns [x, y] coords of the mouse */ function getMousePos(e) { -- 2.11.0