| 1 |
weForms.mixins.Paginate = { |
| 2 |
data: function() { |
| 3 |
return { |
| 4 |
totalItems: 0, |
| 5 |
totalPage: 1, |
| 6 |
currentPage: 1, |
| 7 |
pageNumberInput: 1 |
| 8 |
}; |
| 9 |
}, |
| 10 |
|
| 11 |
methods: { |
| 12 |
isFirstPage: function() { |
| 13 |
return this.currentPage == 1; |
| 14 |
}, |
| 15 |
|
| 16 |
isLastPage: function() { |
| 17 |
return this.currentPage == this.totalPage; |
| 18 |
}, |
| 19 |
|
| 20 |
goFirstPage: function() { |
| 21 |
this.currentPage = 1; |
| 22 |
this.pageNumberInput = this.currentPage; |
| 23 |
|
| 24 |
this.goToPage(); |
| 25 |
}, |
| 26 |
|
| 27 |
goLastPage: function() { |
| 28 |
this.currentPage = this.totalPage; |
| 29 |
this.pageNumberInput = this.currentPage; |
| 30 |
|
| 31 |
this.goToPage(); |
| 32 |
}, |
| 33 |
|
| 34 |
goToPage: function(direction) { |
| 35 |
if ( direction == 'prev' ) { |
| 36 |
this.currentPage--; |
| 37 |
} else if ( direction == 'next' ) { |
| 38 |
this.currentPage++; |
| 39 |
} else { |
| 40 |
if ( ! isNaN( direction ) && ( direction <= this.totalPage ) ) { |
| 41 |
this.currentPage = direction; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
this.pageNumberInput = this.currentPage; |
| 46 |
this.fetchData(); |
| 47 |
}, |
| 48 |
} |
| 49 |
}; |
| 50 |
|