[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/system/js/fields/ -> joomla-field-send-test-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    (function (customElements, Joomla) {
  96      var JoomlaFieldSendTestMail = /*#__PURE__*/function (_HTMLElement) {
  97        _inheritsLoose(JoomlaFieldSendTestMail, _HTMLElement);
  98  
  99        // attributeChangedCallback(attr, oldValue, newValue) {}
 100        function JoomlaFieldSendTestMail() {
 101          var _this;
 102  
 103          _this = _HTMLElement.call(this) || this;
 104  
 105          if (!Joomla) {
 106            throw new Error('Joomla API is not properly initiated');
 107          }
 108  
 109          if (!_this.getAttribute('uri')) {
 110            throw new Error('No valid url for validation');
 111          }
 112  
 113          return _this;
 114        }
 115  
 116        var _proto = JoomlaFieldSendTestMail.prototype;
 117  
 118        _proto.connectedCallback = function connectedCallback() {
 119          var self = this;
 120          var button = document.getElementById('sendtestmail');
 121  
 122          if (button) {
 123            button.addEventListener('click', function () {
 124              self.sendTestMail(self);
 125            });
 126          }
 127        };
 128  
 129        _proto.sendTestMail = function sendTestMail() {
 130          var emailData = {
 131            smtpauth: document.getElementById('jform_smtpauth1').checked ? 1 : 0,
 132            smtpuser: this.querySelector('[name="jform[smtpuser]"]').value,
 133            smtphost: this.querySelector('[name="jform[smtphost]"]').value,
 134            smtpsecure: this.querySelector('[name="jform[smtpsecure]"]').value,
 135            smtpport: this.querySelector('[name="jform[smtpport]"]').value,
 136            mailfrom: this.querySelector('[name="jform[mailfrom]"]').value,
 137            fromname: this.querySelector('[name="jform[fromname]"]').value,
 138            mailer: this.querySelector('[name="jform[mailer]"]').value,
 139            mailonline: document.getElementById('jform_mailonline1').checked ? 1 : 0
 140          };
 141          var smtppass = this.querySelector('[name="jform[smtppass]"]');
 142  
 143          if (smtppass.disabled === false) {
 144            emailData.smtppass = smtppass.value;
 145          } // Remove js messages, if they exist.
 146  
 147  
 148          Joomla.removeMessages();
 149          Joomla.request({
 150            url: this.getAttribute('uri'),
 151            method: 'POST',
 152            data: JSON.stringify(emailData),
 153            perform: true,
 154            headers: {
 155              'Content-Type': 'application/json'
 156            },
 157            onSuccess: function onSuccess(resp) {
 158              var response;
 159  
 160              try {
 161                response = JSON.parse(resp);
 162              } catch (e) {
 163                // eslint-disable-next-line no-console
 164                console.error(e);
 165              }
 166  
 167              if (typeof response.messages === 'object' && response.messages !== null) {
 168                Joomla.renderMessages(response.messages);
 169              }
 170  
 171              document.body.scrollIntoView({
 172                behavior: 'smooth'
 173              });
 174            },
 175            onError: function onError(xhr) {
 176              Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr));
 177              document.body.scrollIntoView({
 178                behavior: 'smooth'
 179              });
 180            }
 181          });
 182        };
 183  
 184        return JoomlaFieldSendTestMail;
 185      }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
 186  
 187      customElements.define('joomla-field-send-test-mail', JoomlaFieldSendTestMail);
 188    })(customElements, Joomla);
 189  
 190  })();


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