diff --git a/checkout-plugin-from-master.sh b/checkout-plugin-from-master.sh
new file mode 100755
index 0000000..7ac4173
--- /dev/null
+++ b/checkout-plugin-from-master.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+git checkout master -- jquery.twbsPagination.js
+git mv -f jquery.twbsPagination.js js/jquery.twbsPagination.js
+git add js/jquery.twbsPagination.js
\ No newline at end of file
diff --git a/index.html b/index.html
index d720ac5..0637431 100644
--- a/index.html
+++ b/index.html
@@ -75,6 +75,10 @@
border-radius: 0;
}
+ .btn {
+ border-radius: 0;
+ }
+
.input-with-button input {
width: 200px;
border-radius: 0;
@@ -412,6 +416,40 @@
Alternative style pagination (with start and end page numbers)
+ Methods 'enable' and 'disable' in action
+
+
+
+
+
+
+ Push the buttons...
+
+
+
+
+
+
+ JS code:
+
+ // ### IF YOU DON'T PASS onPageClick FUNCTION IN OPTIONS OBJECT
+ // ### YOU SHOULD FIRE FIRST PAGE CLICK INDEPENDENTLY
+ // ### BECAUSE PLUGIN DOESN'T HAVE ANY CALLBACK
+ // ### TO FIRE IT DURING INITIALIZATION
+ var $edPag = $('#enable-disable-pagination').twbsPagination({
+ totalPages: 20
+ }).on('page', function (evt, page) {
+ $('#enable-disable-pagination-content').text('Page ' + page);
+ });
+
+ $('#enable-pagination').click(function () {
+ $edPag.twbsPagination('enable');
+ });
+
+ $('#disable-pagination').click(function () {
+ $edPag.twbsPagination('disable');
+ });
+
License
diff --git a/js/jquery.twbsPagination.js b/js/jquery.twbsPagination.js
index 566d940..64ec6d8 100644
--- a/js/jquery.twbsPagination.js
+++ b/js/jquery.twbsPagination.js
@@ -71,6 +71,7 @@
if (this.options.initiateStartPageClick) {
this.show(this.options.startPage);
} else {
+ this.currentPage = this.options.startPage;
this.render(this.getPages(this.options.startPage));
this.setupEvents();
}
@@ -104,6 +105,23 @@
return this;
},
+ enable: function () {
+ this.show(this.currentPage);
+ },
+
+ disable: function () {
+ var _this = this;
+ this.$listContainer.off('click').on('click', 'li', function (evt) {
+ evt.preventDefault();
+ });
+ this.$listContainer.children().each(function () {
+ var $this = $(this);
+ if (!$this.hasClass(_this.options.activeClass)) {
+ $(this).addClass(_this.options.disabledClass);
+ }
+ });
+ },
+
buildListItems: function (pages) {
var listItems = [];
@@ -175,7 +193,7 @@
var _this = this;
this.$listContainer.children().remove();
var items = this.buildListItems(pages);
- jQuery.each(items, function(key, item){
+ $.each(items, function(key, item){
_this.$listContainer.append(item);
});
diff --git a/js/main.js b/js/main.js
index 92802c6..74b5083 100644
--- a/js/main.js
+++ b/js/main.js
@@ -51,5 +51,22 @@ $(document).ready(function () {
$('#alt-style-pagination-content').text('Page ' + page);
}
});
+
+ // ### IF YOU DON'T PASS onPageClick FUNCTION IN OPTIONS OBJECT
+ // ### YOU SHOULD FIRE FIRST PAGE CLICK INDEPENDENTLY
+ // ### BECAUSE PLUGIN DOESN'T HAVE ANY CALLBACK TO FIRE IT DURING INITIALIZATION
+ var $edPag = $('#enable-disable-pagination').twbsPagination({
+ totalPages: 20
+ }).on('page', function (evt, page) {
+ $('#enable-disable-pagination-content').text('Page ' + page);
+ });
+
+ $('#enable-pagination').click(function () {
+ $edPag.twbsPagination('enable');
+ });
+
+ $('#disable-pagination').click(function () {
+ $edPag.twbsPagination('disable');
+ });
});