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

Merge pull request #368 from dgrammatiko/patch-1

Update js scripts
This commit is contained in:
Roland Dalmulder 2023-10-10 12:28:01 +02:00 committed by GitHub
commit 3c132ba2e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 49 deletions

View File

@ -10,8 +10,7 @@
"type": "script", "type": "script",
"uri": "com_patchtester/fetcher.js", "uri": "com_patchtester/fetcher.js",
"attributes": { "attributes": {
"type": "module", "type": "module"
"defer": true
} }
}, },
{ {
@ -19,8 +18,7 @@
"type": "script", "type": "script",
"uri": "com_patchtester/patchtester.js", "uri": "com_patchtester/patchtester.js",
"attributes": { "attributes": {
"type": "module", "type": "module"
"defer": true
} }
}, },
{ {

View File

@ -1,16 +1,19 @@
/** /**
* Patch testing component for the Joomla! CMS * Patch testing component for the Joomla! CMS
* *
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved. * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later * @license GNU General Public License version 2 or later; see LICENSE.txt
*/ */
if (typeof Joomla === 'undefined') { 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);
}
};
/** /**
* EventListener which listens on submitPatch Button, * EventListener which listens on submitPatch Button,
@ -19,38 +22,13 @@ document.addEventListener("DOMContentLoaded", function (event) {
* *
* @param {Event} event * @param {Event} event
*/ */
submitPatch.forEach(function (element) { document.querySelectorAll(".submitPatch").forEach((element) => element.addEventListener("click", (event) => {
element.addEventListener("click", function (event) { const element = document.getElementById('pull_id');
const currentTarget = event.currentTarget; const target = event.currentTarget;
const task = `${currentTarget.dataset.task}.${currentTarget.dataset.task}`
const id = parseInt(currentTarget.dataset.id)
PatchTester.submitpatch(task, id); if (element) {
}); element.value = parseInt(target.dataset.id);
});
});
!function (Joomla, window, document) {
'use strict';
window.PatchTester = {
/**
* 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) { Joomla.submitform(`${target.dataset.task}.${target.dataset.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?'))) { }));
Joomla.submitform(task);
}
};
}(Joomla, window, document);