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-form__js__components__Radio.js
/*** module: node_modules/absol-form/js/components/Radio.js ***/
"use strict";

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

var _FCore = _interopRequireDefault(require("../core/FCore"));

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

var _ContentScalelessComponent = _interopRequireDefault(require("../core/ContentScalelessComponent"));

var _inheritComponentClass = _interopRequireDefault(require("../core/inheritComponentClass"));

var _Checkbox = _interopRequireDefault(require("./Checkbox"));

var _InputAttributeHandlers = _interopRequireWildcard(require("./handlers/InputAttributeHandlers"));

var _Assembler = require("../core/Assembler");




var _ = _FCore.default._;
var $ = _FCore.default.$;

function Radio() {
  _ContentScalelessComponent.default.call(this);
}

(0, _inheritComponentClass.default)(Radio, _ContentScalelessComponent.default);
Radio.prototype.tag = "Radio";
Radio.prototype.menuIcon = "span.mdi.mdi-radiobox-marked";
Object.assign(Radio.prototype.attributeHandlers, _InputAttributeHandlers.default);
Radio.prototype.style.vAlign = 'center';
Radio.prototype.style.display = 'inline-block';
Radio.prototype.attributeHandlers.checked = {
  set: function (value) {
    var prev = this.$content.checked;
    this.$content.checked = !!value;

    if (prev !== this.$content.checked && this.fragment) {
      this.fragment.emittor.emit('radio.' + this.attributes.name, {
        target: this,
        checked: this.$content.checked,
        value: this.attributes.value
      });
    }
  },
  get: function () {
    return this.$content.checked;
  },
  descriptor: {
    type: "bool"
  }
}; // after fragment complete created, do not change groupName, it make the disembark work incorrectly

Radio.prototype.attributeHandlers.groupName = {
  set: function (value) {
    var ref = arguments[arguments.length - 1];
    var prev = ref.get();
    value = (value || '') + '';
    if (this.fragment) this.$content.name = this.fragment.id + value;else this.$content.name = value;

    this._assignToFragment(prev, value);

    if (value !== prev) this.unbindDataInFragment();
    ref.set(value);
    if (value !== prev) this.bindDataToFragment();
    return value;
  },
  descriptor: {
    type: "text",
    regex: /[a-zA-Z0-9_\-]+/,
    sign: "RadioGroupIndent",
    independence: true
  },
  export: function () {
    var value = this.attributes.groupName || '';
    if (value === '') return undefined;
    return value;
  }
};
Radio.prototype.attributeHandlers.value = {
  set: function (value) {
    this.$content.value = value;
  },
  get: function () {
    return this.$content.value;
  },
  descriptor: {
    type: "text",
    sign: "RadioValue",
    independence: true
  }
};
Radio.prototype.attributeHandlers.disabled = _Checkbox.default.prototype.attributeHandlers.disabled;

Radio.prototype.onCreate = function () {
  _ContentScalelessComponent.default.prototype.onCreate.call(this);

  this.style.width = 18;
  this.style.height = 18;
  this.style.vAlign = 'top';
  this.style.hAlign = 'left';
  this.style.textHAlign = 'center';
  this.style.textVAlign = 'center';
  this.attributes.checked = false;
  this.attributes.value = '';
  this.attributes.groupName = 'Radio_group_' + this.constructor.count;
};

Radio.prototype.onCreated = function () {
  _ContentScalelessComponent.default.prototype.onCreated.call(this);

  this.$content.on('change', function () {
    if (this.fragment) {
      this.fragment.emittor.emit('radio.' + this.attributes.groupName, {
        target: this,
        checked: this.$content.checked,
        value: this.attributes.value
      });
      this.notifyChange();
    }
  }.bind(this));
};

Radio.prototype.renderContent = function () {
  return _('radiobutton');
};

Radio.prototype.notifyChange = function () {
  var bounded;

  if (this.attributes.dataBinding && this.fragment) {
    bounded = this.fragment.boundProps[this.attributes.name];

    if (bounded) {
      if (bounded === this || bounded.indexOf && bounded.indexOf(this) >= 0) {
        this.fragment.notifyPropsChange({
          name: this.attributes.groupName
        });
      }
    }
  }
};

Radio.prototype.setStyleWidth = function (value) {
  value = value >= 18 ? value : 18;
  return _ContentScalelessComponent.default.prototype.setStyleWidth.call(this, value);
};

Radio.prototype.setStyleHeight = function (value) {
  value = value >= 18 ? value : 18;
  return _ContentScalelessComponent.default.prototype.setStyleHeight.call(this, value);
};

Radio.prototype.setAttributeGroupName = function (value) {
  this.$content.attr('name', value);
  return value;
};

Radio.prototype.measureMinSize = function () {
  return {
    width: 18,
    height: 18
  };
};

Radio.prototype._assignToFragment = function (oldGName, newGName) {
  if (!this.fragment) return;
  this.fragment.__radio_assigned__ = this.fragment.__radio_assigned__ || {};
  var assigned = this.fragment.__radio_assigned__;
  var list = assigned[oldGName];
  var idx = -1;

  if (list) {
    idx = list.indexOf(this);
  }

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

  list = assigned[newGName];

  if (!list) {
    list = [];
    assigned[newGName] = list;
  }

  list.push(this);
};

Radio.prototype.bindDataToFragment = function () {
  if (!this.fragment) return;
  var obj = this.fragment.props;
  var assigned = this.fragment.__radio_assigned__;
  if (!assigned) return;
  var groupName = this.attributes.groupName;
  var list = assigned[groupName];
  if (!list) return; // not assigned yet

  if (!obj.hasOwnProperty(groupName)) {
    Object.defineProperty(obj, groupName, {
      enumerable: !this.attributes.disembark,
      configurable: true,
      set: function (value) {
        var tempList = list.slice();
        var radio;

        for (var i = 0; i < list.length; ++i) {
          radio = tempList[i];

          if (radio.attributes.value === value) {
            radio.attributes.checked = false;
          }
        }
      },
      get: function () {
        var tempList = list.slice();
        var radio;

        for (var i = 0; i < list.length; ++i) {
          radio = tempList[i];

          if (radio.attributes.checked) {
            return radio.attributes.value;
          }
        }
      }
    });
  }
};

Radio.prototype.unbindDataInFragment = function () {
  if (!this.fragment) return;
  var obj = this.fragment.props;
  var assigned = this.fragment.__radio_assigned__;
  if (!assigned) return;
  var groupName = this.attributes.groupName;
  var list = assigned[groupName];
  if (!list) return; // not assigned yet

  if (list.length === 1 && list[0] === this) {
    delete obj[groupName];
  }
};

_Assembler.AssemblerInstance.addClass(Radio);

var _default = Radio;
exports.default = _default;

VaKeR 2022