broke sidebar extras code out so rdetail can share it
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 21 Nov 2005 20:02:46 +0000 (20:02 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 21 Nov 2005 20:02:46 +0000 (20:02 +0000)
showing subjects and series on rdetail page

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

Open-ILS/web/opac/skin/default/css/layout.css
Open-ILS/web/opac/skin/default/js/rdetail.js
Open-ILS/web/opac/skin/default/js/result_common.js
Open-ILS/web/opac/skin/default/js/sidebar_extras.js [new file with mode: 0644]
Open-ILS/web/opac/skin/default/xml/mresult.xml
Open-ILS/web/opac/skin/default/xml/rdetail.xml
Open-ILS/web/opac/skin/default/xml/rresult.xml

index 017d4c8..5ed8339 100644 (file)
@@ -9,7 +9,7 @@ body { margin: 6px; }
 table { border-collapse: collapse; }
 
 /* generic CSS for a table with data */
-.data_grid { font-weight: 500; border-collapse: collapse; width: 95%;}
+.data_grid { font-weight: 500; border-collapse: collapse;}
 .data_grid thead tr { background: #E0F0E0; color: #000000; }
 .data_grid thead td { border: 1px solid #808080; padding-right: 5px; padding-left: 5px;}
 .data_grid tbody td { border: 1px solid #E0E0E0; padding: 5px; }
index 761b72e..7010dce 100644 (file)
@@ -96,6 +96,11 @@ function _rdetailDraw(r) {
        req.callback(rdetailHandleAddedContent);
        req.send();
 
+       resultBuildCaches( [ record ] );
+       resultDrawSubjects();
+       //resultDrawAuthors();
+       resultDrawSeries();
+
 }
 
 var rdetailTocFetched          = false;
index 7e3c8c7..a3b1ad8 100644 (file)
@@ -455,198 +455,3 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
 }
 
 
-/* captures extraneous info from each record */
-
-var subjectCache = {};
-var authorCache = {};
-var seriesCache = {};
-
-function resultBuildCaches(records) {
-       for( var r in records ) {
-               var rec = records[r];
-               for( var s in rec.subject() ) 
-                       subjectCache[s] == null ? subjectCache[s] = 1 : subjectCache[s]++;
-               authorCache[rec.author()] = 1;
-               for( var s in rec.series() ) seriesCache[rec.series()[s]] = 1;
-       }
-}
-
-function resultSortSubjects(a, b) { return -(a.count - b.count); } /* sort in reverse */
-function resultDrawSubjects() {
-
-       var subjs = [];
-       for( var s in subjectCache )
-               subjs.push( { sub : s, count : subjectCache[s] } );
-       subjs.sort(resultSortSubjects);
-
-       var ss = [];
-       for( var s in subjs ) ss.push(subjs[s].sub);
-
-       resultDrawSidebarTrees( 
-               STYPE_SUBJECT, 
-               "subjectSidebarTree", ss, 
-               $("subject_tree_sidebar"), 
-               $("subject_sidebar_tree_div") );
-}
-
-function resultDrawAuthors() {
-       var auths = new Array();
-       for( var s in authorCache ) auths.push(s);
-
-       resultDrawSidebarTrees( 
-               STYPE_AUTHOR, 
-               "authorSidebarTree", auths.sort(), 
-               $("author_tree_sidebar"), 
-               $("author_sidebar_tree_div") );
-}
-
-function resultDrawSeries() {
-       var sers = new Array();
-       for( var s in seriesCache ) sers.push(s);
-       resultDrawSidebarTrees( 
-               STYPE_SERIES, 
-               "seriesSidebarTree", sers.sort(), 
-               $("series_tree_sidebar"), 
-               $("series_sidebar_tree_div") );
-}
-
-var _oldFashioned = true;
-function resultDrawSidebarTrees( stype, treeName, items, wrapperNode, destNode ) {
-       eval("tree = " + treeName);
-
-       var xrefCache = [];
-       var found = false;
-       var x = 0;
-       for( var i in items ) {
-
-               if(isNull(items[i])) continue;
-               if(x++ > 7) break;
-               found = true;
-
-               var item = normalize(truncate(items[i], 65));
-               var trunc = 65;
-               var args = {};
-               var href = resultQuickLink( items[i], stype );
-               tree.addNode( stype + "_" + items[i], treeName + 'Root', item, href );
-
-               /*
-               if(!IE)
-                       setTimeout('resultFireXRefReq("'+treeName+'","'+stype+'","'+item+'");',200);
-                       */
-               //if(!IE) resultFireXRefReq(treeName, stype, items[i]);
-               //resultFireXRefReq(treeName, stype, items[i]);
-
-
-               if(_oldFashioned)
-                       resultFireXRefReq(treeName, stype, items[i]);
-
-               //setTimeout('resultFireXRefReq("'+treeName+'","'+stype+'","'+item+'");', 100);
-
-               var a = {};
-               a.type = stype;
-               a.term = item;
-               xrefCache.push(a);
-       }
-
-       if(found) {
-               unHideMe(wrapperNode);
-               if(!_oldFashioned)
-                       resultFireXRefBatch(treeName, xrefCache, stype);
-       }
-}
-
-function resultFireXRefBatch(treeName, xrefCache, stype) {
-       var query = [];
-       for( var i = 0; i != xrefCache.length; i++ ) {
-               var topic = xrefCache[i];
-               query.push( [ topic.type, topic.term ] );
-       }
-       var req = new Request(FETCH_CROSSREF_BATCH, query);
-       var tree;
-       eval('tree=' + treeName);
-       req.request._tree = tree;
-       req.request._stype = stype;
-       req.callback(resultRenderXRefTree);
-       req.send();
-}
-
-function resultFireXRefReq( treeName, stype, item ) {
-       var tree;
-       eval('tree=' + treeName);
-       var req = new Request(FETCH_CROSSREF, stype, item);
-       req.request._tree = tree;
-       req.request._item = item;
-       req.request._stype = stype;
-       req.callback(resultAppendCrossRef);
-       req.send();
-}
-
-
-function resultQuickLink( term, type ) {
-       var args = {};
-       args.page = MRESULT;
-       args[PARAM_OFFSET] = 0;
-       args[PARAM_TERM] = term;
-       args[PARAM_STYPE] = type;
-       return buildOPACLink(args);
-}
-
-function resultRenderXRefTree(r) {
-       var tree = r._tree;
-       var res = r.getResultObject();
-       var stype = r._stype;
-
-       for( var c in res ) {
-               var cls = res[c];
-               for( var t in cls ) {
-                       var term = res[c][t];
-                       var froms = term['from'];
-                       var alsos = term['also'];
-                       var total = 0;
-
-                       for( var i = 0; (total++ < 5 && i < froms.length); i++ ) {
-                               var string = normalize(truncate(froms[i], 45));
-                               if($(stype + '_' + froms[i])) continue;
-                               tree.addNode(stype + '_' + froms[i], 
-                                       stype + '_' + t, string, resultQuickLink(froms[i],stype));
-                       }
-                       for( var i = 0; (total++ < 10 && i < alsos.length); i++ ) {
-                               var string = normalize(truncate(alsos[i], 45));
-                               if($(stype + '_' + alsos[i])) continue;
-                               tree.addNode(stype + '_' + alsos[i], 
-                                       stype + '_' + t, string, resultQuickLink(alsos[i],stype));
-                       }
-               }
-       }
-}
-
-
-function resultAppendCrossRef(r) {
-       var tree                = r._tree
-       var item                = r._item
-       var stype       = r._stype;
-       var result      = r.getResultObject();
-       if(!result) return;
-       var froms       = result['from'];
-       var alsos       = result['also'];
-
-       var total = 0;
-
-       for( var i = 0; (total++ < 5 && i < froms.length); i++ ) {
-               var string = normalize(truncate(froms[i], 45));
-               if($(stype + '_' + froms[i])) continue;
-               tree.addNode(stype + '_' + froms[i], 
-                       stype + '_' + item, string, resultQuickLink(froms[i],stype));
-       }
-       for( var i = 0; (total++ < 10 && i < alsos.length); i++ ) {
-               var string = normalize(truncate(alsos[i], 45));
-               if($(stype + '_' + alsos[i])) continue;
-               tree.addNode(stype + '_' + alsos[i], 
-                       stype + '_' + item, string, resultQuickLink(alsos[i],stype));
-       }
-}
-
-
-
-
-
diff --git a/Open-ILS/web/opac/skin/default/js/sidebar_extras.js b/Open-ILS/web/opac/skin/default/js/sidebar_extras.js
new file mode 100644 (file)
index 0000000..e1b6a08
--- /dev/null
@@ -0,0 +1,196 @@
+
+/* captures extraneous info from each record */
+
+var subjectCache = {};
+var authorCache = {};
+var seriesCache = {};
+
+function resultBuildCaches(records) {
+       for( var r in records ) {
+               var rec = records[r];
+               for( var s in rec.subject() ) 
+                       subjectCache[s] == null ? subjectCache[s] = 1 : subjectCache[s]++;
+               authorCache[rec.author()] = 1;
+               for( var s in rec.series() ) seriesCache[rec.series()[s]] = 1;
+       }
+}
+
+function resultSortSubjects(a, b) { return -(a.count - b.count); } /* sort in reverse */
+function resultDrawSubjects() {
+
+       var subjs = [];
+       for( var s in subjectCache )
+               subjs.push( { sub : s, count : subjectCache[s] } );
+       subjs.sort(resultSortSubjects);
+
+       var ss = [];
+       for( var s in subjs ) ss.push(subjs[s].sub);
+
+       resultDrawSidebarTrees( 
+               STYPE_SUBJECT, 
+               "subjectSidebarTree", ss, 
+               $("subject_tree_sidebar"), 
+               $("subject_sidebar_tree_div") );
+}
+
+function resultDrawAuthors() {
+       var auths = new Array();
+       for( var s in authorCache ) auths.push(s);
+
+       resultDrawSidebarTrees( 
+               STYPE_AUTHOR, 
+               "authorSidebarTree", auths.sort(), 
+               $("author_tree_sidebar"), 
+               $("author_sidebar_tree_div") );
+}
+
+function resultDrawSeries() {
+       var sers = new Array();
+       for( var s in seriesCache ) sers.push(s);
+       resultDrawSidebarTrees( 
+               STYPE_SERIES, 
+               "seriesSidebarTree", sers.sort(), 
+               $("series_tree_sidebar"), 
+               $("series_sidebar_tree_div") );
+}
+
+var _oldFashioned = true;
+function resultDrawSidebarTrees( stype, treeName, items, wrapperNode, destNode ) {
+       eval("tree = " + treeName);
+
+       var xrefCache = [];
+       var found = false;
+       var x = 0;
+       for( var i in items ) {
+
+               if(isNull(items[i])) continue;
+               if(x++ > 7) break;
+               found = true;
+
+               var item = normalize(truncate(items[i], 65));
+               var trunc = 65;
+               var args = {};
+               var href = resultQuickLink( items[i], stype );
+               tree.addNode( stype + "_" + items[i], treeName + 'Root', item, href );
+
+               /*
+               if(!IE)
+                       setTimeout('resultFireXRefReq("'+treeName+'","'+stype+'","'+item+'");',200);
+                       */
+               //if(!IE) resultFireXRefReq(treeName, stype, items[i]);
+               //resultFireXRefReq(treeName, stype, items[i]);
+
+
+               if(_oldFashioned)
+                       resultFireXRefReq(treeName, stype, items[i]);
+
+               //setTimeout('resultFireXRefReq("'+treeName+'","'+stype+'","'+item+'");', 100);
+
+               var a = {};
+               a.type = stype;
+               a.term = item;
+               xrefCache.push(a);
+       }
+
+       if(found) {
+               unHideMe(wrapperNode);
+               if(!_oldFashioned)
+                       resultFireXRefBatch(treeName, xrefCache, stype);
+       }
+}
+
+function resultFireXRefBatch(treeName, xrefCache, stype) {
+       var query = [];
+       for( var i = 0; i != xrefCache.length; i++ ) {
+               var topic = xrefCache[i];
+               query.push( [ topic.type, topic.term ] );
+       }
+       var req = new Request(FETCH_CROSSREF_BATCH, query);
+       var tree;
+       eval('tree=' + treeName);
+       req.request._tree = tree;
+       req.request._stype = stype;
+       req.callback(resultRenderXRefTree);
+       req.send();
+}
+
+function resultFireXRefReq( treeName, stype, item ) {
+       var tree;
+       eval('tree=' + treeName);
+       var req = new Request(FETCH_CROSSREF, stype, item);
+       req.request._tree = tree;
+       req.request._item = item;
+       req.request._stype = stype;
+       req.callback(resultAppendCrossRef);
+       req.send();
+}
+
+
+function resultQuickLink( term, type ) {
+       var args = {};
+       args.page = MRESULT;
+       args[PARAM_OFFSET] = 0;
+       args[PARAM_TERM] = term;
+       args[PARAM_STYPE] = type;
+       return buildOPACLink(args);
+}
+
+function resultRenderXRefTree(r) {
+       var tree = r._tree;
+       var res = r.getResultObject();
+       var stype = r._stype;
+
+       for( var c in res ) {
+               var cls = res[c];
+               for( var t in cls ) {
+                       var term = res[c][t];
+                       var froms = term['from'];
+                       var alsos = term['also'];
+                       var total = 0;
+
+                       for( var i = 0; (total++ < 5 && i < froms.length); i++ ) {
+                               var string = normalize(truncate(froms[i], 45));
+                               if($(stype + '_' + froms[i])) continue;
+                               tree.addNode(stype + '_' + froms[i], 
+                                       stype + '_' + t, string, resultQuickLink(froms[i],stype));
+                       }
+                       for( var i = 0; (total++ < 10 && i < alsos.length); i++ ) {
+                               var string = normalize(truncate(alsos[i], 45));
+                               if($(stype + '_' + alsos[i])) continue;
+                               tree.addNode(stype + '_' + alsos[i], 
+                                       stype + '_' + t, string, resultQuickLink(alsos[i],stype));
+                       }
+               }
+       }
+}
+
+
+function resultAppendCrossRef(r) {
+       var tree                = r._tree
+       var item                = r._item
+       var stype       = r._stype;
+       var result      = r.getResultObject();
+       if(!result) return;
+       var froms       = result['from'];
+       var alsos       = result['also'];
+
+       var total = 0;
+
+       for( var i = 0; (total++ < 5 && i < froms.length); i++ ) {
+               var string = normalize(truncate(froms[i], 45));
+               if($(stype + '_' + froms[i])) continue;
+               tree.addNode(stype + '_' + froms[i], 
+                       stype + '_' + item, string, resultQuickLink(froms[i],stype));
+       }
+       for( var i = 0; (total++ < 10 && i < alsos.length); i++ ) {
+               var string = normalize(truncate(alsos[i], 45));
+               if($(stype + '_' + alsos[i])) continue;
+               tree.addNode(stype + '_' + alsos[i], 
+                       stype + '_' + item, string, resultQuickLink(alsos[i],stype));
+       }
+}
+
+
+
+
+
index a64b06c..7c8c01b 100644 (file)
@@ -6,6 +6,7 @@
                <title>Evergreen: Title Groups</title>
                <xi:include href="css_common.xml"/>
                <xi:include href="js_common.xml"/>
+               <script language='javascript' src='../js/sidebar_extras.js'> </script>
                <script language='javascript' src='../js/mresult.js'> </script>
                <script language='javascript' src='../js/result_common.js'> </script>
                <script language='javascript' src='../js/tips.js'> </script>
index 2f1783a..2ce6728 100644 (file)
@@ -7,6 +7,7 @@
                <title>Evergreen: Titles</title>
                <xi:include href="css_common.xml"/>
                <xi:include href="js_common.xml"/>
+               <script language='javascript' src='../js/sidebar_extras.js'> </script>
                <script language='javascript' src='../js/rdetail.js'> </script>
                <script language='javascript' src='../js/holds.js'> </script>
        </head>
index 4650ae3..ca14d50 100644 (file)
@@ -7,6 +7,7 @@
                <title>Evergreen: Titles</title>
                <xi:include href="css_common.xml"/>
                <xi:include href="js_common.xml"/>
+               <script language='javascript' src='../js/sidebar_extras.js'> </script>
                <script language='javascript' src='../js/rresult.js'> </script>
                <script language='javascript' src='../js/result_common.js'> </script>
                <script language='javascript' src='../js/tips.js'> </script>