Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
josecebe#174 If TotalPages is lesser than VisiblePages, VisiblePages …
…shouldn't be lowered (josecebe#175)
  • Loading branch information
josecebe committed Jul 23, 2018
1 parent 4dfd38b commit 7c32fb9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions jquery.twbsPagination.js
Expand Up @@ -42,10 +42,6 @@
return this;
}

if (this.options.totalPages < this.options.visiblePages) {
this.options.visiblePages = this.options.totalPages;
}

if (this.options.href) {
this.options.startPage = this.getPageFromQueryString();
if (!this.options.startPage) {
Expand Down Expand Up @@ -170,13 +166,18 @@
var start = currentPage - half + 1 - this.options.visiblePages % 2;
var end = currentPage + half;

var visiblePages = this.options.visiblePages;
if (visiblePages > this.options.totalPages) {
visiblePages = this.options.totalPages;
}

// handle boundary case
if (start <= 0) {
start = 1;
end = this.options.visiblePages;
end = visiblePages;
}
if (end > this.options.totalPages) {
start = this.options.totalPages - this.options.visiblePages + 1;
start = this.options.totalPages - visiblePages + 1;
end = this.options.totalPages;
}

Expand Down

0 comments on commit 7c32fb9

Please sign in to comment.