[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/system/js/ -> joomla-hidden-mail-es5.js (source)

   1  (function () {
   2    'use strict';
   3  
   4    function _inheritsLoose(subClass, superClass) {
   5      subClass.prototype = Object.create(superClass.prototype);
   6      subClass.prototype.constructor = subClass;
   7  
   8      _setPrototypeOf(subClass, superClass);
   9    }
  10  
  11    function _getPrototypeOf(o) {
  12      _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  13        return o.__proto__ || Object.getPrototypeOf(o);
  14      };
  15      return _getPrototypeOf(o);
  16    }
  17  
  18    function _setPrototypeOf(o, p) {
  19      _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  20        o.__proto__ = p;
  21        return o;
  22      };
  23  
  24      return _setPrototypeOf(o, p);
  25    }
  26  
  27    function _isNativeReflectConstruct() {
  28      if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  29      if (Reflect.construct.sham) return false;
  30      if (typeof Proxy === "function") return true;
  31  
  32      try {
  33        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  34        return true;
  35      } catch (e) {
  36        return false;
  37      }
  38    }
  39  
  40    function _construct(Parent, args, Class) {
  41      if (_isNativeReflectConstruct()) {
  42        _construct = Reflect.construct;
  43      } else {
  44        _construct = function _construct(Parent, args, Class) {
  45          var a = [null];
  46          a.push.apply(a, args);
  47          var Constructor = Function.bind.apply(Parent, a);
  48          var instance = new Constructor();
  49          if (Class) _setPrototypeOf(instance, Class.prototype);
  50          return instance;
  51        };
  52      }
  53  
  54      return _construct.apply(null, arguments);
  55    }
  56  
  57    function _isNativeFunction(fn) {
  58      return Function.toString.call(fn).indexOf("[native code]") !== -1;
  59    }
  60  
  61    function _wrapNativeSuper(Class) {
  62      var _cache = typeof Map === "function" ? new Map() : undefined;
  63  
  64      _wrapNativeSuper = function _wrapNativeSuper(Class) {
  65        if (Class === null || !_isNativeFunction(Class)) return Class;
  66  
  67        if (typeof Class !== "function") {
  68          throw new TypeError("Super expression must either be null or a function");
  69        }
  70  
  71        if (typeof _cache !== "undefined") {
  72          if (_cache.has(Class)) return _cache.get(Class);
  73  
  74          _cache.set(Class, Wrapper);
  75        }
  76  
  77        function Wrapper() {
  78          return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  79        }
  80  
  81        Wrapper.prototype = Object.create(Class.prototype, {
  82          constructor: {
  83            value: Wrapper,
  84            enumerable: false,
  85            writable: true,
  86            configurable: true
  87          }
  88        });
  89        return _setPrototypeOf(Wrapper, Class);
  90      };
  91  
  92      return _wrapNativeSuper(Class);
  93    }
  94  
  95    /**
  96     * @copyright  (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
  97     * @license    GNU General Public License version 2 or later; see LICENSE.txt
  98     */
  99    window.customElements.define('joomla-hidden-mail', /*#__PURE__*/function (_HTMLElement) {
 100      _inheritsLoose(_class, _HTMLElement);
 101  
 102      function _class() {
 103        var _this;
 104  
 105        _this = _HTMLElement.call(this) || this;
 106        _this.newElement = '';
 107        _this.base = '';
 108        return _this;
 109      }
 110      /**
 111       * Lifecycle
 112       */
 113  
 114  
 115      var _proto = _class.prototype;
 116  
 117      _proto.disconnectedCallback = function disconnectedCallback() {
 118        this.innerHTML = '';
 119      }
 120      /**
 121       * Lifecycle
 122       */
 123      ;
 124  
 125      _proto.connectedCallback = function connectedCallback() {
 126        var _this2 = this;
 127  
 128        this.base = this.getAttribute('base') + "/";
 129  
 130        if (this.getAttribute('is-link') === '1') {
 131          this.newElement = document.createElement('a');
 132          this.newElement.setAttribute('href', "mailto:" + this.constructor.b64DecodeUnicode(this.getAttribute('first')) + "@" + this.constructor.b64DecodeUnicode(this.getAttribute('last'))); // Get all of the original element attributes, and pass them to the link
 133  
 134          [].slice.call(this.attributes).forEach(function (attribute, index) {
 135            var _this2$attributes$ite = _this2.attributes.item(index),
 136                nodeName = _this2$attributes$ite.nodeName;
 137  
 138            if (nodeName) {
 139              // We do care for some attributes
 140              if (['is-link', 'is-email', 'first', 'last', 'text'].indexOf(nodeName) === -1) {
 141                var _this2$attributes$ite2 = _this2.attributes.item(index),
 142                    nodeValue = _this2$attributes$ite2.nodeValue;
 143  
 144                _this2.newElement.setAttribute(nodeName, nodeValue);
 145              }
 146            }
 147          });
 148        } else {
 149          this.newElement = document.createElement('span');
 150        }
 151  
 152        if (this.getAttribute('text')) {
 153          var innerStr = this.constructor.b64DecodeUnicode(this.getAttribute('text'));
 154          innerStr = innerStr.replace('src="images/', "src=\"" + this.base + "images/").replace('src="media/', "src=\"" + this.base + "media/");
 155          this.newElement.innerHTML = Joomla.sanitizeHtml(innerStr);
 156        } else {
 157          this.newElement.innerText = window.atob(this.getAttribute('first')) + "@" + window.atob(this.getAttribute('last'));
 158        } // Remove the noscript message
 159  
 160  
 161        this.innerText = ''; // Display the new element
 162  
 163        this.appendChild(this.newElement);
 164      };
 165  
 166      _class.b64DecodeUnicode = function b64DecodeUnicode(str) {
 167        return decodeURIComponent(Array.prototype.map.call(atob(str), function (c) {
 168          return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
 169        }).join(''));
 170      };
 171  
 172      return _class;
 173    }( /*#__PURE__*/_wrapNativeSuper(HTMLElement)));
 174  
 175  })();


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer