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__selectmenu__MSelectMenu.js
/*** module: node_modules/absol-acomp/js/selectmenu/MSelectMenu.js ***/
"use strict";

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

var _SelectMenu = _interopRequireDefault(require("../SelectMenu"));

var _MListModal = _interopRequireDefault(require("../selectlistbox/MListModal"));

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

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

var _MSelectListItem = _interopRequireDefault(require("../selectlistbox/MSelectListItem"));




/***
 * @extends AElement
 * @constructor
 */
function MSelectMenu() {
  this._value = undefined;
  this._isFocus = false;
  this._itemsByValue = {};
  this.$holderItem = (0, _ACore.$)('.am-selectmenu-holder-item', this);
  /***
   * @type {MListModal}
   */

  this.$selectlist = (0, _ACore._)({
    tag: _MListModal.default
  });
  this.$selectlist.cancelWaiting();

  var checkView = () => {
    if (this.isDescendantOf(document.body)) {
      setTimeout(checkView, 10000);
    } else {
      if (this.$selectlist.searchMaster) this.$selectlist.searchMaster.destroy();
    }
  };

  setTimeout(checkView, 30000);
  this.$selectlist.on('pressitem', this.eventHandler.pressItem, true).on('pressout', this.eventHandler.pressOut).on('pressclose', this.eventHandler.pressOut);
  this.on('click', this.eventHandler.click, true);
  this.$attachhook = (0, _ACore.$)('attachhook', this).on('error', this.eventHandler.attached);
  /**
   * @name value
   * @memberof MSelectMenu#
   */

  /**
   * @name items
   * @memberof MSelectMenu#
   */
}

MSelectMenu.tag = 'mselectmenu';

MSelectMenu.render = function () {
  return (0, _ACore._)({
    class: ['absol-selectmenu', 'am-selectmenu', 'as-strict-value'],
    extendEvent: ['change', 'minwidthchange'],
    attr: {
      tabindex: '1'
    },
    child: ['.am-selectmenu-holder-item', {
      tag: 'button',
      class: 'absol-selectmenu-btn',
      child: ['dropdown-ico']
    }, 'attachhook']
  });
};

MSelectMenu.prototype.findItemsByValue = function (value) {
  return this.$selectlist.findItemsByValue(value);
};

MSelectMenu.prototype.updateItem = function () {
  this.$holderItem.clearChild();
  var selected = this.findItemsByValue(this.value);

  if (selected) {
    var elt = (0, _ACore._)({
      tag: _MSelectListItem.default,
      props: {
        data: selected[0]
      }
    }).addTo(this.$holderItem);
  }
};

MSelectMenu.prototype.notifyChange = function (data) {
  this.emit('change', Object.assign({}, data, {
    type: 'change',
    target: this
  }), this);
};

MSelectMenu.prototype._dictByValue = _SelectMenu.default.prototype._dictByValue;

MSelectMenu.prototype.getRecommendWith = function () {
  var res = 12 + this.$selectlist.estimateSize.textWidth + 30;
  if (this.$selectlist.estimateSize.descWidth) res += this.$selectlist.estimateSize.descWidth + 20;
  return res;
};

MSelectMenu.prototype.init = _SelectMenu.default.prototype.init;
MSelectMenu.property = {};
MSelectMenu.property.items = {
  set: function (value) {
    this._itemIdxByValue = null;
    /**
     * verity data
     */

    if (value) {
      value.forEach(function (it) {
        if (it && it.text) {
          it.text = it.text + '';
        }
      });
    }

    this._items = value;
    this._itemsByValue = this._dictByValue(value);
    this.$selectlist.items = value;

    if (!this._itemsByValue[this.value] && value.length > 0 && false) {
      //todo
      this.value = value[0].value;
    } else this.updateItem();

    if (this.style.width === 'auto' || !this.style.width) {
      this.addStyle('--recommend-width', this.getRecommendWith() / 14 + 'em');
    }
  },
  get: function () {
    return this._items || [];
  }
};
MSelectMenu.property.value = {
  set: function (value) {
    this._value = value;
    this.$selectlist.values = [value];
    this.updateItem();
  },
  get: function () {
    if (!this.strictValue) return this._value;
    var selected = this.findItemsByValue(this._value);

    if (selected) {
      return selected[0].value;
    } else {
      if (this._items && this._items.length > 0) {
        return this._items[0].value;
      }
    }

    return this._value;
  }
};
MSelectMenu.property.strictValue = {
  set: function (value) {
    if (value) {
      this.addClass('as-strict-value');
    } else {
      this.removeClass('as-strict-value');
    }
  },
  get: function () {
    return this.hasClass('as-strict-value');
  }
};
MSelectMenu.property.enableSearch = {
  set: function (value) {
    this.$selectlist.enableSearch = !!value;
  },
  get: function () {
    return this.$selectlist.enableSearch;
  }
};
MSelectMenu.property.isFocus = {
  set: function (value) {
    var thisSM = this;
    value = !!value;
    if (value === this._isFocus) return;
    if (this.readOnly || this.disabled) return;
    this._isFocus = value;

    if (value) {
      this.$selectlist.addTo(document.body);

      if (this.$selectlist.$attachhook) {
        this.$selectlist.$attachhook.emit('attached');
      }

      thisSM.$selectlist.viewListAt(0);
      thisSM.$selectlist.viewListAtFirstSelected();
    } else {
      this.$selectlist.selfRemove();
      setTimeout(function () {
        thisSM.$selectlist.resetSearchState();
      }, 100);
    }
  },
  get: function () {
    return this._isFocus;
  }
};
MSelectMenu.property.selectedIndex = _SelectMenu.default.property.selectedIndex;
MSelectMenu.property.disabled = _SelectMenu.default.property.disabled;
MSelectMenu.property.hidden = _SelectMenu.default.property.hidden;
/**
 * @type {MSelectMenu}
 */

MSelectMenu.eventHandler = {};

MSelectMenu.eventHandler.attached = function () {
  if (this.style.width === 'auto' || !this.style.width) {
    this.addStyle('--recommend-width', this.getRecommendWith() / 14 + 'em');
  }
};

MSelectMenu.eventHandler.click = function (event) {
  this.isFocus = !this.isFocus;
};

MSelectMenu.eventHandler.pressOut = function (event) {
  this.isFocus = false;
};

MSelectMenu.eventHandler.pressItem = function (event) {
  var newValue = event.value;

  if (newValue !== this._value) {
    var lastValue = this._value;
    this._value = newValue;
    this.$selectlist.values = [newValue];
    this.updateItem();
    var changeEvent = Object.assign({}, event, {
      lastValue: lastValue
    });
    setTimeout(function () {
      this.notifyChange(changeEvent);
    }.bind(this), 1);
  }

  setTimeout(function () {
    this.isFocus = false;
  }.bind(this), 100);
};

_ACore.default.install(MSelectMenu);

var _default = MSelectMenu;
exports.default = _default;

VaKeR 2022