Skip to content

Commit

Permalink
Remove inline js of com_cache (#105)
Browse files Browse the repository at this point in the history
* Remove inline js of com_cache

* Don't use this
  • Loading branch information
laoneo authored and dneukirchen committed Mar 12, 2018
1 parent d6a04ef commit a4e4a40
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
9 changes: 5 additions & 4 deletions administrator/components/com_cache/tmpl/cache/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));

\Joomla\CMS\HTML\HTMLHelper::_('script', 'com_cache/admin-cache-default.js', ['relative' => true, 'version' => 'auto']);
?>
<form action="<?php echo JRoute::_('index.php?option=com_cache'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
Expand Down Expand Up @@ -46,12 +48,11 @@
</tr>
</tfoot>
<tbody>
<?php
$i = 0;
foreach ($this->data as $folder => $item) : ?>
<?php $i = 0; ?>
<?php foreach ($this->data as $folder => $item) : ?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<input type="checkbox" id="cb<?php echo $i; ?>" name="cid[]" value="<?php echo $this->escape($item->group); ?>" onclick="Joomla.isChecked(this.checked);">
<input type="checkbox" id="cb<?php echo $i; ?>" name="cid[]" value="<?php echo $this->escape($item->group); ?>" class="cache-entry">
</td>
<td>
<label for="cb<?php echo $i; ?>">
Expand Down
18 changes: 18 additions & 0 deletions media/com_cache/js/admin-cache-default.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Joomla = window.Joomla || {};

((document, Joomla) => {
'use strict';

document.addEventListener('DOMContentLoaded', () => {
[].slice.call(document.querySelectorAll('.cache-entry')).forEach((el) => {
el.addEventListener('click', (event) => {
Joomla.isChecked(event.currentTarget.checked);
});
});
});
})(document, Joomla);
23 changes: 23 additions & 0 deletions media/com_cache/js/admin-cache-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* 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 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Joomla = window.Joomla || {};

(function (document, Joomla) {
'use strict';

document.addEventListener('DOMContentLoaded', function () {
[].slice.call(document.querySelectorAll('.cache-entry')).forEach(function (el) {
el.addEventListener('click', function (event) {
Joomla.isChecked(event.currentTarget.checked);
});
});
});
})(document, Joomla);

0 comments on commit a4e4a40

Please sign in to comment.