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

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

var _Fragment = _interopRequireDefault(require("absol/src/AppPattern/Fragment"));

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

require("../../css/keeview/overviewwidget.css");

var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP"));

var _TabView = _interopRequireDefault(require("../TabView"));

var _Hanger = _interopRequireDefault(require("../Hanger"));

var _Vec = _interopRequireDefault(require("absol/src/Math/Vec2"));

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

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

var _OnScreenWidget = _interopRequireDefault(require("../OnScreenWidget"));

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

var _ResizeSystem = _interopRequireDefault(require("absol/src/HTML5/ResizeSystem"));

var _OWModalManager = _interopRequireDefault(require("./OWModalManager"));


/***
 * @extends Fragment
 * @param {{}} host
 * @param {Fragment[]} children
 * @constructor
 */
function OverviewWidget(host, children) {
  _Fragment.default.call(this);

  this.setting = {
    viewPos: {
      x: 0,
      y: 0
    },
    minimize: true
  };
  this.host = host;
  this.children = children || [];
  this.childrenById = this.children.reduce(function (ac, child) {
    ac[child.id] = child;
    return ac;
  }, {});
  this._position = new _Vec.default(0, 0);
  this.setContext("OVERVIEW_WIDGET", this);
  this.children.forEach(function (fg) {
    fg.attach(this);
  }.bind(this));
  this.modalMng = new _OWModalManager.default();
}

_OOP.default.mixClass(OverviewWidget, _Fragment.default);

OverviewWidget.prototype.createView = function () {
  this.$title = (0, _ACore._)({
    tag: 'span',
    class: 'kv-overview-widget-title',
    child: {
      text: '...'
    }
  });
  this.$tabs = this.children.map(function (fg) {
    return (0, _ACore._)({
      tag: 'tabframe',
      class: 'kv-overview-widget-page',
      child: fg.getView(),
      props: {
        name: ' '.repeat(5),
        //||fg.name,
        tabIcon: fg.tabIcon,
        id: fg.id
      }
    });
  });
  this.$view = (0, _ACore._)({
    class: 'kv-overview-widget',
    style: {
      '--x': '0px',
      '--y': '0px',
      visibility: 'hidden'
    },
    child: [{
      tag: _Hanger.default.tag,
      class: 'kv-overview-widget-header',
      child: [this.$title, {
        class: 'kv-overview-widget-header-window-action',
        child: [{
          tag: 'button',
          child: 'span.mdi.mdi-window-minimize',
          on: {
            click: this.minimize.bind(this)
          }
        }]
      }],
      on: {
        predrag: this.ev_headerPredrag.bind(this),
        dragstart: this.ev_headerDragStart.bind(this),
        drag: this.ev_headerDrag.bind(this),
        dragend: this.ev_headerDragEnd.bind(this)
      }
    }, {
      class: 'kv-overview-widget-body',
      child: {
        tag: _TabView.default.tag,
        class: ['kv-overview-widget-tab-view', 'xp-tiny'],
        child: this.$tabs,
        on: {
          activetab: this.ev_activeTab.bind(this)
        }
      }
    }, this.modalMng.getView()]
  });

  this._updateViewPosition();

  this.$bubble = (0, _ACore._)({
    tag: _OnScreenWidget.default.tag,
    class: 'kv-overview-widget-bubble',
    id: 'overview_widget_bubble',
    style: {
      // visibility: 'hidden'
      '--cx': '0.02',
      '--cy': '0.96'
    },
    child: ['<svg class="kv-overview-widget-bubble-background"  viewBox="0 0 24 24">\n' + '    <path fill="currentColor" d="M3 11H11V3H3M5 5H9V9H5M13 21H21V13H13M15 15H19V19H15M3 21H11V13H3M5 15H9V19H5M13 3V11H21V3M19 9H15V5H19Z" />\n' + '</svg>', {
      class: 'kv-overview-widget-bubble-badge',
      child: {
        tag: 'span',
        child: {
          text: '0'
        }
      }
    }],
    on: {
      click: this.toggle.bind(this)
    }
  });
  this.$tabview = (0, _ACore.$)('.kv-overview-widget-tab-view', this.$view);
  this.$action = (0, _ACore.$)('.kv-overview-widget-header-window-action', this.$view);
  this.$bubbleBadge = (0, _ACore.$)('.kv-overview-widget-bubble-badge', this.$bubble);
  this.$badgeText = (0, _ACore.$)('span', this.$bubbleBadge);
  this.$badgeText.requestUpdateSize = this._updateViewPosition.bind(this);
  var self = this;
  this.$tabs.forEach(function (tabElt) {
    tabElt.on('active', function () {
      self.childrenById[this.id].start();
    });
    tabElt.on('deactive', function () {
      self.childrenById[this.id].pause();
    });
  });
  this.updateCounter();
};

OverviewWidget.prototype.saveSetting = function () {
  localStorage.setItem('overview_widget_setting', JSON.stringify(this.setting));
};

OverviewWidget.prototype.loadSetting = function () {
  var setting = {};

  try {
    var settingJson = localStorage.getItem('overview_widget_setting');
    if (settingJson) setting = JSON.parse(settingJson);
  } catch (err) {}

  Object.assign(this.setting, setting);
  this._position = new _Vec.default(this.setting.viewPos.x, this.setting.viewPos.y);

  this._updateViewPosition();
};

