[open-ils-commits] r1363 - in conifer/branches/rel_2_0/web/opac/skin/lul: js xml/result (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Apr 14 23:29:20 EDT 2011


Author: dbs
Date: 2011-04-14 23:29:17 -0400 (Thu, 14 Apr 2011)
New Revision: 1363

Modified:
   conifer/branches/rel_2_0/web/opac/skin/lul/js/result_common.js
   conifer/branches/rel_2_0/web/opac/skin/lul/xml/result/result_table.xml
Log:
Bring search results into sync for the LU skin


Modified: conifer/branches/rel_2_0/web/opac/skin/lul/js/result_common.js
===================================================================
--- conifer/branches/rel_2_0/web/opac/skin/lul/js/result_common.js	2011-04-15 02:21:24 UTC (rev 1362)
+++ conifer/branches/rel_2_0/web/opac/skin/lul/js/result_common.js	2011-04-15 03:29:17 UTC (rev 1363)
@@ -1,3 +1,6 @@
+dojo.require('openils.BibTemplate');
+dojo.requireLocalization("openils.opac", "opac");
+var opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
 
 var recordsHandled = 0;
 var recordsCache = [];
@@ -4,6 +7,11 @@
 var lowHitCount = 4;
 var isbnList = '';
 var googleBooksLink = false;
+
+var resultFetchAllRecords = false;
+var resultCompiledSearch = null;
+var allRecordsReceivedAndProcessed = false;
+
 var enableHoldsOnAvailable = false;
 var enableExtraSearchesLowHits = true;
 var localProxyPrefix = 'http://librweb.laurentian.ca/login?url=';
@@ -26,18 +34,13 @@
         "termTransform": "allKeywords"
     }
 ];
-
-var resultFetchAllRecords = false;
-var resultCompiledSearch = null;
-
+ 
 /* set up the event handlers */
 if( findCurrentPage() == MRESULT || findCurrentPage() == RRESULT ) {
 	G.evt.result.hitCountReceived.push(resultSetHitInfo);
 	G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
 	G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
-	G.evt.result.allRecordsReceived.push(resultBuildCaches, resultDrawSubjects, 
-      resultDrawAuthors, resultDrawSeries, function(){unHideMe($('result_info_2'))},
-	  fetchGoogleBooksLink);
+	G.evt.result.allRecordsReceived.push( function(){unHideMe($('result_info_2'))}, fetchGoogleBooksLink, function() { allRecordsReceivedAndProcessed = true; }, fetchChiliFreshReviews);
 
 	attachEvt('result','lowHits',resultLowHits);
 	attachEvt('result','zeroHits',resultZeroHits);
@@ -103,6 +106,8 @@
     if(getAvail()) args.available = 1;
 
 
+	if(getFacet()) args.facets  = getFacet();
+
 	if(getAudience()) args.audience  = getAudience().split(/,/);
 	if(getLitForm()) args.lit_form	= getLitForm().split(/,/);
 	if(getLanguage()) args.language	= getLanguage().split(/,/);
@@ -115,6 +120,12 @@
 	_debug('Search args: ' + js2JSON(args));
 	_debug('Raw query: ' + getTerm());
 
+	var atomfeed = "/opac/extras/opensearch/1.1/" + findOrgUnit(args.org_unit).shortname() + "/atom-full/" + getStype() + '?searchTerms=' + getTerm();
+	if (args.facets) { atomfeed += ' ' + args.facets; }
+	if (sort) { atomfeed += '&searchSort=' + sort; }
+	if (sortdir) { atomfeed += '&searchSortDir=' + sortdir; }
+	dojo.create('link', {"rel":"alternate", "href":atomfeed, "type":"application/atom+xml"}, dojo.query('head')[0]);
+
 	var req = new Request(method, args, getTerm(), 1);
 	req.callback(handler);
 	req.send();
@@ -275,14 +286,13 @@
 	showCanvas();
 	unHideMe($('result_low_hits'));
 	unHideMe($('result_zero_hits_msg'));
-
 	//if(getTerm()) resultExpandSearch(); /* advanced search */
 }
 
 function resultExpandSearch() {
 	var top = findOrgDepth(globalOrgTree);
 
-    /* We don't want to expand the scope to Everywhere in Conifer, that's just confusing */
+	/* We don't want to expand the scope to Everywhere in Conifer, that's just confusing */
 	if(getDepth() == top || getDepth() - 1 == top) return;
 	unHideMe($('low_hits_expand_range'));
 	var par = $('low_hits_expand_link').parentNode;
@@ -489,6 +499,7 @@
 		zero based position the record should have in the display table */
 function resultDisplayRecord(rec, pos, is_mr) {
 
+    fieldmapper.IDL.load(['mvr']);
 	if(rec == null) rec = new mvr(); /* so the page won't die if there was an error */
 	recordsHandled++;
 	recordsCache.push(rec);
@@ -509,6 +520,27 @@
         }
     }
 
