From 3d3080b54d75ac4418fbd368f91337a3b73896ce Mon Sep 17 00:00:00 2001 From: dbs Date: Fri, 15 Apr 2011 03:29:17 +0000 Subject: [PATCH] Bring search results into sync for the LU skin git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_2_0@1363 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- web/opac/skin/lul/js/result_common.js | 173 ++++++++++++++++++-------- web/opac/skin/lul/xml/result/result_table.xml | 2 +- 2 files changed, 119 insertions(+), 56 deletions(-) diff --git a/web/opac/skin/lul/js/result_common.js b/web/opac/skin/lul/js/result_common.js index af8812aae8..b2d727a66e 100644 --- a/web/opac/skin/lul/js/result_common.js +++ b/web/opac/skin/lul/js/result_common.js @@ -1,9 +1,17 @@ +dojo.require('openils.BibTemplate'); +dojo.requireLocalization("openils.opac", "opac"); +var opac_strings = dojo.i18n.getLocalization("openils.opac", "opac"); var recordsHandled = 0; var recordsCache = []; 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 @@ var externalSearchServices = [ "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 @@ function resultCollectSearchIds( type, method, handler ) { 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 @@ function resultCollectSearchIds( type, method, handler ) { _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 @@ function resultZeroHits() { 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 @@ function unhideGoogleBooksLink (data) { 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 @@ function resultDisplayRecord(rec, pos, is_mr) { } } + 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 @@ function resultDisplayRecord(rec, pos, is_mr) { 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 @@ function resultDisplayRecord(rec, pos, is_mr) { 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 @@ function resultDisplayRecord(rec, pos, is_mr) { 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 @@ function resultDisplayRecord(rec, pos, is_mr) { 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 @@ function resultDisplayRecord(rec, pos, is_mr) { 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 resultBuildFormatIcons( row, rec, is_mr ) { } function fetchGoogleBooksLink () { + if (allRecordsReceivedAndProcessed) { return; } + if (isbnList && googleBooksLink) { var scriptElement = document.createElement("script"); scriptElement.setAttribute("id", "jsonScript"); @@ -687,6 +732,12 @@ function fetchGoogleBooksLink () { } } +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 @@ function resultAddCopyCounts(rec, pagePosition) { 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 @@ function resultAddCopyCounts(rec, pagePosition) { 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 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) { } 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 (!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 (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(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(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' ); + } } } } @@ -839,3 +901,4 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) { } } + diff --git a/web/opac/skin/lul/xml/result/result_table.xml b/web/opac/skin/lul/xml/result/result_table.xml index 3709361543..9ef315dbe8 100644 --- a/web/opac/skin/lul/xml/result/result_table.xml +++ b/web/opac/skin/lul/xml/result/result_table.xml @@ -84,7 +84,7 @@ - &result.localCallNumbers; +