![]() 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/layouts/ |
Upload File : |
import RelativeAnchor from "../anchors/RelativeAnchor"; import FCore from "../core/FCore"; import BaseLayout from "../core/BaseLayout"; import RelativeAnchorEditor from "../anchoreditors/RelativeAnchorEditor"; import OOP from "absol/src/HTML5/OOP"; import {AssemblerInstance} from "../core/Assembler"; var _ = FCore._; function RelativeLayout() { BaseLayout.call(this); } OOP.mixClass(RelativeLayout, BaseLayout); RelativeLayout.prototype.tag = 'RelativeLayout'; RelativeLayout.prototype.menuIcon = 'span.mdi.mdi-relative-scale'; RelativeLayout.prototype.TOP_CLASS_NAME = 'as-relative-layout'; RelativeLayout.prototype.SUPPORT_STYLE_NAMES = ['width', 'height'];//, 'left', 'right', 'top', 'bottom']; RelativeLayout.prototype.getAnchorConstructor = function () { return RelativeAnchor; }; RelativeLayout.prototype.getAnchorEditorConstructor = function () { return RelativeAnchorEditor; }; RelativeLayout.prototype.render = function () { return _({ class: this.TOP_CLASS_NAME }); }; RelativeLayout.prototype.onAddChild = function (child, index) { var anchor = new RelativeAnchor(); anchor.attachChild(child); if (index == -1 || !this.view.childNodes[index]) { this.view.addChild(anchor.view); } else { this.view.addChildBefore(anchor.view, this.view.childNodes[index]); } }; RelativeLayout.prototype.onRemoveChild = function (child, index) { var anchor = child.anchor; anchor.detachChild(); anchor.view.remove(); }; /** * @param {BaseComponent} child, * @param {Number} posX * @param {Number} posY */ RelativeLayout.prototype.addChildByPosition = function (child, posX, posY) { this.addChild(child); var width = this.style.getProperty('width', 'px'); var height = this.style.getProperty('height', 'px'); var cWidth = child.style.getProperty('width', 'px'); var cHeight = child.style.getProperty('height', 'px'); posX = Math.max(0, Math.min(width - cWidth, posX)); posY = Math.max(0, Math.min(height - cHeight, posY)); child.setStyle('left', posX); child.setStyle('top', posY); }; AssemblerInstance.addClass(RelativeLayout); export default RelativeLayout;