OverviewWidget.prototype.updateCounter = function (from) {
  var id;
  var tabElt;
  var counter;

  if (from) {
    id = from.id;
    tabElt = this.$tabview.getTabById(id);
    counter = from.counter;
    if (counter) tabElt.name = '(' + counter + ')';else tabElt.name = '&nbsp;'.repeat(5);
  } else {
    this.$tabs.forEach(function (tabElt) {
      id = tabElt.id;
      var frg = this.childrenById[id];
      var counter = frg.counter;
      if (counter) tabElt.name = '(' + counter + ')';else tabElt.name = '&nbsp;'.repeat(5);
    }.bind(this));
  }

  var sumCounter = this.children.reduce(function (ac, cr) {
    return ac + cr.counter;
  }, 0);
  this.$badgeText.firstChild.data = sumCounter + '';

  if (sumCounter > 0) {
    this.$bubbleBadge.removeStyle('visibility');
  } else {
    this.$bubbleBadge.addStyle('visibility', 'hidden');
  }
};

OverviewWidget.prototype.onStart = function () {
  this.getView();
  this.loadSetting();
  this.$view.addTo(document.body);
  this.$bubble.addTo(document.body);

  _ResizeSystem.default.add(this.$badgeText);

  this._updateViewPosition();

  if (this.setting.minimize) {
    this.$bubble.removeStyle('visibility');
  } else {
    this.$view.removeStyle('visibility');
  }

  this.children.forEach(function (fg) {
    fg.start(true);
  });
  var activeTabId = this.$tabview.getActiveTabId();
  this.childrenById[activeTabId].start();
};

OverviewWidget.prototype.onStop = function () {
  this.getView().remove();
};

OverviewWidget.prototype.ev_activeTab = function (event) {
  var frag = this.childrenById[event.id];
  this.$title.firstChild.data = frag.name + '';
};

OverviewWidget.prototype.ev_headerPredrag = function (event) {
  if ((0, _EventEmitter.hitElement)(this.$action, event)) {
    event.cancel();
  }
};

OverviewWidget.prototype.ev_headerDragStart = function (event) {
  var bound = this.$view.getBoundingClientRect();
  this._dragData = {
    bound: bound,
    p0: new _Vec.default(bound.left, bound.top),
    modal: (0, _ACore._)({
      style: {
        position: 'fixed',
        zIndex: '1000000000',
        left: 0,
        right: 0,
        top: 0,
        bottom: 0,
        background: 'transparent'
      }
    }).addTo(document.body)
  };
};

OverviewWidget.prototype.ev_headerDrag = function (event) {
  var d = event.currentPoint.sub(event.startingPoint);
  this._position = this._dragData.p0.add(d);

  this._updateViewPosition();
};

OverviewWidget.prototype.ev_headerDragEnd = function (event) {
  this._dragData.modal.remove();

  this.setting.viewPos.x = this._position.x;
  this.setting.viewPos.y = this._position.y;
  this.saveSetting();
};

OverviewWidget.prototype._updateViewPosition = function () {
  if (!this.$view) return;
  var screenSize = (0, _Dom.getScreenSize)();
  var bound = this.$view.getBoundingClientRect();
  var x = Math.max(0, Math.min(this._position.x, screenSize.width - bound.width));
  var y = Math.max(0, Math.min(this._position.y, screenSize.height - bound.height));
  this.$view.addStyle({
    '--x': x + 'px',
    '--y': y + 'px'
  });
};

OverviewWidget.prototype.showModal = function (opt) {
  return this.modalMng.showModal(opt, this);
};

Object.defineProperty(OverviewWidget.prototype, 'position', {
  set: function (value) {
    if (!value) value = new _Vec.default(0, 0);

    if (value instanceof Array) {
      if ((0, _utils.isRealNumber)(value[0] && (0, _utils.isRealNumber)(value[1]))) {
        value = new _Vec.default(value[0], value[1]);
      } else {
        value = new _Vec.default(0, 0);
      }
    } else if (!(value instanceof _Vec.default)) {
      if ((0, _utils.isRealNumber)(value.x && (0, _utils.isRealNumber)(value.y))) {
        value = new _Vec.default(value[0], value[1]);
      } else {
        value = new _Vec.default(0, 0);
      }
    }

    this._position = value;

    this._updateViewPosition();
  },
  get: function () {
    return this._position;
  }
});

OverviewWidget.prototype.minimize = function () {
  this.$view.addStyle('visibility', 'hidden'); // this.$bubble.removeStyle('visibility');

  this.setting.minimize = true;
  this.saveSetting();
  var activeTabId = this.$tabview.getActiveTabId();
  this.childrenById[activeTabId].pause();
};

OverviewWidget.prototype.maximize = function () {
  // this.$bubble.addStyle('visibility', 'hidden');
  this.$view.removeStyle('visibility');
  this.setting.minimize = false;
  this.saveSetting();
  var activeTabId = this.$tabview.getActiveTabId();
  this.childrenById[activeTabId].start();
};

OverviewWidget.prototype.toggle = function () {
  if (this.setting.minimize) {
    this.maximize();
  } else {
    this.minimize();
  }
};

var _default = OverviewWidget;
exports.default = _default;

VaKeR 2022