VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-form__js__anchors__LinearAnchor.js
/*** module: node_modules/absol-form/js/anchors/LinearAnchor.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/linearanchor.css");

var _inheritComponentClass = _interopRequireDefault(require("../core/inheritComponentClass"));

var _makeMapStyleHandler = _interopRequireDefault(require("./makeMapStyleHandler"));

var _utils = require("../core/utils");


var _ = _FCore.default._;
var $ = _FCore.default.$;
/**
 * AnchorBox only has one child node
 * @extends FViewable
 */

function LinearAnchor() {
  _FViewable.default.call(this);

  this.style.left = 0;
  this.style.right = 0;
  this.style.top = 0;
  this.style.bottom = 0;
  this.width = 0;
  this.height = 0;
  this.childNode = null; //for quick binding render

  this.viewBinding = {};
  this.onCreate();
  this.domElt = this.render();
  this.onCreated();
}

(0, _inheritComponentClass.default)(LinearAnchor, _FViewable.default);
LinearAnchor.prototype.TOP_CLASS_NAME = 'as-linear-anchor-box';

LinearAnchor.prototype.onCreate = function () {
  /* NOOP */
};

LinearAnchor.prototype.onCreated = function () {
  for (var key in this.viewBinding) {
    this[key] = $(this.viewBinding[key], this.view);
  }
};

LinearAnchor.prototype.compStyleHandlers = {};
LinearAnchor.prototype.compStyleHandlers.height = {
  /***
   * @this BaseComponent
   * @param value
   * @returns {string}
   */
  set: function (value) {
    var ref = arguments[arguments.length - 1];
    var currentValue = ref.get();
    var unit = arguments.length > 2 ? arguments[1] : undefined;
    var current = (0, _utils.parseMeasureValue)(currentValue) || {
      value: 'auto',
      unit: null
    };
    value = this.implicitMeasureSizeValue(value, unit, "height", current.unit);

    if (value === 'auto') {
      this.anchor.domElt.addClass('as-height-auto');
    } else {
      this.anchor.domElt.removeClass('as-height-auto');
    }

    var styleValue = value >= 0 ? value + 'px' : value;
    if (styleValue === 'match_parent') styleValue = '100%';
    this.anchor.domElt.addStyle('height', styleValue);
    this.domElt.removeStyle('height');
    ref.set(value);
    this.onSizeChange();
    return value;
  },

  /***
   * @this BaseComponent
   *
   * */
  get: function () {
    var unit = arguments.length > 1 ? arguments[0] : undefined;
    var ref = arguments[arguments.length - 1];
    var value = ref.get();
    var bound, parentBound;

    if (unit === 'px') {
      if (value !== 'number') {
        bound = this.domElt.getBoundingClientRect();
        return bound.height;
      } else {
        return value;
      }
    } else if (unit === '%') {
      if (typeof value === 'string' && value.match(/%$/)) return parseFloat(value.replace('%', ''));else {
        bound = this.domElt.getBoundingClientRect();
        parentBound = this.parent.domElt.getBoundingClientRect();
        return bound.height * 100 / parentBound.height;
      }
    } else return value;
  },
  descriptor: {
    type: 'measureSize',
    sign: 'LinearHeight',
    independence: true
  }
};
LinearAnchor.prototype.compStyleHandlers.width = {
  /***
   * @this BaseComponent
   * @param value
   * @returns {*}
   */
  set: function (value) {
    var ref = arguments[arguments.length - 1];
    var unit = arguments.length > 2 ? arguments[1] : undefined;
    var currentValue = ref.get();
    var current = (0, _utils.parseMeasureValue)(currentValue) || {
      value: 'auto',
      unit: null
    };
    value = this.implicitMeasureSizeValue(value, unit, 'width', current.unit);

    if (value === 'auto') {
      this.anchor.domElt.addClass('as-width-auto');
    } else {
      this.anchor.domElt.removeClass('as-width-auto');
    }

    var styleValue = value >= 0 ? value + 'px' : value;
    if (styleValue === 'match_parent') styleValue = '100%';
    this.anchor.domElt.addStyle('width', styleValue);
    this.domElt.removeStyle('width');
    ref.set(value);
    this.onSizeChange();
    return value;
  },
  get: function () {
    var unit = arguments.length > 1 ? arguments[0] : undefined;
    var ref = arguments[arguments.length - 1];
    var value = ref.get();
    var bound, parentBound;

    if (unit === 'px') {
      if (value !== 'number') {
        bound = this.domElt.getBoundingClientRect();
        return bound.width;
      } else {
        return value;
      }
    } else if (unit === '%') {
      if (typeof value === 'string' && value.match(/%$/)) return parseFloat(value.replace('%', ''));else {
        bound = this.domElt.getBoundingClientRect();
        parentBound = this.parent.domElt.getBoundingClientRect();
        return bound.width * 100 / parentBound.width;
      }
    } else return value;
  },
  descriptor: {
    type: 'measureSize',
    sign: 'LinearWidth',
    independence: true
  }
};
LinearAnchor.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'
  }
};
['left', 'right', 'top', 'bottom', 'width', 'height', 'hidden'].forEach(function (name) {
  LinearAnchor.prototype.styleHandlers[name] = (0, _makeMapStyleHandler.default)(name);
});
['left', 'right', 'top', 'bottom'].forEach(function (name) {
  LinearAnchor.prototype.compStyleHandlers[name] = {
    /***
     * @this BaseComponent
     * @param value
     * @returns {string|number}
     */
    set: function (value) {
      var ref = arguments[arguments.length - 1];
      var unit = arguments.length > 2 ? arguments[1] : undefined;
      var currentValue = ref.get();
      var current = (0, _utils.parseMeasureValue)(currentValue) || {
        value: 'auto',
        unit: null
      };
      value = this.implicitMeasureSizeValue(value, unit, "width", current.unit);
      var styleValue = typeof value === "number" ? value + 'px' : value;
      this.anchor.domElt.addStyle('padding-' + name, styleValue);
      return value;
    },

    /**
     * @this BaseComponent
     * @returns {number|*}
     */
    get: function () {
      var unit = arguments.length > 1 ? arguments[0] : undefined;
      var ref = arguments[arguments.length - 1];
      var value = ref.get();
      return this.explicitMeasureSizeValue(value, unit, "width");
    },
    export: function (ref) {
      var value = ref.get();
      if (value === 0 || value === '0%') return undefined;
      return value;
    },
    descriptor: {
      type: 'measurePosition',
      min: -Infinity,
      max: Infinity,
      dependency: ['width'],
      sign: 'Linear' + name.substr(0, 1).toUpperCase() + name.substr(1),
      independence: true
    }
  };
});

LinearAnchor.prototype.render = function () {
  var layout = {
    class: ['as-anchor-box', this.TOP_CLASS_NAME]
  };
  return _(layout);
};
/**
 * @param {BaseComponent} child
 */


LinearAnchor.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.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.domElt.addChild(child.view);
  this.view.attr('data-anchor-of', child.tag);
  this.style.loadAttributeHandlers(this.styleHandlers);
  child.style.loadAttributeHandlers(Object.assign({}, child.styleHandlers, this.compStyleHandlers));
  child.onAnchorAttached();
};

LinearAnchor.prototype.detachChild = function () {
  if (this.childNode) {
    this.childNode.view.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");
};

Object.defineProperty(LinearAnchor.prototype, 'view', {
  get: function () {
    return this.domElt;
  }
});
var _default = LinearAnchor;
exports.default = _default;

VaKeR 2022