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
88if ( 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