|
1 | 1 | /** |
2 | 2 | * Patch testing component for the Joomla! CMS |
3 | 3 | * |
4 | | - * @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved. |
5 | | - * @license GNU General Public License version 2 or later |
| 4 | + * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> |
| 5 | + * @license GNU General Public License version 2 or later; see LICENSE.txt |
6 | 6 | */ |
7 | 7 |
|
8 | 8 | if (typeof Joomla === 'undefined') { |
9 | 9 | throw new Error('PatchTester JavaScript requires the Joomla core JavaScript API') |
10 | 10 | } |
11 | 11 |
|
12 | | -document.addEventListener("DOMContentLoaded", function (event) { |
13 | | - const submitPatch = document.querySelectorAll(".submitPatch"); |
| 12 | +Joomla.submitbutton = (task) => { |
| 13 | + 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?'))) { |
| 14 | + Joomla.submitform(task); |
| 15 | + } |
| 16 | +}; |
14 | 17 |
|
15 | | - /** |
16 | | - * EventListener which listens on submitPatch Button, |
17 | | - * checks if it is an apply or revert method and |
18 | | - * processes the patch action |
19 | | - * |
20 | | - * @param {Event} event |
21 | | - */ |
22 | | - submitPatch.forEach(function (element) { |
23 | | - element.addEventListener("click", function (event) { |
24 | | - const currentTarget = event.currentTarget; |
25 | | - const task = `${currentTarget.dataset.task}.${currentTarget.dataset.task}` |
26 | | - const id = parseInt(currentTarget.dataset.id) |
27 | | - |
28 | | - PatchTester.submitpatch(task, id); |
29 | | - }); |
30 | | - }); |
31 | | -}); |
32 | | - |
33 | | -!function (Joomla, window, document) { |
34 | | - 'use strict'; |
35 | | - |
36 | | - window.PatchTester = { |
37 | | - /** |
38 | | - * Process the patch action |
39 | | - * |
40 | | - * @param {String} task The task to perform |
41 | | - * @param {Number} id The item ID |
42 | | - */ |
43 | | - submitpatch: function (task, id) { |
44 | | - var idField = document.getElementById('pull_id'); |
45 | | - idField.value = id; |
46 | | - |
47 | | - Joomla.submitform(task); |
48 | | - } |
49 | | - }; |
50 | | - |
51 | | - Joomla.submitbutton = function (task) { |
52 | | - 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?'))) { |
53 | | - Joomla.submitform(task); |
54 | | - } |
55 | | - }; |
56 | | -}(Joomla, window, document); |
| 18 | +/** |
| 19 | + * EventListener which listens on submitPatch Button, |
| 20 | + * checks if it is an apply or revert method and |
| 21 | + * processes the patch action |
| 22 | + * |
| 23 | + * @param {Event} event |
| 24 | + */ |
| 25 | +document.querySelectorAll(".submitPatch").forEach((element) => element.addEventListener("click", (event) => { |
| 26 | + const element = document.getElementById('pull_id'); |
| 27 | + const target = event.currentTarget; |
| 28 | + |
| 29 | + if (element) { |
| 30 | + element.value = parseInt(target.dataset.id); |
| 31 | + } |
| 32 | + |
| 33 | + Joomla.submitform(`${target.dataset.task}.${target.dataset.task}`); |
| 34 | +})); |
0 commit comments