[open-ils-commits] r1345 - conifer/branches/rel_2_0/web/opac/skin/default/js (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Apr 13 12:02:42 EDT 2011
Author: dbs
Date: 2011-04-13 12:02:39 -0400 (Wed, 13 Apr 2011)
New Revision: 1345
Modified:
conifer/branches/rel_2_0/web/opac/skin/default/js/rdetail.js
conifer/branches/rel_2_0/web/opac/skin/default/js/result_common.js
Log:
Stab at 2.0 versions of rdetail.js and result_common.js
Modified: conifer/branches/rel_2_0/web/opac/skin/default/js/rdetail.js
===================================================================
--- conifer/branches/rel_2_0/web/opac/skin/default/js/rdetail.js 2011-04-13 15:06:40 UTC (rev 1344)
+++ conifer/branches/rel_2_0/web/opac/skin/default/js/rdetail.js 2011-04-13 16:02:39 UTC (rev 1345)
@@ -1,3 +1,4 @@
+
/* */
detachAllEvt('common', 'run');
@@ -12,7 +13,7 @@
var rdetailShowCopyLocation = true;
var rdetailGoogleBookPreview = true;
var rdetailDisplaySerialHoldings = true;
-var rdetailEnableRefWorks = false;
+var rdetailEnableRefWorks = true;
var rdetailRefWorksHost = 'http://refworks.scholarsportal.info';
var enableHoldsOnAvailable = false;
@@ -43,6 +44,9 @@
var rdetailStart = null;
var rdetailEnd = null;
+var mfhdDetails = [];
+var orgHiding = false;
+
/* serials are currently the only use of Dojo strings in the OPAC */
if (rdetailDisplaySerialHoldings) {
dojo.require("dijit.Menu");
@@ -124,17 +128,45 @@
if(getLocation() == globalOrgTree.id())
hideMe(G.ui.rdetail.cp_info_all);
- var req = new Request(FETCH_RMODS, getRid());
- req.callback(_rdetailDraw);
- req.send();
+ if(getRid()) {
- if (rdetailDisplaySerialHoldings) {
+ var req = new Request(FETCH_RMODS, getRid());
+ req.callback(_rdetailDraw);
+ req.send();
+
+ } else { // No record ID was specified
+
+ // If we have an ISBN in the URL, let's try to find that record
+ // This allows direct linking by ISBN.
+ // Note, this uses the first record it finds
+ if(getRtype() == RTYPE_ISBN) {
+ var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() );
+ req.callback(
+ function(r) {
+ var blob = r.getResultObject();
+ if(blob && blob.count > 0)
+ RID = blob.ids[0];
+ var req2 = new Request(FETCH_RMODS, getRid());
+ req2.callback(_rdetailDraw);
+ req2.send();
+ }
+ );
+ req.send();
+ }
+ }
+
+
+ if (rdetailDisplaySerialHoldings && (
+ isXUL() || !fetchOrgSettingDefault(
+ getLocation(), "opac.fully_compressed_serial_holdings")
+ )
+ ) {
var req = new Request(FETCH_MFHD_SUMMARY, getRid());
req.callback(_holdingsDraw);
req.send();
if (isXUL()) {
var here = findOrgUnit(getLocation());
- dojo.place("<div id='mfhd_ad_menu></div>", "rdetail_details_table", "after");
+ dojo.place("<div id='mfhd_ad_menu'></div>", "rdetail_details_table", "after");
var mfhd_add = new dijit.Menu({style:"float: right;"});
new dijit.MenuItem({onClick:function(){
var req = new Request(CREATE_MFHD_RECORD, G.user.session, 1, here.id(), getRid());
@@ -150,6 +182,9 @@
G.evt.result.recordReceived = [];
G.evt.result.copyCountsReceived = [];
G.evt.result.allRecordsReceived = [];
+
+ if(isXUL())
+ unHideMe($('rdetail_show_orders'));
}
function rdetailGetPageIds() {
@@ -211,11 +246,12 @@
dojo.require('openils.PermaCrud');
win.xulG = {
- "record": {"marc": rec.marc()},
+ "record": {"marc": rec.marc(), "rtype": "sre"},
"save": {
"label": opac_strings.SAVE_MFHD_LABEL,
"func": function(xmlString) {
rec.marc(xmlString);
+ rec.edit_date('now');
rec.ischanged(true);
pcrud.update(rec);
}
@@ -241,6 +277,10 @@
dojo.forEach(holdings, _holdingsDrawMFHD);
+ // Populate XUL menus
+ if (isXUL()) {
+ runEvt('rdetail','MFHDDrawn');
+ }
}
function _holdingsDrawMFHD(holdings, entryNum) {
@@ -254,19 +294,19 @@
}
}
- var hh = holdings.holdings();
- var hch = holdings.current_holdings();
- var hs = holdings.supplements();
- var hcs = holdings.current_supplements();
- var hi = holdings.indexes();
- var hci = holdings.current_indexes();
+ var hb = holdings.basic_holdings();
+ var hba = holdings.basic_holdings_add();
+ var hs = holdings.supplement_holdings();
+ var hsa = holdings.supplement_holdings_add();
+ var hi = holdings.index_holdings();
+ var hia = holdings.index_holdings_add();
var ho = holdings.online();
var hm = holdings.missing();
var hinc = holdings.incomplete();
var hloc = holdings.location() || 'MFHD';
- if ( hh.length == 0 && hch.length == 0 && hs.length == 0 &&
- hcs.length == 0 && hi.length == 0 && hci.length == 0 &&
+ if ( hb.length == 0 && hba.length == 0 && hs.length == 0 &&
+ hsa.length == 0 && hi.length == 0 && hia.length == 0 &&
ho.length == 0 && hm.length == 0 && hinc.length == 0
) {
@@ -276,41 +316,61 @@
* record is likely empty or corrupt. This gives cataloguers a
* chance to add holdings or correct the record
*/
- hh = 'PLACEHOLDER';
+ hb = ['PLACEHOLDER'];
} else {
return null;
}
}
- dojo.place("<table style='width: 100%;'><caption id='mfhdHoldingsCaption" + entryNum + "' class='rdetail_header color_1'>" +
- dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [hloc]) +
+ // Show entryNum + 1 in staff client for better menu correlation
+ // Maybe this should be holdings.sre_id() instead? (which could get long after time)
+ var entryNumString = '';
+ if (isXUL()) {
+ var entryNumInc = entryNum + 1;
+ entryNumString = ' [Entry #'+entryNumInc+'] ';
+ }
+
+ var refNode;
+ if (entryNum > 0) {
+ refNode = 'rdetail_holdings_table_' + (entryNum - 1);
+ } else {
+ refNode = 'rdetail_details_table';
+ }
+
+ dojo.place("<table style='width: 100%;' id='rdetail_holdings_table_"+entryNum+"'><caption id='mfhdHoldingsCaption" + entryNum + "' class='rdetail_header color_1'>" +
+ dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [hloc]) + entryNumString +
"</caption><tbody id='rdetail_holdings_tbody_" + entryNum +
- "'></tbody></table>", "rdetail_details_table", "after"
+ "'></tbody></table>", refNode, "after"
);
- if (hh.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.HOLDINGS, hh); }
- if (hch.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.CURRENT_HOLDINGS, hch); }
- if (hs.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENTS, hs); }
- if (hcs.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.CURRENT_SUPPLEMENTS, hcs); }
- if (hi.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEXES, hi); }
- if (hci.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.CURRENT_INDEXES, hci); }
+ if (hb.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.BASIC_HOLDINGS, hb); }
+ if (hba.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.BASIC_HOLDINGS_ADD, hba); }
+ if (hs.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENT_HOLDINGS, hs); }
+ if (hsa.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENT_HOLDINGS_ADD, hsa); }
+ if (hi.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEX_HOLDINGS, hi); }
+ if (hia.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEX_HOLDINGS_ADD, hia); }
if (ho.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.ONLINE_VOLUMES, ho); }
if (hm.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.MISSING_VOLUMES, hm); }
if (hinc.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INCOMPLETE_VOLUMES, hinc); }
if (isXUL()) {
+ mfhdDetails.push({ 'id' : holdings.sre_id(), 'label' : hloc, 'entryNum' : entryNum, 'owning_lib' : holdings.owning_lib() });
dojo.require('openils.Event');
dojo.require('openils.PermaCrud');
var mfhd_edit = new dijit.Menu({});
- new dijit.MenuItem({onClick: function(){loadMarcEditor(holdings.id())}, label:opac_strings.EDIT_MFHD_RECORD}).placeAt(mfhd_edit, "first");
+ new dijit.MenuItem({onClick: function(){loadMarcEditor(holdings.sre_id())}, label:opac_strings.EDIT_MFHD_RECORD}).placeAt(mfhd_edit, "first");
new dijit.MenuItem({onClick:function(){
+ // Avoid accidental deletion of MFHD records
+ if (!confirm(opac_strings.DELETE_MFHD_CONFIRM)) {
+ return;
+ }
var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
- var mfhd_rec = pcrud.retrieve("sre", holdings.id());
+ var mfhd_rec = pcrud.retrieve("sre", holdings.sre_id());
if (mfhd_rec) {
pcrud.eliminate(mfhd_rec);
- alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.id()]));
+ alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.sre_id()]));
}
}, label:opac_strings.DELETE_MFHD}).placeAt(mfhd_edit, "last");
- // new dijit.MenuItem({onClick:function(){alert("Edit properties " + holdings.id());}, label:opac_strings.EDIT_PROPERTIES}).placeAt(mfhd_edit, "last");
+ // new dijit.MenuItem({onClick:function(){alert("Edit properties " + holdings.sre_id());}, label:opac_strings.EDIT_PROPERTIES}).placeAt(mfhd_edit, "last");
var mfhd_mb = new dijit.form.DropDownButton({dropDown: mfhd_edit, label:opac_strings.EDIT_MFHD_MENU, style:"float:right"});
mfhd_mb.placeAt("mfhdHoldingsCaption" + entryNum, "last");
mfhd_edit.startup();
@@ -327,9 +387,13 @@
runEvt('rdetail', 'recordRetrieved', record.doc_id());
+ var currentISBN = cleanISBN(record.isbn());
+
G.ui.rdetail.title.appendChild(text(record.title()));
buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author);
- G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
+ if (currentISBN) {
+ G.ui.rdetail.isbn.appendChild(text(currentISBN));
+ }
G.ui.rdetail.edition.appendChild(text(record.edition()));
G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
G.ui.rdetail.publisher.appendChild(text(record.publisher()));
@@ -342,9 +406,9 @@
G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
if (enableHoldsOnAvailable) {
- unHideMe($('rdetail_place_hold'));
+ unHideMe($('rdetail_place_hold'));
} else {
- hideMe($('rdetail_place_hold'));
+ hideMe($('rdetail_place_hold'));
rdetailCheckAvailable();
}
@@ -352,7 +416,7 @@
if(record.isbn()) {
if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) {
unHideMe($('rdetail.jacket_attrib_div'));
- var href = $('rdetail.jacket_attrib_link').getAttribute('href') +cleanISBN(record.isbn());
+ var href = $('rdetail.jacket_attrib_link').getAttribute('href') +currentISBN;
$('rdetail.jacket_attrib_link').setAttribute('href', href);
}
rdetailCheckForGBPreview();
@@ -390,10 +454,7 @@
displayLabel = note;
}
}
- // IE in quirks mode doesn't render CSS styling for links where the class attribute
- // comes after the href attribute, apparently; we can use Dojo to ensure the class
- // attribute comes first
- dojo.place('<a class="search_link" href="' + href + '">' + displayLabel + '</a>', dojo.byId('rdetail_online'));
+ $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
if (note && note != displayLabel) {
$('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
}
@@ -404,7 +465,7 @@
// Fill in our unAPI ID, if anyone cares
var abbrs = document.getElementsByTagName('abbr');
var span;
- for (var i = 0; i < abbrs.length; i = i + 1) {
+ for (var i = 0; i < abbrs.length; i++) {
if (abbrs[i].getAttribute('name') == 'unapi') {
span = abbrs[i];
break;
@@ -436,34 +497,61 @@
unHideMe($('rdetail_exp_refworks_span'));
}
- $('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
- G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
- // Set extras before recordDrawn event to enable bookbags in barcode searches
- rdetailSetExtrasSelector();
-
+ if (currentISBN) {
+ $('rdetail_img_link').setAttribute('href', buildISBNSrc(currentISBN, 'large'));
+ G.ui.rdetail.image.setAttribute("src", buildISBNSrc(currentISBN));
+ }
runEvt("rdetail", "recordDrawn");
recordsCache.push(record);
+ rdetailSetExtrasSelector();
var breq = new Request(FETCH_BRE, [getRid()]);
breq.callback( rdetailCheckDeleted );
breq.send();
- resultBuildCaches( [ record ] );
- resultDrawSubjects();
- resultDrawSeries();
+ //resultBuildCaches( [ record ] );
+ //resultDrawSubjects();
+ //resultDrawSeries();
// grab added content
- acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
+
+
+ // Proxied through Evergreen AddedContent module
+ if (currentISBN) {
+ acCollectData(currentISBN, rdetailhandleAC);
+ }
+
+ // Not proxied, cross-site javascript
+
+ // ChiliFresh
+ if (chilifresh && chilifresh != '(none)' && currentISBN) {
+ $('chilifreshReviewLink').setAttribute('id','isbn_'+currentISBN);
+ $('chilifreshReviewResult').setAttribute('id','chili_review_'+currentISBN);
+ unHideMe($('rdetail_reviews_link'));
+ unHideMe($('rdetail_chilifresh_reviews'));
+ try {
+ chili_init();
+ } catch(E) {
+ console.log(E + '\n');
+ hideMe($('rdetail_reviews_link'));
+ hideMe($('rdetail_chilifresh_reviews'));
+ }
+ }
+
+ // Novelist
+ if (novelist && currentISBN) {
+ unHideMe($('rdetail_novelist_link'));
+ }
}
function rdetailCheckAvailable() {
- var loc = getLocation();
- var rid = getRid();
- var req = new Request( 'open-ils.search:open-ils.search.biblio.record.copy_count', loc, rid );
- req.callback(rdetailEnableHold);
- req.send();
+ var loc = getLocation();
+ var rid = getRid();
+ var req = new Request( 'open-ils.search:open-ils.search.biblio.record.copy_count', loc, rid );
+ req.callback(rdetailEnableHold);
+ req.send();
}
/*
@@ -472,15 +560,15 @@
* * none of those copies are available
*/
function rdetailEnableHold(r) {
- var ccDepths = r.getResultObject();
- if (
- ((ccDepths[(ccDepths.length - 1)].available) > 0) ||
- ((ccDepths[(ccDepths.length - 1)].count) == 0)
- ) {
- hideMe($('rdetail_place_hold'));
- } else {
- unHideMe($('rdetail_place_hold'));
- }
+ var ccDepths = r.getResultObject();
+ if (
+ ((ccDepths[(ccDepths.length - 1)].available) > 0) ||
+ ((ccDepths[(ccDepths.length - 1)].count) == 0)
+ ) {
+ hideMe($('rdetail_place_hold'));
+ } else {
+ unHideMe($('rdetail_place_hold'));
+ }
}
function rdetailCheckDeleted(r) {
@@ -510,7 +598,7 @@
var index = 3;
doSelectorActions(selector);
- for( var i = 0; i != containers.length; i++ ) {
+ for( var i = 0; i < containers.length; i++ ) {
found = true;
var container = containers[i];
insertSelectorVal( selector, index++, container.name(),
@@ -551,6 +639,7 @@
function rdetailShowExtra(type, args) {
hideMe($('rdetail_copy_info_div'));
+ hideMe($('rdetail_summary_div'));
hideMe($('rdetail_reviews_div'));
hideMe($('rdetail_toc_div'));
hideMe($('rdetail_anotes_div'));
@@ -559,10 +648,12 @@
hideMe($('rdetail_marc_div'));
hideMe($('cn_browse'));
hideMe($('rdetail_cn_browse_div'));
+ hideMe($('rdetail_novelist_div'));
hideMe($('rdetail_notes_div'));
removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
removeCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
+ removeCSSClass($('rdetail_summary_link'), 'rdetail_extras_selected');
removeCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
removeCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
removeCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
@@ -570,6 +661,7 @@
removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected');
removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
+ removeCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected');
switch(type) {
@@ -578,6 +670,11 @@
addCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
break;
+ case "summary":
+ addCSSClass($('rdetail_summary_link'), 'rdetail_extras_selected');
+ unHideMe($('rdetail_summary_div'));
+ break;
+
case "reviews":
addCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
unHideMe($('rdetail_reviews_div'));
@@ -615,6 +712,11 @@
req.send();
break;
+ case "novelist":
+ addCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected');
+ unHideMe($('rdetail_novelist_div'));
+ break;
+
case 'cn':
addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
unHideMe($('rdetail_cn_browse_div'));
@@ -644,7 +746,7 @@
return;
}
- for( var i in arr ) {
+ for( var i = 0; i < arr.length; i++ ) {
var cn = arr[i];
var opt = new Option(cn);
select.options[index++] = opt;
@@ -672,6 +774,7 @@
setSelector( $('cn_browse_selector'), cn );
hideMe($('rdetail_copy_info_div'));
hideMe($('rdetail_reviews_div'));
+ hideMe($('rdetail_summary_div'));
hideMe($('rdetail_toc_div'));
hideMe($('rdetail_marc_div'));
unHideMe($('rdetail_cn_browse_div'));
@@ -682,6 +785,11 @@
function rdetailhandleAC(data) {
+ if( data.summary.html ) {
+ $('rdetail_summary_div').innerHTML = data.summary.html;
+ unHideMe($('rdetail_summary_link'));
+ }
+
if( data.reviews.html ) {
$('rdetail_review_container').innerHTML = data.reviews.html;
unHideMe($('rdetail_reviews_link'));
@@ -710,7 +818,7 @@
var template = par.removeChild($('rdetail_review_template'));
if( res && res.length > 0 ) {
unHideMe($('rdetail_reviews_link'));
- for( var i = 0; i != res.length; i++ ) {
+ for( var i = 0; i < res.length; i++ ) {
var rev = res[i];
if( rev.text && rev.info ) {
var node = template.cloneNode(true);
@@ -753,12 +861,15 @@
if( node ) {
if( !orgIsMine(node, loc) && !orgIsMine(loc,node) ) return;
} else {
- for( var i = 0; i < globalOrgTree.children().length; i++ ) {
- var org = findOrgUnit(globalOrgTree.children()[i]);
- if( orgIsMine(org, loc) ) {
- node = org;
- break;
- }
+ var kids = globalOrgTree.children();
+ if (kids) {
+ for( var i = 0; i < kids.length; i++ ) {
+ var org = findOrgUnit(kids[i]);
+ if( orgIsMine(org, loc) ) {
+ node = org;
+ break;
+ }
+ }
}
}
}
@@ -773,6 +884,14 @@
if(!isXUL() && !isTrue(node.opac_visible())) return;
+ if (orgHiding) {
+ if (isTrue( findOrgType(node.ou_type()).can_have_vols() )) {
+ if ( ! orgIsMine( orgHiding.org, node, orgHiding.depth ) ) {
+ return;
+ }
+ }
+ }
+
var row = copyRow.cloneNode(true);
row.id = "cp_info_" + node.id();
@@ -801,8 +920,11 @@
} else { node = globalOrgTree; }
- for( var c in node.children() )
- _rdetailRows(node.children()[c]);
+ var kids = node.children();
+ if (kids) {
+ for( var c = 0; c < kids.length; c++ )
+ _rdetailRows(kids[c]);
+ }
}
function rdetailCNPrint(orgid, cn) {
@@ -822,6 +944,8 @@
removeChildren(copyRowParent);
+ orgHiding = checkOrgHiding();
+
_rdetailRows();
var summary = r.getResultObject();
@@ -1005,39 +1129,23 @@
}
/**
- * Check for a Google Book preview
+ * Check for a Google Book preview after the main page loads
*/
function rdetailCheckForGBPreview() {
if (!rdetailGoogleBookPreview) return;
- searchForGBPreview( cleanISBN(record.isbn()) );
+ dojo.addOnLoad(function() {
+ searchForGBPreview( cleanISBN(record.isbn()) );
+ });
}
/**
*
- * @param {DOM object} query The form element containing the
- * input parameters "isbns"
+ * @param {DOM object} isbn The form element containing the input parameters "isbns"
*/
function searchForGBPreview( isbn ) {
-
- // Delete any previous Google Booksearch JSON queries.
- var GBPJsonScript = document.getElementById("GBPJsonScript");
- if (GBPJsonScript) {
- GBPJsonScript.parentNode.removeChild(GBPJsonScript);
- }
-
- // Add a script element with the src as the user's Google Booksearch query.
- // JSON output is specified by including the alt=json-in-script argument
- // and the callback function is also specified as a URI argument.
- var GBPScriptElement = document.createElement("script");
-
- GBPScriptElement.setAttribute("id", "GBPJsonScript");
- GBPScriptElement.setAttribute("src",
- "http://books.google.com/books?bibkeys=" +
- isbn + "&jscmd=viewapi&callback=GBPreviewCallback");
- GBPScriptElement.setAttribute("type", "text/javascript");
-
- // make the request to Google booksearch
- document.documentElement.firstChild.appendChild(GBPScriptElement);
+ dojo.require("dojo.io.script");
+ dojo.io.script.get({"url": "https://www.google.com/jsapi"});
+ dojo.io.script.get({"url": "http://books.google.com/books", "content": { "bibkeys": isbn, "jscmd": "viewapi", "callback": "GBPreviewCallback"}});
}
/**
@@ -1046,7 +1154,7 @@
*
* XXX I18N of text needed
*
- * @param {JSON} booksInfo is the JSON object pulled from the Google books service.
+ * @param {JSON} GBPBookInfo is the JSON object pulled from the Google books service.
*/
function GBPreviewCallback(GBPBookInfo) {
var GBPreviewDiv = document.getElementById("rdetail_preview_div");
@@ -1061,11 +1169,6 @@
}
if ( GBPBook.preview != "noview" ) {
- if ( GBPBook.preview == 'full' ) {
- setText( $('rdetail_preview_link'), $('rdetail_preview_full_text').innerHTML );
- $('rdetail_preview_link_a').title = $('rdetail_preview_title').innerHTML;
- }
-
// Add a button below the book cover image to load the preview.
GBPBadge = document.createElement( 'img' );
GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif';
@@ -1104,3 +1207,81 @@
GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) );
}
+
+function rdetailDrawExpandedHoldings(anchor, bibid, type) {
+ var offsets = {"basic": 0, "index": 0, "supplement": 0};
+ var limit = 10; /* XXX give user control over this? */
+ var target_id = "holding_type_" + type;
+ var target = dojo.byId(target_id);
+
+ anchor.innerHTML = "[-]";
+ anchor.oldonclick = anchor.onclick;
+ anchor.onclick = function() {
+ anchor.onclick = anchor.oldonclick;
+ anchor.innerHTML = "[+]";
+ dojo.empty(target);
+ };
+
+ function _load() {
+ dojo.empty(target);
+ fieldmapper.standardRequest(
+ ["open-ils.serial",
+ "open-ils.serial.received_siss.retrieve.by_bib.atomic"], {
+ "params": [bibid, {"offset": offsets[type], "limit": limit}],
+ "async": true,
+ "oncomplete": function(r) {
+ try {
+ if (msg = r.recv().content()) { /* sic, assignment */
+ if (!msg.length) return;
+ offsets[type] += msg.length;
+ var table = dojo.create("table", null, target);
+ dojo.forEach(
+ msg, function(o) {
+ var tr = dojo.create("tr", null, table);
+ dojo.create(
+ "td", {
+ "innerHTML": o.issuance.label(),
+ "style": {"paddingLeft": "3em"}
+ }, tr
+ );
+
+ if (!o.has_units) return;
+ /* can't place holds if no units */
+ var td = dojo.create("td", null, tr);
+ dojo.create(
+ "a", {
+ "href":"javascript:void(0);",
+ "style": {"marginLeft": "1.5em"},
+ "onclick": function() {
+ holdsDrawEditor({
+ "type": "I",
+ "issuance": o.issuance.id()
+ });
+ },
+ "innerHTML": "[" +
+ opac_strings.PLACE_HOLD + "]"
+ }, td
+ );
+ }
+ );
+ if (msg.length == limit) {
+ dojo.create("br", null, target);
+ dojo.create(
+ "a", {
+ "href": "javascript:void(0);",
+ "innerHTML":
+ "[" + opac_strings.MORE + "]",
+ "onclick": _load
+ }, target
+ );
+ }
+ }
+ } catch (E) {
+ void(0);
+ }
+ }
+ }
+ );
+ }
+ _load();
+}
Modified: conifer/branches/rel_2_0/web/opac/skin/default/js/result_common.js
===================================================================
--- conifer/branches/rel_2_0/web/opac/skin/default/js/result_common.js 2011-04-13 15:06:40 UTC (rev 1344)
+++ conifer/branches/rel_2_0/web/opac/skin/default/js/result_common.js 2011-04-13 16:02:39 UTC (rev 1345)
@@ -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 = [];
@@ -7,7 +10,7 @@
var enableHoldsOnAvailable = false;
var enableExtraSearchesLowHits = false;
var localProxyPrefix = '';
-
+
/* an array of the extra services to which we want to direct people, in order of priority:
Properties:
url: will be proxied via localProxyPrefix
@@ -27,6 +30,7 @@
}
];
+
var resultFetchAllRecords = false;
var resultCompiledSearch = null;
@@ -35,9 +39,7 @@
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, fetchChiliFreshReviews);
attachEvt('result','lowHits',resultLowHits);
attachEvt('result','zeroHits',resultZeroHits);
@@ -103,6 +105,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 +119,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();
@@ -232,9 +242,9 @@
resultSuggestSearchClass();
- if (enableExtraSearchesLowHits) {
- resultSuggestExtraSearches();
- }
+ if (enableExtraSearchesLowHits) {
+ resultSuggestExtraSearches();
+ }
if(getTerm()) resultExpandSearch(); /* advanced search */
}
@@ -275,14 +285,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 +498,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 +519,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 +556,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 +570,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 +582,12 @@
pic.parentNode.setAttribute("href", buildOPACLink(args));
}
+ 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);
@@ -566,6 +603,7 @@
$n(r,'place_hold_link').setAttribute(
'href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"T"});');
+
}
buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
@@ -598,6 +636,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);
@@ -670,6 +727,12 @@
}
}
+function fetchChiliFreshReviews() {
+ if (chilifresh && chilifresh != '(none)') {
+ try { chili_init(); } catch(E) { console.log(E + '\n'); }
+ }
+}
+
function resultPageIsDone(pos) {
return (recordsHandled == getDisplayCount()
@@ -690,7 +753,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();
@@ -711,10 +784,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++ ) {
@@ -790,31 +863,34 @@
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' );
+ }
}
}
}
@@ -822,3 +898,4 @@
}
}
+
More information about the open-ils-commits
mailing list