UNPKG

@djs-button-pages/presets

Version:

A set of presets that are used for faster development.

42 lines (41 loc) 1.22 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 first page. */ class FirstPageButton extends djs_button_pages_1.ButtonWrapper { /** * Bind for button that switches pagination to the first page. * @param {ButtonData} style Styling for button. */ constructor(style) { super(style); this.setAction(FirstPageButton._doAction); this.setSwitch(FirstPageButton._switch); } ; /** * Action that switches pagination to the first page. * @param {PaginationSent} pagination Pagination. * @returns {Promise<void>} */ static async _doAction(pagination) { pagination.setPage(0); return pagination.update(); } ; /** * Switch that disables button on the first page. * @param {PaginationSent} pagination Pagination. * @returns {boolean} Button's state. */ static _switch(pagination) { if (pagination.page === 0) return true; return false; } ; } exports.default = FirstPageButton; ;