added some code to make it easier to deep link / ctrl-click to open
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 21 Jun 2005 14:38:18 +0000 (14:38 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 21 Jun 2005 14:38:18 +0000 (14:38 +0000)
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

Open-ILS/src/javascript/opac/AbstractRecordResultPage.js
Open-ILS/src/javascript/opac/GlobalInit.js
Open-ILS/src/javascript/opac/MRResultPage.js
Open-ILS/src/javascript/opac/RecordDetailPage.js
Open-ILS/src/javascript/opac/RecordResultPage.js
Open-ILS/src/javascript/util/ils_utils.js

index 9115361..f86c237 100644 (file)
@@ -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;
index a38e6c5..05c5cda 100644 (file)
@@ -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();
 
+
+
 }
 
 
index 28577ce..d36d745 100644 (file)
@@ -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;
 
index 0bdbf56..2950d9b 100644 (file)
@@ -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) {
 
index b5b6a99..0274523 100644 (file)
@@ -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();
index cddc2b7..e7d3bab 100644 (file)
@@ -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;