@djs-button-pages/presets
Version:
A set of presets that are used for faster development.
42 lines (41 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const djs_button_pages_1 = require("djs-button-pages");
/**
* Bind for button that switches pagination to the previous page.
*/
class PreviousPageButton extends djs_button_pages_1.ButtonWrapper {
/**
* Bind for button that switches pagination to the previous page.
* @param {ButtonData} style Styling for button.
*/
constructor(style) {
super(style);
this.setAction(PreviousPageButton._doAction);
this.setSwitch(PreviousPageButton._switch);
}
;
/**
* Action that switches pagination to the previous page.
* @param {PaginationSent} pagination Pagination.
* @returns {Promise<void>}
*/
static async _doAction(pagination) {
pagination.setPage(pagination.page - 1);
return pagination.update();
}
;
/**
* Switch that disables button on the first page.
* @param {PaginationSent} pagination Pagination.
* @returns {boolean}
*/
static _switch(pagination) {
if (pagination.page === 0)
return true;
return false;
}
;
}
exports.default = PreviousPageButton;
;