Skip to content

Commit e6f60ab

Browse files
authored
Update patchtester.js
1 parent fbbc891 commit e6f60ab

File tree

1 file changed

+35
-42
lines changed

1 file changed

+35
-42
lines changed

media/com_patchtester/js/patchtester.js

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,41 @@ if (typeof Joomla === 'undefined') {
99
throw new Error('PatchTester JavaScript requires the Joomla core JavaScript API')
1010
}
1111

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+
};
17+
18+
const PatchTester = {
19+
/**
20+
* Process the patch action
21+
*
22+
* @param {String} task The task to perform
23+
* @param {Number} id The item ID
24+
*/
25+
submitpatch: function (task, id) {
26+
var idField = document.getElementById('pull_id');
27+
idField.value = id;
28+
29+
Joomla.submitform(task);
30+
}
31+
};
1432

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;
33+
/**
34+
* EventListener which listens on submitPatch Button,
35+
* checks if it is an apply or revert method and
36+
* processes the patch action
37+
*
38+
* @param {Event} event
39+
*/
40+
function patchSubmit(event) {
41+
const currentTarget = event.currentTarget;
42+
const task = `${currentTarget.dataset.task}.${currentTarget.dataset.task}`
43+
const id = parseInt(currentTarget.dataset.id)
44+
45+
PatchTester.submitpatch(task, id);
46+
}
4647

47-
Joomla.submitform(task);
48-
}
49-
};
5048

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);
49+
document.querySelectorAll(".submitPatch").forEach((element) => element.addEventListener("click", patchSubmit));

0 commit comments

Comments
 (0)