more work on the record detail callnumber browse
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 4 Jan 2006 16:34:09 +0000 (16:34 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 4 Jan 2006 16:34:09 +0000 (16:34 +0000)
added client side pre-fetching of next and previous
added local callnumber dropdown to pick different CN's when in browse
expanding cn browse depth for items outside of search range

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

Open-ILS/web/opac/skin/default/js/cn_browse.js
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml

index aaa3376..78c1a0a 100644 (file)
@@ -3,48 +3,103 @@ var cnBrowseTopCn;
 var cnBrowseTopId;
 var cnBrowseBottomCn;
 var cnBrowseBottomId;
+var cnBrowseDepth;
+var cnBrowseCache = {};
+var cnBrowseShowNext = false;
+var cnBrowseShowPrev = false;
 var MAX_CN = 9;
 
-function cnBrowseGo(cn) { 
+function cnBrowseGo(cn, depth) { 
+       if(depth == null) depth = getDepth();
+       cnBrowseDepth = depth;
        cnBrowseCurrent = cn;
        var req = new Request( FETCH_CNBROWSE_TARGET, 
                'org_unit', getLocation(), 
-               'depth', getDepth()
-               'label', cn
+               'depth', cnBrowseDepth
+               'label', cnBrowseCurrent,
                'page_size', MAX_CN );
        req.callback( cnBrowseDraw );
        req.send();
 }
 
 function cnBrowseNext() {
+       cnBrowseShowNext = true;
+       if( cnBrowseCache.next )  /* if we have it, show it */
+               cnBrowseClearNext(cnBrowseCache.next);
+}
+
+function cnBrowsePrev() {
+       cnBrowseShowPrev = true;
+       if( cnBrowseCache.prev ) 
+               cnBrowseClearPrev(cnBrowseCache.prev);
+}
+
+function cnBrowseGrabNext() {
        var req = new Request( FETCH_CNBROWSE_NEXT, 
                'org_unit', getLocation(), 
-               'depth', getDepth(), 
+               'depth', cnBrowseDepth,
                'label', cnBrowseBottomCn, 
                'boundry_id', cnBrowseBottomId,
                'page_size', MAX_CN );
-       req.callback( cnBrowseDraw );
+       req.callback( cnBrowseCacheMe );
+       req.request.next = true;
        req.send();
 }
 
-function cnBrowsePrev() {
+
+function cnBrowseGrabPrev() {
        var req = new Request( FETCH_CNBROWSE_PREV,
                'org_unit', getLocation(), 
-               'depth', getDepth(), 
+               'depth', cnBrowseDepth,
                'label', cnBrowseTopCn, 
                'boundry_id', cnBrowseTopId,
                'page_size', MAX_CN );
-       req.callback( cnBrowseDraw );
+       req.callback( cnBrowseCacheMe );
+       req.request.prev = true;
        req.send();
 }
 
+function cnBrowseClearNext(list) {
+       cnBrowseCache.next = null; 
+       cnBrowseShowNext = false;
+       _cnBrowseDraw(list);
+}
+
+function cnBrowseClearPrev(list) {
+       cnBrowseCache.prev = null; 
+       cnBrowseShowPrev = false;
+       _cnBrowseDraw(list);
+}
+
+/* cache next and previous calls unless they are 
+needed immediately */
+function cnBrowseCacheMe(r) {
+       var list = r.getResultObject();
+       if( r.next ) {
+               cnBrowseCache.next = list;
+               if( cnBrowseShowNext ) {
+                       cnBrowseClearNext(list);
+               } 
+
+       } else if( r.prev ) {
+               cnBrowseCache.prev = list;
+               if( cnBrowseShowPrev )  {
+                       cnBrowseClearPrev(list);
+               } 
+       }
+}
 
-var cnTbody;
-var cnRowT;
-var cnTdT;
 
 function cnBrowseDraw( r ) {
        var list = r.getResultObject();
+       _cnBrowseDraw(list);
+}
+
+
+var cnTbody;
+var cnRowT;
+var cnTdT;
+function _cnBrowseDraw( list ) {
 
        if(!cnTbody) {
                cnTbody = $('cn_tbody');
@@ -103,6 +158,8 @@ function cnBrowseDraw( r ) {
                        cnTbody.appendChild(currentRow);
                }
        }
+       cnBrowseGrabNext();
+       cnBrowseGrabPrev();
 }
 
 function cnBrowseDrawTitle(r) {
index 027b222..2a0ee40 100644 (file)
@@ -173,20 +173,22 @@ function rdetailBuildCNList() {
 
 function rdetailGatherCN() {
        var cn = getSelectorVal($('cn_browse_selector'));
-       rdetailShowCNBrowse( cn );
+       rdetailShowCNBrowse( cn, getDepth() );
+       setSelector( $('cn_browse_selector'), cn );
 }
 
 
-function rdetailShowCNBrowse( cn ) {
+function rdetailShowCNBrowse( cn, depth ) {
        if(!cn) return;
        rdetailBuildCNList();
+       setSelector( $('cn_browse_selector'), cn );
        hideMe($('rdetail_copy_info_div'));
        hideMe($('rdetail_reviews_div'));
        hideMe($('rdetail_toc_div'));
        hideMe($('rdetail_marc_div'));
-       unHideMe($('rdetail_viewcn_link'));
+       unHideMe($('rdetail_cn_browse_div'));
        unHideMe($('cn_browse'));
-       cnBrowseGo(cn);
+       cnBrowseGo(cn, depth);
 }
 
 function rdetailHandleAddedContent(r) {
@@ -295,10 +297,6 @@ function _rdetailBuildInfoRows(r) {
 
                } else rowNode.setAttribute("used", "1");
 
-               var a = elem("a", {href:'javascript:rdetailShowCNBrowse("' + arr[1] + '");' }, arr[1]);
-               addCSSClass(a, 'classic_link');
-               findNodeByName( rowNode, config.names.rdetail.cn_cell ).appendChild(a);
-               
                var cpc_temp = rowNode.removeChild(
                        findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
 
@@ -314,22 +312,30 @@ function _rdetailBuildInfoRows(r) {
                        }
                }
                rdetailSetPath( thisOrg, isLocal );
-
-               /* used for building the shelf browser */
-               var cache = callnumberCache[arr[1]];
-               if( cache ) {
-                       cache.count++;
-                       if(isLocal) cache.local = true;
-               } else { callnumberCache[arr[1]] = { count : 1, local : false };}
+               rdetailBuildBrowseInfo( rowNode, arr[1], isLocal );
 
                if( i == summary.length - 1 && !defaultCN) defaultCN = arr[1];
-
        }
 
        if(!found) unHideMe(G.ui.rdetail.cp_info_none);
 
 }
 
+function rdetailBuildBrowseInfo(row, cn, local) {
+       /* used for building the shelf browser */
+       if(local) {
+               var cache = callnumberCache[cn];
+               if( cache ) cache.count++;
+               else callnumberCache[cn] = { count : 1 };
+       }
+
+       var depth = getDepth();
+       if( !local ) depth = findOrgDepth(globalOrgTree);
+       var a = elem("a", {href:'javascript:rdetailShowCNBrowse("' + cn + '", "'+depth+'");' }, cn);
+       addCSSClass(a, 'classic_link');
+       findNodeByName( row, config.names.rdetail.cn_cell ).appendChild(a);
+}
+
 /* sets the path to org as 'active' and displays the 
        path if it's local */
 function rdetailSetPath(org, local) {
index 5122a23..8a5e5a8 100644 (file)
@@ -69,7 +69,8 @@
                </div>
 
                <div id='rdetail_cn_browse_div' style='text-align: center;' class='hide_me'>
-                       <div style='width: 100%; border: 1px solid black; padding: 10px; margin-top: 5px;'>
+                       <div style='width: 100%; border: 1px solid black; padding: 6px; margin-top: 5px;'>
+                               <span>Local Call Numbers: </span>
                                <select id='cn_browse_selector'>
                                </select>
                        </div>