From 7c32fb9819f4e576e50f53887653ad09dd39f55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Cebell=C3=A1n?= Date: Mon, 23 Jul 2018 18:27:54 +0200 Subject: [PATCH] #174 If TotalPages is lesser than VisiblePages, VisiblePages shouldn't be lowered (#175) --- jquery.twbsPagination.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/jquery.twbsPagination.js b/jquery.twbsPagination.js index b0bb46a..e4ce31c 100644 --- a/jquery.twbsPagination.js +++ b/jquery.twbsPagination.js @@ -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) { @@ -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; }