Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update plugin in docs
  • Loading branch information
Eugene Simakin committed Sep 9, 2014
1 parent 7d9e46b commit 604459e
Showing 1 changed file with 30 additions and 35 deletions.
65 changes: 30 additions & 35 deletions js/jquery.twbsPagination.js
@@ -1,5 +1,5 @@
/**
* jQuery pagination plugin v1.1.2
* jQuery pagination plugin v1.2.0
* http://esimakin.github.io/twbs-pagination/
*
* Copyright 2014, Eugene Simakin
Expand All @@ -18,52 +18,47 @@
var TwbsPagination = function (element, options) {
this.$element = $(element);
this.options = $.extend({}, $.fn.twbsPagination.defaults, options);
this.init(this.options);
};

TwbsPagination.prototype = {

constructor: TwbsPagination,
if (this.options.startPage < 1 || this.options.startPage > this.options.totalPages) {
throw new Error('Start page option is incorrect');
}

init: function (options) {
this.options = $.extend({}, this.options, options);
if (this.options.totalPages <= 0) {
throw new Error('Total pages option cannot be less 1 (one)!');
}

if (this.options.startPage < 1 || this.options.startPage > this.options.totalPages) {
throw new Error('Start page option is incorrect');
}
if (this.options.totalPages < this.options.visiblePages) {
this.options.visiblePages = this.options.totalPages;
}

if (this.options.totalPages <= 0) {
throw new Error('Total pages option cannot be less 1 (one)!');
}
if (this.options.onPageClick instanceof Function) {
this.$element.first().bind('page', this.options.onPageClick);
}

if (this.options.totalPages < this.options.visiblePages) {
this.options.visiblePages = this.options.totalPages;
}
var tagName = (typeof this.$element.prop === 'function') ?
this.$element.prop('tagName') : this.$element.attr('tagName');

if (this.options.onPageClick instanceof Function) {
this.$element.first().bind('page', this.options.onPageClick);
}
if (tagName === 'UL') {
this.$listContainer = this.$element;
} else {
this.$listContainer = $('<ul></ul>');
}

var tagName = (typeof this.$element.prop === 'function') ?
this.$element.prop('tagName') : this.$element.attr('tagName');
this.$listContainer.addClass(this.options.paginationClass);

if (tagName === 'UL') {
this.$listContainer = this.$element;
} else {
this.$listContainer = $('<ul></ul>');
}
if (tagName !== 'UL') {
this.$element.append(this.$listContainer);
}

this.$listContainer.addClass(this.options.paginationClass);
this.render(this.getPages(this.options.startPage));
this.setupEvents();

if (tagName !== 'UL') {
this.$element.append(this.$listContainer);
}
return this;
};

this.render(this.getPages(this.options.startPage));
this.setupEvents();
TwbsPagination.prototype = {

return this;
},
constructor: TwbsPagination,

destroy: function () {
this.$element.empty();
Expand Down

0 comments on commit 604459e

Please sign in to comment.