From 7b0b87278d4e000eca05a32bb87f16efffe51412 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 21 Jun 2005 14:38:18 +0000 Subject: [PATCH] added some code to make it easier to deep link / ctrl-click to open new window, etc. mainly added 'location' and 'depth' url params to overwrite any calculated location (i.e. where the user may be logged in). git-svn-id: svn://svn.open-ils.org/ILS/trunk@886 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../javascript/opac/AbstractRecordResultPage.js | 13 +++++++--- Open-ILS/src/javascript/opac/GlobalInit.js | 29 ++++++++++++++------- Open-ILS/src/javascript/opac/MRResultPage.js | 8 ++++-- Open-ILS/src/javascript/opac/RecordDetailPage.js | 25 +++++++++++++----- Open-ILS/src/javascript/opac/RecordResultPage.js | 30 +++++++++++++++++----- Open-ILS/src/javascript/util/ils_utils.js | 2 +- 6 files changed, 78 insertions(+), 29 deletions(-) diff --git a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js index 9115361976..f86c23721a 100644 --- a/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js +++ b/Open-ILS/src/javascript/opac/AbstractRecordResultPage.js @@ -347,7 +347,9 @@ AbstractRecordResultPage.prototype.mkAuthorLink = function(auth) { "?target=mr_result&mr_search_type=author&page=0&mr_search_query=" + encodeURIComponent(auth) + "&mr_search_depth=" + this.searchDepth + - "&mr_search_location=" + this.searchLocation); + "&mr_search_location=" + this.searchLocation + + "&location=" + this.searchLocation + + "&depth=" + this.searchDepth); href.appendChild(createAppTextNode(auth)); href.title = "Author search for " + auth; @@ -364,7 +366,9 @@ AbstractRecordResultPage.prototype.mkSeriesLink = function(series) { "?target=mr_result&mr_search_type=series&page=0&mr_search_query=" + encodeURIComponent(series) + "&mr_search_depth=" + this.searchDepth + - "&mr_search_location=" + this.searchLocation); + "&mr_search_location=" + this.searchLocation + + "&location=" + this.searchLocation + + "&depth=" + this.searchDepth); href.appendChild(createAppTextNode(series)); href.title = "Series search for " + series; @@ -378,7 +382,10 @@ AbstractRecordResultPage.prototype.mkSubjectLink = function(sub) { "?target=mr_result&mr_search_type=subject&page=0&mr_search_query=" + encodeURIComponent(sub) + "&mr_search_depth=" + this.searchDepth + - "&mr_search_location=" + this.searchLocation); + "&mr_search_location=" + this.searchLocation + + "&location=" + this.searchLocation + + "&depth=" + this.searchDepth); + href.appendChild(createAppTextNode(sub)); href.title = "Subject search for " + sub; return href; diff --git a/Open-ILS/src/javascript/opac/GlobalInit.js b/Open-ILS/src/javascript/opac/GlobalInit.js index a38e6c5869..05c5cdad65 100644 --- a/Open-ILS/src/javascript/opac/GlobalInit.js +++ b/Open-ILS/src/javascript/opac/GlobalInit.js @@ -14,6 +14,11 @@ var locationStack = new Array(); var lastSearchString = null; var lastSearchType = null; +/* this is true if we directed to the record detail page + becuase of only having one hit on the record result + page. this allows us to back up from the detail + page to the mr_result page */ +var recordResultRedirect = false; var loaded = false; @@ -39,16 +44,7 @@ function globalInit() { if( isXUL() && globalAppFrame ) globalAppFrame.document.body.style.background = "#FFF"; - if(paramObj.__location != null) { - globalSelectedLocation = findOrgUnit(paramObj.__location); - debug("Setting selected location to " + globalSelectedLocation.name() ); - } - - if(paramObj.__depth != null) { - globalSearchDepth = findOrgType(paramObj.__depth); - debug("Setting selected depth to " + globalSearchDepth.name() ); - } var page_name = globalPageTarget; @@ -118,6 +114,19 @@ function globalInit() { } globalPage.init(); + + if(paramObj.__location != null) { + globalSelectedLocation = findOrgUnit(paramObj.__location); + debug("Setting selected location to " + globalSelectedLocation.name() ); + } + + + if(paramObj.__depth != null) { + debug("Passed in depth from search params: " + paramObj.__depth); + globalSearchDepth = parseInt(paramObj.__depth); + debug("Setting selected depth to " + globalSearchDepth ); + } + globalPage.setLocDisplay(); globalPage.locationTree = globalOrgTreeWidget; globalPage.setPageTrail(); @@ -128,6 +137,8 @@ function globalInit() { if( globalSearchBarFormChunk != null) globalSearchBarFormChunk.resetPage(); + + } diff --git a/Open-ILS/src/javascript/opac/MRResultPage.js b/Open-ILS/src/javascript/opac/MRResultPage.js index 28577ce56e..d36d745845 100644 --- a/Open-ILS/src/javascript/opac/MRResultPage.js +++ b/Open-ILS/src/javascript/opac/MRResultPage.js @@ -138,7 +138,9 @@ MRResultPage.prototype.mkLink = function(id, type, value, title) { add_css_class(href,"record_result_title_link"); href.setAttribute("href", "?target=record_result&page=0&mrid=" + id + - "&hits_per_page=" + this.hitsPerPage); + "&hits_per_page=" + this.hitsPerPage + + "&location=" + this.searchLocation + + "&depth=" + this.searchDepth ); href.appendChild(createAppTextNode(value)); href.title = "View titles for " + t + ""; break; @@ -148,7 +150,9 @@ MRResultPage.prototype.mkLink = function(id, type, value, title) { add_css_class(href,"record_result_title_link"); href.setAttribute("href", "?target=record_result&page=0&mrid=" + id + - "&hits_per_page=" + this.hitsPerPage); + "&hits_per_page=" + this.hitsPerPage + + "&location=" + this.searchLocation + + "&depth=" + this.searchDepth ); href.title = "View titles for " + t + ""; break; diff --git a/Open-ILS/src/javascript/opac/RecordDetailPage.js b/Open-ILS/src/javascript/opac/RecordDetailPage.js index 0bdbf5613e..2950d9bcdf 100644 --- a/Open-ILS/src/javascript/opac/RecordDetailPage.js +++ b/Open-ILS/src/javascript/opac/RecordDetailPage.js @@ -169,22 +169,33 @@ RecordDetailPage.prototype.drawRecord = function(record) { createAppTextNode(record.types_of_resource())); + pic_cell.appendChild(this.mkImage(record)); + + var orgUnit = globalSelectedLocation; + if(!orgUnit) orgUnit = globalLocation; + + this.drawCopyTrees(orgUnit, record); +} + +/* sets up the cover art image */ +RecordDetailPage.prototype.mkImage = function(record) { var isbn = record.isbn(); if(isbn) isbn = isbn.replace(/\s+/,""); else isbn = ""; - var img_src = "http://images.amazon.com/images/P/" +isbn + ".01.MZZZZZZZ.jpg"; - var pic = createAppElement("img"); - pic.setAttribute("src", img_src); - pic_cell.appendChild(pic); + var big_pic = elem("a", { + href : "http://images.amazon.com/images/P/" +isbn + ".01.LZZZZZZZ.jpg", + title : "Click for larger image" } ); - var orgUnit = globalSelectedLocation; - if(!orgUnit) orgUnit = globalLocation; + var img_src = "http://images.amazon.com/images/P/" +isbn + ".01.MZZZZZZZ.jpg"; + var pic = elem ( "img", { src : img_src }, { border : "0px none" }); + big_pic.appendChild(pic); - this.drawCopyTrees(orgUnit, record); + return big_pic; } + /* if sync, it is a synchronous call */ RecordDetailPage.prototype.grabCopyTree = function(record, orgUnit, callback, sync) { diff --git a/Open-ILS/src/javascript/opac/RecordResultPage.js b/Open-ILS/src/javascript/opac/RecordResultPage.js index b5b6a99dd4..027452339b 100644 --- a/Open-ILS/src/javascript/opac/RecordResultPage.js +++ b/Open-ILS/src/javascript/opac/RecordResultPage.js @@ -138,12 +138,20 @@ RecordResultPage.prototype.mkLink = function(id, type, value) { var href; + var org = globalSelectedLocation; + if(org == null) + org = globalLocation; + switch(type) { + case "title": href = createAppElement("a"); add_css_class(href,"record_result_title_link"); - href.setAttribute("href","?target=record_detail&record=" + id ); + href.setAttribute("href", + "?target=record_detail&record=" + id + + "&location=" + org.id() + + "&depth=" + globalSearchDepth ); href.appendChild(createAppTextNode(value)); href.title = "View title details for " + value; break; @@ -160,7 +168,10 @@ RecordResultPage.prototype.mkLink = function(id, type, value) { case "img": href = createAppElement("a"); add_css_class(href,"record_result_image_link"); - href.setAttribute("href","?target=record_detail&page=0&mrid=" + id ); + href.setAttribute("href", + "?target=record_detail&page=0&mrid=" + id + + "&location=" + org.id() + + "&depth=" + globalSearchDepth ); href.title = "View title details for " + value; break; @@ -322,12 +333,17 @@ RecordResultPage.prototype.mrSearch = function(mrid) { try{ obj.gatherIDs(req.getResultObject()); - if(parseInt(obj.hitCount) == 1) { - debug("Redirecting to record detail page with record " + obj.recordIDs[0] ); + if(!recordResultRedirect) { /* if the user isn't just hitting the 'back' button */ + if(parseInt(obj.hitCount) == 1) { + recordResultRedirect = true; + debug("Redirecting to record detail page with record " + obj.recordIDs[0] ); url_redirect( [ - "target", "record_detail", - "record", obj.recordIDs[0] ] ); - return; + "target", "record_detail", + "record", obj.recordIDs[0] ] ); + return; + } + } else { + recordResultRedirect = false; } obj.collectRecords(); diff --git a/Open-ILS/src/javascript/util/ils_utils.js b/Open-ILS/src/javascript/util/ils_utils.js index cddc2b7346..e7d3babc5c 100644 --- a/Open-ILS/src/javascript/util/ils_utils.js +++ b/Open-ILS/src/javascript/util/ils_utils.js @@ -22,7 +22,7 @@ function findOrgType(type_id) { for(var type in globalOrgTypes) { var t =globalOrgTypes[type]; - if( t.id() == type_id ) + if( t.id() == type_id || t.id() == parseInt(type_id) ) return t; } return null; -- 2.11.0