[open-ils-commits] r645 - in conifer/trunk/web/opac/skin/uwin: css js (pzed)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Sep 4 11:04:22 EDT 2009
Author: pzed
Date: 2009-09-04 11:04:19 -0400 (Fri, 04 Sep 2009)
New Revision: 645
Removed:
conifer/trunk/web/opac/skin/uwin/css/colors.css
conifer/trunk/web/opac/skin/uwin/js/myopac.js.prod
conifer/trunk/web/opac/skin/uwin/js/rdetail.js.orig
Log:
removed some unnecessary files
Deleted: conifer/trunk/web/opac/skin/uwin/css/colors.css
===================================================================
--- conifer/trunk/web/opac/skin/uwin/css/colors.css 2009-09-04 15:00:19 UTC (rev 644)
+++ conifer/trunk/web/opac/skin/uwin/css/colors.css 2009-09-04 15:04:19 UTC (rev 645)
@@ -1,112 +0,0 @@
-/*
-not sure this will work, there is no id in the result
-but could be strange javascript combo weirdness
-- art, May 28, 2009
-*/
-.place_hold_span {hidden:true; display:none;}
-
-body a { color: black; text-decoration: none;}
-body a:visited { color: black; text-decoration: none;}
-body a:hover { color: red; text-decoration: underline;}
-
-
-/* the idea is to have 4 complimentary colors that
- * are used throughout the opac. Edit those colors
- * in this file
- */
-
-.color_1 { background: #B2BB1E; color: #000000; }
-.color_2 { background: #B2BB1E; color: #000000; }
-.color_3 { background: #EEE; color: #000000; }
-.color_4 { background: #E7E0D5; color: #000000; }
-
-.border_1 { border: 1px solid #005595; }
-.border_2 { border: 1px solid #B2BB1E; }
-.border_3 { border: 1px solid #EEE; }
-.border_4 { border: 1px solid #E7E0D5; }
-
-.border_1_2 { border: 2px solid #B2BB1E; }
-.border_2_2 { border: 2px solid #B2BB1E; }
-.border_3_2 { border: 2px solid #EEE; }
-.border_4_2 { border: 2px solid #E7E0D5; }
-
-.border_1_3 { border: 3px solid #B2BB1E; }
-.border_2_3 { border: 3px solid #B2BB1E; }
-.border_3_3 { border: 3px solid #EEE; }
-.border_4_3 { border: 3px solid #E7E0D5; }
-
-/* general purpose light borders */
-.border_5 { border: 1px solid #D0D0D0; }
-.border_6 { border: 1px solid #808080; }
-
-/*
-input:focus { background: #EEE; color: #000000;}
-a:focus { background: #E0F0E0; color: #000000;}
-*/
-
-/* ---------------------------------------------------------------------- */
-
-.canvas { /* main content div for each page */
- border-left: 3px solid #005595;
- border-bottom: 3px solid #005595;
- border-top: 3px solid #005595;
-}
-
-/* border around home search box */
-.home_search { border: 3px solid #005595; }
-
-/* main nav sidebar */
-.sidebar_item_active { background: #005595; color: #EEE; }
-.sidebar_item_active a { background: #005595; color: #EEE; }
-.sidebar_item_active a:hover { background: #005595; color: #EEE; text-decoration: none; }
-/* #advanced_link { background: #005595; color: #EEE; } */
-#sidebar_results_wrapper { border-right: 0; }
-
-/* record detail summary block */
-.rdetail_desc { border: 1px solid #CCC; }
-.rdetail_item { border: 1px solid #CCC; }
-.rdetails_extra_links { border: 1px solid #CCC; }
-.rdetail_extras_td { border: 1px solid #CCC; }
-.rdetail_extras_selected { background: #B2BB1E;}
-.rdetail_extras_selected a:hover { color: #FF0;}
-#rdetail_image_cell { border: 1px solid white; border-right: 1px solid #CCC;}
-
-
-.data_grid thead tr { background: #E7E0D5; color: #000000; }
-.data_grid thead td { border: 1px solid #CCC; }
-.data_grid tbody td { border: 1px solid #CCC; }
-.data_grid_nb thead tr { background: #CCC; color: #000000; }
-.data_grid_nb thead td { border: none; }
-.data_grid_nb tbody td { border: none; }
-.copy_count_cell { border-right: 1px solid #CCC; }
-.copy_count_div { border-left: 2px solid #CCC; border-right: 2px solid #CCC; }
-
-.light_border { border: 1px solid #CCC; }
-
-.adv_quick_search_submit { border-bottom: 3px solid #CCC;}
-
-.myopac_link_active { background: #E0F6E0; }
-
-.sidebar_extra_link { text-decoration: none; }
-#searchbar_tag_on { color: red; }
-.searchbar_item { color: black; }
-#login_box { border-top: 1px solid #808080; border-bottom: 1px solid #808080; }
-#next_prev_links_dead { color: #808080; text-decoration: none; }
-
-.nav_link_active {font-weight: bold;}
-
-.search_link { text-decoration: none; }
-.result_table_subtable { border-top: 1px solid #E0E0E0; }
-
-.x_mark { color: red; }
-.check_mark { color: green; }
-
-#myopac_holds_thaw_date_form { border: 1px solid #E0E0E0; }
-
-.invalid_field { border: 3px solid red; }
-
-#lib_selector_link:hover { color: #FF0; }
-#adv_global_search #lib_selector_link:hover { color: red; }
-#rdetail_place_hold:hover { color: #FF0; }
-#home_adv_search_link:hover { color: #FF0; }
-#home_myopac_link:hover { color: #FF0; }
Deleted: conifer/trunk/web/opac/skin/uwin/js/myopac.js.prod
===================================================================
--- conifer/trunk/web/opac/skin/uwin/js/myopac.js.prod 2009-09-04 15:00:19 UTC (rev 644)
+++ conifer/trunk/web/opac/skin/uwin/js/myopac.js.prod 2009-09-04 15:04:19 UTC (rev 645)
@@ -1,1632 +0,0 @@
-
-attachEvt("common", "run", myOPACInit );
-//attachEvt("common", "loggedIn", myOPACInit );
-attachEvt('common','locationUpdated', myopacReload );
-
-var fleshedUser = null;
-var fleshedContainers = {};
-var holdCache = {};
-var holdStatusCache = {};
-var allowPendingAddr = false;
-
-
-function clearNodes( node, keepArray ) {
- if(!node) return;
- for( var n in keepArray ) node.removeChild(keepArray[n]);
- removeChildren(node);
- for( var n in keepArray ) node.appendChild(keepArray[n]);
-}
-
-function myOPACInit() {
-
- if(!(G.user && G.user.session)) {
- initLogin();
-
- } else {
-
- allowPendingAddr = fetchOrgSettingDefault(G.user.home_ou(), 'opac.allow_pending_address');
- if(allowPendingAddr)
- unHideMe($('myopac_pending_addr_td'));
- myOPACChangePage( "summary" );
- }
-
- $('myopac_holds_thaw_date_input').onkeyup =
- function(){holdsVerifyThawDateUI('myopac_holds_thaw_date_input'); }
- $('myopac_holds_thaw_date_input').onchange =
- function(){holdsVerifyThawDateUI('myopac_holds_thaw_date_input'); }
-
-}
-
-function myopacReload() {
- //swapCanvas($('myopac_reloading'));
- var a = {};
- a[PARAM_LOCATION] = getNewSearchLocation();
- a[PARAM_DEPTH] = getNewSearchDepth();
- hideMe($('canvas_main'));
- goTo(buildOPACLink(a, true));
-}
-
-
-function myOPACChangePage( page ) {
- showCanvas();
-
- var s = $("myopac_summary_td");
- var c = $("myopac_checked_td");
- var f = $("myopac_fines_td");
- var h = $("myopac_holds_td");
- var p = $("myopac_prefs_td");
- var b = $('myopac_bookbag_td');
-
- var ss = $("myopac_summary_div");
- var cc = $("myopac_checked_div");
- var ff = $("myopac_fines_div");
- var hh = $("myopac_holds_div");
- var pp = $("myopac_prefs_div");
- var bb = $('myopac_bookbag_div');
-
- var cls = "myopac_link";
- var acls = "myopac_link_active";
-
- hideMe(ss);
- hideMe(cc); hideMe(ff);
- hideMe(hh); hideMe(pp);
- hideMe(bb);
-
- removeCSSClass(s, acls );
- removeCSSClass(c, acls );
- removeCSSClass(f, acls );
- removeCSSClass(h, acls );
- removeCSSClass(p, acls );
- removeCSSClass(b, acls );
-
- switch( page ) {
-
- case "summary":
- unHideMe(ss);
- addCSSClass(s, acls );
- myOPACShowSummary();
- break;
-
- case "checked":
- unHideMe(cc);
- addCSSClass(c, acls );
- myOPACShowChecked();
- break;
-
- case "holds":
- unHideMe(hh);
- addCSSClass(h, acls );
- myOPACShowHolds();
- break;
-
- case "fines":
- unHideMe(ff);
- addCSSClass(f, acls );
- myOPACShowFines();
- break;
-
- case "prefs":
- unHideMe(pp);
- addCSSClass(p, acls );
- myOPACShowPrefs();
- break;
-
- case 'bookbag':
- unHideMe(bb);
- addCSSClass(b, acls);
- myOPACShowBookbags();
- break;
- }
-}
-
-function myOPACShowChecked() {
- if(checkedDrawn) return;
- var req = new Request(FETCH_CHECKED_OUT_SUM, G.user.session, G.user.id());
- req.callback(myOPACDrawCheckedOutSlim);
- req.send();
-
- var nreq = new Request(FETCH_NON_CAT_CIRCS, G.user.session);
- nreq.callback(myOPACDrawNonCatCircs);
- nreq.send();
-}
-
-
-var checkedRowTemplate;
-var circsCache = new Array();
-var checkedDrawn = false;
-
-function moClearCheckedTable() {
- var tbody = $("myopac_checked_tbody");
- var loading = $("myopac_checked_loading");
- var none = $("myopac_checked_none");
- clearNodes( tbody, [ loading, none ] );
-}
-
-var __can_renew_one = false;
-
-function myOPACDrawCheckedOutSlim(r) {
-
- var checked = r.getResultObject();
- var tbody = $("myopac_checked_tbody");
- var loading = $("myopac_checked_loading");
- var none = $("myopac_checked_none");
-
- __can_renew_one = false;
-
- if(checkedDrawn) return;
- checkedDrawn = true;
- if(!checkedRowTemplate)
- checkedRowTemplate = tbody.removeChild($("myopac_checked_row"));
-
- moClearCheckedTable();
-
- hideMe(loading); /* remove all children and start over */
- if(!(checked && (checked.out || checked.overdue))) {
- unHideMe(none);
- return;
- }
-
- for( var i = 0; i < checked.overdue.length; i++ ) {
- var req = new Request(FETCH_CIRC_BY_ID, G.user.session, checked.overdue[i]);
- req.request.tbody = tbody;
- req.request.od = true;
- req.callback(myOPACDrawCheckedItem);
- req.send();
- }
-
-
- for( var i = 0; i < checked.out.length; i++ ) {
- var req = new Request(FETCH_CIRC_BY_ID, G.user.session, checked.out[i]);
- req.request.tbody = tbody;
- req.callback(myOPACDrawCheckedItem);
- req.send();
- }
-
- appendClear($('mo_items_out_count'),
- text(new String( parseInt(checked.overdue.length) + parseInt(checked.out.length) )) );
-
- if( checked.overdue.length > 0 ) {
- addCSSClass($('mo_items_overdue_count'), 'overdue');
- appendClear($('mo_items_overdue_count'),
- text(new String( parseInt(checked.overdue.length) )) );
- }
-
-}
-
-
-function myOPACDrawCheckedItem(r) {
-
- var circ = r.getResultObject();
- var tbody = r.tbody;
- var row = checkedRowTemplate.cloneNode(true);
- row.id = 'myopac_checked_row_ ' + circ.id();
- row.setAttribute('circid', circ.id());
-
- var due = _trimTime(circ.due_date());
-
- var dlink = $n( row, "myopac_checked_due" );
- var rlink = $n( row, "myopac_checked_renewals" );
- //var rnlink = $n( row, "myopac_checked_renew_link" );
-
- //if( r.od ) due = elem('b', {style:'color:red;font-size:110%'},due);
- if( r.od ) {
- due = elem('b', null, due);
- addCSSClass(due, 'overdue');
- } else {
- due = text(due);
- }
-
- dlink.appendChild(due);
- rlink.appendChild(text(circ.renewal_remaining()));
- unHideMe(row);
- //rnlink.setAttribute('href', 'javascript:myOPACRenewCirc("'+circ.id()+'");');
- circsCache.push(circ);
-
- if( circ.renewal_remaining() < 1 ) {
- $n(row, 'selectme').disabled = true;
- if(!__can_renew_one)
- $('mo_renew_button').disabled = true;
- } else {
- __can_renew_one = true;
- $('mo_renew_button').disabled = false;
- $n(row, 'selectme').disabled = false;
- }
-
- tbody.appendChild(row);
-
- var req = new Request(FETCH_MODS_FROM_COPY, circ.target_copy() );
- req.request.alertEvent = false;
- req.request.circ = circ.id();
- req.request.copy = circ.target_copy();
- req.callback(myOPACDrawCheckedTitle);
- req.send();
-}
-
-var __circ_titles = {};
-
-function myOPACDrawCheckedTitle(r) {
- var record = r.getResultObject();
- var circid = r.circ;
-
- if(!record || checkILSEvent(record)) {
- var req = new Request( FETCH_COPY, r.copy );
- req.request.circ = circid
- req.callback(myOPACDrawNonCatalogedItem);
- req.send();
- return;
- }
-
- var row = $('myopac_checked_row_ ' + circid);
- var tlink = $n( row, "myopac_checked_title_link" );
- var alink = $n( row, "myopac_checked_author_link" );
- buildTitleDetailLink(record, tlink);
- buildSearchLink(STYPE_AUTHOR, record.author(), alink);
- __circ_titles[circid] = record.title();
-}
-
-function myOPACDrawNonCatalogedItem(r) {
- var copy = r.getResultObject();
- var circid = r.circ;
-
- var row = $('myopac_checked_row_ ' + circid);
- var tlink = $n( row, "myopac_checked_title_link" );
- var alink = $n( row, "myopac_checked_author_link" );
-
- tlink.parentNode.appendChild(text(copy.dummy_title()));
- alink.parentNode.appendChild(text(copy.dummy_author()));
- __circ_titles[circid] = copy.dummy_title();
-}
-
-
-/*
-function myOPACRenewCirc(circid) {
-
- var circ;
- for( var i = 0; i != circsCache.length; i++ )
- if(circsCache[i].id() == circid)
- circ = circsCache[i];
-
- if(!confirm($('myopac_renew_confirm').innerHTML)) return;
-
- var req = new Request(RENEW_CIRC, G.user.session,
- { patron : G.user.id(), copyid : circ.target_copy(), opac_renewal : 1 } );
- req.request.alertEvent = false;
- req.send(true);
- var res = req.result();
-
- if(checkILSEvent(res) || checkILSEvent(res[0])) {
- alertId('myopac_renew_fail');
- return;
- }
-
- alert($('myopac_renew_success').innerHTML);
- checkedDrawn = false;
- myOPACShowChecked();
-}
-*/
-
-
-
-function myOPACShowHolds() {
- var req = new Request(FETCH_HOLDS, G.user.session, G.user.id());
- req.callback(myOPACDrawHolds);
- req.send();
- $('myopac_holds_actions_none').selected = true;
-}
-
-var holdsTemplateRowOrig;
-var holdsTemplateRow;
-var myopacForceHoldsRedraw = false;
-function myOPACDrawHolds(r) {
-
- var tbody = $("myopac_holds_tbody");
- if(holdsTemplateRow && !myopacForceHoldsRedraw) return;
- myopacForceHoldsRedraw = false;
-
- if(holdsTemplateRowOrig) {
- holdsTemplateRow = holdsTemplateRowOrig;
- removeChildren(tbody);
- } else {
- holdsTemplateRow = tbody.removeChild($("myopac_holds_row"));
- holdsTemplateRowOrig = holdsTemplateRow;
- }
-
- hideMe($('myopac_holds_loading'));
-
- var holds = r.getResultObject();
-
- if(!holds || holds.length < 1) unHideMe($('myopac_holds_none'));
- for( var i = 0; i != holds.length; i++ ) {
-
- var h = holds[i];
- holdCache[h.id()] = h;
-
- var row = holdsTemplateRow.cloneNode(true);
- row.id = "myopac_holds_row_" + h.id();
-
- var form = $n(row, "myopac_holds_formats");
- form.id = "myopac_holds_form_" + h.id();
-
- var orglink = $n(row, "myopac_holds_location");
- orglink.appendChild(text(findOrgUnit(h.pickup_lib()).name()));
-
- tbody.appendChild(row);
-
- $n(row,'myopac_holds_edit_link').setAttribute(
- 'href','javascript:myOPACEditHold("'+ h.id()+'");');
-
- if(isTrue(h.frozen())) {
- hideMe($n(row, 'myopac_hold_unfrozen_true'))
- unHideMe($n(row, 'myopac_hold_unfrozen_false'))
- if(h.thaw_date()) {
- var d = dojo.date.stamp.fromISOString(h.thaw_date());
- $n(row, 'myopac_holds_frozen_until').appendChild(text(dojo.date.locale.format(d, {selector: 'date', fullYear: true})));
- }
- } else {
- unHideMe($n(row, 'myopac_hold_unfrozen_true'))
- hideMe($n(row, 'myopac_hold_unfrozen_false'))
- }
-
- $n(row, 'myopac_holds_selected_chkbx').checked = false;
-
- var exp_date;
- if(h.expire_time()) {
- exp_date = dojo.date.stamp.fromISOString(h.expire_time());
- $n(row, 'myopac_hold_expire_time').appendChild(
- text(dojo.date.locale.format(exp_date, {selector:'date'})));
- }
-
- unHideMe(row);
-
- var interval = fetchOrgSettingDefault(G.user.home_ou(), 'circ.hold_expire_alert_interval');
- if(interval && exp_date) {
- secs = interval_to_seconds(interval) * 1000;
- var diff = exp_date.getTime() - new Date().getTime();
- if(diff < secs)
- addCSSClass($n(row, 'myopac_hold_expire_time'), 'hold_expire_warning');
- }
-
- myOPACDrawHoldTitle(h);
- myOPACDrawHoldStatus(h);
- }
-}
-
-function myOPACEditHold(holdid) {
- var hold = holdCache[holdid];
-
- holdsDrawEditor(
- {
- editHold : hold,
- onComplete : function(){
- holdsTemplateRow = null;
- myOPACShowHolds();
- }
- }
- );
-}
-
-
-function myOPACDrawHoldStatus(hold) {
- var req = new Request(FETCH_HOLD_STATUS, G.user.session, hold.id() );
- req.callback(myOShowHoldStatus);
- req.request.hold = hold;
- req.send();
-}
-
-var myopacShowHoldEstimate = false;
-function myOShowHoldStatus(r) {
-
- var hold = r.hold;
- var qstats = r.getResultObject();
- holdStatusCache[hold.id()] = qstats;
-
- var row = $("myopac_holds_row_" + r.hold.id());
-
- if(qstats.estimated_wait || myopacShowHoldEstimate) {
- myopacShowHoldEstimate = true;
- if(qstats.estimated_wait)
- $n(row, 'myopac_holds_estimated_wait').appendChild(text(qstats.estimated_wait));
- unHideMe($('myopac_holds_estimated_wait_column'));
- unHideMe($n(row, 'myopac_holds_estimated_wait'));
- }
-
- if( qstats.status == 4 ) {
- unHideMe($n(row, 'hold_status_available'));
- hideMe($n(row, 'myopac_holds_cancel_link'));
- }
-
- if(false) {
- var node = $n(row, 'hold_qstats');
- // XXX best way to display this info + dojo i18n
- node.appendChild(text('hold #' + qstats.queue_position+' of '+qstats.queue_position+' and '+qstats.potential_copies+' item(s)'));
- unHideMe(node);
-
- } else {
- if( qstats.status < 3 )
- unHideMe($n(row, 'hold_status_waiting'));
-
- if( qstats.status == 3 )
- unHideMe($n(row, 'hold_status_transit'));
- }
-}
-
-
-function myOPACDrawHoldTitle(hold) {
- var method;
-
- if( hold.hold_type() == 'T' || hold.hold_type() == 'M' ) {
- if(hold.hold_type() == "M") method = FETCH_MRMODS;
- if(hold.hold_type() == "T") method = FETCH_RMODS;
- var req = new Request(method, hold.target());
- req.callback(myOPACFleshHoldTitle);
- req.request.hold = hold;
- req.request.alertEvent = false;
- req.send();
-
- } else {
- holdFetchObjects(hold,
- function(a) { _myOPACFleshHoldTitle(hold, a);});
- }
-}
-
-function myOPACFleshHoldTitle(r) {
- var rec = r.getResultObject();
- _myOPACFleshHoldTitle(r.hold, {recordObject: rec});
-}
-
-function _myOPACFleshHoldTitle(hold, holdObjects) {
-
- var record = holdObjects.recordObject;
- var volume = holdObjects.volumeObject;
- var copy = holdObjects.copyObject;
-
- var row = $("myopac_holds_row_" + hold.id());
- var title_link = $n(row, "myopac_holds_title_link");
- var author_link = $n(row, "myopac_holds_author_link");
-
- if(!record || checkILSEvent(record) ) {
- addCSSClass(row, 'invalid_hold');
- $n(row, 'myopac_holds_edit_link').setAttribute('href', 'javascript:void(0);');
- $n(row, 'myopac_holds_edit_link').onclick = function(){alertId('invalid_hold');};
- return;
- }
-
- buildTitleDetailLink(record, title_link);
- buildSearchLink(STYPE_AUTHOR, record.author(), author_link);
-
- if( volume ) {
- $n(row, 'volume').appendChild(text(volume.label()));
- unHideMe($n(row, 'vol_copy'));
- if(copy) $n(row, 'copy').appendChild(text(copy.barcode()));
- }
-
- var form = $("myopac_holds_form_" + hold.id());
-
- if(form) {
- var mods_formats = record.types_of_resource();
-
- if( hold.hold_type() == 'M' ) {
- var data = holdsParseMRFormats(hold.holdable_formats());
- mods_formats = data.mods_formats;
- }
-
- for( var i = 0; i < mods_formats.length; i++ ) {
- var img = elem("img");
- setResourcePic(img, mods_formats[i]);
- form.appendChild(img);
- }
- }
-}
-
-var finesShown = false;
-function myOPACShowFines() {
- if(finesShown) return; finesShown = true;
- var req = new Request(FETCH_FINES_SUMMARY, G.user.session, G.user.id() );
- req.callback(_myOPACShowFines);
- req.send();
-}
-
-function _myOPACShowFines(r) {
- hideMe($('myopac_fines_summary_loading'));
- unHideMe($('myopac_fines_summary_row'));
-
- var summary = r.getResultObject();
- var total = "0.00"; /* localization? */
- var paid = "0.00";
- var balance = "0.00";
- if( instanceOf(summary,mous) ) {
-
- total = _finesFormatNumber(summary.total_owed());
- paid = _finesFormatNumber(summary.total_paid());
- balance = _finesFormatNumber(summary.balance_owed());
-
- var req = new Request(FETCH_TRANSACTIONS, G.user.session, G.user.id() );
- req.callback(myOPACShowTransactions);
- req.send();
- }
-
- $('myopac_fines_summary_total').appendChild(text(total));
- $('myopac_fines_summary_paid').appendChild(text(paid));
- $('myopac_fines_summary_balance').appendChild(text(balance));
-}
-
-function _finesFormatNumber(num) {
- if(isNull(num)) num = 0;
- num = num + "";
- if(num.length < 2 || !num.match(/\./)) num += ".00";
- if(num.match(/\./) && num.charAt(num.length-2) == '.') num += "0";
- return num;
-}
-
-//function _trimTime(time) { if(!time) return ""; return time.replace(/\ .*/,""); }
-function _trimTime(time) {
- if(!time) return "";
- var d = dojo.date.stamp.fromISOString(time);
- if(!d) return ""; /* date parse failed */
- return d.iso8601Format('YMD');
-}
-
-function _trimSeconds(time) {
- if(!time) return "";
- var d = dojo.date.stamp.fromISOString(time);
- if(!d) return ""; /* date parse failed */
- return d.iso8601Format('YMDHM',null,true,true);
-}
-
-function myOPACShowTransactions(r) {
-
- if(myopacGenericTransTemplate || myopacCircTransTemplate) return;
-
- var transactions = r.getResultObject();
-
- for( var idx in transactions ) {
-
- var trans = transactions[idx].transaction;
- var record = transactions[idx].record;
- var circ = transactions[idx].circ;
-
- if(trans.xact_type() == 'circulation')
- myOPACShowCircTransaction(trans, record, circ);
-
- else if(trans.xact_type() == 'grocery' )
- myopacShowGenericTransaction( trans );
- }
-}
-
-var myopacGenericTransTemplate;
-function myopacShowGenericTransaction( trans ) {
- var tbody = $('myopac_trans_tbody');
-
- if(!myopacGenericTransTemplate) {
- myopacGenericTransTemplate =
- tbody.removeChild($('myopac_trans_row'));
- removeChildren(tbody);
- }
-
- var row = myopacGenericTransTemplate.cloneNode(true);
-
- $n(row,'myopac_trans_start').appendChild(
- text(_trimSeconds(trans.xact_start())));
-
- $n(row,'myopac_trans_last_payment').appendChild(
- text(_trimSeconds(trans.last_payment_ts())));
-
- $n(row,'myopac_trans_init_amount').appendChild(
- text(_finesFormatNumber(trans.total_owed())));
-
- $n(row,'myopac_trans_total_paid').appendChild(
- text(_finesFormatNumber(trans.total_paid())));
-
- $n(row,'myopac_trans_balance').appendChild(
- text(_finesFormatNumber(trans.balance_owed())));
-
- var req = new Request(FETCH_MONEY_BILLING, G.user.session, trans.id());
- req.send(true);
- var bills = req.result();
- if(bills && bills[0])
- $n(row,'myopac_trans_bill_type').appendChild(
- text(bills[0].billing_type()));
-
- tbody.appendChild(row);
- unHideMe($('myopac_trans_div'));
-}
-
-
-
-/* draws a circulation transaction summary */
-var myopacCircTransTemplate;
-function myOPACShowCircTransaction(trans, record, circ) {
- var tbody = $('myopac_circ_trans_tbody');
-
- if(!myopacCircTransTemplate) {
- myopacCircTransTemplate = tbody.removeChild($('myopac_circ_trans_row'));
- removeChildren(tbody);
- }
-
- var row = myopacCircTransTemplate.cloneNode(true);
-
- if(record) {
- buildTitleDetailLink(record, $n(row,'myopac_circ_trans_title'));
-
- $n(row,'myopac_circ_trans_author').appendChild(text(
- normalize(truncate(record.author(), 65))));
-
- } else {
-
- var req = new Request( FETCH_COPY, circ.target_copy() );
- req.alertEvents = false;
- req.send(true);
- var copy = req.result();
- if( copy ) {
- $n(row,'myopac_circ_trans_title').appendChild(text(copy.dummy_title()));
- $n(row,'myopac_circ_trans_author').appendChild(text(copy.dummy_author()));
- }
- }
-
-
- $n(row,'myopac_circ_trans_start').
- appendChild(text(_trimTime(trans.xact_start())));
-
- var due = _trimTime(circ.due_date());
- var checkin = _trimTime(circ.stop_fines_time());
-
- $n(row,'myopac_circ_trans_due').appendChild(text(due))
- if(checkin)
- appendClear($n(row,'myopac_circ_trans_finished'), text(checkin));
- if(circ.stop_fines() == 'LOST')
- appendClear($n(row,'myopac_circ_trans_finished'), text(circ.stop_fines()));
- if(circ.stop_fines() == 'CLAIMSRETURNED')
- appendClear($n(row,'myopac_circ_trans_finished'), text(""));
-
-
- $n(row,'myopac_circ_trans_balance').
- appendChild(text(_finesFormatNumber(trans.balance_owed())));
-
- tbody.appendChild(row);
- unHideMe($('myopac_circ_trans_div'));
-}
-
-
-function myOPACSavePrefs() {
- G.user.prefs[PREF_HITS_PER] = getSelectorVal($('prefs_hits_per'));
- G.user.prefs[PREF_DEF_FONT] = getSelectorVal($('prefs_def_font'));
- G.user.prefs[PREF_HOLD_NOTIFY] = getSelectorVal($('prefs_hold_notify'));
- G.user.prefs[PREF_DEF_DEPTH] = getSelectorVal($('prefs_def_range'));
-
- if( $('myopac_pref_home_lib').checked == true )
- G.user.prefs[PREF_DEF_LOCATION] = null;
- else
- G.user.prefs[PREF_DEF_LOCATION] = getSelectorVal($('prefs_def_location'));
-
- if(commitUserPrefs())
- alert($('prefs_update_success').innerHTML);
- else alert($('prefs_update_failure').innerHTML);
-}
-
-
-function myOPACShowDefFont() {
- var font;
- if(G.user.prefs[PREF_DEF_FONT])
- font = G.user.prefs[PREF_DEF_FONT];
- else font = "regular";
- setSelector($('prefs_def_font'), font);
-}
-
-function myOPACShowHoldNotify() {
- var pref = G.user.prefs[PREF_HOLD_NOTIFY];
-
- if(pref) {
- if(pref.match(/email/i) && pref.match(/phone/i)) {
- setSelector($('prefs_hold_notify'), 'phone:email');
- } else if( pref.match(/email/i) ) {
- setSelector($('prefs_hold_notify'), 'email');
- } else if( pref.match(/phone/i) ) {
- setSelector($('prefs_hold_notify'), 'phone');
- }
-
- } else {
- setSelector($('prefs_hold_notify'), 'phone:email');
- }
-}
-
-function myOPACShowPrefs() {
- grabUserPrefs();
- myOPACShowHitsPer();
- myOPACShowDefFont();
- myOPACShowHoldNotify();
- myOPACShowDefLocation();
- hideMe($('myopac_prefs_loading'));
-}
-
-var defSearchLocationDrawn = false;
-var defDepthIndex = 0;
-function myOPACShowDefLocation() {
-
- var selector = $('prefs_def_location');
- var rsel = $('prefs_def_range');
-
- if(!defSearchLocationDrawn) {
-
- defSearchLocationDrawn = true;
-
- var org = G.user.prefs[PREF_DEF_LOCATION];
-
- if(!org) {
- $('myopac_pref_home_lib').checked = true;
- $('prefs_def_location').disabled = true;
- org = G.user.home_ou();
- }
-
- buildOrgSel(selector, globalOrgTree, 0);
-
- globalOrgTypes = globalOrgTypes.sort(
- function(a, b) {
- if( a.depth() < b.depth() ) return -1;
- return 1;
- }
- );
-
- iterate(globalOrgTypes,
- function(t) {
- if( t.depth() <= findOrgDepth(org) ) {
- setSelectorVal(rsel, defDepthIndex++, t.opac_label(), t.depth());
- if( t.depth() == findOrgDepth(org) )
- setSelector(rsel, t.depth());
- }
- }
- );
- }
-
- setSelector(selector, org);
-}
-
-function myOPACShowHitsPer() {
- var hits = 10;
- if(G.user.prefs[PREF_HITS_PER])
- hits = G.user.prefs[PREF_HITS_PER];
- var hitsSel = $('prefs_hits_per');
- setSelector(hitsSel, hits);
-}
-
-var userShown = false;
-function myOPACShowSummary() {
- if(userShown) return; userShown = true;
- var req = new Request(FETCH_FLESHED_USER,G.user.session, G.user.id());
- req.callback(_myOPACSummaryShowUer);
- req.send();
-}
-
-var addrRowTemplate;
-var notesTemplate;
-function _myOPACSummaryShowUer(r) {
-
- var user = r.getResultObject();
- fleshedUser = user;
- if(!user) return;
-
- var expireDate = dojo.date.stamp.fromISOString(user.expire_date());
- if( expireDate < new Date() ) {
- appendClear($('myopac.expired.date'), expireDate.iso8601Format('YMD'));
- unHideMe($('myopac.expired.alert'));
- }
-
- var iv1 = user.ident_value()+'';
- if (iv1.length > 4 && iv1.match(/\d{4}/)) iv1 = iv1.substring(0,4) + '***********';
-
-
- appendClear($('myopac_summary_prefix'),text(user.prefix()));
- appendClear($('myopac_summary_first'),text(user.first_given_name()));
- appendClear($('myopac_summary_middle'),text(user.second_given_name()));
- appendClear($('myopac_summary_dayphone'),text(user.day_phone()));
- appendClear($('myopac_summary_eveningphone'),text(user.evening_phone()));
- appendClear($('myopac_summary_otherphone'),text(user.other_phone()));
- appendClear($('myopac_summary_last'),text(user.family_name()));
- appendClear($('myopac_summary_suffix'),text(user.suffix()));
- appendClear($('myopac_summary_username'),text(user.usrname()));
- appendClear($('myopac_summary_email'),text(user.email()));
- appendClear($('myopac_summary_barcode'),text(user.card().barcode()));
- appendClear($('myopac_summary_ident1'),text(iv1));
- appendClear($('myopac_summary_homelib'),text(findOrgUnit(user.home_ou()).name()));
- appendClear($('myopac_summary_create_date'),text(_trimTime(user.create_date())));
-
- var req = new Request(
- FETCH_USER_NOTES, G.user.session, {pub:1, patronid:G.user.id()});
- req.callback(myopacDrawNotes);
- req.send();
-
-
- var tbody = $('myopac_addr_tbody');
- var template;
-
- if(addrRowTemplate) {
- template = addrRowTemplate;
- } else {
- template = tbody.removeChild($('myopac_addr_row'));
- addrRowTemplate = template;
- }
- removeChildren(tbody);
-
- var addrs = user.addresses();
- for( var a in addrs ) {
- var addr = addrs[a];
- if(!allowPendingAddr && isTrue(addr.pending()))
- continue;
- if(addr.replaces() != null) continue;
- var row = template.cloneNode(true);
- myOPACDrawAddr(row, addr, addrs);
- tbody.appendChild(row);
- }
-}
-
-
-function myopacDrawNotes(r) {
- var notes = r.getResultObject();
- var tbody = $('myopac.notes.tbody');
- if(!notesTemplate)
- notesTemplate = tbody.removeChild($('myopac.notes.tr'));
- removeChildren(tbody);
-
- iterate(notes,
- function(note) {
- unHideMe($('myopac.notes.div'));
- var row = notesTemplate.cloneNode(true);
- $n(row, 'title').appendChild(text(note.title()));
- $n(row, 'value').appendChild(text(note.value()));
- tbody.appendChild(row);
- }
- );
-}
-
-
-
-function myOPACDrawAddr(row, addr, addrs) {
- appendClear($n(row, 'myopac_addr_type'),text(addr.address_type()));
- appendClear($n(row, 'myopac_addr_street'),text(addr.street1()));
- appendClear($n(row, 'myopac_addr_street2'),text(addr.street2()));
- appendClear($n(row, 'myopac_addr_city'),text(addr.city()));
- appendClear($n(row, 'myopac_addr_county'),text(addr.county()));
- appendClear($n(row, 'myopac_addr_state'),text(addr.state()));
- appendClear($n(row, 'myopac_addr_country'),text(addr.country()));
- appendClear($n(row, 'myopac_addr_zip'),text(addr.post_code()));
-
- if(!allowPendingAddr) return;
-
- $n(row, 'myopac_addr_edit_link').onclick = function(){myopacEditAddress(addr)};
- unHideMe($n(row, 'myopac_addr_edit_td'));
-
- /* if we have a replacement address, plop it into the table next to this addr */
- var repl = grep(addrs,
- function(a) {
- return a.replaces() == addr.id();
- }
- );
-
- $n(row, 'myopac_pending_addr_td').id = 'myopac_pending_addr_td_' + addr.id();
-
- if(repl) {
- hideMe($n(row, 'myopac_addr_edit_td')); // hide the edit link
- repl = repl[0];
- myopacSetAddrInputs(row, repl);
- }
-}
-
-function myopacEditAddress(addr) {
- var td = $('myopac_pending_addr_td_' + addr.id());
- var row = td.parentNode;
- myopacSetAddrInputs(row, addr);
-}
-
-function myopacSetAddrInputs(row, addr, prefix) {
- unHideMe($n(row, 'myopac_pending_addr_td'));
- $n(row, 'myopac_pending_addr_type').value = addr.address_type();
- $n(row, 'myopac_pending_addr_street').value = addr.street1();
- $n(row, 'myopac_pending_addr_street2').value = addr.street2();
- $n(row, 'myopac_pending_addr_city').value = addr.city();
- $n(row, 'myopac_pending_addr_county').value = addr.county();
- $n(row, 'myopac_pending_addr_state').value = addr.state();
- $n(row, 'myopac_pending_addr_country').value = addr.country();
- $n(row, 'myopac_pending_addr_zip').value = addr.post_code();
- $n(row, 'myopac_pending_addr_edit_link').onclick = function(){myopacSaveAddress(row, addr)};
- $n(row, 'myopac_pending_addr_del_link').onclick = function(){myopacSaveAddress(row, addr, true)};
-}
-
-// if no pending addr exists, this is called with the original address
-function myopacSaveAddress(row, addr, deleteMe) {
-
- if(addr.replaces() == null) {
- // we are editing a non-pending address. create a pending address to manage that
- var repl = new aua();
- repl.usr(addr.usr());
- repl.address_type(addr.address_type());
- repl.within_city_limits(addr.within_city_limits());
- repl.replaces(addr.id());
- repl.pending('t');
- repl.isnew(true);
- repl.id(null);
- addr = repl;
- }
-
- if(deleteMe) {
- if(addr.id() == null) {
- hideMe($n(row, 'myopac_pending_addr_td'));
- return;
- }
- addr.isdeleted(true);
- } else {
- addr.address_type($n(row, 'myopac_pending_addr_type').value);
- addr.street1($n(row, 'myopac_pending_addr_street').value);
- addr.street2($n(row, 'myopac_pending_addr_street2').value);
- addr.city($n(row, 'myopac_pending_addr_city').value);
- addr.county($n(row, 'myopac_pending_addr_county').value);
- addr.state($n(row, 'myopac_pending_addr_state').value);
- addr.country($n(row, 'myopac_pending_addr_country').value);
- addr.post_code($n(row, 'myopac_pending_addr_zip').value);
- }
-
- var req = new Request(
- 'open-ils.actor:open-ils.actor.user.address.pending.cud',
- G.user.session, addr);
-
- req.callback(
- function(r) {
- var resp = r.getResultObject();
-
- if(addr.isnew()) {
- // new, add to list of addrs
- addr.id(resp);
- fleshedUser.addresses().push(addr);
-
- } else {
- // deleted, remove from list of addrs
- if(addr.isdeleted()) {
- hideMe($n(row, 'myopac_pending_addr_td'));
- var addrs = [];
- for(var i in fleshedUser.addresses()) {
- var a = fleshedUser.addresses()[i];
- if(a.id() != addr.id())
- addrs.push(a);
- }
- fleshedUser.addresses(addrs);
- }
- }
- alertId('myopac_addr_changes_saved');
- }
- );
- req.send();
-};
-
-
-function myOPACUpdateUsername() {
- var username = $('myopac_new_username').value;
- if(username == null || username == "") {
- alert($('myopac_username_error').innerHTML);
- return;
- }
-
- if( username.match(/.*\s.*/) ) {
- alert($('myopac_invalid_username').innerHTML);
- return;
- }
-
- r = fetchOrgSettingDefault(globalOrgTree.id(), 'opac.barcode_regex');
- if(r) REGEX_BARCODE = new RegExp(r);
-
- if(username.match(REGEX_BARCODE)) {
- alert($('myopac_invalid_username').innerHTML);
- return;
- }
-
- /* first see if the requested username is taken */
- var req = new Request(CHECK_USERNAME, G.user.session, username);
- req.send(true);
- var res = req.result();
- /* If the username does not already exist, res will be null;
- * we can move on to updating the username.
- *
- * If the username does exist, then res will be the user ID.
- * G.user.id() gives us the currently authenticated user ID.
- * If res == G.user.id(), we try to update the username anyways.
- */
- if( res !== null && res != G.user.id() ) {
- alertId('myopac_username_dup');
- return;
- }
-
- var req = new Request(UPDATE_USERNAME, G.user.session, username );
- req.send(true);
- if(req.result()) {
-
- var evt;
- var res = req.result();
- if(evt = checkILSEvent(res)) {
- alertILSEvent(res);
- return;
- }
-
- G.user.usrname(username);
- hideMe($('myopac_update_username_row'));
- userShown = false;
- alertId('myopac_username_success');
- myOPACShowSummary();
- return;
- }
-
- alert($('myopac_username_failure').innerHTML);
-}
-
-function myOPACUpdateEmail() {
- var email = $('myopac_new_email').value;
- if(email == null || email == "") {
- alert($('myopac_email_error').innerHTML);
- return;
- }
-
- var req = new Request(UPDATE_EMAIL, G.user.session, email );
- req.send(true);
- if(req.result()) {
- G.user.usrname(email);
- hideMe($('myopac_update_email_row'));
- userShown = false;
- alertId('myopac_email_success');
- myOPACShowSummary();
- return;
- }
-
- alert($('myopac_email_failure').innerHTML);
-}
-
-
-function myOPACUpdatePassword() {
- var curpassword = $('myopac_current_password').value;
- var password = $('myopac_new_password').value;
- var password2 = $('myopac_new_password2').value;
-
- if( curpassword == null || curpassword == "" ||
- password == null || password == "" ||
- password2 == null || password2 == "" || password != password2 ) {
- alert($('myopac_password_error').innerHTML);
- return;
- }
-
- if(!strongPassword(password, true)) return;
-
- var req = new Request(UPDATE_PASSWORD, G.user.session, password, curpassword );
- req.send(true);
- if(req.result()) {
- hideMe($('myopac_update_password_row'));
- userShown = false;
- alertId('myopac_password_success');
- myOPACShowSummary();
- return;
- }
-
- alert($('myopac_password_failure').innerHTML);
-}
-
-
-
-
-var containerTemplate;
-function myOPACShowBookbags(force) {
-
- var tbody =$('myopac_bookbag_tbody') ;
-
- if(!containerTemplate)
- containerTemplate = tbody.removeChild($('myopac_bookbag_tr'));
- else if(!force) return;
-
- removeChildren(tbody);
-
- var containers = containerFetchAll();
-
- var found = false;
- for( var i in containers ) {
- found = true;
- var cont = containers[i];
- var row = containerTemplate.cloneNode(true);
- row.id = 'myopac_bookbag_row_' + cont.id();
- var link = $n(row, 'myopac_expand_bookbag');
- var dlink = $n(row, 'myopac_container_delete');
- link.appendChild( text(cont.name()) );
- link.setAttribute('href',
- 'javascript:myOPACExpandBookbag("' + cont.id() + '","' + cont.name() + '");');
- myOPACFetchBBItems( cont.id(), row );
- dlink.setAttribute('href', 'javascript:myOPACDeleteBookbag("'+cont.id()+'");');
-
- if( isTrue(cont.pub()) ) {
- unHideMe($n(row, 'myopac_bb_published_yes'));
- var link = $n(row, 'myopac_bb_published_view');
- link.setAttribute('href', buildExtrasLink( 'feed/bookbag/html-full/'+cont.id(), false));
- link.setAttribute('target', '_blank' );
- unHideMe(link);
-
- link = $n(row, 'myopac_bb_published_atom');
- link.setAttribute('href', buildExtrasLink( 'feed/bookbag/rss2-full/'+cont.id(), false));
- link.setAttribute('target', '_blank' );
- unHideMe(link);
-
- link = $n(row, 'myopac_bb_make_unpublished');
- link.setAttribute('href', 'javascript:myOPACMakeBBPublished("'+cont.id()+'", true);');
- unHideMe(link);
-
- } else {
- unHideMe($n(row, 'myopac_bb_published_no'));
- var link = $n(row, 'myopac_bb_make_published');
- link.setAttribute('href', 'javascript:myOPACMakeBBPublished("'+cont.id()+'");');
- unHideMe(link);
- }
-
- tbody.appendChild(row);
- }
-
- if(!found) unHideMe($('myopac_bookbags_none'));
- else unHideMe($('myopac_bookbag_table'));
-}
-
-function myOPACMakeBBPublished(bbid, hideme) {
-
- var bb = fleshedContainers[bbid];
-
- if(hideme) {
- if(!confirm($('myopac_make_unpublished_confirm').innerHTML)) return;
- bb.pub('f');
- } else {
- if(!confirm($('myopac_make_published_confirm').innerHTML)) return;
- bb.pub('t');
- }
-
- var result = containerUpdate(bb);
-
- var code = checkILSEvent(result);
- if(code) { alertILSEvent(result); return; }
-
- alert($('myopac_bb_update_success').innerHTML);
- myOPACShowBookbags(true);
-}
-
-
-
-function myOPACDeleteBookbag(id) {
- if( confirm( $('myopac_delete_bookbag_warn').innerHTML ) ) {
- var result = containerDelete(id);
- var code = checkILSEvent(result);
- if(code) { alertILSEvent(result); return; }
- alert($('myopac_bb_update_success').innerHTML);
- hideMe($('myopac_bookbag_items_table'));
- hideMe($('myopac_bookbag_items_name'));
- hideMe($('myopac_bookbag_no_items'));
- myOPACShowBookbags(true);
- }
-}
-
-function myOPACFetchBBItems( id, row, block ) {
- if(!block) {
- containerFlesh( id, _myOPACSetBBItems, { row: row } );
- } else {
- var cont = containerFlesh(id);
- myOPACSetBBItems( cont, row );
- }
-}
-
-function _myOPACSetBBItems(r) { myOPACSetBBItems( r.getResultObject(), r.args.row ); }
-
-function myOPACSetBBItems( container, row ) {
- fleshedContainers[container.id()] = container;
- var node = $n(row, 'myopac_bookbag_item_count');
- removeChildren(node);
- node.appendChild( text(container.items().length) );
-}
-
-var BBItemsRow;
-function myOPACExpandBookbag( id, name ) {
-
- var tbody = $('myopac_bookbag_items_tbody');
- if(!BBItemsRow) BBItemsRow = tbody.removeChild($('myopac_bookbag_items_row'));
- removeChildren(tbody);
- removeChildren($('myopac_bookbag_items_name'));
-
- $('myopac_bookbag_items_name').appendChild(text(name));
-
- if( fleshedContainers[id] ) {
- var len = fleshedContainers[id].items().length;
-
- if( len == 0 ) {
- unHideMe($('myopac_bookbag_no_items'));
- hideMe($('myopac_bookbag_items_table'));
- return;
- }
-
- hideMe($('myopac_bookbag_no_items'));
- unHideMe($('myopac_bookbag_items_table'));
-
- for( var i = 0; i != len; i++ ) {
- var row = BBItemsRow.cloneNode(true);
- found = true;
-
- var item = fleshedContainers[id].items()[i];
- var tlink = $n(row,'myopac_bookbag_items_title');
- var alink = $n(row,'myopac_bookbag_items_author');
-
- var req = new Request( FETCH_RMODS, item.target_biblio_record_entry() );
- req.request.tlink = tlink;
- req.request.alink = alink;
- req.callback(myOPACShowBBItem);
- req.send();
-
- var clink = $n(row, 'myopac_bookbag_items_remove');
- clink.setAttribute('href', 'javascript:myOPACRemoveBBItem("'+item.id()+'","'+id+'","'+name+'");');
-
- tbody.appendChild(row);
- }
- }
-}
-
-function myOPACRemoveBBItem( id, containerid, container_name ) {
- if(!confirm($('myopac_remove_bb_item_confirm').innerHTML)) return;
- var stat = containerRemoveItem( id );
- if(stat) alert($('myopac_bb_update_success').innerHTML);
- myOPACFetchBBItems( containerid, $('myopac_bookbag_row_' + containerid), true);
- myOPACExpandBookbag( containerid, container_name );
-}
-
-function myOPACShowBBItem(r) {
- var record = r.getResultObject();
- buildTitleDetailLink(record, r.tlink);
- buildSearchLink(STYPE_AUTHOR, record.author(), r.alink);
-}
-
-function myOPACCreateBookbag() {
- var name = $('myopac_bookbag_new_name').value;
- if(!name) return;
-
- var exists = false;
- for( var c in fleshedContainers ) { exists = true; break; }
-
- /* let them know what they are getting into... */
- if(!exists) if(!confirm($('bb_create_warning').innerHTML)) return;
-
- var result = containerCreate( name, $('bb_public_yes').checked );
- var code = checkILSEvent(result);
- if(code) { alertILSEvent(result); return; }
- if(result) alert($('myopac_bb_update_success').innerHTML);
- myOPACShowBookbags(true);
-}
-
-
-/* ---------------------------------------------------------------------- */
-/* Non cat circs */
-/* ---------------------------------------------------------------------- */
-
-var nonCatCircIds;
-var nonCatTypes;
-/* if we have some circs, grab the non-cat types */
-function myOPACDrawNonCatCircs(r) {
- var ids = r.getResultObject();
- if(ids.length == 0) return;
- nonCatCircIds = ids;
- unHideMe($('non_cat_circs_div'));
- var req = new Request(FETCH_NON_CAT_TYPES, G.user.home_ou());
- req.callback(myOPACDrawNonCatCircs2);
- req.send();
-}
-
-
-/* now we have circs and the types.. draw each one */
-var nonCatTbody;
-var nonCatRow;
-function myOPACDrawNonCatCircs2(r) {
- nonCatTypes = r.getResultObject();
- nonCatTbody = $('non_cat_circs_tbody');
- if(!nonCatRow) nonCatRow =
- nonCatTbody.removeChild($('non_cat_circs_row'));
- removeChildren(nonCatTbody);
- for( var i in nonCatCircIds ) {
- var req = new Request(FETCH_NON_CAT_CIRC, G.user.session, nonCatCircIds[i]);
- req.callback(myOPACDrawNonCatCirc);
- req.send();
- }
-}
-
-
-/* draw a single circ */
-function myOPACDrawNonCatCirc(r) {
- var circ = r.getResultObject();
-
-
- var type = grep(nonCatTypes,
- function(i){
- return (i.id() == circ.item_type());
- }
- )[0];
-
-
- var row = nonCatTbody.appendChild(nonCatRow.cloneNode(true));
- appendClear($n(row, 'circ_lib'), text(findOrgUnit(circ.circ_lib()).name()));
- appendClear($n(row, 'item_type'), text(type.name()));
-
- var duration = interval_to_seconds(type.circ_duration());
- duration = parseInt(duration + '000');
-
- var dtf = circ.circ_time();
- var start = dojo.date.stamp.fromISOString(circ.circ_time());
- var due = new Date( start.getTime() + duration );
- appendClear($n(row, 'circ_time'), text(due.iso8601Format('YMDHM', null, true, true)));
-}
-
-
-
-
-function myopacSelectAllChecked() {
- __myopacSelectChecked(true);
-}
-
-function myopacSelectNoneChecked() {
- __myopacSelectChecked(false);
-}
-
-function __myopacSelectChecked(value) {
- var rows = myopacGetCheckedOutRows();
- for( var i = 0; i < rows.length; i++ ) {
- var row = rows[i];
- var box = $n(row, 'selectme');
- if( box && ! box.disabled )
- box.checked = value;
- }
-}
-
-function myopacGetCheckedOutRows() {
- var rows = [];
- var tbody = $('myopac_checked_tbody');
- var children = tbody.childNodes;
- for( var i = 0; i < children.length; i++ ) {
- var child = children[i];
- if( child.nodeName.match(/^tr$/i) )
- if( $n(child, 'selectme') )
- rows.push(child);
- }
- return rows;
-}
-
-var __renew_circs = [];
-
-/* true if 1 renewal succeeded */
-var __success_count = 0;
-
-/* renews all selected circulations */
-function myOPACRenewSelected() {
- var rows = myopacGetCheckedOutRows();
- if(!confirm($('myopac_renew_confirm').innerHTML)) return;
- __success_count = 0;
-
- for( var i = 0; i < rows.length; i++ ) {
-
- var row = rows[i];
- if( ! $n(row, 'selectme').checked ) continue;
- var circ_id = row.getAttribute('circid');
-
- var circ;
- for( var j = 0; j != circsCache.length; j++ )
- if(circsCache[j].id() == circ_id)
- circ = circsCache[j];
-
- __renew_circs.push(circ);
- }
-
- if( __renew_circs.length == 0 ) return;
-
- unHideMe($('my_renewing'));
- moClearCheckedTable();
-
- for( var i = 0; i < __renew_circs.length; i++ ) {
- var circ = __renew_circs[i];
- moRenewCirc( circ.target_copy(), G.user.id(), circ );
- }
-}
-
-
-/* renews a single circulation */
-function moRenewCirc(copy_id, user_id, circ) {
-
- _debug('renewing circ ' + circ.id() + ' with copy ' + copy_id);
- var req = new Request(RENEW_CIRC, G.user.session,
- { patron : user_id,
- copyid : copy_id,
- opac_renewal : 1
- }
- );
-
- req.request.alertEvent = false;
- req.callback(myHandleRenewResponse);
- req.request.circ = circ;
- req.send();
-}
-
-
-
-/* handles the circ renew results */
-function myHandleRenewResponse(r) {
- var res = r.getResultObject();
- var circ = r.circ;
-
- /* remove this circ from the list of circs to renew */
- __renew_circs = grep(__renew_circs, function(i) { return (i.id() != circ.id()); });
-
- _debug("handling renew result for " + circ.id());
-
- if(checkILSEvent(res) || checkILSEvent(res[0]))
- alertIdText('myopac_renew_fail', __circ_titles[circ.id()]);
- else __success_count++;
-
- if(__renew_circs) return; /* more to come */
-
- __renew_circs = [];
-
- if( __success_count > 0 )
- alertIdText('myopac_renew_success', __success_count);
-
- hideMe($('my_renewing'));
- checkedDrawn = false;
- myOPACShowChecked();
-}
-
-/** ---- batch hold processing ------------ */
-
-
-/* myopac_holds_checkbx */
-function myopacSelectAllHolds() {
- var rows = getTableRows($("myopac_holds_tbody"));
- for(var i = 0; i < rows.length; i++) {
- cb = $n(rows[i], 'myopac_holds_selected_chkbx');
- if(cb) cb.checked = true;
- }
-}
-
-function myopacSelectNoneHolds() {
- var rows = getTableRows($("myopac_holds_tbody"));
- for(var i = 0; i < rows.length; i++) {
- cb = $n(rows[i], 'myopac_holds_selected_chkbx');
- if(cb) cb.checked = false;
- }
-}
-
-function myopacSelectedHoldsRows() {
- var r = [];
- var rows = getTableRows($("myopac_holds_tbody"));
- for(var i = 0; i < rows.length; i++) {
- cb = $n(rows[i], 'myopac_holds_selected_chkbx');
- if(cb && cb.checked)
- r.push(rows[i]);
- }
- return r;
-}
-
-var myopacProcessedHolds = 0;
-var myopacHoldsToProcess = 0;
-function myopacDoHoldAction() {
-
- var selectedRows = myopacSelectedHoldsRows();
- action = getSelectorVal($('myopac_holds_actions'));
- $('myopac_holds_actions_none').selected = true;
- if(selectedRows.length == 0) return;
-
- myopacProcessedHolds = 0;
-
- if(!confirmId('myopac.holds.'+action+'.confirm')) return;
- myopacSelectNoneHolds(); /* clear the selection */
-
-
- /* first, let's collect the holds that actually need processing and
- collect the full process count while we're at it */
- var holds = [];
- for(var i = 0; i < selectedRows.length; i++) {
- hold = holdCache[myopacHoldIDFromRow(selectedRows[i])];
- var qstats = holdStatusCache[hold.id()];
- switch(action) {
- case 'cancel':
- holds.push(hold);
- break;
- case 'thaw_date':
- case 'thaw':
- if(isTrue(hold.frozen()))
- holds.push(hold);
- break;
- case 'freeze':
- if(!isTrue(hold.frozen()) && qstats.status < 3)
- holds.push(hold);
- break;
- }
- }
- myopacHoldsToProcess = holds;
- if(myopacHoldsToProcess.length == 0) return;
-
- if(action == 'thaw_date' || action == 'freeze')
- myopacDrawHoldThawDateForm();
- else
- myopacProcessHolds(action);
-}
-
-
-function myopacProcessHolds(action, thawDate) {
-
- myopacShowHoldProcessing();
- /* now we process them */
- for(var i = 0; i < myopacHoldsToProcess.length; i++) {
-
- hold = myopacHoldsToProcess[i];
-
- var req;
- switch(action) {
-
- case 'cancel':
- req = new Request(CANCEL_HOLD, G.user.session, hold.id());
- break;
-
- case 'thaw':
- hold.frozen('f');
- hold.thaw_date(null);
- req = new Request(UPDATE_HOLD, G.user.session, hold);
- break;
-
- case 'thaw_date':
- case 'freeze':
- hold.frozen('t');
- hold.thaw_date(thawDate);
- req = new Request(UPDATE_HOLD, G.user.session, hold);
- break;
- //thawDate = prompt($('myopac.holds.freeze.select_thaw').innerHTML);
-
- }
-
- req.callback(myopacBatchHoldCallback);
- req.send();
- req = null;
- }
-}
-
-function myopacDrawHoldThawDateForm() {
- hideMe($('myopac_holds_main_table'));
- unHideMe($('myopac_holds_thaw_date_form'));
- $('myopac_holds_thaw_date_input').focus();
-}
-
-function myopacApplyThawDate() {
- var dateString = dijit.byId('myopac_holds_thaw_date_input').getValue();
- if(dateString) {
- dateString = dojo.date.stamp.toISOString(dateString);
- if(dateString) {
- dateString = holdsVerifyThawDate(dateString);
- if(!dateString) return;
- } else {
- dateString = null;
- }
- }
- myopacProcessHolds('freeze', dateString);
-}
-
-function myopacHoldIDFromRow(row) {
- return row.id.replace(/.*_(\d+)$/, '$1');
-}
-
-function myopacShowHoldProcessing() {
- unHideMe($('myopac_holds_processing'));
- hideMe($('myopac_holds_main_table'));
-}
-
-function myopacHideHoldProcessing() {
- hideMe($('myopac_holds_processing'));
- unHideMe($('myopac_holds_main_table'));
- hideMe($('myopac_holds_thaw_date_form'));
-}
-
-function myopacBatchHoldCallback(r) {
- if(r) /* force load any exceptions */
- r.getResultObject();
- if(++myopacProcessedHolds >= myopacHoldsToProcess.length) {
- myopacHideHoldProcessing();
- holdCache = {};
- holdStatusCache = {};
- myopacForceHoldsRedraw = true;
- myOPACShowHolds();
- }
-}
-
Deleted: conifer/trunk/web/opac/skin/uwin/js/rdetail.js.orig
===================================================================
--- conifer/trunk/web/opac/skin/uwin/js/rdetail.js.orig 2009-09-04 15:00:19 UTC (rev 644)
+++ conifer/trunk/web/opac/skin/uwin/js/rdetail.js.orig 2009-09-04 15:04:19 UTC (rev 645)
@@ -1,1062 +0,0 @@
-/* */
-
-
-detachAllEvt('common', 'run');
-attachEvt("common", "run", rdetailDraw);
-attachEvt("rdetail", "recordDrawn", rdetailBuildStatusColumns);
-attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows);
-attachEvt("rdetail", "recordDrawn", rdetailGetPageIds);
-
-var record = null;
-var cp_statuses = null;
-var recordsCache = [];
-
-var copyRowParent = null;
-var copyRow = null;
-var statusRow = null;
-var numStatuses = null;
-var defaultCN;
-var callnumberCache = {};
-var rdetailLocalOnly = true;
-var globalCNCache = {};
-var localTOC;
-var cachedRecords;
-var _statusPositions = {};
-
-var rdetailShowLocal = true;
-var rdetailShowCopyLocation = true;
-var googleBookPreview = true;
-var enableHoldsOnAvailable = false;
-var displaySerialHoldings = true;
-var opac_strings;
-
-/* serials are currently the only use of Dojo strings in the OPAC */
-if (displaySerialHoldings) {
- dojo.requireLocalization("openils.opac", "opac");
- opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
-}
-
-var nextContainerIndex;
-
-function rdetailReload() {
- var args = {};
- args[PARAM_LOCATION] = getNewSearchLocation();
- args[PARAM_DEPTH] = depthSelGetDepth();
- goTo(buildOPACLink(args));
-}
-
-var nextRecord;
-var prevRecord;
-
-var rdetailPrev = null;
-var rdetailNext = null;
-var rdetailStart = null;
-var rdetailEnd = null;
-
-
-
-/* looks to see if we have a next and/or previous record in the
- record cache, if so, set up the nav links */
-function rdetailSetPaging(ids) {
-
- cachedRecords = {};
- cachedRecords.ids = ids;
-
- for( var i = 0; i < cachedRecords.ids.length; i++ ) {
- var rec = cachedRecords.ids[i];
- if( rec == getRid() ) {
- if( i > 0 ) prevRecord = cachedRecords.ids[i-1];
- if( i < cachedRecords.ids.length - 1 )
- nextRecord = cachedRecords.ids[i+1];
- break;
- }
- }
-
- $('np_offset').appendChild(text(i + 1));
- $('np_count').appendChild(text(getHitCount()));
-
- if(prevRecord) {
- unHideMe($('np_table'));
- unHideMe($('np_prev'));
- unHideMe($('np_start'));
- rdetailPrev = function() { _rdetailNav(prevRecord); };
- rdetailStart = function() { _rdetailNav(cachedRecords.ids[0]); };
- }
-
- if(nextRecord) {
- unHideMe($('np_table'));
- unHideMe($('np_next'));
- unHideMe($('np_end'));
- rdetailNext = function() { _rdetailNav(nextRecord); };
- rdetailEnd = function() { _rdetailNav(cachedRecords.ids[cachedRecords.ids.length-1]); };
- }
-
- runEvt('rdetail', 'nextPrevDrawn', i, cachedRecords.ids.length);
-}
-
-
-function _rdetailNav(id, offset) {
- var args = {};
- args[PARAM_RID] = id;
- goTo(buildOPACLink(args));
-}
-
-function rdetailDraw() {
-
- detachAllEvt('common','depthChanged');
- detachAllEvt('common','locationUpdated');
- attachEvt('common','depthChanged', rdetailReload);
- attachEvt('common','locationUpdated', rdetailReload);
- attachEvt('common','holdUpdated', rdetailReload);
- attachEvt('common','holdUpdateCanceled', rdetailReload);
-
- copyRowParent = G.ui.rdetail.cp_info_row.parentNode;
- copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row);
- statusRow = G.ui.rdetail.cp_status.parentNode;
- statusRow.id = '__rdsrow';
-
- G.ui.rdetail.cp_info_local.onclick = rdetailShowLocalCopies;
- G.ui.rdetail.cp_info_all.onclick = rdetailShowAllCopies;
-
- if(getLocation() == globalOrgTree.id())
- hideMe(G.ui.rdetail.cp_info_all);
-
- var req = new Request(FETCH_RMODS, getRid());
- req.callback(_rdetailDraw);
- req.send();
-
- if (displaySerialHoldings) {
- var req = new Request(FETCH_MFHD_SUMMARY, getRid());
- req.callback(_holdingsDraw);
- req.send();
- }
-
- detachAllEvt("result", "idsReceived");
- G.evt.result.hitCountReceived = [];
- G.evt.result.recordReceived = [];
- G.evt.result.copyCountsReceived = [];
- G.evt.result.allRecordsReceived = [];
-}
-
-function rdetailGetPageIds() {
- attachEvt("result", "idsReceived", rdetailSetPaging );
- resultFetchAllRecords = true;
- rresultCollectIds(true);
-}
-
-
-function buildunAPISpan (span, type, id) {
- var cgi = new CGI();
- var d = new Date();
-
- addCSSClass(span,'unapi-id');
-
- span.setAttribute(
- 'title', 'tag:' + cgi.server_name + ',' +
- d.getFullYear() + ':' + type + '/' + id
- );
-}
-
-function rdetailViewMarc(r,id) {
- hideMe($('rdetail_extras_loading'));
- $('rdetail_view_marc_box').innerHTML = r.getResultObject();
-
- var div = elem('div', { "class" : 'hide_me' });
- var span = div.appendChild( elem('abbr') );
-
- buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
-
- $('rdetail_view_marc_box').insertBefore(span, $('rdetail_view_marc_box').firstChild);
-}
-
-
-function rdetailShowLocalCopies() {
- rdetailShowLocal = true;
- rdetailBuildInfoRows();
- hideMe(G.ui.rdetail.cp_info_local);
- unHideMe(G.ui.rdetail.cp_info_all);
- hideMe(G.ui.rdetail.cp_info_none);
-}
-
-function rdetailShowAllCopies() {
-
- rdetailShowLocal = false;
- rdetailBuildInfoRows();
- hideMe(G.ui.rdetail.cp_info_all);
- unHideMe(G.ui.rdetail.cp_info_local);
- hideMe(G.ui.rdetail.cp_info_none);
-}
-
-function OpenMarcEditWindow(pcrud, rec) {
- /*
- To run in Firefox directly, must set signed.applets.codebase_principal_support
- to true in about:config
- */
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
- dojo.require('openils.PermaCrud');
-
- win.xulG = {
- "record": {"marc": rec.marc()},
- "save": {
- "label": opac_strings.SAVE_MFHD_LABEL,
- "func": function(xmlString) {
- rec.marc(xmlString);
- rec.ischanged(true);
- pcrud.update(rec);
- }
- }
- };
-}
-
-function loadMarcEditor(recId) {
- var pcrud = new openils.PermaCrud({"authtoken": G.user.session});
- var rec = pcrud.retrieve("sre", recId);
- if (rec) {
- OpenMarcEditWindow(pcrud, rec);
- }
-}
-
-/*
- * This function could be written much more intelligently
- * Limited brain power means that I'm brute-forcing it for now
- */
-function _holdingsDraw(h) {
- holdings = h.getResultObject();
- if (!holdings) { return null; }
-
- dojo.forEach(holdings, _holdingsDrawMFHD);
-}
-
-function _holdingsDrawMFHD(holdings, entryNum) {
- var here = findOrgUnit(getLocation());
- if (getDepth() > 0 || getDepth === 0 ) {
- while (getDepth() < findOrgDepth(here))
- here = findOrgUnit( here.parent_ou() );
- if (!orgIsMine(findOrgUnit(here), findOrgUnit(holdings.owning_lib()))) {
- return null;
- }
- }
-
- 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 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 &&
- ho.length == 0 && hm.length == 0 && hinc.length == 0 && !isXUL()
- ) {
- return null;
- }
-
- dojo.place("<table style='width: 100%;'><caption id='mfhdHoldingsCaption' class='rdetail_header color_1'>" +
- dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [hloc]) +
- "</caption><tbody id='rdetail_holdings_tbody_" + entryNum +
- "'></tbody></table>", "rdetail_details_table", "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 (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()) {
- dojo.require('openils.Event');
- dojo.require('openils.PermaCrud');
- dojo.place("<span> - </span><a class='classic_link' href='javascript:loadMarcEditor(" +
- holdings.id() + ")'>" + opac_strings.EDIT_LABEL + "</a>",
- "mfhdHoldingsCaption", "last"
- );
- }
-}
-
-function _holdingsDrawMFHDEntry(entryNum, entryName, entry) {
- var flatEntry = entry.toString().replace(/,/g, ', ');
- dojo.place("<tr><td> </td><td nowrap='nowrap' class='rdetail_desc'>" + entryName + "</td><td class='rdetail_item'>" + flatEntry + "</td></tr>", "rdetail_holdings_tbody_" + entryNum, "last");
-}
-
-function _rdetailDraw(r) {
- record = r.getResultObject();
-
- runEvt('rdetail', 'recordRetrieved', record.doc_id());
-
- 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())));
- G.ui.rdetail.edition.appendChild(text(record.edition()));
- G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
- G.ui.rdetail.publisher.appendChild(text(record.publisher()));
- $('rdetail_physical_desc').appendChild(text(record.physical_description()));
- r = record.types_of_resource();
- if(r) {
- G.ui.rdetail.tor.appendChild(text(r[0]));
- setResourcePic( G.ui.rdetail.tor_pic, r[0]);
- }
- G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
-
- if (enableHoldsOnAvailable) {
- unHideMe($('rdetail_place_hold'));
- } else {
- hideMe($('rdetail_place_hold'));
- rdetailCheckAvailable();
- }
-
- try{
- 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());
- $('rdetail.jacket_attrib_link').setAttribute('href', href);
- }
- rdetailCheckForGBPreview();
-
- } else {
- hideMe($("rdetail.jacket_attrib_div"));
- hideMe($("rdetail_img_link"));
- }
- } catch(E) {}
-
-
- // see if the record has any external links
- var links = record.online_loc();
- for( var i = 0; links && links.length > 0 && i < links.length; i = i + 3 ) {
- var href = links[i];
- // avoid matching "HTTP: The Complete Reference"
- if( href.match(/https?:\/|ftps?:\/|mailto:/i) ) {
- unHideMe($('rdetail_online_row'));
- // MODS can contain a display label (used for the text of the link)
- // as well as a note about the URL; many legacy systems conflate the
- // two and generate MARC records that expect the note to be used as
- // the text of the link, with no display label; here's the canonical
- // format:
- //
- // 856 40 $uhttp://localhost$yDisplay label$zPublic note
- //
- // Note that the MARC21slim2MODS XSL concatenates $3 and $y together
- // (as $y was defined later in MARC21's life as the display label)
- var displayLabel = '' + links[i+1];
- var note = '' + links[i+2];
- if(!displayLabel || displayLabel.match(/https?:\/|ftps?:\/|mailto:/i)) {
- if(!note || note.match(/https?:\/|ftps?:\/|mailto:/i)) {
- displayLabel = href;
- } else {
- displayLabel = note;
- }
- }
- $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel));
- if (note && note != displayLabel) {
- $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note));
- }
- $('rdetail_online').appendChild(elem('br'));
- }
- }
-
- // 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) {
- if (abbrs[i].getAttribute('name') == 'unapi') {
- span = abbrs[i];
- break;
- }
- }
- buildunAPISpan( span, 'biblio-record_entry', record.doc_id() );
-
- $('rdetail_place_hold').setAttribute(
- 'href','javascript:holdsDrawEditor({record:"'+record.doc_id()+'",type:"T"});');
-
- var RW = $('rdetail_exp_refworks');
- if (RW) {
-
- var here = (findOrgUnit(getLocation())).name();
- var org_name = here.replace(" ", "+");
- var cgi = new CGI();
-
- RW.setAttribute(
- 'href',
- 'http://refworks.scholarsportal.info/express/expressimport.asp?vendor='
- + org_name
- + '&filter=MARC+Format&database=All+MARC+Formats&encoding=65001&url=http%3A%2F%2F'
- + cgi.server_name+'/opac/extras/supercat/marctxt/record/'
- + record.doc_id()
- );
-
- RW.setAttribute('target', 'RefWorksMain');
- }
-
- $('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
- G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
- runEvt("rdetail", "recordDrawn");
- recordsCache.push(record);
-
- rdetailSetExtrasSelector();
-
- var breq = new Request(FETCH_BRE, [getRid()]);
- breq.callback( rdetailCheckDeleted );
- breq.send();
-
- resultBuildCaches( [ record ] );
- resultDrawSubjects();
- resultDrawSeries();
-
- // grab added content
- acCollectData(cleanISBN(record.isbn()), rdetailhandleAC);
-}
-
-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();
-}
-
-/*
- * Display the "Place Hold" link if:
- * * the current location holds at least one copy and
- * * 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'));
- }
-}
-
-function rdetailCheckDeleted(r) {
- var br = r.getResultObject()[0];
- if( isTrue(br.deleted()) ) {
- hideMe($('rdetail_place_hold'));
- $('rdetail_more_actions_selector').disabled = true;
- unHideMe($('rdetail_deleted_exp'));
- }
-}
-
-function rdetailSetExtrasSelector() {
- if(!grabUser()) return;
- unHideMe($('rdetail_more_actions'));
-
- var req = new Request(
- FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );
- req.callback(rdetailAddBookbags);
- req.send();
-}
-
-function rdetailAddBookbags(r) {
-
- var containers = r.getResultObject();
- var selector = $('rdetail_more_actions_selector');
- var found = false;
- var index = 3;
- doSelectorActions(selector);
-
- for( var i = 0; i != containers.length; i++ ) {
- found = true;
- var container = containers[i];
- insertSelectorVal( selector, index++, container.name(),
- "container_" + container.id(), rdetailAddToBookbag, 1 );
- }
-
- nextContainerIndex = index;
-}
-
-var _actions = {};
-function rdetailNewBookbag() {
- var name = prompt($('rdetail_bb_new').innerHTML,"");
- if(!name) return;
-
- var id;
- if( id = containerCreate( name ) ) {
- alert($('rdetail_bb_success').innerHTML);
- var selector = $('rdetail_more_actions_selector');
- insertSelectorVal( selector, nextContainerIndex++, name,
- "container_" + id, rdetailAddToBookbag, 1 );
- setSelector( selector, 'start' );
- }
-}
-
-
-function rdetailAddToBookbag() {
- var selector = $('rdetail_more_actions_selector');
- var id = selector.options[selector.selectedIndex].value;
- setSelector( selector, 'start' );
-
- if( containerCreateItem( id.substring(10), record.doc_id() )) {
- alert($('rdetail_bb_item_success').innerHTML);
- }
-}
-
-
-var rdetailMarcFetched = false;
-function rdetailShowExtra(type, args) {
-
- hideMe($('rdetail_copy_info_div'));
- hideMe($('rdetail_reviews_div'));
- hideMe($('rdetail_toc_div'));
- hideMe($('rdetail_anotes_div'));
- hideMe($('rdetail_excerpt_div'));
- hideMe($('rdetail_preview_div'));
- hideMe($('rdetail_marc_div'));
- hideMe($('cn_browse'));
- hideMe($('rdetail_cn_browse_div'));
- hideMe($('rdetail_notes_div'));
-
- removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
- removeCSSClass($('rdetail_viewcn_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');
- removeCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
- removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
- removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected');
- removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
-
- switch(type) {
-
- case "copyinfo":
- unHideMe($('rdetail_copy_info_div'));
- addCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected');
- break;
-
- case "reviews":
- addCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected');
- unHideMe($('rdetail_reviews_div'));
- break;
-
- case "excerpt":
- addCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected');
- unHideMe($('rdetail_excerpt_div'));
- break;
-
- case "preview":
- addCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected');
- unHideMe($('rdetail_preview_div'));
- rdetailDisplayGBPreview();
- break;
-
- case "anotes":
- addCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected');
- unHideMe($('rdetail_anotes_div'));
- break;
-
- case "toc":
- addCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected');
- unHideMe($('rdetail_toc_div'));
- break;
-
- case "marc":
- addCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected');
- unHideMe($('rdetail_marc_div'));
- if(rdetailMarcFetched) return;
- unHideMe($('rdetail_extras_loading'));
- rdetailMarcFetched = true;
- var req = new Request( FETCH_MARC_HTML, record.doc_id() );
- req.callback(rdetailViewMarc);
- req.send();
- break;
-
- case 'cn':
- addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected');
- unHideMe($('rdetail_cn_browse_div'));
- rdetailShowCNBrowse(defaultCN, getLocation(), null, true);
- break;
-
- }
-}
-
-function rdetailVolumeDetails(args) {
- var row = $(args.rowid);
- var tbody = row.parentNode;
- cpdBuild( tbody, row, record, args.cn, args.org, args.depth, args.copy_location );
- return;
-}
-
-function rdetailBuildCNList() {
-
- var select = $('cn_browse_selector');
- var index = 0;
- var arr = [];
- for( var cn in callnumberCache ) arr.push( cn );
- arr.sort();
-
- if( arr.length == 0 ) {
- hideMe($('rdetail_cn_browse_select_div'));
- return;
- }
-
- for( var i in arr ) {
- var cn = arr[i];
- var opt = new Option(cn);
- select.options[index++] = opt;
- }
- select.onchange = rdetailGatherCN;
-}
-
-function rdetailGatherCN() {
- var cn = getSelectorVal($('cn_browse_selector'));
- rdetailShowCNBrowse( cn, getLocation(), getDepth(), true );
- setSelector( $('cn_browse_selector'), cn );
-}
-
-
-function rdetailShowCNBrowse( cn, loc, depth, fromOnclick ) {
-
- if(!cn) {
- unHideMe($('cn_browse_none'));
- hideMe($('rdetail_cn_browse_select_div'));
- return;
- }
-
- unHideMe($('rdetail_cn_browse_select_div'));
- 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_cn_browse_div'));
- unHideMe($('cn_browse'));
- if( !rdetailLocalOnly && ! fromOnclick ) depth = findOrgDepth(globalOrgTree);
- cnBrowseGo(cn, loc, depth);
-}
-
-function rdetailhandleAC(data) {
-
- if( data.reviews.html ) {
- $('rdetail_review_container').innerHTML = data.reviews.html;
- unHideMe($('rdetail_reviews_link'));
- }
-
- if( data.toc.html ) {
- $('rdetail_toc_div').innerHTML = data.toc.html;
- unHideMe($('rdetail_toc_link'));
- }
-
- if( data.excerpt.html ) {
- $('rdetail_excerpt_div').innerHTML = data.excerpt.html;
- unHideMe($('rdetail_excerpt_link'));
- }
-
- if( data.anotes.html ) {
- $('rdetail_anotes_div').innerHTML = data.anotes.html;
- unHideMe($('rdetail_anotes_link'));
- }
-}
-
-function rdetailShowReviews(r) {
- hideMe($('rdetail_extras_loading'));
- var res = r.getResultObject();
- var par = $('rdetail_reviews_div');
- var template = par.removeChild($('rdetail_review_template'));
- if( res && res.length > 0 ) {
- unHideMe($('rdetail_reviews_link'));
- for( var i = 0; i != res.length; i++ ) {
- var rev = res[i];
- if( rev.text && rev.info ) {
- var node = template.cloneNode(true);
- $n(node, 'review_header').appendChild(text(rev.info));
- $n(node, 'review_text').appendChild(text(rev.text));
- par.appendChild(node);
- }
- }
- }
-}
-
-
-function rdetailShowTOC(r) {
- hideMe($('rdetail_extras_loading'));
- var resp = r.getResultObject();
- if(resp) {
- unHideMe($('rdetail_toc_link'));
- $('rdetail_toc_div').innerHTML = resp;
- }
-}
-
-function rdetailBuildInfoRows() {
- var req;
- var method = FETCH_COPY_COUNTS_SUMMARY;
- if (rdetailShowCopyLocation)
- method = FETCH_COPY_LOCATION_COUNTS_SUMMARY;
-
- if( rdetailShowLocal )
- req = new Request(method, record.doc_id(), getLocation(), getDepth())
- else
- req = new Request(method, record.doc_id());
- req.callback(_rdetailBuildInfoRows);
- req.send();
-}
-
-function _rdetailRows(node) {
-
- if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) {
- var loc = findOrgUnit(getLocation());
- 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;
- }
- }
- }
- }
-
- if(!node && findOrgType(globalOrgTree.ou_type()).can_have_vols())
- node = globalOrgTree;
-
-
- /* don't show hidden orgs */
-
- if(node) {
-
- if(!isXUL() && !isTrue(node.opac_visible())) return;
-
- var row = copyRow.cloneNode(true);
- row.id = "cp_info_" + node.id();
-
- var libtd = findNodeByName( row, config.names.rdetail.lib_cell );
- var cntd = findNodeByName( row, config.names.rdetail.cn_cell );
- var cpctd = findNodeByName( row, config.names.rdetail.cp_count_cell );
- var actions = $n(row, 'rdetail_actions_cell');
-
- var p = libtd.getElementsByTagName('a')[0];
- libtd.insertBefore(text(node.name()), p);
- libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1) * 9) + "px;");
-
- if(!findOrgType(node.ou_type()).can_have_vols()) {
-
- row.removeChild(cntd);
- row.removeChild(cpctd);
- row.removeChild(actions);
- row.setAttribute('novols', '1');
-
- libtd.setAttribute("colspan", numStatuses + 3 );
- libtd.colSpan = numStatuses + 3;
- addCSSClass(row, 'copy_info_region_row');
- }
-
- copyRowParent.appendChild(row);
-
- } else { node = globalOrgTree; }
-
- for( var c in node.children() )
- _rdetailRows(node.children()[c]);
-}
-
-function rdetailCNPrint(orgid, cn) {
- var div = cpdBuildPrintWindow( record, orgid);
- var template = div.removeChild($n(div, 'cnrow'));
- var rowNode = $("cp_info_" + orgid);
- cpdStylePopupWindow(div);
- openWindow(div.innerHTML);
-}
-
-var localCNFound = false;
-var ctr = 0;
-function _rdetailBuildInfoRows(r) {
-
- if (rdetailShowCopyLocation)
- unHideMe( $n( $('rdetail_copy_info_table'), 'rdetail_copylocation_header' ) );
-
- removeChildren(copyRowParent);
-
- _rdetailRows();
-
- var summary = r.getResultObject();
- if(!summary) return;
-
- var found = false;
- for( var i = 0; i < summary.length; i++ ) {
-
- var arr = summary[i];
- globalCNCache[arr[1]] = 1;
- var thisOrg = findOrgUnit(arr[0]);
- var rowNode = $("cp_info_" + thisOrg.id());
- if(!rowNode) continue;
-
- if(rowNode.getAttribute("used")) {
-
- if( rowNode.nextSibling ) {
- sib = rowNode.nextSibling;
- o ='cp_info_'+thisOrg.id()+'_';
- /* push the new row on as the last row for this org unit */
- while( sib && sib.id.match(o) ) {
- sib = sib.nextSibling;
- }
- if(sib)
- rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), sib);
- else
- rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
- } else {
- rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
- }
-
- var n = findNodeByName( rowNode, config.names.rdetail.lib_cell );
- n.appendChild(text(thisOrg.name()));
- n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1) * 9) + "px;");
- rowNode.id = "cp_info_" + thisOrg.id() + '_' + (++ctr);
-
- } else {
- rowNode.setAttribute("used", "1");
- }
-
- var cpc_temp = rowNode.removeChild(
- findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
-
- var statuses = arr[2];
- var cl = '';
- if (rdetailShowCopyLocation) {
- cl = arr[2];
- statuses = arr[3];
- }
-
-
- rdetailApplyStatuses(rowNode, cpc_temp, statuses);
-
- var isLocal = false;
- if( orgIsMine( findOrgUnit(getLocation()), thisOrg ) ) {
- found = true;
- isLocal = true;
- if(!localCNFound) {
- localCNFound = true;
- defaultCN = arr[1];
- }
- }
-
- //if(isLocal) unHideMe(rowNode);
- unHideMe(rowNode);
-
- rdetailSetPath( thisOrg, isLocal );
- rdetailBuildBrowseInfo( rowNode, arr[1], isLocal, thisOrg, cl );
-
- if( i == summary.length - 1 && !defaultCN) defaultCN = arr[1];
- }
-
- if(!found) unHideMe(G.ui.rdetail.cp_info_none);
-}
-
-function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) {
-
- if(local) {
- var cache = callnumberCache[cn];
- if( cache ) cache.count++;
- else callnumberCache[cn] = { count : 1 };
- }
-
- var depth = getDepth();
- if( !local ) depth = findOrgDepth(globalOrgTree);
-
- $n(row, 'rdetail_callnumber_cell').appendChild(text(cn));
-
- if (rdetailShowCopyLocation) {
- var cl_cell = $n(row, 'rdetail_copylocation_cell');
- cl_cell.appendChild(text(cl));
- unHideMe(cl_cell);
- }
-
- _debug('setting action clicks for cn ' + cn);
-
- var dHref = 'javascript:rdetailVolumeDetails('+
- '{copy_location : "'+cl+'", rowid : "'+row.id+'", cn :"'+cn+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});';
-
- var bHref = 'javascript:rdetailShowCNBrowse("' + cn + '", '+orgNode.id()+', "'+depth+'");';
-
- unHideMe( $n(row, 'details') )
- $n(row, 'details').setAttribute('href', dHref);
- unHideMe( $n(row, 'browse') )
- $n(row, 'browse').setAttribute('href', bHref);
-
- if(isXUL()) {
- unHideMe($n(row, 'hold_div'));
- $n(row, 'hold').onclick = function() {
- var req = new Request(FETCH_VOLUME_BY_INFO, cn, record.doc_id(), orgNode.id());
- req.callback(
- function(r) {
- var vol = r.getResultObject();
- holdsDrawEditor({type: 'V', volumeObject : vol});
- }
- );
- req.send();
- };
- }
-}
-
-// sets the path to org as 'active' and displays the path if it's local
-function rdetailSetPath(org, local) {
- if( findOrgDepth(org) == 0 ) return;
- var row = $("cp_info_" + org.id());
- row.setAttribute("hasinfo", "1");
- unHideMe(row);
- rdetailSetPath(findOrgUnit(org.parent_ou()), local);
-}
-
-//Append all the statuses for a given summary to the
-//copy summary table
-function rdetailApplyStatuses( row, template, statuses ) {
- for( var j in _statusPositions ) {
- var stat = _statusPositions[j];
- var val = statuses[stat.id()];
- var nn = template.cloneNode(true);
- if(val) nn.appendChild(text(val));
- else nn.appendChild(text(0));
- row.appendChild(nn);
- }
-}
-
-//Add one td (creating a new column) to the copy summary
-//table for each opac_visible copy status
-function rdetailBuildStatusColumns() {
-
- rdetailGrabCopyStatuses();
- var parent = statusRow;
- var template = parent.removeChild(G.ui.rdetail.cp_status);
-
- var i = 0;
- for( i = 0; i < cp_statuses.length; i++ ) {
-
- var c = cp_statuses[i];
- if( c && isTrue(c.opac_visible()) ) {
- var name = c.name();
- _statusPositions[i] = c;
- var node = template.cloneNode(true);
- var data = findNodeByName( node, config.names.rdetail.cp_status);
-
- data.appendChild(text(name));
- parent.appendChild(node);
- }
- }
-
- numStatuses = 0;
- for(x in _statusPositions) numStatuses++;
-}
-
-function rdetailGrabCopyStatuses() {
- if(cp_statuses) return cp_statuses;
- var req = new Request(FETCH_COPY_STATUSES);
- req.send(true);
- cp_statuses = req.result();
- cp_statuses = cp_statuses.sort(_rdetailSortStatuses);
-}
-
-function _rdetailSortStatuses(a, b) {
- return parseInt(a.id()) - parseInt(b.id());
-}
-
-/**
- * Check for a Google Book preview
- */
-function rdetailCheckForGBPreview() {
- if (!googleBookPreview) return;
- searchForGBPreview( cleanISBN(record.isbn()) );
-}
-
-/**
- *
- * @param {DOM object} query 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);
-}
-
-/**
- * This function is the call-back function for the JSON scripts which
- * executes a Google book search response.
- *
- * XXX I18N of text needed
- *
- * @param {JSON} booksInfo is the JSON object pulled from the Google books service.
- */
-function GBPreviewCallback(GBPBookInfo) {
- var GBPreviewDiv = document.getElementById("rdetail_preview_div");
- var GBPBook;
-
- for ( i in GBPBookInfo ) {
- GBPBook = GBPBookInfo[i];
- }
-
- if ( !GBPBook ) {
- return;
- }
-
- 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';
- GBPBadge.title = $('rdetail_preview_badge').innerHTML;
- GBPBadge.style.border = 0;
- GBPBadgelink = document.createElement( 'a' );
- GBPBadgelink.href = 'javascript:rdetailShowExtra("preview");';
- GBPBadgelink.appendChild( GBPBadge );
- $('rdetail_image_cell').appendChild( GBPBadgelink );
- $('rdetail_preview_div').style.height = 600;
-
- /* Display the "Preview" tab in the Extras section */
- unHideMe( $('rdetail_preview_link' ) );
- }
-}
-
-/**
- * This is called when the user clicks on the 'Preview' link. We assume
- * a preview is available from Google if this link was made visible.
- *
- * XXX I18N of Google Book Preview language attribute needed
- */
-function rdetailDisplayGBPreview() {
- unHideMe($('rdetail_extras_loading'));
- GBPreviewPane = $('rdetail_preview_div');
- if ( GBPreviewPane.getAttribute('loaded') == null ||
- GBPreviewPane.getAttribute('loaded') == "false" ) {
- google.load("books", "0", {"callback" : rdetailGBPViewerLoadCallback, "language": "en"} );
- GBPreviewPane.setAttribute('loaded', 'true');
- }
-}
-
-function rdetailGBPViewerLoadCallback() {
- hideMe($('rdetail_extras_loading'));
- var GBPViewer = new google.books.DefaultViewer(document.getElementById('rdetail_preview_div'));
- GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) );
-
-}
More information about the open-ils-commits
mailing list