Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Small code cleanup
  • Loading branch information
Eugene Simakin committed Sep 25, 2016
1 parent 2157531 commit 68a933f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions jquery.twbsPagination.js
Expand Up @@ -101,25 +101,24 @@
buildListItems: function (pages) {
var listItems = [];

// Add "first" page button
if (this.options.first) {
listItems.push(this.buildItem('first', 1));
}
// Add "previous" page button

if (this.options.prev) {
var prev = pages.currentPage > 1 ? pages.currentPage - 1 : this.options.loop ? this.options.totalPages : 1;
listItems.push(this.buildItem('prev', prev));
}
// Add "pages"

for (var i = 0; i < pages.numeric.length; i++) {
listItems.push(this.buildItem('page', pages.numeric[i]));
}
// Add "next" page button

if (this.options.next) {
var next = pages.currentPage < this.options.totalPages ? pages.currentPage + 1 : this.options.loop ? 1 : this.options.totalPages;
listItems.push(this.buildItem('next', next));
}
// Add "last" page button

if (this.options.last) {
listItems.push(this.buildItem('last', this.options.totalPages));
}
Expand All @@ -130,9 +129,8 @@
buildItem: function (type, page) {
var $itemContainer = $('<li></li>'),
$itemContent = $('<a></a>'),
itemText = null;
itemText = this.options[type] ? this.makeText(this.options[type], page) : page;

itemText = this.options[type] ? this.makeText(this.options[type], page) : page;
$itemContainer.addClass(this.options[type + 'Class']);
$itemContainer.data('page', page);
$itemContainer.data('page-type', type);
Expand Down

0 comments on commit 68a933f

Please sign in to comment.