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-acomp__js__Follower.js
/*** module: node_modules/absol-acomp/js/Follower.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

require("../css/follower.css");

var _ACore = _interopRequireDefault(require("../ACore"));

var _Dom = _interopRequireDefault(require("absol/src/HTML5/Dom"));

var _Rectangle = _interopRequireDefault(require("absol/src/Math/Rectangle"));

var _AElement = _interopRequireDefault(require("absol/src/HTML5/AElement"));

var _AttachHook = _interopRequireDefault(require("absol/src/HTML5/AttachHook"));

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


var _ = _ACore.default._;
var $ = _ACore.default.$;
/***
 * @extends AElement
 * @constructor
 */

function Follower() {
  this.$attachhook = _('attachhook', this).addTo(this).on('attached', function () {
    this.requestUpdateSize();

    _Dom.default.addToResizeSystem(this);
  });
  this.$attachhook.requestUpdateSize = this.updatePosition.bind(this);
  this.$followTarget = undefined;
  this.$scrollTrackElts = [];
  this._scrollTrackEventHandler = undefined;
  this._anchor = Follower.ANCHOR_PRIORITY;
  this.defineEvent(['updateposition', 'preupdateposition']);
  /***
   * @name followTarget
   * @type {AElement}
   * @memberOf Follower#
   */
}

Follower.prototype.cancelWaiting = function () {
  Array.prototype.forEach.call(this.childNodes, function (elt) {
    if (elt.emit && elt.isSupportedEvent('attached') && elt.cancelWaiting()) {
      elt.cancelWaiting();
    }
  });
};

Follower.prototype.revokeResource = function () {
  this.cancelWaiting();
  this.followTarget = null;
};

Follower.tag = 'Follower'.toLowerCase();

Follower.render = function () {
  return _('.absol-follower');
};

Follower.prototype.clearChild = function () {
  var children = Array.prototype.slice.call(this.children);
  var attachhookElt = this.$attachhook;
  children.forEach(function (elt) {
    if (elt !== attachhookElt) elt.remove();
  });
  return this;
};

Follower.prototype.addTo = function (elt) {
  if (elt.addChild) {
    elt.addChild(this);
  } else if (elt.appendChild) {
    elt.appendChild(this);
  }

  if (this.isDescendantOf(document.body)) {
    Array.prototype.forEach.call(this.childNodes, function (elt) {
      if (elt.emit && elt.isSupportedEvent('attached')) {
        elt.resetState();
        elt.emit('attached');
      }
    });
  }

  return this;
};

Follower.prototype.selfRemove = function () {
  Array.prototype.forEach.call(this.childNodes, function (elt) {
    if (elt.emit && elt.isSupportedEvent('attached')) {
      elt.cancelWaiting();
    }
  });
  this.remove();
  return this;
}; //Todo: remove child, find child....

/**
 * X = $target.x + F[anchor_index][0] * $target.width + F[anchor_index][1] * $content.width
 * Y = $target.y + F[anchor_index][2] * $target.height + F[anchor_index][3] * $content.height
 */


Follower.ANCHOR_FACTORS = [[1, 0, 0, 0], //0
[0, 0, 1, 0], //1
[1, -1, 1, 0], //2
[0, -1, 0, 0], //3
[0, -1, 1, -1], //4
[1, -1, 0, -1], //5
[0, 0, 0, -1], //6
[1, 0, 1, -1], //7
[1, 0, 0.5, -0.5], //8
[0.5, -0.5, 1, 0], //9
[0, -1, 0.5, -0.5], //10
[0.5, -0.5, 0, -1], //11
[1, 0, 1, 0], //12
[0, -1, 1, 0], //13
[0, -1, 0, -1], //14
[1, 0, 0, -1] //15
];
Follower.ANCHOR_PRIORITY = [1, 6, 2, 5, 0, 7, 3, 4, 9, 11, 8, 10, 12, 15, 13, 14];

