31
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-06-10 09:12:22 +00:00

Update patchtester.js

This commit is contained in:
Dimitris Grammatikogiannis 2023-10-07 00:12:23 +03:00 committed by GitHub
parent fbbc89169b
commit e6f60ab93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,31 +9,13 @@ if (typeof Joomla === 'undefined') {
throw new Error('PatchTester JavaScript requires the Joomla core JavaScript API') throw new Error('PatchTester JavaScript requires the Joomla core JavaScript API')
} }
document.addEventListener("DOMContentLoaded", function (event) { Joomla.submitbutton = (task) => {
const submitPatch = document.querySelectorAll(".submitPatch"); if (task !== 'reset' || confirm(Joomla.JText._('COM_PATCHTESTER_CONFIRM_RESET', 'Resetting will attempt to revert all applied patches and removes all backed up files. This may result in a corrupted environment. Are you sure you want to continue?'))) {
Joomla.submitform(task);
}
};
/** const PatchTester = {
* EventListener which listens on submitPatch Button,
* checks if it is an apply or revert method and
* processes the patch action
*
* @param {Event} event
*/
submitPatch.forEach(function (element) {
element.addEventListener("click", function (event) {
const currentTarget = event.currentTarget;
const task = `${currentTarget.dataset.task}.${currentTarget.dataset.task}`
const id = parseInt(currentTarget.dataset.id)
PatchTester.submitpatch(task, id);
});
});
});
!function (Joomla, window, document) {
'use strict';
window.PatchTester = {
/** /**
* Process the patch action * Process the patch action
* *
@ -48,9 +30,20 @@ document.addEventListener("DOMContentLoaded", function (event) {
} }
}; };
Joomla.submitbutton = function (task) { /**
if (task !== 'reset' || confirm(Joomla.JText._('COM_PATCHTESTER_CONFIRM_RESET', 'Resetting will attempt to revert all applied patches and removes all backed up files. This may result in a corrupted environment. Are you sure you want to continue?'))) { * EventListener which listens on submitPatch Button,
Joomla.submitform(task); * checks if it is an apply or revert method and
* processes the patch action
*
* @param {Event} event
*/
function patchSubmit(event) {
const currentTarget = event.currentTarget;
const task = `${currentTarget.dataset.task}.${currentTarget.dataset.task}`
const id = parseInt(currentTarget.dataset.id)
PatchTester.submitpatch(task, id);
} }
};
}(Joomla, window, document);
document.querySelectorAll(".submitPatch").forEach((element) => element.addEventListener("click", patchSubmit));