![]() 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-form/js/anchors/HyperAnchor.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _FCore = _interopRequireDefault(require("../core/FCore")); var _FViewable = _interopRequireDefault(require("../core/FViewable")); require("../../css/relativeanchor.css"); require("../../css/alignbox.css"); var _inheritComponentClass = _interopRequireDefault(require("../core/inheritComponentClass")); var _makeMapStyleHandler = _interopRequireDefault(require("./makeMapStyleHandler")); var _utils = require("../core/utils"); var _BaseComponent = _interopRequireDefault(require("../core/BaseComponent")); var _ = _FCore.default._; var $ = _FCore.default.$; /** * AnchorBox only has on child node * @extends FViewable * @constructor */ function HyperAnchor(childNode) { _FViewable.default.call(this); this.childNode = childNode; childNode.anchor = this; this.domElt = childNode.domElt; this.style.loadAttributeHandlers(this.styleHandlers); this.childNode.style.loadAttributeHandlers(Object.assign({}, this.childNode.styleHandlers, this.compStyleHandlers)); } (0, _inheritComponentClass.default)(HyperAnchor, _FViewable.default); HyperAnchor.prototype.V_ALIGN_VALUE = ['top', 'bottom', 'center', 'fixed']; HyperAnchor.prototype.H_ALIGN_VALUE = ['left', 'right', 'center', 'fixed']; HyperAnchor.prototype.H_ALIGN_CLASS_NAMES = { left: 'as-h-align-left', right: 'as-h-align-right', center: 'as-h-align-center', fixed: 'as-h-align-fixed' }; HyperAnchor.prototype.V_ALIGN_CLASS_NAMES = { top: 'as-v-align-top', bottom: 'as-v-align-bottom', center: 'as-v-align-center', fixed: 'as-v-align-fixed' }; HyperAnchor.prototype.compStyleHandlers = {}; HyperAnchor.prototype.compStyleHandlers.display = { set: function (value, ref) { if (['block', 'inline-block', 'inline'].indexOf(value) < 0) value = this.constructor.prototype.style.display; //to default this.domElt.removeClass('as-display-' + ref.get()).addClass('as-display-' + value); return value; }, descriptor: function () { return { type: 'enum', hidden: !this.parent || this.parent.tag !== 'HyperLayout', values: ['block', 'inline-block', 'inline'] }; }, export: function (ref) { var value = ref.get() || undefined; if (['block', 'inline-block', 'inline'].indexOf(value) < 0) { value = undefined; } if (value === this.constructor.prototype.style.display) value = undefined; return value; } }; HyperAnchor.prototype.compStyleHandlers.position = { set: function (value, ref) { if (['static', 'relative', 'absolute'].indexOf(value) < 0) value = this.constructor.prototype.style.position; //to default this.domElt.removeClass('as-position-' + ref.get()).addClass('as-position-' + value); return value; }, descriptor: function () { return { type: 'enum', hidden: !this.parent || this.parent.tag !== 'HyperLayout', values: ['static', 'relative', 'absolute'] }; }, export: function (ref) { var value = ref.get() || undefined; if (['static', 'relative', 'absolute'].indexOf(value) < 0) { value = undefined; } if (value === this.constructor.prototype.style.position) value = undefined; return value; } }; /* HyperAnchor.prototype.compStyleHandlers.hAlign = { set: function (value) { // var anchor = this.anchor; // var ref = arguments[arguments.length - 1]; // var currentValue = ref.get(); // if (!anchor.HALIGN_VALUE.includes(value)) value = anchor.HALIGN_VALUE[0]; // anchor.domElt.removeClass(anchor.HALIGN_CLASS_NAMES[currentValue]); // anchor.domElt.addClass(anchor.HALIGN_CLASS_NAMES[value]); // ref.set(value); // this.style['left'] = this.style.left; // this.style['right'] = this.style.right; // this.style['width'] = this.style.width; return value; }, descriptor: { type: 'enum', values: ['left', 'right', 'center', 'fixed'], disabled: false, sign: 'RelativeAnchor_HAlign' }, export: function () { return undefined; } };*/ HyperAnchor.prototype.compStyleHandlers.vAlign = { set: function (value) { var anchor = this.anchor; if (!anchor.V_ALIGN_CLASS_NAMES[value]) value = this.constructor.prototype.style.vAlign; var ref = arguments[arguments.length - 1]; var currentValue = ref.get(); this.domElt.removeClass(anchor.V_ALIGN_CLASS_NAMES[currentValue]); this.domElt.addClass(anchor.V_ALIGN_CLASS_NAMES[value]); return value; }, descriptor: { type: 'enum', values: ['top', 'bottom', 'center', 'fixed'], disabled: false, sign: 'RelativeAnchor_VAlign' }, export: function () { return undefined; } }; HyperAnchor.prototype.compStyleHandlers.left = { /*** * @this BaseComponent * @param value * @param args * @returns {*} */ set: function (value, ...args) { var ref = args.pop(); var unit = args.shift(); var currentValue = ref.get(); var currentMS = (0, _utils.parseMeasureValue)(currentValue) || { value: "auto", unit: null }; value = this.implicitMeasureSizeValue(value, unit, "width", currentMS.unit); var styleValue = value >= 0 ? value + 'px' : value; this.domElt.addStyle('--as-left', styleValue); return value; }, get: function () { var ref = arguments[arguments.length - 1]; var value = ref.get(); var unit = arguments.length > 1 ? arguments[0] : undefined; var disabled = this.style.hAlign === 'center' || this.style.hAlign === 'right'; var bound; var parentBound; if (disabled || unit === 'px') { if (typeof value != 'number' || disabled) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return bound.left - parentBound.left; } else { return value; } } else if (unit === '%') { if (typeof value == 'string' && !value.match(/%$/) || typeof value != 'string' || disabled) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return (bound.left - parentBound.left) * 100 / parentBound.width; } else { return parseFloat(value.replace('%', '')); } } else return value; }, descriptor: function () { return { type: 'measurePosition', min: -Infinity, max: Infinity, disabled: this.style.hAlign === 'center' || this.style.hAlign === 'right', livePreview: true, dependency: ['hAlign', 'right', 'width'] }; } }; /* HyperAnchor.prototype.compStyleHandlers.right = { set: function (value) { var unit = arguments.length > 2 ? arguments[1] : undefined; var ref = arguments[arguments.length - 1]; var currentValue = ref.get(); var currentMS = parseMeasureValue(currentValue) || { value: "auto", unit: null }; value = this.implicitMeasureSizeValue(value, unit, "width", currentMS.unit); var styleValue = value >= 0 ? value + 'px' : value; this.domElt.addStyle('--as-right', styleValue); // if (this.style.hAlign !== 'center' && this.style.hAlign !== 'left') { // this.anchor.domElt.addStyle('right', styleValue); // } // else // this.anchor.domElt.removeStyle('right'); ref.set(value); this.onSizeChange(); return value; }, get: function () { var ref = arguments[arguments.length - 1]; var value = ref.get(); var unit = arguments.length > 1 ? arguments[0] : undefined; var disabled = this.style.hAlign === 'center' || this.style.hAlign === 'left'; var bound, parentBound; if (disabled || unit === 'px') { if (typeof value != 'number' || disabled) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return parentBound.right - bound.right; } else { return value; } } else if (unit === '%') { if (((typeof value == 'string') && (!value.match(/%$/))) || (typeof value != 'string') || disabled) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return (parentBound.right - bound.right) * 100 / parentBound.width; } else { return parseFloat(value.replace('%', '')); } } else { return value } }, descriptor: function () { return { type: 'measurePosition', min: -Infinity, max: Infinity, disabled: this.style.hAlign === 'center' || this.style.hAlign === 'left', livePreview: true, dependency: ['hAlign', 'left', 'width'], sign: 'RelativeRight' }; } }; HyperAnchor.prototype.compStyleHandlers.top = { set: function (value) { var unit = arguments.length > 2 ? arguments[1] : undefined; var ref = arguments[arguments.length - 1]; var currentValue = ref.get(); var currentMS = parseMeasureValue(currentValue) || { value: "auto", unit: null }; value = this.implicitMeasureSizeValue(value, unit, "height", currentMS.unit); var styleValue = value >= 0 ? value + 'px' : value; this.domElt.addStyle('--as-top', styleValue); // if (this.style.vAlign !== 'center' && this.style.vAlign !== 'bottom') { // this.anchor.domElt.addStyle('top', styleValue); // } // else this.anchor.domElt.removeStyle('top'); ref.set(value); this.onSizeChange(); return value; }, get: function () { var ref = arguments[arguments.length - 1]; var value = ref.get(); var unit = arguments.length > 1 ? arguments[0] : undefined; var disabled = this.style.vAlign === 'center' || this.style.vAlign === 'bottom'; var bound, parentBound; if (disabled || unit === 'px') { if (typeof value != 'number' || disabled) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return bound.top - parentBound.top; } else { return value; } } else if (unit === '%') { if (((typeof value == 'string') && (!value.match(/%$/))) || (typeof value != 'string') || disabled) { { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return (bound.top - parentBound.top) * 100 / parentBound.height; } } else { return parseFloat(value.replace('%', '')); } } else return value; }, descriptor: function () { return { type: 'measurePosition', min: -Infinity, max: Infinity, disabled: this.style.vAlign === 'center' || this.style.vAlign === 'bottom', livePreview: true, dependency: ['vAlign', 'bottom', 'height'], sign: 'RelativeTop' }; } }; HyperAnchor.prototype.compStyleHandlers.bottom = { set: function (value) { var unit = arguments.length > 2 ? arguments[1] : undefined; var ref = arguments[arguments.length - 1]; var currentValue = ref.get(); var currentMS = parseMeasureValue(currentValue) || { value: "auto", unit: null }; value = this.implicitMeasureSizeValue(value, unit, "height", currentMS.unit); var styleValue = value >= 0 ? value + 'px' : value; this.domElt.addStyle('--as-bottom', styleValue); // if (this.style.vAlign !== 'center' && this.style.vAlign !== 'top') { // this.anchor.domElt.addStyle('bottom', styleValue); // } // else this.anchor.domElt.removeStyle('bottom'); ref.set(value); this.onSizeChange(); return value; }, get: function () { var ref = arguments[arguments.length - 1]; var value = ref.get(); var unit = arguments.length > 1 ? arguments[0] : undefined; var disabled = this.style.vAlign === 'center' || this.style.vAlign === 'top'; var bound, parentBound; if (disabled || unit === 'px') { if (typeof value != 'number' || disabled) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return parentBound.bottom - bound.bottom; } else { return value; } } else if (unit === '%') { if (((typeof value == 'string') && (!value.match(/%$/))) || (typeof value != 'string') || disabled) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return (parentBound.bottom - bound.bottom) * 100 / parentBound.height; } else { return parseFloat(value.replace('%', '')); } } else return value; }, descriptor: function () { return { type: 'measurePosition', min: -Infinity, max: Infinity, disabled: this.style.vAlign === 'center' || this.style.vAlign === 'top', livePreview: true, dependency: ['vAlign', 'top', 'height'], sign: 'RelativeBottom' }; } }; HyperAnchor.prototype.compStyleHandlers.width = { set: function (value) { console.log(value) if (value === null || value === undefined || value === '') value = 'auto'; var ref = arguments[arguments.length - 1]; var unit = arguments.length > 2 ? arguments[1] : undefined; var currentValue = ref.get(); var currentMS = parseMeasureValue(currentValue) || { value: "auto", unit: null }; value = this.implicitMeasureSizeValue(value, unit, "width", currentMS.unit); var styleValue = value >= 0 ? value + 'px' : value; if (styleValue === 'match_parent') styleValue = '100%'; if (styleValue === 'auto'){ this.domElt.removeStyle('--as-width'); this.domElt.addClass('as-width-auto'); } else { this.domElt.addStyle('--as-width', styleValue); } ref.set(value); this.onSizeChange(); return value; }, get: function () { //todo var ref = arguments[arguments.length - 1]; var value = ref.get(); var unit = arguments.length > 1 ? arguments[0] : undefined; var bound, parentBound; if ( unit === 'px') { if ( typeof value != 'number') { bound = this.domElt.getBoundingClientRect(); return bound.width } else { return value; } } else if (unit === '%') { if ( ((typeof value === 'string') && (!value.match(/%$/))) || (typeof value != 'string')) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return bound.width * 100 / parentBound.width; } else { return parseFloat(value.replace('%', '')); } } else return value; }, descriptor: function () { return { type: 'measureSize', disabled: this.style.hAlign === 'fixed', dependency: ['hAlign', 'left', 'right'], sign: 'RelativeWidth' }; } }; /* HyperAnchor.prototype.compStyleHandlers.height = { set: function (value) { if (value === null || value === undefined || value === '') value = 'auto'; if (value && value.startsWith && value.startsWith('auto')) value = 'auto'; var ref = arguments[arguments.length - 1]; var unit = arguments.length > 2 ? arguments[1] : undefined; var currentValue = ref.get(); var vAlign = this.style.vAlign; var currentMS = parseMeasureValue(currentValue) || { value: "auto", unit: null }; value = this.implicitMeasureSizeValue(value, unit, "height", currentMS.unit); var styleValue = value >= 0 ? value + 'px' : value; if (styleValue === 'match_parent') styleValue = '100%'; if (vAlign === 'center') { this.anchor.domElt.removeStyle('height'); this.domElt.addStyle('height', styleValue); } else { this.domElt.removeStyle('height'); if (vAlign === 'fixed') { this.anchor.domElt.removeStyle('height', styleValue); } else { this.anchor.domElt.addStyle('height', styleValue); } } ref.set(value); this.onSizeChange(); return value; }, get: function () { var ref = arguments[arguments.length - 1]; var unit = arguments.length > 1 ? arguments[0] : undefined; var disabled = this.style.vAlign === 'fixed'; var parentBound, bound; var currentValue = ref.get(); var vAlign = this.style.vAlign; if (disabled || unit === 'px') { if (disabled || typeof currentValue != 'number') { bound = this.domElt.getBoundingClientRect(); return bound.height; } else { return currentValue; } } else if (unit === '%') { if (vAlign === 'match_parent') return 100; else if (disabled || ((typeof currentValue === 'string') && (!currentValue.match(/%$/))) || (typeof currentValue != 'string')) { bound = this.domElt.getBoundingClientRect(); parentBound = this.parent.domElt.getBoundingClientRect(); return bound.height * 100 / parentBound.height; } else { return parseFloat(currentValue.replace('%', '')); } } else return currentValue; }, descriptor: function () { return { type: 'measureSize', disabled: this.style.vAlign === 'fixed', dependency: ['vAlign', 'top', 'bottom'], sign: 'RelativeHeight' } } }; HyperAnchor.prototype.compStyleHandlers.hidden = { set: function (value) { value = !!value; if (value) this.anchor.domElt.addClass('as-display-hidden'); else this.anchor.domElt.removeClass('as-display-hidden'); this.domElt.removeClass('as-display-hidden'); return value; }, descriptor: { type: 'bool', sign: 'hidden' } }; */ ['hAlign', 'vAlign', 'left', 'right', 'top', 'bottom', 'width', 'height', 'hidden'].forEach(function (name) { HyperAnchor.prototype.styleHandlers[name] = (0, _makeMapStyleHandler.default)(name); }); HyperAnchor.prototype.TOP_CLASS_NAME = 'as-relative-anchor-box'; HyperAnchor.prototype.destroy = function () { if (this.childNode) { this.childNode.style.unloadAttributeHandlers(Object.assign({}, this.childNode.styleHandlers, this.compStyleHandlers)); this.childNode.anchor = null; this.childNode = null; } }; /** * @param {BaseComponent} child */ HyperAnchor.prototype.attachChild = function (child) { if (this.childNode) { this.childNode.domElt.remove(); this.childNode = null; this.childNode.anchor = null; } if (child.anchor) throw new Error("Detach anchorBox first"); //preinit this.childNode = child; child.anchor = this; this.childNode.style.left = this.childNode.style.left || 0; this.childNode.style.right = this.childNode.style.right || 0; this.childNode.style.top = this.childNode.style.top || 0; this.childNode.style.bottom = this.childNode.style.bottom || 0; this.childNode.style.vAlign = this.childNode.style.vAlign || 'top'; this.childNode.style.hAlign = this.childNode.style.hAlign || 'left'; this.style.left = this.childNode.style.left; this.style.right = this.childNode.style.right; this.style.top = this.childNode.style.top; this.style.bottom = this.childNode.style.bottom; this.style.vAlign = this.childNode.style.vAlign; this.style.hAlign = this.childNode.style.hAlign; this.$containter.addChild(child.domElt); this.$containter.attr('data-anchor-of', child.tag); this.style.loadAttributeHandlers(this.styleHandlers); child.style.loadAttributeHandlers(Object.assign({}, child.styleHandlers, this.compStyleHandlers)); child.onAnchorAttached(); }; HyperAnchor.prototype.detachChild = function () { if (this.childNode) { this.childNode.domElt.remove(); this.style.unloadAttributeHandlers(this.styleHandlers); this.childNode.style.unloadAttributeHandlers(Object.assign({}, this.childNode.styleHandlers, this.compStyleHandlers)); this.childNode.onAnchorDetached(); this.childNode.anchor = null; this.childNode = null; } else throw new Error("Nothing to detach"); }; HyperAnchor.prototype.HALIGN_ACCEPT_STYLE = { left: { left: true, right: false }, right: { left: false, right: true }, center: { left: false, right: false }, // component need set width fixed: { left: true, right: true } }; HyperAnchor.prototype.VALIGN_ACCEPT_STYLE = { top: { top: true, bottom: false }, bottom: { top: false, bottom: true }, center: { top: false, bottom: false }, // component need set height fixed: { top: true, bottom: true } }; HyperAnchor.prototype.updateVAlignStyle = function () { for (var key in this.VALIGN_ACCEPT_STYLE[this.childNode.style.vAlign]) { if (this.VALIGN_ACCEPT_STYLE[this.childNode.style.vAlign][key]) { this.domElt.addStyle(key, this.childNode.style[key] + 'px'); } else { this.domElt.removeStyle(key); } } this.setStyle('width', this.childNode.style.width); this.setStyle('height', this.childNode.style.height); }; HyperAnchor.prototype.updateHAlignStyle = function () { for (var key in this.HALIGN_ACCEPT_STYLE[this.childNode.style.hAlign]) { if (this.HALIGN_ACCEPT_STYLE[this.childNode.style.hAlign][key]) { this.childNode.style[key] = key; } else { this.domElt.removeStyle(key); } } this.setStyle('width', this.childNode.style.width); this.setStyle('height', this.childNode.style.height); }; Object.defineProperty(HyperAnchor.prototype, 'view', { get: function () { return this.domElt; } }); var _default = HyperAnchor; exports.default = _default;