Initial dev repository
[kcls-web.git] / opac / extras / mobile / mobile / js / account / summary.js
diff --git a/opac/extras/mobile/mobile/js/account/summary.js b/opac/extras/mobile/mobile/js/account/summary.js
new file mode 100644 (file)
index 0000000..12f9c9b
--- /dev/null
@@ -0,0 +1,5 @@
+module("account.account_summary",imports("eg.eg_api","plugin"),function(e){return $.fn.account_summary=function(){this.plugin("account_summary").append($("<div>").acct_summary());return this.refresh(function(){var b;if(typeof(b=e.auth.session==null?undefined:e.auth.session.user)!=="undefined"&&b!==null)this.publish("userid",[e.auth.session.user.id]);return false})}});
+module("account.summary",imports("eg.eg_api","template","plugin","account.fines","account.checkouts","account.holds"),function(e,b){var f,k,g,h,i,l,m,n,o;n=b.template("$<%= nf %> fines owing");h=function(){$("#fines_summary").openils("fines summary","actor.user.fines.summary.authoritative",function(a){return this.text(n({nf:a.balance_owed}))});return false};m=b.template("<%= nco %> items checked out,\n<%= nod %> overdue,\n<%= nxx %> other items");g=function(){$("#checkouts_summary").openils("checkouts summary",
+"actor.user.checked_out.count.authoritative",function(a){var d,c;return this.text(m({nco:d=a.out,nod:c=a.overdue,nxx:a.total-d-c}))});return false};o=b.template("<%= nh %> items on hold,\n<%= ns %> holds suspended");i=function(){$("#holds_summary").openils("holds summary","circ.holds.retrieve",function(a){var d,c,p,j;return this.text(o({nh:a.length,ns:function(){d=[];c=0;for(p=a.length;c<p;c++){j=a[c];j.frozen&&d.push(j)}return d}().length}))});return false};l=b.template("<%= nbb %> bookbags created");
+k=function(){$("#bookbags_summary").openils("bookbags summary","actor.container.retrieve_by_class",function(a){return this.text(l({nbb:a.length}))});return false};f=function(){h();g();return i()};return $.fn.acct_summary=function(){$("#account_fines").fines();$("#account_checkouts").checkouts();$("#account_holds").holds();e.logged_in()?f():this.openils("account summaries","auth.session.retrieve",f);return this.plugin("acct_summary").subscribe("userid",function(){this.is(":visible")&&this.refresh();
+return false}).subscribe("login_event",f).subscribe("logout_event",function(){$("#account_summary .accordion.on").click();$("#fines_summary").empty();$("#checkouts_summary").empty();$("#holds_summary").empty();return false}).subscribe("fines_summary",h).subscribe("checkouts_summary",g).subscribe("holds_summary",i).subscribe("bookbags_summary",k).refresh(f)}});