Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Remove inline Javascript for administrator/components/com_joomlaupda…
Browse files Browse the repository at this point in the history
…te/tmpl/update/default.php (#100)

* update2

* use array
  • Loading branch information
astridx authored and dneukirchen committed Mar 7, 2018
1 parent 0c36940 commit 3849822
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
24 changes: 13 additions & 11 deletions administrator/components/com_joomlaupdate/tmpl/update/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;

// Include jQuery.
JHtml::_('jquery.framework');

Expand All @@ -21,17 +24,16 @@
$ajaxUrl = JUri::base() . 'components/com_joomlaupdate/restore.php';
$returnUrl = 'index.php?option=com_joomlaupdate&task=update.finalise&' . JFactory::getSession()->getFormToken() . '=1';

JFactory::getDocument()->addScriptDeclaration(
"
var joomlaupdate_password = '$password';
var joomlaupdate_totalsize = '$filesize';
var joomlaupdate_ajax_url = '$ajaxUrl';
var joomlaupdate_return_url = '$returnUrl';
jQuery(document).ready(function(){
window.pingExtract();
});
"
HTMLHelper::_('script', 'com_joomlaupdate/admin-update-default.js', ['relative' => true, 'version' => 'auto']);

Factory::getDocument()->addScriptOptions(
'joomlaupdate',
[
'password' => $password,
'totalsize' => $filesize,
'ajax_url' => $ajaxUrl,
'return_url' => $returnUrl,
]
);
?>

Expand Down
17 changes: 17 additions & 0 deletions media/com_joomlaupdate/js/admin-update-default.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Joomla = window.Joomla || {};


document.addEventListener('DOMContentLoaded', () => {
const JoomlaUpdateOptions = Joomla.getOptions('joomlaupdate');
window.joomlaupdate_password = JoomlaUpdateOptions.password;
window.joomlaupdate_totalsize = JoomlaUpdateOptions.totalsize;
window.joomlaupdate_ajax_url = JoomlaUpdateOptions.ajax_url;
window.joomlaupdate_return_url = JoomlaUpdateOptions.return_url;
window.pingExtract();
});

20 changes: 20 additions & 0 deletions media/com_joomlaupdate/js/admin-update-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Joomla = window.Joomla || {};

document.addEventListener('DOMContentLoaded', function () {
var JoomlaUpdateOptions = Joomla.getOptions('joomlaupdate');
window.joomlaupdate_password = JoomlaUpdateOptions.password;
window.joomlaupdate_totalsize = JoomlaUpdateOptions.totalsize;
window.joomlaupdate_ajax_url = JoomlaUpdateOptions.ajax_url;
window.joomlaupdate_return_url = JoomlaUpdateOptions.return_url;
window.pingExtract();
});

0 comments on commit 3849822

Please sign in to comment.