![]() 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-card/js/taskboard/TLCard.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _Core = _interopRequireDefault(require("../dom/Core")); var _BoardTable = require("absol-acomp/js/BoardTable"); require("../../css/tlcard.css"); var _utils = require("./utils"); var _QuickMenu = _interopRequireDefault(require("absol-acomp/js/QuickMenu")); var _status2Icon = _interopRequireDefault(require("../dom/status2Icon")); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _Color = _interopRequireDefault(require("absol/src/Color/Color")); var _AElement = _interopRequireDefault(require("absol/src/HTML5/AElement")); var _EventEmitter = require("absol/src/HTML5/EventEmitter"); var _datetime = require("absol/src/Time/datetime"); var _ = _Core.default._; var $ = _Core.default.$; /*** * @extends AElement * @constructor */ function TLCard() { var thisC = this; this.$title = $('.tl-card-title', this); this.$body = $('.tl-card-body', this); var thisB = this; this._quickmenuAdapter = { getMenuProps: function () { if (thisB._quickmenu.getMenuProps) { return thisB._quickmenu.getMenuProps(); } return thisB._quickmenu.props; }, onSelect: function () { if (typeof thisB._quickmenu.onSelect == 'function') thisB._quickmenu.onSelect.apply(thisB, arguments); } }; this.$contextBtn = $('.tl-card-context-btn', this); this._quickmenuHolder = null; this._quickmenu = null; this.quickmenu = (0, _utils.createDefaultTaskCardQuickMenu)(); this.$priority = $('.tl-card-priority', this); this._priority = -1; this.$statusCtn = $('.tl-card-status-ctn', this); this._status = []; this.status = []; _OOP.default.drillProperty(this, this, 'name', 'title'); _('attachhook').on('attached', function () { this.remove(); thisC.updateAutoStyleValue(); }).addTo(this); this.addEventListener('click', this.eventHandler.cardNativeClick); } TLCard.tag = "TLCard".toLowerCase(); TLCard.render = function () { return _({ tag: 'board', class: ['tl-card', _BoardTable.DRAG_ZONE_CLASS_NAME], extendEvent: ['click'], child: [{ class: ['tl-card-header'], child: [{ tag: 'div', class: 'tl-card-title', child: [] }, { class: 'tl-card-context-btn-ctn', child: [{ tag: 'button', class: ['tl-card-context-btn', 'tl-transparent-btn'], child: 'span.mdi.mdi-dots-horizontal' }] }] }, { class: 'tl-card-body' }, { class: 'tl-card-footer', child: ['span.mdi.tl-card-priority.tl-card-footer-icon', { class: 'tl-card-status-ctn' }] }] }, true); }; ['addChild', 'findChildBefore', 'findChildAfter', 'removeChild', 'clearChild', 'addChildBefore', 'addChildAfter'].forEach(function (name) { TLCard.prototype[name] = function () { this.$body[name].apply(this.$body, arguments); }; }); TLCard.prototype.updateAutoStyleValue = function () { var backgroundColorStyle = this.getComputedStyleValue('background-color'); var backgroundColor; try { backgroundColor = _Color.default.parse(backgroundColorStyle); } catch (error) { backgroundColor = _Color.default.parse('white'); } var contractColor = backgroundColor.getContrastYIQ(); var hsba = contractColor.toHSBA().slice(); hsba[2] = 0.5 * 0.3 + hsba[2] * 0.7; var lowContractColor = _Color.default.fromHSB(hsba[0], hsba[1], hsba[2]); this.addStyle('--background-yiq-color', contractColor.toString('hex6')); this.addStyle('--background-low-yiq-color', lowContractColor.toString('hex6')); }; TLCard.prototype.addStyle = function () { if (arguments[0] === 'background-color' || arguments[0] === 'background' || arguments[0] === 'backgroundColor') { _AElement.default.prototype.addStyle.apply(this, arguments); this.updateAutoStyleValue(); return this; } else { return _AElement.default.prototype.addStyle.apply(this, arguments); } }; /*** * @memberOf TLCard# * @type {{}} */ TLCard.eventHandler = {}; /*** * @this TLCard * @param event */ TLCard.eventHandler.cardNativeClick = function (event) { if (!(0, _EventEmitter.hitElement)(this.$contextBtn, event)) { this.emit('click', event, this); } }; TLCard.property = {}; /*** * * @type {{}|TLCard} */ TLCard.property.title = { set: function (value) { this.$title.clearChild(); if (value === null || value === undefined) { this._title = null; } this._title = value; if (value !== null) { if (typeof value === 'string' || typeof value === "number") { this.$title.addChild(_({ tag: 'span', child: { text: value } })); } else if (value instanceof Date) { this.$title.addChild(_({ text: (0, _datetime.formatDateTime)(value, 'dd/MM/yyyy hh:mm a') })); } else if (value instanceof Array) { this.$title.addChild(value.map(o => _(o))); } else { this.$title.addChild(_(value)); } } }, get: function () { return this._title || null; } }; TLCard.property.quickmenu = { set: function (value) { value = value || null; if (value) { this.addClass('tl-has-context-menu'); } else { this.removeClass('tl-has-context-menu'); } if (value) { if (!this._quickmenuHolder) this._quickmenuHolder = _QuickMenu.default.toggleWhenClick(this.$contextBtn, this._quickmenuAdapter); } else { if (this._quickmenuHolder) { this._quickmenuHolder.remove(); this._quickmenuHolder = null; } } this._quickmenu = value; }, get: function () { return this._quickmenu; } }; TLCard.property.isLoading = { set: function (value) { value = value || false; if (this._isLoading === value) return; this._isLoading = value; if (!this.$loadingIconCtn && value) { this.$loadingIconCtn = _({ class: 'tl-card-loading-icon-ctn', child: 'spinnericon.tl-card-loading-icon' }); } if (value) { this.appendChild(this.$loadingIconCtn); } else { if (this.$loadingIconCtn) this.$loadingIconCtn.remove(); } }, get: function () { return this._isLoading; } }; /*** * * @type {{}|TLCard} */ TLCard.property.priority = { set: function (value) { if (typeof value !== "number") value = -1; var className; if (this._priority >= 0) { className = this._priority < 10 ? 'mdi-numeric-' + this._priority + '-box' : 'mdi-numeric-9-plus-box'; this.$priority.removeClass(className); if (value < 0) { this.removeClass('tl-has-priority'); } } else { if (value > 0) { this.addClass('tl-has-priority'); } } this._priority = value; if (this._priority >= 0) { className = this._priority < 10 ? 'mdi-numeric-' + this._priority + '-box' : 'mdi-numeric-9-plus-box'; this.$priority.addClass(className); } }, get: function () { return this._priority; } }; TLCard.property.status = { set: function (status) { status = status || ''; if (status.match) { //is string status = status.match(/[^\s,.]+/g); } if (status.reduce) { status = Object.keys(status.reduce(function (ac, cr) { ac[cr] = true; return ac; }, {})); } else { status = []; } if (status.length !== this._status.length) { if (status.length > 0) { this.addClass('tl-has-status'); } else { this.removeClass('tl-has-status'); } } this._status = status; this.$statusCtn.clearChild(); for (var i = 0; i < status.length; ++i) { if (_status2Icon.default[status[i]]) { this.$statusCtn.addChild(_(_status2Icon.default[status[i]]).addClass('tl-card-footer-icon')); } } }, get: function () { return this._status; } }; TLCard.property.star = { get: function () { return this.hasClass('tl-card-has-star'); }, set: function (value) { if (value) { this.addClass('tl-card-has-star'); } else { this.removeClass('tl-card-has-star'); } } }; _Core.default.install(TLCard); var _default = TLCard; exports.default = _default;