Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
'Init' method removed by reason of ambiguity
  • Loading branch information
Eugene Simakin committed Aug 25, 2014
1 parent 32e1401 commit 69f23da
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions jquery.twbsPagination.js
Expand Up @@ -17,52 +17,48 @@

var TwbsPagination = function (element, options) {
this.$element = $(element);
this.init(options);
};

TwbsPagination.prototype = {
this.options = $.extend({}, $.fn.twbsPagination.defaults, options);

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({}, $.fn.twbsPagination.defaults, 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 69f23da

Please sign in to comment.