[open-ils-commits] r1344 - 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 11:06:43 EDT 2011
Author: dbs
Date: 2011-04-13 11:06:40 -0400 (Wed, 13 Apr 2011)
New Revision: 1344
Modified:
conifer/branches/rel_2_0/web/opac/skin/default/js/myopac.js
Log:
Update to a more stock 2.0 myopac.js
Keep an eye on the formatting of due dates, etc.
Modified: conifer/branches/rel_2_0/web/opac/skin/default/js/myopac.js
===================================================================
--- conifer/branches/rel_2_0/web/opac/skin/default/js/myopac.js 2011-04-13 14:48:25 UTC (rev 1343)
+++ conifer/branches/rel_2_0/web/opac/skin/default/js/myopac.js 2011-04-13 15:06:40 UTC (rev 1344)
@@ -3,16 +3,18 @@
//attachEvt("common", "loggedIn", myOPACInit );
attachEvt('common','locationUpdated', myopacReload );
+dojo.requireLocalization("openils.opac", "opac");
+
+var opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
var fleshedUser = null;
var fleshedContainers = {};
var holdCache = {};
var holdStatusCache = {};
+var showHoldQueuePosition = false;
var allowPendingAddr = false;
-var preventRenewOverdue = false;
-var myopacEnableRefWorks = true;
+var myopacEnableRefWorks = false;
var myopacRefWorksHost = 'http://refworks.scholarsportal.info';
-
function clearNodes( node, keepArray ) {
if(!node) return;
for( var n in keepArray ) node.removeChild(keepArray[n]);
@@ -22,6 +24,14 @@
function myOPACInit() {
+ fieldmapper.IDL.load(['mous']);
+
+ var orgHiding = checkOrgHiding();
+ if (orgHiding) {
+ hideMe($('prefs_def_location_row'));
+ hideMe($('prefs_def_range_row'));
+ }
+
if(!(G.user && G.user.session)) {
initLogin();
@@ -249,8 +259,7 @@
//rnlink.setAttribute('href', 'javascript:myOPACRenewCirc("'+circ.id()+'");');
circsCache.push(circ);
- // Disable renewals if no renewals left or item already overdue
- if( circ.renewal_remaining() < 1 || (preventRenewOverdue && circ._od)) {
+ if( circ.renewal_remaining() < 1 ) {
$n(row, 'selectme').disabled = true;
if(!__can_renew_one)
$('mo_renew_button').disabled = true;
@@ -276,10 +285,11 @@
var record = r.getResultObject();
var circid = r.circ;
- if(!record || checkILSEvent(record)) {
+ /* Draw pre-cataloged items */
+ if(!record || checkILSEvent(record) || !(record.title() || record.author())) {
var req = new Request( FETCH_COPY, r.copy );
- req.request.circ = circid
- req.callback(myOPACDrawNonCatalogedItem);
+ req.request.circ = circid;
+ req.callback(myOPACDrawPreCatalogedItem);
req.send();
return;
}
@@ -287,12 +297,13 @@
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) {
+function myOPACDrawPreCatalogedItem(r) {
var copy = r.getResultObject();
var circid = r.circ;
@@ -452,8 +463,11 @@
if(qstats.estimated_wait || myopacShowHoldEstimate) {
myopacShowHoldEstimate = true;
- if(qstats.estimated_wait)
- $n(row, 'myopac_holds_estimated_wait').appendChild(text(qstats.estimated_wait));
+ if(qstats.estimated_wait) {
+ // wait is currently returned in seconds, but displayed in days
+ var wait = Math.ceil(qstats.estimated_wait / 86400);
+ $n(row, 'myopac_holds_estimated_wait').appendChild(text(wait));
+ }
unHideMe($('myopac_holds_estimated_wait_column'));
unHideMe($n(row, 'myopac_holds_estimated_wait'));
}
@@ -463,10 +477,13 @@
hideMe($n(row, 'myopac_holds_cancel_link'));
}
- if(false) {
+ if (showHoldQueuePosition) {
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)'));
+ if (qstats.potential_copies == 1) {
+ node.appendChild(text(dojo.string.substitute(opac_strings.HOLD_STATUS_SINGULAR, [qstats.queue_position, qstats.total_holds, qstats.potential_copies])));
+ } else {
+ node.appendChild(text(dojo.string.substitute(opac_strings.HOLD_STATUS_PLURAL, [qstats.queue_position, qstats.total_holds, qstats.potential_copies])));
+ }
unHideMe(node);
} else {
@@ -588,7 +605,7 @@
//function _trimTime(time) { if(!time) return ""; return time.replace(/\ .*/,""); }
function _trimTime(time) {
- if(!time) return "";
+ if(!time) return "";
time = time.replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3");
var d = dojo.date.stamp.fromISOString(time);
if(!d) return ""; /* date parse failed */
@@ -599,7 +616,7 @@
if(!time) return "";
var d = dojo.date.stamp.fromISOString(time.replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3"));
if(!d) return ""; /* date parse failed */
- return d.iso8601Format('YMDHM',null,true,true);
+ return dojo.date.locale.format(d, { "timePattern" : "h:ma", "formatLength" : "medium" });
}
function myOPACShowTransactions(r) {
@@ -619,6 +636,12 @@
else if(trans.xact_type() == 'grocery' )
myopacShowGenericTransaction( trans );
+
+/* XXX need to copy circulation output function here
+ else if(trans.xact_type() == 'reservation' )
+ myopacShowReservationTransaction( trans );
+*/
+
}
}
@@ -834,7 +857,7 @@
var expireDate = dojo.date.stamp.fromISOString(user.expire_date());
if( expireDate < new Date() ) {
- appendClear($('myopac.expired.date'), expireDate.iso8601Format('YMD'));
+ appendClear($('myopac.expired.date'), dojo.date.locale.format(expireDate, { "formatLength" : "medium", "selector" : "date" }));
unHideMe($('myopac.expired.alert'));
}
@@ -917,6 +940,9 @@
appendClear($n(row, 'myopac_addr_country'),text(addr.country()));
appendClear($n(row, 'myopac_addr_zip'),text(addr.post_code()));
+ if(!isTrue(addr.valid()))
+ unHideMe($n(row, 'myopac_invalid_addr_row'));
+
if(!allowPendingAddr) return;
$n(row, 'myopac_addr_edit_link').onclick = function(){myopacEditAddress(addr)};
@@ -1388,13 +1414,13 @@
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().replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3"));
- var due = new Date( start.getTime() + duration );
- appendClear($n(row, 'circ_time'), text(due.iso8601Format('YMDHM', null, true, true)));
+ appendClear(
+ $n(row, 'circ_time'),
+ text(dojo.date.locale.format(
+ dojo.date.stamp.fromISOString(circ.duedate()),
+ {format : 'short'}
+ ))
+ );
}
More information about the open-ils-commits
mailing list