![]() 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/anchors/ |
Upload File : |
import FCore from "../core/FCore"; import FViewable from "../core/FViewable"; import LinearAnchor from "./LinearAnchor"; import '../../css/chainanchor.css'; import inheritComponentClass from "../core/inheritComponentClass"; import makeMapStyleHandler from "./makeMapStyleHandler"; var _ = FCore._; var $ = FCore.$; /*** * @extends LinearAnchor * @constructor */ function ChainAnchor() { FViewable.call(this); this.style.left = 0; this.style.right = 0; this.style.top = 0; this.style.bottom = 0; this.style.vAlign = 'top'; this.childNode = null; //for quick binding render this.viewBinding = {}; this.onCreate(); this.domElt = this.render(); this.onCreated(); } inheritComponentClass(ChainAnchor, LinearAnchor); ChainAnchor.prototype.TOP_CLASS_NAME = 'as-chain-anchor-box'; ChainAnchor.prototype.VALIGN_CLASS_NAMES = { top: 'as-valign-top', center: 'as-valign-center', bottom: 'as-valign-bottom' }; ChainAnchor.prototype.VALIGN_ACCEPTS_VALUES = ['top', 'center', 'bottom']; ChainAnchor.prototype.getAcceptsStyleNames = function () { return LinearAnchor.prototype.getAcceptsStyleNames.call(this).concat(['vAlign']); }; ['left', 'right', 'top', 'bottom', 'width', 'height', 'vAlign', 'hidden'].forEach(function (name) { ChainAnchor.prototype.styleHandlers[name] = makeMapStyleHandler(name); }); ChainAnchor.prototype.compStyleHandlers.vAlign = { set: function (value) { var currentValue = arguments[arguments.length - 1].get(); if (this.anchor.VALIGN_ACCEPTS_VALUES.indexOf(value) < 0) value = this.anchor.VALIGN_ACCEPTS_VALUES[0]; if (this.anchor.VALIGN_CLASS_NAMES[currentValue]) { this.anchor.domElt.removeClass(this.anchor.VALIGN_CLASS_NAMES[currentValue]) } this.anchor.domElt.addClass(this.anchor.VALIGN_CLASS_NAMES[value]); return value; }, descriptor: function () { return { type: 'enum', values: this.anchor.VALIGN_ACCEPTS_VALUES, disabled: false, sign: 'ChainAnchor_VAlign', independence: true } } }; ChainAnchor.prototype.render = function () { var layout = { class: [this.TOP_CLASS_NAME] }; return _(layout); }; /** * @param {BaseComponent} child */ ChainAnchor.prototype.attachChild = function (child) { if (this.childNode) { this.childNode.view.remove(); this.childNode = null; this.childNode.anchor = null; } if (child.anchor) throw new Error("Detach anchorBox first"); this.childNode = child; child.anchor = this; this.childNode.style.width = this.childNode.style.width || 0; this.childNode.style.height = this.childNode.style.height || 0; 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.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.view.addChild(child.view); this.style.loadAttributeHandlers(this.styleHandlers); child.style.loadAttributeHandlers(Object.assign({}, child.styleHandlers, this.compStyleHandlers)); child.onAnchorAttached(); }; export default ChainAnchor;