2016-03-16 05:18:16 +00:00
/ * *
* Patch testing component for the Joomla ! CMS
*
2018-09-01 14:32:23 +00:00
* @ copyright Copyright ( C ) 2011 - 2012 Ian MacLennan , Copyright ( C ) 2013 - 2018 Open Source Matters , Inc . All rights reserved .
2016-03-16 05:18:16 +00:00
* @ license GNU General Public License version 2 or later
* /
2015-12-05 18:08:38 +00:00
2016-03-16 05:18:16 +00:00
if ( typeof Joomla === 'undefined' ) {
throw new Error ( 'PatchTester JavaScript requires the Joomla core JavaScript API' )
}
2015-12-05 18:08:38 +00:00
2019-10-01 12:07:26 +00:00
document . addEventListener ( "DOMContentLoaded" , function ( event ) {
var submitPatch = document . querySelectorAll ( ".submitPatch" ) ;
2016-03-16 05:18:16 +00:00
2019-09-10 13:22:19 +00:00
/ * *
* EventListener which listens on submitPatch Button ,
* checks if it is an apply or revert method and
* processes the patch action
*
* @ param { Event } event
* /
2019-10-01 12:07:26 +00:00
submitPatch . forEach ( function ( element ) {
element . addEventListener ( "click" , function ( event ) {
var currentTarget = event . currentTarget ;
2020-03-21 10:26:42 +00:00
var task = currentTarget . dataset . task
var id = currentTarget . dataset . id
2016-03-16 05:18:16 +00:00
2020-03-21 10:26:42 +00:00
PatchTester . submitpatch ( task , id ) ;
2019-10-01 12:07:26 +00:00
} ) ;
} ) ;
2019-09-10 13:22:19 +00:00
} ) ;
2020-03-21 10:26:42 +00:00
! 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 ) {
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 ) ;