1 function LiTablePager() {
4 this.init = function(dataLoader, liTable, offset, limit) {
5 this.dataLoader = dataLoader;
6 this.liTable = liTable;
7 this.liTable.isUni = true;
8 this.liTable.pager = this; /* XXX memory leak waiting to happen? */
10 this.displayLimit = limit || 15;
11 this.displayOffset = offset || 0;
13 dojo.byId("acq-litpager-controls-prev").onclick =
14 function() { self.go(-1); }
15 dojo.byId("acq-litpager-controls-next").onclick =
16 function() { self.go(1); }
19 this.go = function(n /* generally (-1, 0, 1) */) {
20 if (n) this.displayOffset += n * this.displayLimit;
23 this.dataLoader(this); /* not a normal method, but a callback */
24 this.enableControls(true);
25 this.relabelControls();
28 this.show = function() {
29 this.liTable.reset(/* keep_selectors */ true);
30 this.liTable.show("list");
33 this.enableControls = function(yes) {
34 dojo.byId("acq-litpager-controls-prev").disabled =
35 (!yes) || this.displayOffset < 1;
36 dojo.byId("acq-litpager-controls-next").disabled =
38 (typeof(this.total) != "undefined") &&
39 this.displayOffset + this.displayLimit >= this.total
41 dojo.attr("acq-litpager-controls", "disabled", String(!yes));
44 this.relabelControls = function() {
45 if (typeof(this.total) != "undefined") {
46 dojo.byId("acq-litpager-controls-total").innerHTML = this.total;
47 openils.Util.show("acq-litpager-controls-total-holder", "inline");
49 openils.Util.hide("acq-litpager-controls-total-holder");
52 if (this.batch_length) {
53 dojo.byId("acq-litpager-controls-batch-start").innerHTML =
54 this.displayOffset + 1;
55 dojo.byId("acq-litpager-controls-batch-end").innerHTML =
56 this.displayOffset + this.batch_length;
57 openils.Util.show("acq-litpager-controls-batch-range", "inline");
59 openils.Util.hide("acq-litpager-controls-batch-range");
63 this.getAllLineitemIDs = function(callback) {
69 "oncomplete": callback
73 this.init.apply(this, arguments);