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-vchart__src__ToolTip.js
/*** module: node_modules/absol-vchart/src/ToolTip.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.showTooltip = showTooltip;
exports.closeTooltip = closeTooltip;

var _ACore = require("absol-acomp/ACore");

var _utils = require("absol-acomp/js/utils");

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

function TooltipSession(content, x, y) {
  this.content = content;
  this.x = (0, _utils.isRealNumber)(x) ? x : 0;
  this.y = (0, _utils.isRealNumber)(y) ? y : 0;
  this.open();
}
/**
 *
 * @type {{$ctn: AElement, $anchor: AElement, holder: TooltipSession}}
 */


TooltipSession.prototype.share = {
  $anchor: null,
  $ctn: null,
  holder: null
};

TooltipSession.prototype._prepare = function () {
  if (this.share.$anchor) return;
  this.share.$ctn = (0, _ACore._)({
    class: "vchart-tooltip-container"
  });
  this.share.$anchor = (0, _ACore._)({
    class: 'vchart-tooltip-anchor',
    child: this.share.$ctn
  });
};

TooltipSession.prototype.open = function () {
  this._prepare();

  if (this.share.holder === this) return;

  if (this.share.holder) {
    this.share.holder.close();
  }

  this.share.holder = this;
  this.share.$anchor.addStyle({
    visibility: 'hidden',
    left: this.x + 'px',
    top: this.y + 'px'
  }).addTo(document.body);
  this.share.$ctn.clearChild();

  if (typeof this.content === "string") {
    this.content.split(/\r?\n/).forEach((line, i) => {
      if (i) (0, _ACore._)('br').addTo(this.share.$ctn);
      (0, _ACore._)({
        tag: 'span',
        child: {
          text: line
        }
      }).addTo(this.share.$ctn);
    });
  } else {
    console.error("Not support tooltip.content ", this.content);
  }

  var bound = this.share.$ctn.getBoundingClientRect();
  var screenBound = (0, _Dom.getScreenSize)();

  if (this.y < bound.height) {
    this.share.$ctn.addStyle('top', '0').addStyle('bottom', 'unset');
  } else {
    this.share.$ctn.removeStyle('top').removeStyle('bottom');
  }

  if (this.x + bound.width > screenBound.width) {
    this.share.$ctn.addStyle('right', '0').addStyle('left', 'unset');
  } else {
    this.share.$ctn.removeStyle('right').removeStyle('left');
  }

  this.share.$anchor.removeStyle('visibility');
};

TooltipSession.prototype.close = function () {
  if (this.share.holder !== this) return;
  this.share.holder = null;
  this.share.$ctn.clearChild();
  this.share.$anchor.remove();
};
/**
 * adapt old version
 * @param cb
 * @returns {TooltipSession}
 */


TooltipSession.prototype.then = function (cb) {
  if (typeof cb === "string") {
    cb(this);
  }

  return this;
};

function showTooltip(text, clientX, clientY) {
  return new TooltipSession(text, clientX, clientY);
}

function closeTooltip(token) {
  if (token && token.close) token.close();
}

VaKeR 2022