![]() 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/CheckTreeLeafOnlyBox.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TreeLeafOnlyNodeHolder = TreeLeafOnlyNodeHolder; exports.default = void 0; var _ACore = _interopRequireWildcard(require("../ACore")); var _CheckTreeBox = _interopRequireWildcard(require("./CheckTreeBox")); var _CheckTreeItem = _interopRequireDefault(require("./CheckTreeItem")); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _LanguageSystem = _interopRequireDefault(require("absol/src/HTML5/LanguageSystem")); var _utils = require("./utils"); var _BrowserDetector = _interopRequireDefault(require("absol/src/Detector/BrowserDetector")); var _Searcher = _interopRequireDefault(require("./Searcher")); var normalizeItem = item => { var nItem = Object.assign({}, item); if (!nItem.isLeaf && nItem.noSelect) { delete nItem.noSelect; } if (nItem.items && nItem.items.map) nItem.items = normalizeItems(nItem.items); return nItem; }; var normalizeItems = items => { return items.map(it => normalizeItem(it)); }; var verifyItems = items => { var leafDict = {}; var subTreeDict = {}; var visit = () => {}; items.forEach(visit); }; /*** * Only tree has leaf can be selected * @extends CheckTreeBox * @constructor */ function CheckTreeLeafOnlyBox() { _CheckTreeBox.default.apply(this, arguments); } CheckTreeLeafOnlyBox.tag = 'CheckTreeLeafOnlyBox'.toLowerCase(); CheckTreeLeafOnlyBox.render = function () { var mobile = arguments[1] && arguments[1].forceMobile || _BrowserDetector.default.isMobile; var footer = { class: 'as-dropdown-box-footer', child: [{ tag: 'checkbox', class: 'as-select-list-box-check-all', props: { checked: false, text: _LanguageSystem.default.getText('txt_check_all') || _LanguageSystem.default.getText('txt_all') || 'Check All' } }, { class: 'as-dropdown-box-footer-right', child: [{ tag: 'a', class: 'as-select-list-box-cancel-btn', attr: { "data-ml-key": 'txt_cancel' } }].concat(mobile ? [] : [{ tag: 'a', class: 'as-select-list-box-close-btn', attr: { "data-ml-key": 'txt_close' } }]) }] }; var content = { class: ['as-check-tree-box-scroller', 'as-bscroller', 'as-select-list-box-scroller'], child: { class: ['as-check-tree-box-content', 'as-select-list-box-content'], child: Array(this.prototype.preLoadN).fill('.as-select-list-box-page') } }; if (mobile) { return (0, _ACore._)({ props: { mobile: true }, extendEvent: ['change', 'close', 'toggleitem', 'cancel'], class: ['am-check-tree-box-modal', 'am-modal', 'am-dropdown-box-modal'], child: { class: ['am-check-tree-box', 'am-dropdown-box', 'as-dropdown-box-common-style'], child: [{ class: 'am-dropdown-box-header', child: [{ tag: _Searcher.default.tag }, { tag: 'button', class: 'am-dropdown-box-close-btn', child: 'span.mdi.mdi-close' }] }, content, footer] } }); } return (0, _ACore._)({ tag: 'follower', extendEvent: ['change', 'toggleitem', 'cancel', 'close'], class: ['as-check-tree-leaf-only-box', 'as-check-tree-box', 'as-select-list-box', 'as-anchor-1'], child: [{ class: 'as-select-list-box-search-ctn', child: 'searchtextinput' }, content, footer], props: { anchor: [1, 6, 2, 5] } }); }; Object.assign(CheckTreeLeafOnlyBox.prototype, _CheckTreeBox.default.prototype); CheckTreeLeafOnlyBox.property = Object.assign({}, _CheckTreeBox.default.property); CheckTreeLeafOnlyBox.eventHandler = Object.assign({}, _CheckTreeBox.default.eventHandler); CheckTreeLeafOnlyBox.prototype._pool = []; CheckTreeLeafOnlyBox.property.items = { get: _CheckTreeBox.default.property.items.get, set: function (items) { items = normalizeItems(items || []); verifyItems(items); _CheckTreeBox.default.property.items.set.call(this, items); } }; CheckTreeLeafOnlyBox.prototype._requestItem = function () { var res = this._pool.pop() || (0, _ACore._)({ tag: _CheckTreeItem.default.tag, class: 'as-check-tree-leaf-only-item', props: { menuElt: this }, on: { presstoggle: function (event) { this.menuElt.eventHandler.toggleItem(this, event); }, select: function (event) { this.menuElt.eventHandler.selectItem(this, event); } } }); res.menuElt = this; return res; }; CheckTreeLeafOnlyBox.prototype.HolderClass = TreeLeafOnlyNodeHolder; _ACore.default.install(CheckTreeLeafOnlyBox); var _default = CheckTreeLeafOnlyBox; /*** * @extends TreeRootHolder * @param {CheckTreeLeafOnlyBox} boxElt * @param items * @constructor */ exports.default = _default; function TreeLeafOnlyRootHolder(boxElt, items) { _CheckTreeBox.TreeRootHolder.apply(this, arguments); } CheckTreeLeafOnlyBox.prototype.RootHolderClass = TreeLeafOnlyRootHolder; _OOP.default.mixClass(TreeLeafOnlyRootHolder, _CheckTreeBox.TreeRootHolder); /*** * @extends TreeNodeHolder * @constructor */ function TreeLeafOnlyNodeHolder() { _CheckTreeBox.TreeNodeHolder.apply(this, arguments); /*** * @memberOf TreeLeafOnlyNodeHolder# * @type {number} */ this.leafCount = 0; if (this.item.isLeaf) { this.leafCount = 1; } else { this.leafCount = this.child.reduce((ac, c) => ac + c.leafCount, 0); } if (this.child.length > 0) { this.item.noSelect = this.child.every(c => c.item.noSelect); //all child is noSelect=> noSelect } this.canSelect = this.canSelect && this.leafCount > 0; this.canSelectAll = this.canSelect && !this.item.noSelect && this.child.every(c => c.canSelectAll || c.leafCount === 0); if (this.leafCount === 0) this.selected = 'empty'; } _OOP.default.mixClass(TreeLeafOnlyNodeHolder, _CheckTreeBox.TreeNodeHolder); TreeLeafOnlyRootHolder.prototype.SubHolderClass = TreeLeafOnlyNodeHolder; TreeLeafOnlyNodeHolder.prototype.setValues = function (values) { if (values[(0, _utils.keyStringOf)(this.item.value)]) { this.selectAll(true); } else { this.child.forEach(c => c.setValues(values)); } this.updateFromChild(); }; TreeLeafOnlyNodeHolder.prototype.getValues = function (ac) { ac = ac || []; if (this.selected === 'all' && this.item.isLeaf) { ac.push(this.item.value); } else { this.child.forEach(c => c.getValues(ac)); } return ac; }; TreeLeafOnlyNodeHolder.prototype.getViewValues = function (ac) { ac = ac || []; if (this.selected === 'all') { ac.push(this.item.value); } else if (this.selected === 'child') { this.child.forEach(c => c.getViewValues(ac)); } return ac; }; /*** * * @param {boolean=} isDownUpdate */ TreeLeafOnlyNodeHolder.prototype.selectAll = function (isDownUpdate) { if (this.selected === 'empty') return; return _CheckTreeBox.TreeNodeHolder.prototype.selectAll.apply(this, arguments); }; TreeLeafOnlyNodeHolder.prototype.unselectAll = function (isDownUpdate) { if (this.selected === 'empty') return; return _CheckTreeBox.TreeNodeHolder.prototype.unselectAll.apply(this, arguments); }; TreeLeafOnlyNodeHolder.prototype.updateFromChild = function () { if (this.child.length === 0) return; var count = this.child.reduce((ac, cr) => { ac[cr.selected]++; return ac; }, { all: 0, child: 0, none: 0, empty: 0 }); // if (this.boxElt.debug) // console.log( this.item, count.empty , count.all, this.child.length);//0, 9, 10 if (count.empty === this.child.length) { this.selected = 'empty'; } else if (count.empty + count.all === this.child.length) { this.selected = 'all'; } else if (count.all + count.child > 0) { this.selected = 'child'; } else if (this.selected !== "empty") { this.selected = 'none'; } if (this.itemElt) { this.itemElt.selected = this.selected; } };