- md5
- 19ca8d078615c2cd799fa1da7948a1a4
- sha1
- 59a1f423e462cf9836d10271ead6093737fa49f4
- sha256
- 4c25f95eae8c907831e0e22aa061ea3c7529f26ff2be2c23ebe6c15bbbc45726
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
/**
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(document => {
document.addEventListener('DOMContentLoaded', () => {
window.jSelectModuleType = () => {
const elements = document.querySelectorAll('#moduleDashboardAddModal .modal-footer .btn.hidden');
if (elements.length) {
setTimeout(() => {
elements.forEach(button => {
button.classList.remove('hidden');
});
}, 1000);
}
};
const buttons = document.querySelectorAll('#moduleDashboardAddModal .modal-footer .btn');
const hideButtons = [];
let isSaving = false;
if (buttons.length) {
buttons.forEach(button => {
if (button.classList.contains('hidden')) {
hideButtons.push(button);
}
button.addEventListener('click', event => {
let elem = event.currentTarget; // There is some bug with events in iframe where currentTarget is "null"
// => prevent this here by bubble up
if (!elem) {
elem = event.target;
}
if (elem) {
const clickTarget = elem.dataset.bsTarget; // We remember to be in the saving process
isSaving = clickTarget === '#saveBtn'; // Reset saving process, if e.g. the validation of the form fails
setTimeout(() => {
isSaving = false;
}, 1500);
const iframe = document.querySelector('#moduleDashboardAddModal iframe');
const content = iframe.contentDocument || iframe.contentWindow.document;
const targetBtn = content.querySelector(clickTarget);
if (targetBtn) {
targetBtn.click();
}
}
});
});
}
const elementH = document.querySelector('#moduleDashboardAddModal');
if (elementH) {
elementH.addEventListener('hide.bs.modal', () => {
hideButtons.forEach(button => {
button.classList.add('hidden');
});
});
elementH.addEventListener('hidden.bs.modal', () => {
if (isSaving) {
setTimeout(() => {
window.parent.location.reload();
}, 1000);
}
});
}
});
})(document);
The same content is in 68 releases, Joomla 4.0.0-rc1 to 4.2.9. See them all, or every version of this file.