![]() 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/EditableText.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("../css/editabletext.css"); var _ACore = _interopRequireDefault(require("../ACore")); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _AElement = _interopRequireDefault(require("absol/src/HTML5/AElement")); var _ = _ACore.default._; var $ = _ACore.default.$; /*** * @extends AElement * @constructor */ function EditableText() { var thisET = this; this.$span = $('span', this); this.$text = document.createTextNode(''); this.$span.addChild(this.$text); this.$higne = $('.absol-editabe-text-higne', this); this.$input = $('input', this); _OOP.default.drillProperty(this, this.$input, ['selectionStart', 'selectionEnd']); this.sync = new Promise(function (rs) { _('attachhook').addTo(thisET).once('error', rs); }); this.$input.on('keydown', this.eventHandler.inputKeyDown, true); this.$input.on('change', this.eventHandler.inputChange); this.$input.on('blur', this.eventHandler.inputBlur); } ; EditableText.tag = 'EditableText'.toLowerCase(); EditableText.render = function () { return _({ class: 'absol-editabe-text', extendEvent: ['blur', 'focus', 'change', 'modify'], child: [{ class: 'absol-editabe-text-higne', child: '<input type="text">' }, 'span'] }); }; EditableText.prototype.focus = function () { this.$input.focus(); }; EditableText.prototype.blur = function () { this.$input.blur(); }; EditableText.prototype.select = function () { this.$input.select(); }; EditableText.prototype.edit = function (flag, select) { this.editing = !!flag; this.sync = this.sync.then(function () { if (flag) { this.focus(); if (select) this.select(); } else this.blur(); }.bind(this)); return this.sync; }; EditableText.prototype._update = function () { this.sync = this.sync.then(function () { return new Promise(function (rs) { // setTimeout(function () { var bound = this.getBoundingClientRect(); var higneBound = this.$higne.getBoundingClientRect(); var fsize = this.getFontSize(); this.$input.addStyle('width', bound.width + 4 + fsize * 0 + 'px'); this.$input.addStyle('height', bound.height + 4 + 'px'); this.$input.addStyle('left', bound.left - higneBound.left - 2 + 'px'); this.$input.addStyle('top', bound.top - higneBound.top + 'px'); rs(); }.bind(this)); }.bind(this)); }; EditableText.property = {}; EditableText.property.text = { set: function (value) { this.$text.textContent = value; this.$input.value = value; }, get: function () { return this.$text.textContent; } }; EditableText.property.editing = { set: function (value) { if (this._editting === value) return; this._editting = !!value; if (value) { this.$input.value = this.text; this._update(); this.sync = this.sync.then(function () { this.addClass('editing'); this.$input.value = this.text; this.$input.addStyle('font', this.$span.getComputedStyleValue('font')); this.$input.addStyle('font-style', this.$span.getComputedStyleValue('font-style')); this.$input.addStyle('color', this.$span.getComputedStyleValue('color')); }.bind(this)); } else { this.removeClass('editing'); } }, get: function () { return !!this._editting; } }; EditableText.eventHandler = {}; EditableText.eventHandler.inputKeyDown = function (event) { requestAnimationFrame(function () { this.text = this.$input.value; this._update(); event.text = this.text; this.emit('modify', event); }.bind(this)); }; EditableText.eventHandler.inputChange = function (event) { this.editing = false; this.emit('change', event); }; EditableText.eventHandler.inputBlur = function (event) { this.editing = false; this.emit('blur', event); }; _ACore.default.install(EditableText); var _default = EditableText; exports.default = _default;