mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-12-22 19:09:00 +00:00
Update patchtester.js
This commit is contained in:
parent
fbbc89169b
commit
e6f60ab93a
@ -9,48 +9,41 @@ 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
|
* Process the patch action
|
||||||
* processes the patch action
|
*
|
||||||
*
|
* @param {String} task The task to perform
|
||||||
* @param {Event} event
|
* @param {Number} id The item ID
|
||||||
*/
|
*/
|
||||||
submitPatch.forEach(function (element) {
|
submitpatch: function (task, id) {
|
||||||
element.addEventListener("click", function (event) {
|
var idField = document.getElementById('pull_id');
|
||||||
const currentTarget = event.currentTarget;
|
idField.value = id;
|
||||||
const task = `${currentTarget.dataset.task}.${currentTarget.dataset.task}`
|
|
||||||
const id = parseInt(currentTarget.dataset.id)
|
|
||||||
|
|
||||||
PatchTester.submitpatch(task, id);
|
Joomla.submitform(task);
|
||||||
});
|
}
|
||||||
});
|
};
|
||||||
});
|
|
||||||
|
|
||||||
!function (Joomla, window, document) {
|
/**
|
||||||
'use strict';
|
* EventListener which listens on submitPatch Button,
|
||||||
|
* 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)
|
||||||
|
|
||||||
window.PatchTester = {
|
PatchTester.submitpatch(task, id);
|
||||||
/**
|
}
|
||||||
* Process the patch action
|
|
||||||
*
|
|
||||||
* @param {String} task The task to perform
|
|
||||||
* @param {Number} id The item ID
|
|
||||||
*/
|
|
||||||
submitpatch: function (task, id) {
|
|
||||||
var idField = document.getElementById('pull_id');
|
|
||||||
idField.value = id;
|
|
||||||
|
|
||||||
Joomla.submitform(task);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Joomla.submitbutton = function (task) {
|
document.querySelectorAll(".submitPatch").forEach((element) => element.addEventListener("click", patchSubmit));
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}(Joomla, window, document);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user