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-mobile__js__dom__MMultiCheckMenu.js
/*** module: node_modules/absol-mobile/js/dom/MMultiCheckMenu.js ***/
"use strict";

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

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

var _MSelectMenu = _interopRequireDefault(require("./MSelectMenu"));

var _Core = _interopRequireWildcard(require("./Core"));

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

var _MSelectBox = _interopRequireDefault(require("./MSelectBox"));

var _SelectListItem = require("absol-acomp/js/SelectListItem");




var boxItemPool = [];

function closeBoxItem(event) {
  var thisSB = this.$parent;
  if (!thisSB) return;
  var itemValue = this.value;
  var index = thisSB.values.indexOf(itemValue);

  if (index >= 0) {
    thisSB.values = thisSB.values.slice(0, index).concat(thisSB.values.slice(index + 1));
    thisSB.emit('remove', {
      type: 'remove',
      values: thisSB.values,
      target: thisSB,
      itemElt: this,
      value: this.value,
      itemData: this.data
    }, thisSB);
    thisSB.emit('change', {
      type: 'change',
      values: thisSB.values,
      target: thisSB
    }, thisSB);
  }
}
/**
 * @returns {MSelectListItem}
 */


function makeItem() {
  return (0, _Core._)({
    tag: 'selectboxitem',
    on: {
      close: closeBoxItem
    }
  });
}

function requireBoxItem($parent) {
  var item;

  if (boxItemPool.length > 0) {
    item = boxItemPool.pop();
  } else {
    item = makeItem();
  }

  item.$parent = $parent;
  return item;
}

function releaseBoxItem(item) {
  item.$parent = null;
  boxItemPool.push(item);
}
/***
 * @extends AElement
 * @constructor
 */


function MMultiCheckMenu() {
  this._isFocus = false;
  this._values = [];
  this._orderly = false;
  this._itemsByValue = {};
  this.$boxItems = [];
  this.$selectlist = (0, _Core._)({
    tag: 'mchecklistmodal',
    on: {
      change: this.eventHandler.modalChange,
      pressout: this.eventHandler.modalSubmit,
      pressclose: this.eventHandler.modalSubmit,
      cancel: this.eventHandler.modalCancel
    }
  });
  this.on('click', this.eventHandler.click);
  this.$attachhook = (0, _Core.$)('attachhook', this).on('error', this.eventHandler.attached);
  this._tempValues = []; //20p

  this.orderly = false;
  this.items = [];
  this.values = [];
}

MMultiCheckMenu.tag = 'MMultiCheckMenu'.toLowerCase();
Object.assign(MMultiCheckMenu.prototype, _MSelectBox.default.prototype);
MMultiCheckMenu.property = Object.assign({}, _MSelectBox.default.property);
MMultiCheckMenu.eventHandler = Object.assign({}, _MSelectBox.default.eventHandler);

MMultiCheckMenu.render = function () {
  return (0, _Core._)({
    tag: 'bscroller',
    class: ['absol-selectbox', 'absol-bscroller', 'am-select-box', 'am-multi-check-menu'],
    extendEvent: ['change', 'add', 'remove', 'minwidthchange'],
    attr: {
      tabindex: '1'
    },
    child: 'attachhook'
  }, true);
};

MMultiCheckMenu.property.isFocus = {
  set: function (value) {
    if (!this._isFocus && value) {
      this._tempValues = this._values.slice();
      this.$selectlist.values = this._tempValues;
    }

    _MSelectBox.default.property.isFocus.set.call(this, value);
  },
  get: _MSelectBox.default.property.isFocus.get
};

MMultiCheckMenu.eventHandler.modalChange = function (event) {
  var value, idx;

  switch (event.action) {
    case "check":
      value = event.value;
      idx = this._tempValues.indexOf(value);

      if (idx < 0) {
        this._tempValues.push(value);

        this._sortValuesIfNeed(this._tempValues);
      }

      break;

    case "uncheck":
      value = event.value;
      idx = this._tempValues.indexOf(value);

      if (idx >= 0) {
        this._tempValues.splice(idx, 1);
      }

      break;

    case "check_all":
      this._tempValues = this._items.map(function (item) {
        return (0, _SelectListItem.getValueOfListItem)(item);
      });
      break;

    case "uncheck_all":
      this._tempValues.splice(0, this._tempValues.length);

      break;
  }

  this.viewItemsByValues(this._tempValues);
};

MMultiCheckMenu.eventHandler.modalSubmit = function (event) {
  var curDict = this._values.reduce(function (ac, cr) {
    ac[cr + ''] = true;
    return ac;
  }, {});

  var newDict = this._tempValues.reduce(function (ac, cr) {
    ac[cr + ''] = true;
    return ac;
  }, {});

  var removedValues = this._values.filter(function (val) {
    return !newDict[val + ''];
  });

  var addedValues = this._tempValues.filter(function (val) {
    return !curDict[val + ''];
  });

  this._values = this._tempValues.slice();

  this._sortValuesIfNeed(this._values);

  this.$selectlist.remove();

  if (removedValues.length > 0) {
    removedValues.forEach(function (value) {
      var item = this._itemsByValue[value + ''];
      this.emit('remove', {
        type: 'remove',
        itemData: item,
        value: value
      }, this);
    }.bind(this));
  }

  if (addedValues.length > 0) {
    addedValues.forEach(function (value) {
      var item = this._itemsByValue[value + ''];
      this.emit('remove', {
        type: 'add',
        itemData: item,
        value: value
      }, this);
    }.bind(this));
  }

  if (removedValues.length > 0 || addedValues.length > 0) {
    this.emit('change', {
      type: 'change',
      values: this.values,
      target: this
    }, this);
  }

  this.isFocus = false;
};

MMultiCheckMenu.eventHandler.modalCancel = function (event) {
  this.viewItemsByValues(this._values);
  this.isFocus = false;
};

_Core.default.install('MSelectBox'.toLowerCase(), MMultiCheckMenu);

_Core.default.install(MMultiCheckMenu);

var _default = MMultiCheckMenu;
exports.default = _default;

VaKeR 2022