Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Introduced josecebe#23, also checked jquery. Minimal required 1.8.1
  • Loading branch information
pavelthq committed Nov 4, 2015
1 parent 799e2d5 commit 192658e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 42 deletions.
4 changes: 2 additions & 2 deletions bower.json
@@ -1,6 +1,6 @@
{
"name": "twbs-pagination",
"version": "1.3.1",
"version": "1.4",
"homepage": "https://github.com/esimakin/twbs-pagination",
"authors": [
"Eugene Simakin <eugenesimakin@mail.ru>"
Expand All @@ -11,7 +11,7 @@
"globals"
],
"dependencies": {
"jquery": ">=1.7.0"
"jquery": ">=1.8.1"
},
"keywords": [
"pagination",
Expand Down
52 changes: 18 additions & 34 deletions jquery.twbsPagination.js
@@ -1,8 +1,8 @@
/*!
* jQuery pagination plugin v1.2.6
* jQuery pagination plugin v1.4
* http://esimakin.github.io/twbs-pagination/
*
* Copyright 2014, Eugene Simakin
* Copyright 2014-2015, Eugene Simakin
* Released under Apache 2.0 license
* http://apache.org/licenses/LICENSE-2.0.html
*/
Expand Down Expand Up @@ -101,24 +101,25 @@
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 @@ -131,31 +132,8 @@
$itemContent = $('<a></a>'),
itemText = null;

switch (type) {
case 'page':
itemText = page;
$itemContainer.addClass(this.options.pageClass);
break;
case 'first':
itemText = this.options.first;
$itemContainer.addClass(this.options.firstClass);
break;
case 'prev':
itemText = this.options.prev;
$itemContainer.addClass(this.options.prevClass);
break;
case 'next':
itemText = this.options.next;
$itemContainer.addClass(this.options.nextClass);
break;
case 'last':
itemText = this.options.last;
$itemContainer.addClass(this.options.lastClass);
break;
default:
break;
}

itemText = this.options[type] ? this.makeText(this.options[type]) : page;
$itemContainer.addClass(this.options[type + 'Class']);
$itemContainer.data('page', page);
$itemContainer.data('page-type', type);
$itemContainer.append($itemContent.attr('href', this.makeHref(page)).html(itemText));
Expand Down Expand Up @@ -241,8 +219,13 @@
});
},

makeHref: function (c) {
return this.options.href ? this.options.href.replace(this.options.hrefVariable, c) : "#";
makeHref: function (page) {
return this.options.href ? this.makeText(this.options.href, page) : "#";
},

makeText: function (text, page) {
return text.replace(this.options.pageVariable, page)
.replace(this.options.totalPagesVariable, this.options.totalPages)
}

};
Expand All @@ -269,7 +252,8 @@
visiblePages: 5,
initiateStartPageClick: true,
href: false,
hrefVariable: '{{number}}',
pageVariable: '{{page}}',
totalPagesVariable: '{{total_pages}}',
first: 'First',
prev: 'Previous',
next: 'Next',
Expand Down
4 changes: 2 additions & 2 deletions jquery.twbsPagination.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,13 +1,13 @@
{
"name": "twbs-pagination",
"nativeName": "jQuery Bootstrap Pagination",
"version": "1.3.1",
"version": "1.4",
"homepage": "https://github.com/esimakin/twbs-pagination",
"author": "Eugene Simakin <eugenesimakin@mail.ru>",
"description": "jQuery simple pagination plugin for bootstrap-style webpages",
"main": "jquery.twbsPagination",
"dependencies": {
"jquery": ">=1.7.0"
"jquery": ">=1.8.1"
},
"devDependencies": {
"grunt": "^0.4.5",
Expand Down
4 changes: 2 additions & 2 deletions twbs-pagination.jquery.json
@@ -1,6 +1,6 @@
{
"name": "twbs-pagination",
"version": "1.3.1",
"version": "1.4",
"title": "jQuery Bootstrap Pagination",
"author": {
"name": "Eugene Simakin",
Expand All @@ -14,7 +14,7 @@
}
],
"dependencies": {
"jquery": "> 1.7"
"jquery": "> 1.8.1"
},
"description": "Twbs Pagination is a jQuery plugin that provides pagination for your web site or application. Check out the demo!",
"keywords": [
Expand Down

0 comments on commit 192658e

Please sign in to comment.