![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-acomp/js/PageSelector.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("../css/pageselector.css"); var _ACore = _interopRequireDefault(require("../ACore")); var _ = _ACore.default._; var $ = _ACore.default.$; /*** * @extends AElement * @constructor */ function PageSelector() { this.$pageCount = $('.absol-page-count', this); this.$pageInput = $('.absol-page-number-input input', this); this.$pageInput.on('keyup', this.eventHandler.pressEnterKey); this.$prevBtn = $('li.page-previous', this); this.$nextBtn = $('li.page-next', this); this.$firstBtn = $('li.page-first', this); this.$lastBtn = $('li.page-last', this); this.$nextBtn.on('click', this.eventHandler.clickNext); this.$prevBtn.on('click', this.eventHandler.clickPrev); this.$firstBtn.on('click', this.eventHandler.clickFirst); this.$lastBtn.on('click', this.eventHandler.clickLast); this.$buttonContainer = $('.absol-page-number-buttons', this); this._buttons = []; this._pageOffset = 1; this._selectedIndex = 1; this._pageCount = 1; this._pageRange = 1; this.$pageInput.value = this._selectedIndex; } PageSelector.tag = 'PageSelector'.toLowerCase(); PageSelector.render = function () { return _({ class: ['absol-page-selector'], extendEvent: ['change'], child: [{ class: 'absol-page-number-input', child: [{ tag: 'label', child: { text: "Page" } }, { tag: 'input', attr: { type: 'text' } }, { tag: 'span', child: { text: '/ ' } }, { tag: 'span', class: 'absol-page-count', child: { text: '1' } }] }, { tag: 'ul', class: 'absol-page-number-buttons', child: [{ tag: 'li', class: "page-first", attr: { title: 'First' }, child: 'a.mdi.mdi-chevron-double-left' }, { tag: 'li', attr: { title: 'Previous' }, class: 'page-previous', child: 'a.mdi.mdi-chevron-left' }, { tag: 'li', attr: { title: 'Next' }, class: 'page-next', child: 'a.mdi.mdi-chevron-right' }, { tag: 'li', attr: { title: 'Last' }, class: 'page-last', child: 'a.mdi.mdi-chevron-double-right' }] }] }); }; PageSelector.eventHandler = {}; PageSelector.eventHandler.pressEnterKey = function (event) { if (event.keyCode != 13) return; var index = parseInt(this.$pageInput.value.trim(), 10); if (index < 1 || index > this._pageCount) { this.$pageInput.value = this._selectedIndex; return; } this.selectPage(index, true); }; PageSelector.eventHandler.clickLast = function (event) { this.selectPage(this._pageCount, true); }; PageSelector.eventHandler.clickFirst = function (event) { this.selectPage(1, true); }; PageSelector.eventHandler.clickNext = function (event) { if (this._selectedIndex == this._pageCount) return; this.selectPage(this._selectedIndex + 1, true); }; PageSelector.eventHandler.clickPrev = function (event) { if (this._selectedIndex == 1) return; this.selectPage(this._selectedIndex - 1, true); }; PageSelector.eventHandler.clickIndex = function (index, event) { this.selectPage(index + this._pageOffset, true); }; PageSelector.prototype._createButton = function (index) { var button = _({ tag: 'li', class: 'absol-page-number', child: { tag: 'a', attr: { 'data-index-text': index + 1 } }, on: { click: PageSelector.eventHandler.clickIndex.bind(this, index) } }); this.$buttonContainer.addChildBefore(button, this.$nextBtn); return button; }; PageSelector.prototype.setPageRange = function (pageCount) { this._pageRange = pageCount; while (this._buttons.length < pageCount) { this._buttons.push(this._createButton(this._buttons.length)); } while (this._buttons.length > pageCount) { this._buttons.pop().remove(); } }; PageSelector.prototype.setStartPage = function (index) { this._buttons.forEach(function (e, i) { e.firstChild.attr('data-index-text', i + index + ''); }); this._pageOffset = index; }; PageSelector.prototype.selectPage = function (index, userActive) { if (index == this._selectedIndex) this.setStartPage(index - parseInt(this._pageRange / 2)); if (index >= this._pageOffset + this._pageRange) this.setStartPage(index - parseInt(this._pageRange / 2)); if (index > this._selectedIndex) { if (index == this._pageOffset + this._pageRange - 1) this.setStartPage(index - parseInt(this._pageRange / 2)); } if (index < this._selectedIndex) { if (index == this._pageOffset) this.setStartPage(index - parseInt(this._pageRange / 2)); } if (index > this._pageCount - parseInt(this._pageRange / 2)) this.setStartPage(this._pageCount - this._pageRange + 1); if (index <= parseInt(this._pageRange / 2)) this.setStartPage(1); var pageOffset = this._pageOffset; this._buttons.forEach(function (e, i) { if (i + pageOffset == index) { e.addClass('active'); } else { e.removeClass('active'); } }); if (this._selectedIndex != index) { this._selectedIndex = index; this.$pageInput.value = index; this.emit('change', { target: this, selectedIndex: index, userActive: !!userActive }, this); } }; PageSelector.prototype.getSelectedPage = function () { return this._selectedIndex; }; PageSelector.prototype.setPageCount = function (count) { this._pageCount = count; this.$pageCount.firstChild.data = '' + count; this.attr('data-page-count', count); }; PageSelector.property = {}; PageSelector.property.selectedIndex = { set: function (value) { this.selectPage(value, false); }, get: function () { return this._selectedIndex; } }; PageSelector.property.pageCount = { set: function (value) { this.setPageCount(value); }, get: function () { return this._pageCount; } }; PageSelector.property.pageOffset = { set: function (value) { this.setStartPage(value); }, get: function () { return this._pageOffset; } }; PageSelector.property.pageRange = { set: function (value) { this.setPageRange(value); }, get: function () { return this._pageRange; } }; PageSelector.prototype.init = function (props) { props = props || {}; props.pageOffset = props.pageOffset || 1; props.pageRange = props.pageRange || 5; props.pageCount = props.pageCount || 15; props.selectedIndex = typeof props.selectedIndex == "number" ? props.selectedIndex : props.pageOffset; if (props.pageCount < props.pageRange) props.pageRange = props.pageCount; this.setPageCount(props.pageCount); this.setPageRange(props.pageRange); this.setStartPage(props.pageOffset); this.selectPage(props.selectedIndex); props = Object.assign({}, props); delete props.pageOffset; delete props.pageRange; delete props.pageCount; delete props.selectedIndex; }; _ACore.default.install(PageSelector); var _default = PageSelector; exports.default = _default;