CoreFiles by mySites.guru
joomla-field-send-test-mail.js70 lines, 2,203 bytes, from Joomla_4.0.0-alpha6-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha5
md5
cbec6ea2d7a7e83bc90fd81b7fa6cac9
sha1
db27ff7aa2ce89b23911e58171d956faae78b81c
sha256
050f1c010ee6a7b0c08983c40d2aef4fe09042b2df44ec52a23dce4289f08584
"use strict";

;

((customElements, Joomla) => {
  class JoomlaFieldSendTestMail extends HTMLElement {
    // attributeChangedCallback(attr, oldValue, newValue) {}
    constructor() {
      super();

      if (!Joomla) {
        throw new Error('Joomla API is not properly initiated');
      }

      if (!this.getAttribute('uri')) {
        throw new Error('No valid url for validation');
      }
    }

    connectedCallback() {
      const self = this;
      const button = document.getElementById('sendtestmail');

      if (button) {
        button.addEventListener('click', () => {
          self.sendTestMail(self);
        });
      }
    }

    sendTestMail() {
      const email_data = {
        smtpauth: this.querySelector('[name="jform[smtpauth]"]').value,
        smtpuser: this.querySelector('[name="jform[smtpuser]"]').value,
        smtppass: this.querySelector('[name="jform[smtppass]"]').value,
        smtphost: this.querySelector('[name="jform[smtphost]"]').value,
        smtpsecure: this.querySelector('[name="jform[smtpsecure]"]').value,
        smtpport: this.querySelector('[name="jform[smtpport]"]').value,
        mailfrom: this.querySelector('[name="jform[mailfrom]"]').value,
        fromname: this.querySelector('[name="jform[fromname]"]').value,
        mailer: this.querySelector('[name="jform[mailer]"]').value,
        mailonline: this.querySelector('[name="jform[mailonline]"]').value
      }; // Remove js messages, if they exist.

      Joomla.removeMessages();
      Joomla.request({
        url: this.getAttribute('uri'),
        method: 'POST',
        data: JSON.stringify(email_data),
        perform: true,
        headers: {
          'Content-Type': 'application/json'
        },
        onSuccess: (response, xhr) => {
          response = JSON.parse(response);

          if (typeof response.messages === 'object' && response.messages !== null) {
            Joomla.renderMessages(response.messages);
          }
        },
        onError: xhr => {
          Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr));
        }
      });
    }

  }

  customElements.define('joomla-field-send-test-mail', JoomlaFieldSendTestMail);
})(customElements, Joomla);

No other release has this exact content. See every version of this file.