+    if (currentISBN && chilifresh && chilifresh != '(none)') {
+        var cfrow = $n(r, "chilifreshReview");
+        if (cfrow) {
+            removeCSSClass( cfrow, 'hide_me' );
+        }
+        var cflink = $n(r, "chilifreshReviewLink");
+        if (cflink) {
+            cflink.setAttribute(
+                'id',
+                'isbn_' + currentISBN
+            );
+        }
+        var cfdiv = $n(r, "chilifreshReviewResult");
+        if (cfdiv) {
+            cfdiv.setAttribute(
+                'id',
+                'chili_review_' + currentISBN
+            )
+        }
+    }
+
 /*
 	try {
 		var rank = parseFloat(ranks[pos + getOffset()]);
@@ -525,8 +557,9 @@
 	var title_link = $n(r, config.names.result.item_title);
 	var author_link = $n(r, config.names.result.item_author);
 
+	var onlyrec;
 	if( is_mr )  {
-		var onlyrec = onlyrecord[ getOffset() + pos ];
+		onlyrec = onlyrecord[ getOffset() + pos ];
 		if(onlyrec) {
 			buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', onlyrec);
 
@@ -538,7 +571,7 @@
 			pic.parentNode.setAttribute("href", buildOPACLink(args));
 			title_link.setAttribute("href", buildOPACLink(args));
 			title_link.appendChild(text(normalize(truncate(rec.title(), 65))));
-			
+
 		} else {
 			buildunAPISpan($n(r,'unapi'), 'metabib-metarecord', rec.doc_id());
 
@@ -550,7 +583,14 @@
 			pic.parentNode.setAttribute("href", buildOPACLink(args));
 		}
 
+		if (enableHoldsOnAvailable) {
+			unHideMe($n(r,'place_hold_span'));
+			$n(r,'place_hold_link').setAttribute(
+				'href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"M"});');
+		}
+
 	} else {
+		onlyrec = rec.doc_id();
 		buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id());
 
 		buildTitleDetailLink(rec, title_link); 
@@ -562,26 +602,10 @@
 
 		if (enableHoldsOnAvailable) {
 			unHideMe($n(r,'place_hold_span'));
+			$n(r,'place_hold_link').setAttribute(
+				'href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"T"});');
 		}
 
-		$n(r,'place_hold_link').setAttribute(
-			'href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"T"});');
-
-                // Stolen from trunk
-                var here = findOrgUnit(getLocation());
-                dojo.require('openils.BibTemplate');
-                var l_cn_list = $n(r,'local_callnumber_list');
-                var onlyrec = rec.doc_id();
-
-                dojo.addOnLoad(function () {
-                        new openils.BibTemplate({
-                                root : l_cn_list,
-                                record : '' + onlyrec,
-                                org_unit : here.shortname()
-                        }).render();
-                        unHideMe(l_cn_list);
-                });
-
 	}
 
 	buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
@@ -615,6 +639,25 @@
 
 	resultBuildFormatIcons( r, rec, is_mr );
 
+	var bt_params = {
+		sync			: false,
+		root			: r,
+		subObjectLimit  : 10,
+		org_unit		: findOrgUnit(getLocation()).shortname(),
+		depth			: getDepth()
+	};
+
+	if (!is_mr) {
+		bt_params = dojo.mixin( bt_params, { record : onlyrec } );
+	} else {
+		bt_params = dojo.mixin( bt_params, { metarecord : onlyrec } );
+	}
+
+	if (findOrgType(findOrgUnit(getLocation()).ou_type()).can_have_vols())
+		unHideMe($n(r,'local_callnumber_list'));
+
+	new openils.BibTemplate( bt_params ).render();
+
 	unHideMe(r);
 	
 	runEvt("result", "recordDrawn", rec.doc_id(), title_link);
@@ -675,6 +718,8 @@
 }
 
 function fetchGoogleBooksLink () {
+    if (allRecordsReceivedAndProcessed) { return; }
+
     if (isbnList && googleBooksLink) {
         var scriptElement = document.createElement("script");
         scriptElement.setAttribute("id", "jsonScript");
@@ -687,6 +732,12 @@
     }
 }
 
+function fetchChiliFreshReviews() {
+    if (chilifresh && chilifresh != '(none)') {
+        try { chili_init(); } catch(E) { console.log(E + '\n'); }
+    }
+}
+
 function resultPageIsDone(pos) {
 
 	return (recordsHandled == getDisplayCount() 
@@ -707,7 +758,17 @@
 	var ccell = $n(countsrow, config.names.result.count_cell);
 
 	var nodes = orgNodeTrail(findOrgUnit(getLocation()));
-	var node = nodes[0];
+	var start_here = 0;
+	var orgHiding = checkOrgHiding();
+	if (orgHiding) {
+		for (var i = 0; i < nodes.length; i++) {
+			if (orgHiding.depth == findOrgDepth(nodes[i])) {
+				start_here = i;
+			}
+		}
+	}
+
+	var node = nodes[start_here];
 	var type = findOrgType(node.ou_type());
 	ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
 	ccell.title = type.opac_label();
@@ -728,10 +789,10 @@
 		resultCCHeaderApplied = true;
 	}
 
-	if(nodes[1]) {
+	if(nodes[start_here+1]) {
 
-		var x = 1;
-		var d = findOrgDepth(nodes[1]);
+		var x = start_here+1;
+		var d = findOrgDepth(nodes[start_here+1]);
 		var d2 = findOrgDepth(nodes[nodes.length -1]);
 
 		for( var i = d; i <= d2 ; i++ ) {
@@ -806,32 +867,33 @@
 	}
 
 	var i = 0;
-	var metarecords = (findCurrentPage() == MRESULT);
 	while(copy_counts[i] != null) {
 		var cell = $("copy_count_cell_" + i +"_" + pagePosition);
-		var cts = copy_counts[i];
-		cell.appendChild(text(cts.available + " / " + cts.count));
+		if (cell) {
+			var cts = copy_counts[i];
+			cell.appendChild(text(cts.available + " / " + cts.count));
 
-		if (!enableHoldsOnAvailable && (i == (copy_counts.length - 1))) {
-			var resultTBody = findParentByNodeName(cell, 'TBODY');
-			if (cts.available == 0 && cts.count > 0 && !metarecords) {
-				dojo.query('[name="place_hold_span"]', resultTBody).removeClass('hide_me');
-			} else {
-				dojo.query('[name="place_hold_span"]', resultTBody).addClass('hide_me');
+			if (!enableHoldsOnAvailable && (i == (copy_counts.length - 1))) {
+				var resultTBody = findParentByNodeName(cell, 'TBODY');
+				if (cts.available == 0 && cts.count > 0 && !metarecords) {
+					dojo.query('[name="place_hold_span"]', resultTBody).removeClass('hide_me');
+				} else {
+					dojo.query('[name="place_hold_span"]', resultTBody).addClass('hide_me');
+				}
 			}
-		}
 
-		if(isXUL()) {
-			/* here we style opac-invisible records for xul */
+			if(isXUL()) {
+				/* here we style opac-invisible records for xul */
 
-			if( cts.depth == 0 ) {
-				if(cts.transcendant == null && cts.unshadow == 0) {
-					_debug("found an opac-shadowed record: " + rec.doc_id());
-					var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode; 
-					if( cts.count == 0 ) 
-						addCSSClass( row, 'no_copies' );
-					else 
-						addCSSClass( row, 'shadowed' );
+				if( cts.depth == 0 ) {
+					if(cts.transcendant == null && cts.unshadow == 0) {
+						_debug("found an opac-shadowed record: " + rec.doc_id());
+						var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode; 
+						if( cts.count == 0 ) 
+							addCSSClass( row, 'no_copies' );
+						else 
+							addCSSClass( row, 'shadowed' );
+					}
 				}
 			}
 		}
@@ -839,3 +901,4 @@
 	}
 }
 
+

Modified: conifer/branches/rel_2_0/web/opac/skin/lul/xml/result/result_table.xml
===================================================================
--- conifer/branches/rel_2_0/web/opac/skin/lul/xml/result/result_table.xml	2011-04-15 02:21:24 UTC (rev 1362)
+++ conifer/branches/rel_2_0/web/opac/skin/lul/xml/result/result_table.xml	2011-04-15 03:29:17 UTC (rev 1363)
@@ -84,7 +84,7 @@
                             </tr>
 
                             <tr name="local_callnumber_list" class="result_table_title_cell">
-                                <td>&result.localCallNumbers;
+                                <td>
                                 <!--
                                     we snag the record id from the 901 field, and then use it
                                     for lining up the resolver content



More information about the open-ils-commits mailing list