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

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

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

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

var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP"));

var _Dom = _interopRequireDefault(require("absol/src/HTML5/Dom"));

var _AElement = _interopRequireDefault(require("absol/src/HTML5/AElement"));


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

function RadioButton() {
  var thisRB = this;
  this.defineEvent('change');
  this.$input = $('input', this).on('change', this.notifyChange.bind(this));

  _OOP.default.drillProperty(this, this.$input, ['value', 'checked']);
}

RadioButton.tag = 'radiobutton';
RadioButton.radioProto = _('<svg class="absol-radio-icon" width="20" height="20" version="1.1" viewBox="0 0 5.2917 5.2917"' + '   xmlns="http://www.w3.org/2000/svg">' + '    <g transform="translate(0 -291.71)">' + '        <circle class="bound" cx="2.6458" cy="294.35" r="2.4626" style="stroke-opacity:.99497;stroke-width:.26458;" />' + '        <circle class="dot" cx="2.6458" cy="294.35"  r= "0.92604" style="fill-rule:evenodd;" />' + '    </g>' + '</svg>');

RadioButton.render = function () {
  return _({
    tag: 'label',
    class: 'absol-radio-button',
    child: [{
      tag: 'input',
      attr: {
        type: 'radio'
      }
    }, RadioButton.radioProto.cloneNode(true)]
  });
};

RadioButton.prototype.notifyChange = function () {
  this.emit('change', {
    type: 'change',
    checked: this.checked,
    target: this
  }, this);
};

RadioButton.prototype.getAllFriend = function () {
  return Radio.getAllByName(this.name);
};

RadioButton.attribute = {
  checked: {
    set: function (value) {
      if (value == 'false' || value == null) {
        this.checked = false;
      } else {
        this.checked = true;
      }
    },
    get: function () {
      return this.checked ? 'true' : 'false';
    },
    remove: function () {
      this.checked = false;
    }
  },
  disabled: {
    set: function (value) {
      if (value == 'false' || value == null) {
        this.disabled = false;
      } else {
        this.disabled = true;
      }
    },
    get: function () {
      return this.disabled ? 'true' : 'false';
    },
    remove: function () {
      this.disabled = false;
    }
  },
  name: {
    set: function (value) {
      this.name = value;
    },
    get: function () {
      return this.name;
    },
    remove: function () {
      this.name = null;
    }
  }
};
RadioButton.property = {
  name: {
    set: function (name) {
      if (name == null) this.$input.removeAttribute('name');else this.$input.setAttribute('name', name);
    },
    get: function () {
      return this.$input.getAttribute('name');
    }
  },
  disabled: {
    set: function (value) {
      this.$input.disabled = !!value;

      if (value) {
        this.addClass('disabled');
      } else {
        this.removeClass('disabled');
      }
    },
    get: function () {
      return this.$input.disabled;
    }
  }
};

RadioButton.getAllByName = function (name) {
  return (document.getElementsByTagName('input') || []).filter(function (elt) {
    return elt.getAttribute('type') == 'radio' && elt.getAttribute('name') == name;
  });
};

RadioButton.getValueByName = function (name) {
  var inputs = RadioButton.getAllByName(name);
  var res = null;
  var input;

  for (var i = 0; i < inputs.length; ++i) {
    input = inputs[i];

    if (input.checked) {
      res = input.value;
    }
  }

  return res;
};

RadioButton.autoReplace = function () {
  var placeHolders = Array.prototype.slice.call(document.getElementsByTagName(this.tag));
  var ph;
  var attOfPH;
  var attrs;
  var style;
  var classList;
  var attNode;
  var attrName, attrValue;
  var props;

  for (var i = 0; i < placeHolders.length; ++i) {
    ph = placeHolders[i];
    attOfPH = ph.attributes;
    classList = [];
    style = {};
    attrs = {};
    props = {};

    for (var j = 0; j < attOfPH.length; ++j) {
      attNode = attOfPH[j];
      attrName = attNode.nodeName;
      attrValue = attNode.nodeValue;

      if (attrName == 'style') {
        attrValue.trim().split(';').reduce(function (style, prop) {
          var p = prop.split(':');

          if (p.length == 2) {
            style[p[0].trim()] = p[1].trim();
          }

          return style;
        }, style);
      } else if (attrName == 'class') {
        classList = attrValue.trim().split(/\s+/);
      } else if (attrName == 'onchange') {
        props.onchange = new Function('event', 'sender', attrValue);
      } else {
        attrs[attrName] = attrValue;
      }
    }

    var newElt = _({
      tag: this.tag,
      attr: attrs,
      class: classList,
      style: style,
      props: props
    });

    $(ph).selfReplace(newElt);
  }
};

RadioButton.initAfterLoad = function () {
  _Dom.default.documentReady.then(function () {
    RadioButton.autoReplace();
  });
};

_ACore.default.install('RadioButton'.toLowerCase(), RadioButton);

var _default = RadioButton;
exports.default = _default;

VaKeR 2022