vue-paginate
Advanced tools
Comparing version 2.1.1 to 2.1.2
/*! | ||
* vue-paginate v2.1.0 | ||
* vue-paginate v2.1.2 | ||
* (c) 2016 Taha Shashtari | ||
@@ -208,3 +208,3 @@ * Released under the MIT License. | ||
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; | ||
@@ -266,2 +266,3 @@ | ||
_this.originalList = newVal; | ||
_this.setNumberOfPages(_this.originalList.length); | ||
vm['refresh' + utils.capitalize(_this.listName) + 'Page'](); | ||
@@ -268,0 +269,0 @@ }); |
/*! | ||
* vue-paginate v2.1.0 | ||
* 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;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;e<t.length;e++){var s=t[e];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(i,s.key,s)}}return function(t,e,s){return e&&i(t.prototype,e),s&&i(t,s),t}}(),a=function(i){if(Array.isArray(i)){for(var t=0,e=Array(i.length);t<i.length;t++)e[t]=i[t];return e}return Array.from(i)},n="»",r="«",l="…",h=function(){function i(t,s,a){e(this,i),this.vm=t,this.list=s,this.listName=a}return s(i,[{key:"generate",value:function(i){this.limit=i||4;var e=[];return this.shouldShowLeftArrow()&&e.push(r),this.rightArrowOrElipsesIsClicked()&&(e[0]!==r&&e.push(r),this.showNextNavSet()),this.leftArrowIsClicked()&&(this.list.initial<=this.limit&&e[0]===r&&e.shift(),this.showPreviousNavSet()),this.lastPageIsClicked()&&(e[0]!==r&&e.push(r),this.showLastNavSet()),e.push(this.list.initial+1),this.limit=this.limit>this.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<this.initialOfLastNav(this.limit)}}]),i}(),u={twoWay:!0,params:["limit"],bind:function(){var e=this;i.Vue.config.silent=!0;var s=this.vm;this.listName=this.expression;var a=this.getPerPage(),n=+this.params.limit;if(!s[this.listName])throw new Error('[vue-paginate] the list name "'+this.listName+'" is not defined in your vm instance.');this.originalList=s[this.listName],s.$set("full"+t.capitalize(this.listName),this.originalList),s.$watch("full"+t.capitalize(this.listName),function(i,a){e.originalList=i,s["refresh"+t.capitalize(e.listName)+"Page"]()}),this.isPerPageDynamic()&&s.$watch(this.arg,function(i){e.list.perPage=0>=+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+1<e.list.numberOfPages?e.list.currentPage+1:e.list.currentPage},s["prev"+t.capitalize(this.listName)+"Page"]=function(){s[e.listName]=e.originalList,e.list.currentPage=e.list.currentPage-1>0?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})}); | ||
!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;e<t.length;e++){var s=t[e];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(i,s.key,s)}}return function(t,e,s){return e&&i(t.prototype,e),s&&i(t,s),t}}(),a=function(i){if(Array.isArray(i)){for(var t=0,e=Array(i.length);t<i.length;t++)e[t]=i[t];return e}return Array.from(i)},n="»",r="«",l="…",h=function(){function i(t,s,a){e(this,i),this.vm=t,this.list=s,this.listName=a}return s(i,[{key:"generate",value:function(i){this.limit=i||4;var e=[];return this.shouldShowLeftArrow()&&e.push(r),this.rightArrowOrElipsesIsClicked()&&(e[0]!==r&&e.push(r),this.showNextNavSet()),this.leftArrowIsClicked()&&(this.list.initial<=this.limit&&e[0]===r&&e.shift(),this.showPreviousNavSet()),this.lastPageIsClicked()&&(e[0]!==r&&e.push(r),this.showLastNavSet()),e.push(this.list.initial+1),this.limit=this.limit>this.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<this.initialOfLastNav(this.limit)}}]),i}(),u={twoWay:!0,params:["limit"],bind:function(){var e=this;i.Vue.config.silent=!0;var s=this.vm;this.listName=this.expression;var a=this.getPerPage(),n=+this.params.limit;if(!s[this.listName])throw new Error('[vue-paginate] the list name "'+this.listName+'" is not defined in your vm instance.');this.originalList=s[this.listName],s.$set("full"+t.capitalize(this.listName),this.originalList),s.$watch("full"+t.capitalize(this.listName),function(i,a){e.originalList=i,e.setNumberOfPages(e.originalList.length),s["refresh"+t.capitalize(e.listName)+"Page"]()}),this.isPerPageDynamic()&&s.$watch(this.arg,function(i){e.list.perPage=0>=+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+1<e.list.numberOfPages?e.list.currentPage+1:e.list.currentPage},s["prev"+t.capitalize(this.listName)+"Page"]=function(){s[e.listName]=e.originalList,e.list.currentPage=e.list.currentPage-1>0?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})}); |
{ | ||
"name": "vue-paginate", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "A simple vue.js plugin to paginate data", | ||
@@ -5,0 +5,0 @@ "main": "dist/vue-paginate.js", |
@@ -46,2 +46,3 @@ import {Vue} from './index'; | ||
this.originalList = newVal; | ||
this.setNumberOfPages(this.originalList.length); | ||
vm['refresh' + utils.capitalize(this.listName) + 'Page'](); | ||
@@ -48,0 +49,0 @@ }); |
@@ -136,2 +136,18 @@ import {should} from 'chai'; should(); | ||
}); | ||
it('updates the links when the list is updated', (done) => { | ||
vm = new Vue({ | ||
template: '<div v-paginate:1="langs" limit="6">Hello</div>', | ||
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(); | ||
}); | ||
}); | ||
}); | ||
@@ -138,0 +154,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46881
862