diff --git a/dist/vue-paginate.js b/dist/vue-paginate.js index 33b0c92..4fb7c9b 100644 --- a/dist/vue-paginate.js +++ b/dist/vue-paginate.js @@ -1,5 +1,5 @@ /*! - * vue-paginate v2.1.1 + * vue-paginate v2.1.2 * (c) 2016 Taha Shashtari * Released under the MIT License. */ @@ -262,6 +262,7 @@ // Update the original list when the user changes the full list. vm.$watch('full' + utils.capitalize(this.listName), function (newVal, oldVal) { _this.originalList = newVal; + _this.setNumberOfPages(_this.originalList.length); vm['refresh' + utils.capitalize(_this.listName) + 'Page'](); }); @@ -291,7 +292,6 @@ _this.list.currentPage = typeof page == 'number' ? page - 1 : page; - _this.setNumberOfPages(_this.originalList.length); _this.setLimitedPages(limit); }; diff --git a/dist/vue-paginate.min.js b/dist/vue-paginate.min.js index 51eba1b..1f054d8 100644 --- a/dist/vue-paginate.min.js +++ b/dist/vue-paginate.min.js @@ -1,6 +1,6 @@ /*! - * vue-paginate v2.1.1 + * vue-paginate v2.1.2 * (c) 2016 Taha Shashtari * Released under the MIT License. */ -!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(i.VuePaginate=i.VuePaginate||{})}(this,function(i){"use strict";var t={capitalize:function(i){return i.charAt(0).toUpperCase()+i.slice(1)},generateLinksArray:function(i,t){for(var e=arguments.length<=2||void 0===arguments[2]?0:arguments[2],s=[],a=i;a<=t&&(s.push(a),!(e&&s.length>=e));a++);return s}},e=function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")},s=function(){function i(i,t){for(var e=0;ethis.list.numberOfPages?this.list.numberOfPages:this.limit,e=e.concat(t.generateLinksArray(this.list.initial+2,this.list.numberOfPages,this.limit-1)),this.shouldShowElipses()&&e.push(l),e.push(this.list.numberOfPages),this.notLastNavSet()&&e.push(n),[].concat(a(new Set(e)))}},{key:"shouldShowLeftArrow",value:function(){return this.list.numberOfPages>this.limit+1&&this.list.initial>=this.limit}},{key:"rightArrowOrElipsesIsClicked",value:function(){return this.list.currentPage===l||this.list.currentPage===n}},{key:"showNextNavSet",value:function(){return this.list.numberOfPages-this.list.initial>this.limit+1?(this.list.initial+=this.limit,void this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.initial+1)):(this.list.currentPage=this.list.numberOfPages,void this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.currentPage))}},{key:"leftArrowIsClicked",value:function(){return this.list.currentPage===r}},{key:"showPreviousNavSet",value:function(){return this.list.initial>this.limit-1?(this.list.initial-=this.limit,void this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.initial+this.limit)):(this.list.currentPage=this.list.initial,void this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.currentPage+1))}},{key:"lastPageIsClicked",value:function(){return this.list.currentPage==this.list.numberOfPages-1}},{key:"showLastNavSet",value:function(){this.list.numberOfPages-this.list.initial>this.limit+1&&(this.list.initial=this.initialOfLastNav(this.limit),this.list.currentPage=this.list.initial+this.limit,this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.currentPage+1))}},{key:"shouldShowElipses",value:function(){return this.list.numberOfPages-this.list.initial>this.limit+1}},{key:"initialOfLastNav",value:function(){var i=~~(this.list.numberOfPages/this.limit),t=this.list.numberOfPages-this.limit*i;return t=t<=1?t+this.limit:t,this.list.numberOfPages-t}},{key:"notLastNavSet",value:function(){return this.list.initial1),s["change"+t.capitalize(this.listName)+"Page"]=function(i){s[e.listName]=e.originalList,e.list.currentPage="number"==typeof i?i-1:i,e.setNumberOfPages(e.originalList.length),e.setLimitedPages(n)},s["next"+t.capitalize(this.listName)+"Page"]=function(){s[e.listName]=e.originalList,e.list.currentPage=e.list.currentPage+10?e.list.currentPage-1:0},s["refresh"+t.capitalize(this.listName)+"Page"]=function(){s["change"+t.capitalize(e.listName)+"Page"](1)},i.Vue.config.silent=!1},update:function(i){this.setNumberOfPages(i.length),this.list.currentPage=this.list.currentPage>=this.list.numberOfPages?this.list.numberOfPages-1:this.list.currentPage,this.setCurrentPage();var t=this.list.currentPage*this.list.perPage;this.set(i.slice(t,t+this.list.perPage))},setNumberOfPages:function(i){var e=i;this.list.numberOfPages=Math.ceil(e/this.list.perPage);var s=t.generateLinksArray(1,this.list.numberOfPages);this.vm.$set(this.listName+"Links",s)},setCurrentPage:function(){i.Vue.config.silent=!0,this.vm.$set("current"+t.capitalize(this.listName)+"Page",this.list.currentPage+1),this.vm.$set("has"+t.capitalize(this.listName)+"Links",this.list.numberOfPages>1),i.Vue.config.silent=!1},setLimitedPages:function(i){var e=new h(this.vm,this.list,this.listName).generate(i);this.vm.$set("limited"+t.capitalize(this.listName)+"Links",e)},getPerPage:function(){function i(){return Object.keys(e.$data).find(function(i){return i.match(a)})}function t(){return+e[i()]>0}var e=this.vm,s=this.arg,a=new RegExp(s,"i");return this.isPerPageDynamic()?t()?(this.arg=i(),+e[this.arg]):1:+s},isPerPageDynamic:function(){return!Number.isInteger(Number.parseInt(this.arg))}};i.Vue={};var c={};c.install=function(t){i.Vue=t,i.Vue.directive("paginate",u)},"undefined"!=typeof window&&window.Vue&&window.Vue.use(c),module.exports=c,i.default=c,Object.defineProperty(i,"__esModule",{value:!0})}); \ No newline at end of file +!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(i.VuePaginate=i.VuePaginate||{})}(this,function(i){"use strict";var t={capitalize:function(i){return i.charAt(0).toUpperCase()+i.slice(1)},generateLinksArray:function(i,t){for(var e=arguments.length<=2||void 0===arguments[2]?0:arguments[2],s=[],a=i;t>=a&&(s.push(a),!(e&&s.length>=e));a++);return s}},e=function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")},s=function(){function i(i,t){for(var e=0;ethis.list.numberOfPages?this.list.numberOfPages:this.limit,e=e.concat(t.generateLinksArray(this.list.initial+2,this.list.numberOfPages,this.limit-1)),this.shouldShowElipses()&&e.push(l),e.push(this.list.numberOfPages),this.notLastNavSet()&&e.push(n),[].concat(a(new Set(e)))}},{key:"shouldShowLeftArrow",value:function(){return this.list.numberOfPages>this.limit+1&&this.list.initial>=this.limit}},{key:"rightArrowOrElipsesIsClicked",value:function(){return this.list.currentPage===l||this.list.currentPage===n}},{key:"showNextNavSet",value:function(){return this.list.numberOfPages-this.list.initial>this.limit+1?(this.list.initial+=this.limit,void this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.initial+1)):(this.list.currentPage=this.list.numberOfPages,void this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.currentPage))}},{key:"leftArrowIsClicked",value:function(){return this.list.currentPage===r}},{key:"showPreviousNavSet",value:function(){return this.list.initial>this.limit-1?(this.list.initial-=this.limit,void this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.initial+this.limit)):(this.list.currentPage=this.list.initial,void this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.currentPage+1))}},{key:"lastPageIsClicked",value:function(){return this.list.currentPage==this.list.numberOfPages-1}},{key:"showLastNavSet",value:function(){this.list.numberOfPages-this.list.initial>this.limit+1&&(this.list.initial=this.initialOfLastNav(this.limit),this.list.currentPage=this.list.initial+this.limit,this.vm["change"+t.capitalize(this.listName)+"Page"](this.list.currentPage+1))}},{key:"shouldShowElipses",value:function(){return this.list.numberOfPages-this.list.initial>this.limit+1}},{key:"initialOfLastNav",value:function(){var i=~~(this.list.numberOfPages/this.limit),t=this.list.numberOfPages-this.limit*i;return t=1>=t?t+this.limit:t,this.list.numberOfPages-t}},{key:"notLastNavSet",value:function(){return this.list.initial=+i?1:+i,s["refresh"+t.capitalize(e.listName)+"Page"]()}),this.list={currentPage:0,initial:0,perPage:a},this.setNumberOfPages(this.originalList.length),this.setLimitedPages(n),s.$set("has"+t.capitalize(this.listName)+"Links",this.list.numberOfPages>1),s["change"+t.capitalize(this.listName)+"Page"]=function(i){s[e.listName]=e.originalList,e.list.currentPage="number"==typeof i?i-1:i,e.setLimitedPages(n)},s["next"+t.capitalize(this.listName)+"Page"]=function(){s[e.listName]=e.originalList,e.list.currentPage=e.list.currentPage+10?e.list.currentPage-1:0},s["refresh"+t.capitalize(this.listName)+"Page"]=function(){s["change"+t.capitalize(e.listName)+"Page"](1)},i.Vue.config.silent=!1},update:function(i){this.setNumberOfPages(i.length),this.list.currentPage=this.list.currentPage>=this.list.numberOfPages?this.list.numberOfPages-1:this.list.currentPage,this.setCurrentPage();var t=this.list.currentPage*this.list.perPage;this.set(i.slice(t,t+this.list.perPage))},setNumberOfPages:function(i){var e=i;this.list.numberOfPages=Math.ceil(e/this.list.perPage);var s=t.generateLinksArray(1,this.list.numberOfPages);this.vm.$set(this.listName+"Links",s)},setCurrentPage:function(){i.Vue.config.silent=!0,this.vm.$set("current"+t.capitalize(this.listName)+"Page",this.list.currentPage+1),this.vm.$set("has"+t.capitalize(this.listName)+"Links",this.list.numberOfPages>1),i.Vue.config.silent=!1},setLimitedPages:function(i){var e=new h(this.vm,this.list,this.listName).generate(i);this.vm.$set("limited"+t.capitalize(this.listName)+"Links",e)},getPerPage:function(){function i(){return Object.keys(e.$data).find(function(i){return i.match(a)})}function t(){return+e[i()]>0}var e=this.vm,s=this.arg,a=new RegExp(s,"i");return this.isPerPageDynamic()?t()?(this.arg=i(),+e[this.arg]):1:+s},isPerPageDynamic:function(){return!Number.isInteger(Number.parseInt(this.arg))}};i.Vue={};var c={};c.install=function(t){i.Vue=t,i.Vue.directive("paginate",u)},"undefined"!=typeof window&&window.Vue&&window.Vue.use(c),module.exports=c,i["default"]=c,Object.defineProperty(i,"__esModule",{value:!0})}); \ No newline at end of file diff --git a/dist/vue-paginate.min.js.gz b/dist/vue-paginate.min.js.gz index 9487bdb..3d8d41f 100644 Binary files a/dist/vue-paginate.min.js.gz and b/dist/vue-paginate.min.js.gz differ diff --git a/package.json b/package.json index 5a69aae..93b577d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-paginate", - "version": "2.1.1", + "version": "2.1.2", "description": "A simple vue.js plugin to paginate data", "main": "dist/vue-paginate.js", "scripts": {