From be1f74d5778fa6a0b9129f2e303fc9e8b85cc0fc Mon Sep 17 00:00:00 2001 From: Taha Shashtari Date: Sat, 3 Sep 2016 14:47:45 +0300 Subject: [PATCH] Revert "Fix limited links update bug" This reverts commit 0268bf9391e473dc568ba9fd56a81d9f30ad3dd8. --- dist/vue-paginate.js | 5 ++--- dist/vue-paginate.min.js | 4 ++-- dist/vue-paginate.min.js.gz | Bin 1925 -> 1915 bytes package.json | 2 +- src/paginate.js | 1 - test/functional/test.js | 16 ---------------- 6 files changed, 5 insertions(+), 23 deletions(-) diff --git a/dist/vue-paginate.js b/dist/vue-paginate.js index 4fb7c9b..83d679b 100644 --- a/dist/vue-paginate.js +++ b/dist/vue-paginate.js @@ -1,5 +1,5 @@ /*! - * vue-paginate v2.1.2 + * vue-paginate v2.1.0 * (c) 2016 Taha Shashtari * Released under the MIT License. */ @@ -205,7 +205,7 @@ }, { key: 'initialOfLastNav', value: function initialOfLastNav() { - var numberOfNavs = ~~(this.list.numberOfPages / this.limit); + var numberOfNavs = ~ ~(this.list.numberOfPages / this.limit); var rest = this.list.numberOfPages - this.limit * numberOfNavs; rest = rest <= 1 ? rest + this.limit : rest; @@ -262,7 +262,6 @@ // 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'](); }); diff --git a/dist/vue-paginate.min.js b/dist/vue-paginate.min.js index 1f054d8..ad84d2c 100644 --- a/dist/vue-paginate.min.js +++ b/dist/vue-paginate.min.js @@ -1,6 +1,6 @@ /*! - * vue-paginate v2.1.2 + * vue-paginate v2.1.0 * (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;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 +!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 3d8d41f6f5b1be566fcafd65095931de59000479..7faba006911fb950b670a30204ca6cb9a3169ba4 100644 GIT binary patch delta 1906 zcmV-&2aWiJ5Bm;~9)GZhHWq0v0!$9rr0s=aEExH>%|@0ClCm?kwdm9IrjM|9`zU>q z{t~H^C1qz8SriCji6Z~Q_n$d0o)5lro;$|`ZVr4aBCf$X-ue@NoGp6+ac;+xKRX}! zjyoTAT0kLVI=>nYsnJih?;c9GYLB@7D|S z=q+7)&RrqzsrH2bw*=l>9a-b;ayh3Y_4H0CT8WGTCkh;;r9h!)M~+&ubHEQm^HBT~ zruD57bRr{1_A?Gq}@M&KaPH=WJauy@b_F z`4FMDl79+;)n6``!GtP5h@*|zCg%HKOx+_76L1A8n4@u$Xh-vn(093K`o?$O%NXsZ zA5a|Se}9Gtsz{nza7wu~1za!ej(`eJ`v)28ICD)3gsOZEH&LCY9zk2w9R?B2E$<8C z0k~GFuGtt(VAm}GWTx+m=b1(@V5wJ3;D3eTpb*j!-pF{5R8tx;_t#%sD)Hw(E)ALc z-+%qvrMn&*pv07uGnjA?C_VoA$34^LDHKXGRewFd<$H9~g0(`>mS+TQ>K0z^(j56l zxY*Nsp_#Z`{xmc8UY4rl-_@N@EU!C&+uxRZU*Ip(WaAQgFy2t{&&rR*aWVAm42=0o0;r zeOetwhlDJs0Oui2tx{521Lj08azxzEx03;wydocfh@g{k(;q~SDl_t zre3$gea`nS*w^^fT&SHoo^C(cFj6yfJce4^AU9nGx%s0EQjvX(W$dYMZ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}wGGNPqt`d%zOqxdo?^TVV$4rQHEg?kWEuQk81g#0+6stidL%^4vpUi>AW>qJ`ys zZae_iYSk5)f(h)p1pv*}UHLp$00vvBHR14IX*gC2X$Wscx(BK`PKf*KFD@4F^B)(- z#QpET{_Wyuzy=^Ors&K}IB<|2e*NQ~DDxC^seg#9pWo6wxM|5+0%)r&_bdF_UdXp>pVp@6u4T+~}3UOqALZmR{5 z%YpTvJ_-)WbWnvWHugmAXzkQQ8E6S2R}xFFcSi@z7_yH zFuq)dJ|#_E8?OIkHE+6#H5Fg>_(DT*T+}a{R#q-l%w)&h2}oPj)|!A$FKFUww(h#u z(^25{D?H?U--3OEPs4?}spIMP6D=dPGsk17bq#XUXONpe${;n_$5_Um`qnnlZhui* z^eR;RFT)hVF_>rhLY=!?I>^n*QTj!dJ(={MH zjC7a5$EB_>fHwF*1>MVF8aw9ZeSxek|(9!czk2}6wYkY>U;?yGsme};@6Db!-18{ZdA?v*Go4S#$up=*FS zG>*R-Ah<&e>BA?g!ss!_8^f1w#oJIv!G!-#35p@(+(;_H6kBJ9C(9J50H7sk=HY#S_ zl!0csmNd(jPQd7k@)#aA;%%TzUyr zq4%<0^N_t(>pk(jUbPWFFKKw?bsE&zNoO0%GH}<1jMRzxsUh+0P{N zLWIqq5q$f{01{%pa)A`hVrYKhb?D~T{plwr-xP;kd^UagXbP4?^Zx-<#*;WS82|t+ ChqPD# diff --git a/package.json b/package.json index 93b577d..5a69aae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-paginate", - "version": "2.1.2", + "version": "2.1.1", "description": "A simple vue.js plugin to paginate data", "main": "dist/vue-paginate.js", "scripts": { diff --git a/src/paginate.js b/src/paginate.js index 5a39feb..1933ca0 100644 --- a/src/paginate.js +++ b/src/paginate.js @@ -43,7 +43,6 @@ export default { // Update the original list when the user changes the full list. vm.$watch('full' + utils.capitalize(this.listName), (newVal, oldVal) => { this.originalList = newVal; - this.setNumberOfPages(this.originalList.length); vm['refresh' + utils.capitalize(this.listName) + 'Page'](); }); diff --git a/test/functional/test.js b/test/functional/test.js index 944d7d6..4d5d8d9 100644 --- a/test/functional/test.js +++ b/test/functional/test.js @@ -133,22 +133,6 @@ describe('Vue-Paginate', () => { vm.$data.limitedLangsLinks.should.eql([1, 2, 3, 4, 5, 6, 7]); }); - - it('updates the links when the list is updated', (done) => { - vm = new Vue({ - template: '
Hello
', - data: { - langs: ['PHP'] - } - }).$mount(); - - vm.$data.fullLangs = ['PHP', 'JavaScript', 'HTML', 'CSS', 'Ruby', 'Python', 'Erlang']; - - Vue.nextTick(() => { - vm.$data.limitedLangsLinks.should.eql([1, 2, 3, 4, 5, 6, 7]); - done(); - }); - }); }); describe('Dynamic perPage', () => {