- md5
- 68d2cde8906af007e71c437d80ed5901
- sha1
- 25f9fc79b1cb7e6364ee7f41741c7fbe4d520a4d
- sha256
- 7714ee5dce34f6d6229235fe0d3c9a9168c9f055ea55f44dd1836047c3ff638f
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
"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: document.getElementById("jform_smtpauth1").checked ? 1 : 0,
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: document.getElementById("jform_mailonline1").checked ? 1 : 0
}; // 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);
The same content is in 8 releases, Joomla 4.0.0-alpha7 to 4.0.0-beta2. See them all, or every version of this file.