1 function LiTablePager() {
4 this.init = function(dataLoader, liTable, offset, limit) {
5 this.dataLoader = dataLoader;
6 this.liTable = liTable;
7 this.displayLimit = limit || 15;
8 this.displayOffset = offset || 0;
10 dojo.byId("acq-litpager-controls-prev").onclick =
11 function() { self.go(-1); }
12 dojo.byId("acq-litpager-controls-next").onclick =
13 function() { self.go(1); }
16 this.go = function(n /* generally (-1, 0, 1) */) {
17 if (n) this.displayOffset += n * this.displayLimit;
20 this.dataLoader(this); /* not a normal method, but a callback */
21 this.enableControls(true);
22 this.relabelControls();
25 this.show = function() {
26 this.liTable.reset(/* keep_selectors */ true);
27 this.liTable.show("list");
30 this.enableControls = function(yes) {
31 dojo.byId("acq-litpager-controls-prev").disabled =
32 (!yes) || this.displayOffset < 1;
33 dojo.byId("acq-litpager-controls-next").disabled =
35 (typeof(this.total) != "undefined") &&
36 this.displayOffset + this.displayLimit >= this.total
38 dojo.attr("acq-litpager-controls", "disabled", String(!yes));
41 this.relabelControls = function() {
42 if (typeof(this.total) != "undefined") {
43 dojo.byId("acq-litpager-controls-total").innerHTML = this.total;
44 openils.Util.show("acq-litpager-controls-total-holder", "inline");
46 openils.Util.hide("acq-litpager-controls-total-holder");
49 if (this.batch_length) {
50 dojo.byId("acq-litpager-controls-batch-start").innerHTML =
51 this.displayOffset + 1;
52 dojo.byId("acq-litpager-controls-batch-end").innerHTML =
53 this.displayOffset + this.batch_length;
54 openils.Util.show("acq-litpager-controls-batch-range", "inline");
56 openils.Util.hide("acq-litpager-controls-batch-range");
60 this.init.apply(this, arguments);