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