![]() 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-form/js/components/ |
Upload File : |
import FCore from "../core/FCore"; import ScalableComponent from "../core/ScalableComponent"; import showdown from 'showdown'; import inheritComponentClass from "../core/inheritComponentClass"; import TextStyleHandlers from "./handlers/TextStyleHandlers"; import {AssemblerInstance} from "../core/Assembler"; import Text from "./Text"; var _ = FCore._; /*** * @extends ScalableComponent * @constructor */ function SelectListText() { ScalableComponent.call(this); this._items = []; this._value = null; this._itemByValue = {}; } inheritComponentClass(SelectListText, ScalableComponent); SelectListText.prototype.tag = "SelectListText"; SelectListText.prototype.menuIcon = "span.mdi.mdi-format-color-text"; SelectListText.prototype.attributeHandlers.items = { /*** * @this SelectListText * @param items */ set: function (items) { items = items || []; this._items = items; this._itemByValue = {}; var dict = this._itemByValue; items.forEach(function visit(item) { dict[item.value] = item; if (item.items && item.items.length > 0) item.items.forEach(visit) }) if (!this._itemByValue[this._value] && this._items.length > 0) { this._value = this._items[0].value; this.pinFire('value'); } this._updateText(); }, get: function () { return this._items; }, descriptor: { type: 'SelectList' } }; SelectListText.prototype.attributeHandlers.treeList = { set: function (value) { this.attributes.items = value; }, get: function () { return this.attributes.items; }, descriptor: { type: 'SelectList' } }; SelectListText.prototype.attributeHandlers.list = SelectListText.prototype.attributeHandlers.treeList; SelectListText.prototype.attributeHandlers.value = { set: function (value) { if (this._value !== value) { this._value = value; this._updateText(); this.pinFire('value'); } }, get: function () { return this._value; } }; Object.assign(SelectListText.prototype.styleHandlers, TextStyleHandlers); SelectListText.prototype.pinHandlers.value = { get: function () { return this.attributes.value; }, receives: function (value) { this.attributes.value = value; }, descriptor: { type: 'number|text' } }; SelectListText.prototype.pinHandlers.text = { get: function () { return this.domElt.value; }, descriptor: { type: 'text' } }; SelectListText.prototype.pinHandlers.items = { receives: function (value) { this.attributes.items = value; }, descriptor: { type: 'SelectList' } }; SelectListText.prototype.pinHandlers.treeList = SelectListText.prototype.pinHandlers.items; SelectListText.prototype.pinHandlers.list = SelectListText.prototype.pinHandlers.items; SelectListText.prototype.onCreate = function () { ScalableComponent.prototype.onCreate.call(this); this.attributes.text = this.attributes.name; this.attributes.textDecode = 'none'; this.style.font = undefined; this.style.fontStyle = undefined; this.style.textSize = 0; this.style.textAlign = 'left'; this.style.textColor = 'black'; this.style.font = 'unset'; }; SelectListText.prototype._updateText = function () { var item = this._itemByValue[this.attributes.value]; var prevText = this.domElt.value; if (item) { this.domElt.value = item.text; } else { this.domElt.value = ''; } if (prevText !== this.domElt.value) { this.pinFire('text'); } // this.attributes.text = this.attributes.text + ''; }; SelectListText.prototype.render = function () { return _('input[type="text"][readonly="true"].as-select-list-text'); }; SelectListText.prototype.createDataBindingDescriptor = function () { var thisC = this; var subObj = {}; Object.defineProperties(subObj, { value: { configurable: true, enumerable: true, set: function (value) { thisC.setAttribute('value', value); }, get: function () { return thisC.getAttribute('value'); } }, items: { enumerable: false, configurable: true, get: function () { return thisC.attributes.items; }, set: function (value) { thisC.attributes.items = value; } }, list: { enumerable: false, configurable: true, get: function () { return thisC.attributes.items; }, set: function (value) { thisC.attributes.items = value; } }, treeList: { enumerable: false, configurable: true, get: function () { return thisC.attributes.items; }, set: function (value) { thisC.attributes.items = value; } }, }); return { set: function (value) { Object.assign(subObj, value); }, get: function () { return subObj; } }; }; AssemblerInstance.addClass(SelectListText); export default SelectListText;