/* global Vue, gl */ /* eslint-disable no-param-reassign */ ((gl) => { gl.VueGlPagination = Vue.extend({ props: [ 'changepage', 'count', 'pagenum', ], methods: { pagestatus(n) { if (this.getItems[1].prev) { if (n === +this.pagenum) return true; } if (n - 1 === +this.pagenum) return true; return false; }, prevstatus(index) { if (index > 0) return false; if (+this.pagenum < 2) return true; return false; }, createSection(n) { return Array.from(Array(n)).map((e, i) => i); }, }, computed: { last() { return Math.ceil(+this.count / 5); }, getItems() { const items = []; const pages = this.createSection(+this.last + 1); pages.shift(); if (+this.pagenum > 1) items.push({ text: 'First', first: true }); items.push({ text: 'Prev', prev: true, class: this.prevstatus() }); pages.forEach(i => items.push({ text: i, number: true })); let nextDisabled = false; if (+this.pagenum === this.last) { nextDisabled = true; } items.push({ text: 'Next', next: true, disabled: nextDisabled }); if (+this.pagenum !== this.last) items.push({ text: 'Last ยป', last: true }); return items; }, }, template: `
`, }); })(window.gl || (window.gl = {}));