![]() 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/TableVScroller.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("../css/tablevscroller.css"); var _ACore = _interopRequireDefault(require("../ACore")); var _Dom = _interopRequireWildcard(require("absol/src/HTML5/Dom")); var _utils = require("./utils"); var _ = _ACore.default._; var $ = _ACore.default.$; function TableVScroller() { var thisTS = this; this.$attachHook = $('attachhook', this); this.$attachHook.updateSize = () => { this.updateStyle(); this.updateSize(); }; this.sync = new Promise(function (rs) { thisTS.$attachHook.on('attached', rs); }); this.$viewport = $('.absol-table-vscroller-viewport', this); this.$attachHook.on('attached', function () { _Dom.default.addToResizeSystem(thisTS.$attachHook); this.updateSize(); }); this.$topTable = $('.absol-table-vscroller-head', this); this.$headLine = $('.absol-table-vscroller-head-line', this); this.swappedContentPairs = []; } TableVScroller.tag = 'TableVScroller'.toLowerCase(); TableVScroller.render = function () { return _({ class: 'absol-table-vscroller', child: ['.absol-table-vscroller-viewport', 'table.absol-table-vscroller-head', '.absol-table-vscroller-head-line', 'attachhook'] }); }; TableVScroller.prototype.clearChild = function () { this.$viewport.clearChild(); this.$topTable.clearChild(); }; TableVScroller.prototype.addChild = function (elt) { if (this.$viewport.childNodes.length == 0) { this.$table = elt.$table || $('table', elt); if (this.$table) { this.$viewport.addChild(elt); this.update(); } else { throw new Error('Element must be a table!'); } } else { throw new Error("Only 1 table accepted!"); } }; TableVScroller.prototype._trackBackgroundColor = function (element) { var current = this.$thead; var res; while (current && !res && res != 'rgba(0, 0, 0, 0)') { res = window.getComputedStyle(element).getPropertyValue('background-color'); current = current.parentNode; } if (res == 'rgba(0, 0, 0, 0)') return 'white'; return res; }; TableVScroller.prototype.updateStyle = function () { if (!this.$thead) return; var clazz = this.$table.attr('class'); if (clazz) { clazz = clazz.trim().split(/\s+/); for (var i = 0; i < clazz.length; ++i) { this.$topTable.addClass(clazz[i]); } } var bgColor = this._trackBackgroundColor(this.$thead); this.$topTable.addStyle('background-color', bgColor); }; TableVScroller.prototype.updateSize = function () { if (!this.$thead) return; var theadBound = this.$thead.getBoundingClientRect(); var tableBound = this.$table.getBoundingClientRect(); this.$topTable.addStyle({ width: tableBound.width + 'px', height: theadBound.height + 'px' }); this.$headLine.addStyle({ top: theadBound.height + 'px', maxWidth: tableBound.width + 'px' }); if (this.$viewport.clientHeight < this.$viewport.scrollHeight) { this.addClass('scroll-v'); } else { this.removeClass('scroll-v'); } var realNodes = this.$tr.childNodes; var topNodes = this.$topTr.childNodes; var widthStyle; var displayStyle; for (var i = 0; i < realNodes.length; ++i) { if (!realNodes[i].tagName) continue; widthStyle = $(realNodes[i]).getComputedStyleValue('width'); displayStyle = realNodes[i].getComputedStyleValue('display'); if (!widthStyle) { widthStyle = realNodes[i].getBoundingClientRect().width; if (!widthStyle) { displayStyle = 'none'; } widthStyle += 'px'; } // console.trace(getAncestorElementOf(realNodes[i]), widthStyle, displayStyle) $(topNodes[i]).attr('style', realNodes[i].attr('style')).addStyle('width', widthStyle).addStyle('display', displayStyle); } this.$topTable.removeStyle('display'); }; TableVScroller.prototype.updateContent = function () { this.swappedContentPairs.forEach((originElt, copyElt) => { this.swappedContentPairs.push([originElt, copyElt]); }); this.swappedContentPairs = []; var elt = this.$table; this.$thead = $('thead', elt); this.$tr = $('tr', this.$thead); this.$topThead = (0, _Dom.depthClone)(this.$thead, (originElt, copyElt) => { if (originElt.tagName === 'TH') { (0, _utils.swapChildrenInElt)(originElt, copyElt); this.swappedContentPairs.push([originElt, copyElt]); } }); this.$topTr = $('tr', this.$topThead); this.$topTable.clearChild().addChild(this.$topThead).addStyle('display', 'none'); }; TableVScroller.prototype.update = function () { if (!this.$table) return; this.updateContent(); this.updateStyle(); this.updateSize(); }; _ACore.default.install(TableVScroller); var _default = TableVScroller; exports.default = _default;