![]() 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/SpanInput.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("../css/spaninput.css"); var _ACore = _interopRequireDefault(require("../ACore")); var _utils = require("./utils"); var _Text = require("absol/src/HTML5/Text"); var _ = _ACore.default._; var $ = _ACore.default.$; function SpanInput() { this.defineEvent(['change']); this._inputType = 0; this._lastValue = null; this.on('paste', this.eventHandler.paste).on('keyup', this.eventHandler.keyup).on('keydown', this.eventHandler.keydown).on('blur', this.eventHandler.blur); } SpanInput.prototype.notifyValueChange = function (event) { var cValue = this.value; if (this._lastValue != cValue && (this._inputType != 1 || !isNaN(this._lastValue) || !isNaN(cValue))) { this._lastValue = cValue; this.emit('change', { type: 'change', value: cValue, originEvent: event }, this); } }; SpanInput.eventHandler = {}; SpanInput.eventHandler.keyup = function (event) { if (this._inputType == 0) { this.notifyValueChange(event); } else if (this._inputType == 1) { this.eventHandler.numberKeyup(event); } }; SpanInput.eventHandler.keydown = function (event) { if (this._inputType == 0) {} else if (this._inputType == 1) { this.eventHandler.numberKeydown(event); } }; SpanInput.eventHandler.numberBlur = function (value) { this.notifyValueChange(event); }; SpanInput.eventHandler.textBlur = function (event) { this.notifyValueChange(event); }; SpanInput.eventHandler.blur = function (event) { if (this._inputType == 0) { this.eventHandler.textBlur(event); } else if (this._inputType == 1) { this.eventHandler.numberKeydown(event); } }; SpanInput.eventHandler.numberKeyup = function (event) { this.notifyValueChange(); }; SpanInput.eventHandler.numberKeydown = function (event) { var key = event.key; if (key == 'Enter') { event.preventDefault(); this.blur(); this.notifyValueChange(); return; } if (key && key.length == 1 && !event.ctrlKey && !event.altKey) { if (key.match(/[0-9.\-\+]/)) { if (key == '.' && this.text.indexOf('.') >= 0) event.preventDefault(); if ((key == '+' || key == '-') && (this.text.indexOf('+') >= 0 || this.text.indexOf('-') >= 0 || getCaretPosition(this) > 0)) event.preventDefault(); } else event.preventDefault(); } }; SpanInput.eventHandler.paste = function (event) { event.preventDefault(); if (event.clipboardData && event.clipboardData.getData) { var text = event.clipboardData.getData("text/plain"); if (this._inputType == 1) text = text.replace(/[^0-9.\-+]/g, ''); document.execCommand("insertHTML", false, text); if (this._inputType == 1) { if (isNaN(this.value)) { this.value = NaN; } } } else if (window.clipboardData && window.clipboardData.getData) { var text = window.clipboardData.getData("Text"); if (this._inputType == 1) text = text.replace(/[^0-9.\-+]/g, ''); (0, _utils.insertTextAtCursor)(text); if (this._inputType == 1) { if (isNaN(this.value)) { this.value = NaN; } } } }; SpanInput.property = {}; SpanInput.property.value = { set: function (value) { if (this._inputType == 1 && isNaN(value)) value = null; this.clearChild(); if (value !== null) this.addChild(_({ text: value + '' })); }, get: function () { if (this._inputType == 1) { return parseFloat(this.text); } else { return this.text; } } }; SpanInput.property.type = { set: function (value) { var index = ['text', 'number'].indexOf(value); if (index < 0) index = 0; this._inputType = index; if (index == 1) { this.addClass('absol-span-input-empty-minus'); } else { this.removeClass('absol-span-input-empty-minus'); } }, get: function () { return ['text', 'number'][this._inputType]; } }; SpanInput.property.text = { get: function () { return (0, _Text.getTextIn)(this); } }; SpanInput.tag = 'spaninput'; SpanInput.render = function () { return _('span.absol-span-input[contenteditable="true"]'); }; _ACore.default.install(SpanInput); var _default = SpanInput; exports.default = _default;