Initial dev repository
[kcls-web.git] / opac / extras / mobile / mobile / js / account / checkouts.js
diff --git a/opac/extras/mobile/mobile/js/account/checkouts.js b/opac/extras/mobile/mobile/js/account/checkouts.js
new file mode 100644 (file)
index 0000000..c2f66e0
--- /dev/null
@@ -0,0 +1,7 @@
+var __hasProp=Object.prototype.hasOwnProperty,__bind=function(d,e){return function(){return d.apply(e,arguments)}};module("account.account_checkouts",imports("eg.eg_api","plugin"),function(d){return $.fn.account_checkouts=function(){$("<div>").checkouts().appendTo(this);return this.refresh(function(){var e;if(typeof(e=d.auth.session==undefined?undefined:d.auth.session.user)!=="undefined"&&e!==null)this.publish("userid",[d.auth.session.user.id]);return false})}});
+module("account.checkouts",imports("eg.eg_api","template","plugin"),function(d,e){var r,s,t;t=e.template('<div class="my_checkout" id="circ_id_<%= circ_id %>">\n\t<input type="checkbox" name="copy_id" />\n\t<span class="info_line">\n\t\t<span class="title" />\n\t\t<span class="author" />\n\t\t<span class="types" />\n\t</span>\n\t<div class="status_line">\n\t\t<span class="copy_status"><%= circ_type %></span>\n\t\tDue date <span class="due_date" />\n\t\tRemaining renewals <span class="remaining_renewals" />\n\t</div>\n</div>');
+r=function(a){a.title&&$(".title",this).text(a.title);a.author&&$(".author",this).text("/ "+a.author);if(a.types_of_resource)return $(".types",this).text("/ "+a.types_of_resource.join(", "))};s=function(a){$(".due_date",this).text(a.due_date.slice(0,10));$(".remaining_renewals",this).text(a.renewal_remaining);return $("input:checkbox",this).val(a.target_copy)};return $.fn.checkouts=function(){var a,k,l;a=this;l=function(b){return d.openils("circ.renew",parseInt(b),function(){return null})};k=function(){return a.ajaxStop(function(){$(this).unbind("ajaxStop").refresh().publish("checkouts_summary");
+return false})};this.plugin("acct_checkouts").subscribe("userid",function(){this.is(":visible")&&this.refresh();return false}).subscribe("logout_event",function(){this.empty();return false}).refresh(function(){var b,f,g;this.empty().append(b=$('<form>\n\t<input type="submit" class="renew" name="some" value="Renew selected items"/>\n\t<input type="submit" class="renew" name="all" value="Renew all"/>\n</form>'));g=$('.renew[name="some"]',this).hide();f=$('.renew[name="all"]',this).hide();b.openils("checkout details",
+"actor.user.checked_out.authoritative",function(c){var m,h;a.publish("items_checked_out",[c]);m=[];for(h in c)__hasProp.call(c,h)&&function(){var n,i,u,o=h,v=c[h];return m.push(function(){n=[];i=0;for(u=v.length;i<u;i++)(function(){var p=v[i];return n.push(function(){b.prepend(t({circ_id:p,circ_type:o}));if(o==="out")f.is(":visible")?g.show():f.show();return function(w,j){return $(".status_line",j).openils("checkout status","circ.retrieve",p,function(q){s.call(this.parent(),q);$(".info_line",j).openils("title info",
+"search.biblio.mods_from_copy",q.target_copy,r);w!=="out"&&j.addClass("inactive");return w!=="out"||q.renewal_remaining===0?j.find(":checkbox").attr("disabled",true):null})}(o,$("#circ_id_"+p))}())})();return n}())}();return m});return false});this.delegate(".renew[name=some]","click",__bind(function(){var b,f,g,c;c=$("form",$(this)).serializeArray();if(c.length){b=0;for(f=c.length;b<f;b++){g=c[b];l(g.value)}k()}else $(this).publish("notice",["Nothing was done because no items were selected."]);return false},
+this));return this.delegate(".renew[name=all]","click",__bind(function(){var b;b=$(this).find("input:checkbox:enabled");if(b.length){b.each(function(){return l($(this).val())});k()}else $(this).publish("notice",["Nothing was done because no items can be renewed."]);return false},this))}});