Fix paginator

This commit is contained in:
calzoneman 2014-01-08 10:57:48 -06:00
parent a4260bd25b
commit 2d7b0fe2ac
1 changed files with 5 additions and 3 deletions

View File

@ -14,7 +14,7 @@
for(var k in defaults)
if(!this.opts[k])
this.opts[k] = defaults[k];
this.paginator = $("<div/>").addClass("pagination");
this.paginator = $("<ul/>").addClass("pagination");
this.loadPage(0);
}
@ -22,9 +22,11 @@
var pages = parseInt(this.items.length / this.opts.itemsPerPage) + 1;
var endcaps = pages > this.opts.maxPages;
this.paginator.html("");
if(this.items.length < this.opts.itemsPerPage)
if (this.items.length < this.opts.itemsPerPage) {
this.paginator.css("margin-top", "0");
return;
var ul = $("<ul/>").appendTo(this.paginator);
}
var ul = this.paginator;
var s = p - parseInt(this.opts.maxPages / 2);
s = s + this.opts.maxPages < pages ? s : pages - this.opts.maxPages;
s = s < 0 ? 0 : s;