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

Commit

Permalink
Transform com_finder to ES6 and remove inline script [ Part1 ] (#90)
Browse files Browse the repository at this point in the history
* com_finder es6 1

* make simple
  • Loading branch information
anuragteapot authored and dneukirchen committed Mar 10, 2018
1 parent a823fc7 commit bbcc06b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
21 changes: 3 additions & 18 deletions administrator/components/com_finder/tmpl/filters/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,15 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;

$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));

JText::script('COM_FINDER_INDEX_CONFIRM_DELETE_PROMPT');

JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbutton = function(pressbutton)
{
if (pressbutton == "filters.delete")
{
if (confirm(Joomla.JText._("COM_FINDER_INDEX_CONFIRM_DELETE_PROMPT")))
{
Joomla.submitform(pressbutton);
}
else
{
return false;
}
}
Joomla.submitform(pressbutton);
};
');
HTMLHelper::_('script', 'com_finder/filters.js', ['relative' => true, 'version' => 'auto']);
?>
<form action="<?php echo JRoute::_('index.php?option=com_finder&view=filters'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
Expand Down
20 changes: 20 additions & 0 deletions media/com_finder/js/filters.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @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 || {};

(() => {
'use strict';

document.addEventListener('DOMContentLoaded', () => {
Joomla.submitbutton = (pressbutton) => {
if (pressbutton === 'filters.delete' && !window.confirm(Joomla.JText._('COM_FINDER_INDEX_CONFIRM_DELETE_PROMPT'))) {
return false;
}
Joomla.submitform(pressbutton);
return true;
};
});
})();
25 changes: 25 additions & 0 deletions media/com_finder/js/filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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 () {
'use strict';

document.addEventListener('DOMContentLoaded', function () {
Joomla.submitbutton = function (pressbutton) {
if (pressbutton === 'filters.delete' && !window.confirm(Joomla.JText._('COM_FINDER_INDEX_CONFIRM_DELETE_PROMPT'))) {
return false;
}
Joomla.submitform(pressbutton);
return true;
};
});
})();

0 comments on commit bbcc06b

Please sign in to comment.