Skip to content

Commit c877301

Browse files
authored
more simplifications
1 parent 2887150 commit c877301

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed
Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Patch testing component for the Joomla! CMS
33
*
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
66
*/
77

88
if (typeof Joomla === 'undefined') {
@@ -15,32 +15,19 @@ Joomla.submitbutton = (task) => {
1515
}
1616
};
1717

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: (task, id) => {
26-
const value = document.getElementById('pull_id')?.value;
27-
28-
if (value) {
29-
value = id;
30-
}
31-
32-
Joomla.submitform(task);
33-
}
34-
};
35-
3618
/**
3719
* EventListener which listens on submitPatch Button,
3820
* checks if it is an apply or revert method and
3921
* processes the patch action
4022
*
4123
* @param {Event} event
4224
*/
43-
const patchSubmit = (event) => PatchTester.submitpatch(`${event.currentTarget.dataset.task}.${currentTarget.dataset.task}`, parseInt(event.currentTarget.dataset.id));
44-
25+
document.querySelectorAll(".submitPatch").forEach((element) => element.addEventListener("click", (event) => {
26+
const value = document.getElementById('pull_id')?.value;
27+
28+
if (value) {
29+
value = parseInt(event.currentTarget.dataset.id);
30+
}
4531

46-
document.querySelectorAll(".submitPatch").forEach((element) => element.addEventListener("click", patchSubmit));
32+
Joomla.submitform(`${event.currentTarget.dataset.task}.${currentTarget.dataset.task}`);
33+
}));

0 commit comments

Comments
 (0)