| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Pagination. |
| 5 |
* |
| 6 |
* @since 3.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
?> |
| 10 |
|
| 11 |
<script type="text/x-template" id="tmpl-lp-pagination"> |
| 12 |
<div class="pagination" v-if="total > 1"> |
| 13 |
<form prevent.submit=""> |
| 14 |
<button class="button first" :disabled="page == 1" v-if="total > 2 && page > 1 && page != 2" |
| 15 |
@click.prevent="previousFirstPage">« |
| 16 |
</button> |
| 17 |
<button class="button previous" :disabled="page == 1" |
| 18 |
@click.prevent="previousPage"><?php echo esc_html_x( 'Previous', 'page-navigation', 'learnpress' ); ?></button> |
| 19 |
<button class="button next" :disabled="page == total" |
| 20 |
@click.prevent="nextPage"><?php echo esc_html_x( 'Next', 'page-navigation', 'learnpress' ); ?></button> |
| 21 |
<button class="button last" :disabled="page == total" |
| 22 |
v-if="total > 2 && page < total && page != (total - 1)" |
| 23 |
@click.prevent="nextLastPage">» |
| 24 |
</button> |
| 25 |
<span class="index">{{page}} / {{total}}</span> |
| 26 |
</form> |
| 27 |
</div> |
| 28 |
</script> |
| 29 |
|
| 30 |
<script type="text/javascript"> |
| 31 |
window.$Vue = window.$Vue || Vue; |
| 32 |
|
| 33 |
jQuery( function( $ ) { |
| 34 |
( function( $store ) { |
| 35 |
$Vue.component( 'lp-pagination', { |
| 36 |
template: '#tmpl-lp-pagination', |
| 37 |
props: ['total'], |
| 38 |
data: function () { |
| 39 |
return { page: 1 } |
| 40 |
}, |
| 41 |
methods: { |
| 42 |
update: function() { |
| 43 |
this.$emit( 'update', this.page ); |
| 44 |
}, |
| 45 |
nextPage: function() { |
| 46 |
if ( this.page < this.total ) { |
| 47 |
this.page++; |
| 48 |
this.update(); |
| 49 |
} |
| 50 |
}, |
| 51 |
nextLastPage: function() { |
| 52 |
if ( this.page < this.total ) { |
| 53 |
this.page = this.total; |
| 54 |
this.update(); |
| 55 |
} |
| 56 |
}, |
| 57 |
previousPage: function() { |
| 58 |
if ( this.page > 1 ) { |
| 59 |
this.page--; |
| 60 |
this.update(); |
| 61 |
} |
| 62 |
}, |
| 63 |
previousFirstPage: function() { |
| 64 |
if ( this.page > 1 ) { |
| 65 |
this.page = 1; |
| 66 |
this.update(); |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
}); |
| 71 |
})( LP_Curriculum_Store ); |
| 72 |
}); |
| 73 |
</script> |
| 74 |
|