UNPKG

@djs-button-pages/presets

Version:

A set of presets that are used for faster development.

42 lines (41 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const djs_button_pages_1 = require("djs-button-pages"); /** * Bind for button that switches pagination to the last page. */ class LastPageButton extends djs_button_pages_1.ButtonWrapper { /** * Bind for button that switches pagination to the last page. * @param {ButtonData} style Styling for button. */ constructor(style) { super(style); this.setAction(LastPageButton._doAction); this.setSwitch(LastPageButton._switch); } ; /** * Action that switches pagination to the last page. * @param {PaginationSent} pagination Pagination. * @returns {Promise<void>} */ static async _doAction(pagination) { pagination.setPage(pagination.data.embeds.length - 1); return pagination.update(); } ; /** * Switch that disables button on the last page. * @param {PaginationSent} pagination Pagination. * @returns {boolean} Button's state. */ static _switch(pagination) { if (pagination.page === pagination.data.embeds.length - 1) return true; return false; } ; } exports.default = LastPageButton; ;