From 7180c7992b2be56c61cfb88a922f6d24a3f38b3b Mon Sep 17 00:00:00 2001 From: Eugene Simakin Date: Mon, 25 Aug 2014 23:28:33 +0400 Subject: [PATCH 1/3] Task specific code removed --- jquery.twbsPagination.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jquery.twbsPagination.js b/jquery.twbsPagination.js index 3887141..2b12849 100644 --- a/jquery.twbsPagination.js +++ b/jquery.twbsPagination.js @@ -17,7 +17,6 @@ var TwbsPagination = function (element, options) { this.$element = $(element); - this.options = $.extend({}, $.fn.twbsPagination.defaults, options); this.init(this.options); }; @@ -26,7 +25,7 @@ constructor: TwbsPagination, init: function (options) { - this.options = $.extend({}, this.options, options); + this.options = $.extend({}, $.fn.twbsPagination.defaults, options); if (this.options.startPage < 1 || this.options.startPage > this.options.totalPages) { throw new Error('Start page option is incorrect'); From 32e1401632e9010ec8face965e5c5982525861fc Mon Sep 17 00:00:00 2001 From: Eugene Simakin Date: Mon, 25 Aug 2014 23:40:49 +0400 Subject: [PATCH 2/3] Stupid mistake fixed --- jquery.twbsPagination.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.twbsPagination.js b/jquery.twbsPagination.js index 2b12849..eff3d5f 100644 --- a/jquery.twbsPagination.js +++ b/jquery.twbsPagination.js @@ -17,7 +17,7 @@ var TwbsPagination = function (element, options) { this.$element = $(element); - this.init(this.options); + this.init(options); }; TwbsPagination.prototype = { From 69f23da79033ca09a600c30ba0a359578f063489 Mon Sep 17 00:00:00 2001 From: Eugene Simakin Date: Tue, 26 Aug 2014 00:01:14 +0400 Subject: [PATCH 3/3] 'Init' method removed by reason of ambiguity --- jquery.twbsPagination.js | 64 +++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/jquery.twbsPagination.js b/jquery.twbsPagination.js index eff3d5f..be6875f 100644 --- a/jquery.twbsPagination.js +++ b/jquery.twbsPagination.js @@ -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 = $('
    '); + } - 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 = $('
      '); - } + 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();