Follower.prototype.updatePosition = function () {
  if (!this.$followTarget) return;
  this.emit('preupdateposition', {
    target: this
  }, this);
  if (!this.$followTarget) return; // target is removed

  var targetBound = this.$followTarget.getBoundingClientRect();

  var screenSize = _Dom.default.getScreenSize();

  var outRect = new _Rectangle.default(0, 0, screenSize.width, screenSize.height);
  var bound = this.getBoundingClientRect();
  var x = 0;
  var y = 0;
  var score;
  var anchors = this._lastAnchor === undefined ? this.anchor : [this._lastAnchor].concat(this.anchor);
  var factor;
  var bestX,
      bestY,
      bestScore = -100000;
  var newContentRect;
  var bestAnchor;

  for (var i = 0; i < anchors.length; ++i) {
    factor = Follower.ANCHOR_FACTORS[anchors[i]];
    x = targetBound.left + factor[0] * targetBound.width + factor[1] * bound.width;
    y = targetBound.top + factor[2] * targetBound.height + factor[3] * bound.height;
    newContentRect = new _Rectangle.default(x, y, bound.width, bound.height);
    score = newContentRect.collapsedSquare(outRect);

    if (score - 10 > bestScore) {
      bestAnchor = anchors[i];
      bestScore = score;
      bestX = x;
      bestY = y;
    }
  }

  if (this._lastAnchor !== bestAnchor) {
    this.removeClass('as-anchor-' + this._lastAnchor);
    this._lastAnchor = bestAnchor;
    this.addClass('as-anchor-' + this._lastAnchor);
  }

  this.addStyle({
    left: bestX + 'px',
    top: bestY + 'px'
  });
  this.emit('updateposition', {
    target: this
  }, this);
};

Follower.prototype.refollow = function () {
  if (!this.$followTarget) return;
  this.updatePosition();
  this.addClass('following');
  if (this._scrollTrackEventHandler) this.unfollow();
  this._scrollTrackEventHandler = this.updatePosition.bind(this);
  this.$scrollTrackElts = [];
  var trackElt = this.$followTarget;

  while (trackElt) {
    if (trackElt.addEventListener) trackElt.addEventListener('scroll', this._scrollTrackEventHandler, false);else trackElt.attachEvent('onscroll', this._scrollTrackEventHandler, false);
    this.$scrollTrackElts.push(trackElt);
    trackElt = trackElt.parentElement;
  }

  if (document.addEventListener) {
    document.addEventListener('scroll', this._scrollTrackEventHandler, false);
  } else {
    document.attachEvent('onscroll', this._scrollTrackEventHandler, false);
  }

  this.$scrollTrackElts.push(document);
};

Follower.prototype.unfollow = function () {
  if (!this._scrollTrackEventHandler) return; // nothing to do

  this.removeClass('following');
  var trackElt;

  for (var i = 0; i < this.$scrollTrackElts.length; ++i) {
    trackElt = this.$scrollTrackElts[i];
    if (trackElt.removeEventListener) trackElt.removeEventListener('scroll', this._scrollTrackEventHandler, false);else trackElt.dettachEvent('onscroll', this._scrollTrackEventHandler, false);
  }

  this.$scrollTrackElts = [];
  this._scrollTrackEventHandler = undefined;
};

Follower.prototype.revokeResource = function () {
  this.$attachhook.cancelWaiting();
  this.followTarget = null;

  while (this.lastChild) {
    (0, _utils.revokeResource)(this.lastChild);
    this.removeChild(this.lastChild);
  }
};

Follower.property = {};
Follower.property.followTarget = {
  set: function (elt) {
    if (elt === null || elt === undefined || !elt) {
      this.unfollow();
      this.$followTarget = undefined;
      return;
    } else if (typeof elt == 'string') {
      elt = $(elt) || document.getElementById(elt);
    }

    if (_Dom.default.isDomNode(elt)) {
      this.$followTarget = elt;
      this._lastAnchor = undefined;
      this.refollow();
    } else throw new Error("Invalid element");
  },
  get: function () {
    return this.$followTarget;
  }
};
Follower.property.anchor = {
  set: function (value) {
    value = value || Follower.ANCHOR_PRIORITY;
    if (value == 'auto') value = Follower.ANCHOR_PRIORITY;
    if (typeof value == null) value = [value];
    if (!(value instanceof Array)) throw new Error('Invalid anchor ' + value);
    value = value.map(function (x) {
      x = Math.floor(x);

      if (x >= 0 && x < Follower.ANCHOR_FACTORS.length) {
        return x;
      } else throw new Error("Invalid anchor: " + x);
    });
    this._anchor = value;
    this._lastAnchor = undefined;
    this.updatePosition();
  },
  get: function () {
    return this._anchor;
  }
};

_ACore.default.install(Follower);

var _default = Follower;
exports.default = _default;

VaKeR 2022