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-card__js__dashboard__DBGridster.js
/*** module: node_modules/absol-card/js/dashboard/DBGridster.js ***/
"use strict";

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

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

var _Core = _interopRequireDefault(require("../dom/Core"));

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


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

function DBGridster() {
  this.cellSize = 50;
}

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

DBGridster.render = function () {
  return _({
    extendEvent: ['positionlistchange'],
    class: ['db-gridster', 'as-bscroller'],
    child: ['.db-gridster-place-preview']
  });
};
/***
 *
 * @param {DOMRect} cRect
 * @returns {{"--grid-x": number, "--grid-width": number, "--grid-y": number, "--grid-height": number}}
 */


DBGridster.prototype.findPosition = function (cRect) {
  var cBound = this.getBoundingClientRect();
  var bound = {
    width: this.clientWidth,
    height: this.clientHeight,
    top: cBound.top,
    left: cBound.left
  };
  var width, height;
  var x, y;
  var cellWidth = this.cellSize;
  x = Math.round((cRect.left - bound.left + this.scrollLeft - 10) / cellWidth);
  var right = Math.round((cRect.right + 12 - bound.left + this.scrollLeft - 10) / cellWidth);
  var cellHeight = this.cellSize;
  y = Math.round((cRect.top - bound.top + this.scrollTop - 10) / cellHeight);
  var bottom = Math.round((cRect.bottom + 12 - bound.top + this.scrollTop - 10) / cellHeight);
  x = Math.max(0, x);
  y = Math.max(0, y);
  width = Math.max(1, right - x);
  height = Math.max(1, bottom - y);
  return {
    '--grid-x': x,
    '--grid-y': y,
    '--grid-width': width,
    '--grid-height': height
  };
};

DBGridster.prototype.getPositionList = function () {
  return Array.prototype.reduce.call(this.childNodes, function (ac, elt) {
    if (elt.getGridPosition) {
      ac[elt.id] = elt.getGridPosition();
    }

    return ac;
  }, {});
};

DBGridster.prototype.applyPositionList = function (positionList) {
  Array.prototype.forEach.call(this.childNodes, function (elt) {
    if (elt.setGridPosition) {
      if (positionList[elt.id]) {
        elt.setGridPosition(positionList[elt.id]);
      }
    }
  }, {});
};

DBGridster.prototype.activeWidget = function (elt) {
  var c;

  for (var i = 0; i < this.childNodes.length; ++i) {
    c = this.childNodes[i];

    if (c === elt) {
      c.addClass('db-active');
    } else {
      c.removeClass('db-active');
    }
  }
};
/**
 *
 * @param {number} width
 * @param {number} height
 */


DBGridster.prototype.findAvailableNewRect = function (width, height) {
  var nCol = this.nCol;
  var h = Array(nCol).fill(0);
  var rects = this.getPositionList();
  var rect;

  for (var name in rects) {
    rect = rects[name];

    for (var x = rect.x; x < rect.x + rect.width; ++x) {
      h[x] = Math.max(h[x], rect.y + rect.height);
    }
  } //todo: better performance


  var bestX = -1;
  var bestY = 100000000;
  var y;

  for (var x = 0; x < nCol - width; ++x) {
    y = Math.max.apply(Math, h.slice(x, x + width));

    if (y < bestY) {
      bestX = x;
      bestY = y;
    }
  }

  return new _Rectangle.default(bestX, bestY, width, height);
};

DBGridster.property = {};
DBGridster.property.cellSize = {
  set: function (val) {
    val = val || 20;

    if (typeof val === "number") {
      this.addStyle('--gridster-cell-size', val + 'px');
    } else this.addStyle('--gridster-cell-size', val);
  },
  get: function () {
    return parseFloat(this.getComputedStyleValue('--gridster-cell-size').replace('px', ''));
  }
};
DBGridster.property.nCol = {
  set: function () {},
  get: function () {
    return Math.floor((this.clientWidth - 20) / this.cellSize) || 1;
  }
};
DBGridster.property.nRow = {
  set: function () {},
  get: function () {
    return Math.floor((this.clientHeight - 20) / this.cellSize) || 1;
  }
};
DBGridster.property.positionList = {
  set: function (value) {
    this.applyPositionList(value);
  },
  get: function () {
    return this.getPositionList();
  }
};
var _default = DBGridster;
exports.default = _default;

VaKeR 2022