![]() 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/checktreebox/MCTBItemHolder.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ACore = require("../../ACore"); var _MCheckTreeItem = _interopRequireDefault(require("./MCheckTreeItem")); var _utils = require("../utils"); /*** * * @param {MCheckTreeBox} boxElt * @param {MCTBItemHolder|CTBModeNormal|CTBModeSearch}parent * @param data * @constructor */ function MCTBItemHolder(boxElt, parent, data) { this.ref = null; this.boxElt = boxElt; this.$list = this.boxElt.$list; this.data = data; this.parent = parent; this.level = parent ? parent.level + 1 : 0; this._elt = null; this.children = null; this.hasIcon = !!data.icon; this.hasDesc = !!data.desc; this.status = 'none'; this.selected = 'none'; this.hasLeaf = data.isLeaf; this.noSelect = data.noSelect; this.hasNoSelect = this.noSelect; if (data.items && data.items.map && data.items.length > 0) { this.children = data.items.map(it => new MCTBItemHolder(boxElt, this, it)); this.hasIcon = this.hasIcon || this.children.some(child => child.hasIcon); this.hasDesc = this.hasDesc || this.children.some(child => child.hasDesc); this.hasLeaf = this.hasLeaf || this.children.some(child => child.hasLeaf); this.hasNoSelect = this.hasNoSelect || this.children.some(child => child.hasNoSelect); this.status = 'close'; } } MCTBItemHolder.prototype.getViewElements = function (ac) { ac = ac || []; ac.push(this.elt); if (this.status === 'open' && this.children) { this.children.forEach(child => child.getViewElements(ac)); } return ac; }; Object.defineProperty(MCTBItemHolder.prototype, 'elt', { get: function () { if (!this._elt) { this._elt = (0, _ACore._)({ tag: this.boxElt.classes.ItemElement, props: { data: this.data, level: this.level, status: this.status, selected: this.selected, hasLeaf: this.hasLeaf, noSelect: this.hasNoSelect }, on: { checkedchange: this.ev_checkedChange.bind(this), statuschange: this.ev_statusChange.bind(this) } }); } return this._elt; } }); MCTBItemHolder.prototype.ev_checkedChange = function () { var selected = this._elt.selected; if (this.ref) { if (selected === 'all') { this.ref.select(true); } else { this.ref.select(false); } this.getRoot().updateSelectedFromRef(); } else { if (selected === 'all') { this.select(true); } else { this.select(false); } } this.boxElt.notifyChange(); }; MCTBItemHolder.prototype.ev_statusChange = function () { if (this._elt.status === this.status) return; var viewElements; if (this.status === 'open') { viewElements = this.getViewElements(); viewElements.shift(); viewElements.forEach(elt => { elt.remove(); }); this.status = this._elt.status; } else if (this.status === 'close') { this.status = this._elt.status; viewElements = this.getViewElements(); viewElements.shift(); (0, _utils.addElementAfter)(this.$list, viewElements, this._elt); } }; MCTBItemHolder.prototype.updateUp = function () { var selected = { child: 0, all: 0, none: 0 /*dont: 0*/ }; var childN = this.children.length; this.children.reduce((ac, child) => { ac[child.selected]++; return ac; }, selected); if (childN === selected.all) { this.selected = 'all'; } else if (childN === selected.none) { this.selected = "none"; } else { this.selected = 'child'; } if (this._elt) { this._elt.selected = this.selected; } if (this.parent) this.parent.updateUp(); }; MCTBItemHolder.prototype.select = function (flag, isDownUpdate) { var leafOnly = this.boxElt.leafOnly; if (flag && leafOnly && !this.hasLeaf) return; var selected = { child: 0, all: 0, none: 0, exclude: 0 /*dont: 0*/ }; var childN = 0; if (this.children && this.children.length > 0) { childN = this.children.length; this.children.reduce((ac, child) => { child.select(flag, true); if (leafOnly && !child.hasLeaf) { ac.exclude++; } else { ac[child.selected]++; } return ac; }, selected); if (leafOnly) { if (this.hasLeaf) { if (childN === selected.all + selected.exclude) { this.selected = 'all'; } else if (selected.all + selected.child > 0) { this.selected = 'child'; } else { this.selected = 'none'; } } else { this.selected = "none"; } } else { if (childN === selected.all) { this.selected = 'all'; } else if (childN === selected.none) { this.selected = "none"; } else { this.selected = 'child'; } } } else { if (flag && (!leafOnly || this.hasLeaf)) { this.selected = 'all'; } else { this.selected = 'none'; } } if (this._elt) { this._elt.selected = this.selected; } if (!isDownUpdate && this.parent) { this.parent.updateUp(); } }; MCTBItemHolder.prototype.getRoot = function () { var c = this; while (c.parent) { c = c.parent; } return c; }; var _default = MCTBItemHolder; /*********************************** ADAPT OLD VERSION ***************************************************************/ exports.default = _default; Object.defineProperty(MCTBItemHolder.prototype, 'item', { get: function () { return this.data; } });