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

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

var _MSTBItemHolder = _interopRequireDefault(require("./MSTBItemHolder"));

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

var _CTBModes = require("../checktreebox/CTBModes");


function STLBModeNormal(elt, items) {
  this.level = -1;
  this.elt = elt;
  this.$list = elt.$list;
  this.children = items.map(item => new _MSTBItemHolder.default(elt, this, item));
  this.hasDesc = this.hasDesc || this.children.some(child => child.hasDesc);
  this.hasIcon = this.hasIcon || this.children.some(child => child.hasIcon);
  this.dict = this.children.reduce(function visit(ac, child) {
    var key = (0, _utils.keyStringOf)(child.data.value);

    if (ac[key]) {
      console.error('Duplicate value:', ac[key].data, child.data);
    }

    ac[key] = child;

    if (child.children) {
      child.children.reduce(visit, ac);
    }

    return ac;
  }, {});
  this.selectedHolder = null;
}

STLBModeNormal.prototype.getHolderByValue = _CTBModes.CTBModeNormal.prototype.getHolderByValue;

STLBModeNormal.prototype.getItemByValue = function (value) {
  var holder = this.getHolderByValue(value);
  if (holder) return holder.data;
  return null;
};

STLBModeNormal.prototype.getFirstLeafHolder = function () {
  var res = null;

  if (this.children) {
    this.children.some(function visit(node) {
      if (node.data.isLeaf) {
        res = node;
        return true;
      }

      if (node.children) {
        return node.children.some(visit);
      }

      return false;
    });
  }

  return res;
};

STLBModeNormal.prototype.onStart = function () {
  this.$list.clearChild();
  var rootHolders = this.children;
  var viewElements = [];
  rootHolders.forEach(holder => {
    holder.getViewElements(viewElements);
  }, []);
  this.$list.addChild(viewElements);
};

STLBModeNormal.prototype.setValue = function (value, strict) {
  var holder = this.selectedHolder;

  if (holder) {
    holder.select(false);
  }

  holder = this.getHolderByValue(value);
  if (holder && !holder.data.isLeaf) holder = null;

  if (!holder && strict) {
    holder = this.getFirstLeafHolder();
  }

  if (holder && holder.data.isLeaf) {
    holder.select(true);
  }

  this.selectedHolder = holder;
};

STLBModeNormal.prototype.getValue = function (strict) {
  var holder = this.selectedHolder;
  if (strict && !holder) holder = this.getFirstLeafHolder();

  if (holder) {
    return holder.data.value;
  } else {
    throw new Error('Not selected!');
  }
};

STLBModeNormal.prototype.viewToSelected = function () {
  if (!this.selectedHolder) return;

  var visitUp = node => {
    var parent = node.parent;

    if (parent !== this) {
      visitUp(parent);
    }

    if (node.status === 'close') {
      node.elt.status = 'open';
      node.ev_statusChange();
    }
  };

  visitUp(this.selectedHolder);
  (0, _utils.vScrollIntoView)(this.selectedHolder.elt);
};

STLBModeNormal.prototype.onStop = function () {};

function STLBModeSearch(elt, items) {
  this.level = -1;
  this.elt = elt;
  this.$list = this.elt.$list;
  this.children = items.map(item => new _MSTBItemHolder.default(elt, this, item));
  this.dict = this.children.reduce(function visit(ac, child) {
    var key = (0, _utils.keyStringOf)(child.data.value);

    if (ac[key]) {
      console.error('Duplicate value:', ac[key].data, child.data);
    }

    ac[key] = child;

    if (child.children) {
      child.children.reduce(visit, ac);
    }

    return ac;
  }, {});
  this.selectedHolder = null;
}

STLBModeSearch.prototype.updateSelectedFromRef = function () {
  if (this.selectedHolder) this.selectedHolder.select(false);
  this.selectedHolder = null;
  var value = this.elt.value;
  var holder = this.dict[(0, _utils.keyStringOf)(value)];

  if (holder) {
    holder.select(true);
    this.selectedHolder = holder;
  }
};

STLBModeSearch.prototype.onStart = function () {
  STLBModeNormal.prototype.onStart.call(this);
  this.updateSelectedFromRef();
};

STLBModeSearch.prototype.onStop = function () {};

VaKeR 2022