33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-30 16:53:59 +00:00

Update script.js

This commit is contained in:
Dimitris Grammatikogiannis 2022-01-15 16:33:10 +01:00 committed by GitHub
parent 9d12ef26e1
commit 8769bcc066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,18 +1,18 @@
(() => { (() => {
const jsonDataElement = document.getElementById('jed-rules-json'); const jsonDataElement = document.getElementById('jed-rules-json');
if (!jsonDataElement) { if (!jsonDataElement) {
thrown new Error('Initialization data is missing'); throw new Error('Initialization data is missing');
} }
let jedOptions; let jedOptions;
try { try {
jedOptions = JSON.parse(jsonDataElement.innerHTML); jedOptions = JSON.parse(jsonDataElement.innerHTML);
} catch (e) { } catch (e) {
thrown new Error('Initialization data is missing'); throw new Error('Initialization data is missing');
} }
if (!jedOptions) thrown new Error('Initialization data is missing'); if (!jedOptions) throw new Error('Initialization data is missing');
const add_validation = () => { add_validation = () => {
// Loop over them and prevent submission // Loop over them and prevent submission
[...document.querySelectorAll('.needs-validation')].forEach((form) => { [...document.querySelectorAll('.needs-validation')].forEach((form) => {
form.addEventListener('submit', (event) => { form.addEventListener('submit', (event) => {
@ -66,7 +66,7 @@
} }
let jed_collapse_init = false; let jed_collapse_init = false;
Joomla.submitbutton = function (task) { window.Joomla.submitbutton = function (task) {
if (task == 'check') { if (task == 'check') {
[...document.querySelectorAll(".jedchecker-results")].map((el) => el.removeClass("hidden")); [...document.querySelectorAll(".jedchecker-results")].map((el) => el.removeClass("hidden"));
[...document.querySelectorAll('.jedchecker-results .badge:not(.bg-success)')].map((el) => el.innerHTML = ''); [...document.querySelectorAll('.jedchecker-results .badge:not(.bg-success)')].map((el) => el.innerHTML = '');
@ -94,5 +94,11 @@
} }
} }
document.getElementById('extension-upload').addEventListener('click', (event) => {
add_validation();
document.getElementById('jed_uploading_spinner').classList.remove('hidden');
Joomla.submitbutton('uploads.upload')
});
new bootstrap.Tooltip(document.getElementById('jedchecker'), {container: 'body', selector: '[data-bs-toggle=tooltip]'}); new bootstrap.Tooltip(document.getElementById('jedchecker'), {container: 'body', selector: '[data-bs-toggle=tooltip]'});
})(); })();