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

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

var _EventEmitter = require("absol/src/HTML5/EventEmitter");

var STATE_INIT = 0;
var STATE_ATTACHED = 1;
var STATE_RELEASED = 2;
var STATE_FIRED = 3;
var STATE_DESTROYED = 4;
/***
 *
 * @param {AElement[]|AElement} eltList
 * @param {"click"|"mousedown"} eventType
 * @param {function} callback
 * @param {number=} initAfter
 * @param {number=} fireDelay
 * @param {*[]=} args
 * @constructor
 */

function BlurTrigger(eltList, eventType, callback, initAfter, fireDelay, args) {
  this.args = args || [];
  this.callback = callback;
  this.eltTargets = eltList || [];
  this.initAfter = initAfter || 0;
  this.fireDelay = fireDelay || 0;
  this.state = STATE_INIT;
  this.eventType = eventType;
  this['ev_mouse'] = this.ev_mouse.bind(this);
  this['ev_blur'] = this.ev_blur.bind(this);

  if (this.initAfter > 0) {
    setTimeout(this._attach.bind(this));
  } else this._attach();
}

BlurTrigger.prototype._attach = function () {
  if (this.state !== STATE_INIT) return;
  document.addEventListener(this.eventType, this.ev_mouse);
  window.addEventListener('blur', this.ev_blur);
  this.state = STATE_ATTACHED;
};

BlurTrigger.prototype._fire = function () {
  if (this.state !== STATE_RELEASED) return;
  this.callback.apply(this, this.args);
  this.state = STATE_FIRED;
};

BlurTrigger.prototype._release = function () {
  if (this.state !== STATE_ATTACHED) return;
  document.removeEventListener(this.eventType, this.ev_mouse);
  window.removeEventListener('blur', this.ev_blur);
  this.state = STATE_RELEASED;
};

BlurTrigger.prototype.destroy = function () {
  if (this.state === 4) return;
  if (this.state === STATE_ATTACHED) this._release();
  this.state = STATE_DESTROYED;
};

BlurTrigger.prototype._prepareFire = function () {
  if (this.fireDelay > 0) {
    setTimeout(this._fire.bind(this), this.fireDelay);
  } else {
    this._fire();
  }
};

BlurTrigger.prototype.ev_mouse = function (event) {
  var hit = false;

  if (this.eltTargets instanceof Array) {
    hit = this.eltTargets.some(function (elt) {
      return (0, _EventEmitter.hitElement)(elt, event);
    });
  } else if (typeof hit === "function") {
    hit = this.eltTargets.call(this, event.target);
  }

  if (!hit) {
    this._release();

    this._prepareFire();
  }
};

BlurTrigger.prototype.ev_blur = function () {
  setTimeout(function () {
    if (this.state !== STATE_ATTACHED) return;
    var tagName = document.activeElement && document.activeElement.tagName || '';
    tagName = tagName.toLowerCase();

    if (tagName === 'iframe') {
      this._release();

      this._prepareFire();
    }
  }.bind(this), 0);
};

var _default = BlurTrigger;
exports.default = _default;

VaKeR 2022