Skip to content

Commit

Permalink
Transform com_finder to ES6 and remove inline script [ Part 3 ] (joom…
Browse files Browse the repository at this point in the history
…la#92)

* com_finder es6 3

* Update index.es6.js

* Update index.js

* //TODO replace with joomla-alert

* //TODO replace with joomla-alert

* make simple

* make simple

* make simple
  • Loading branch information
anuragteapot authored and dneukirchen committed Mar 11, 2018
1 parent 70cbc83 commit 5982b99
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 30 deletions.
32 changes: 2 additions & 30 deletions administrator/components/com_finder/tmpl/index/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

use Joomla\Component\Finder\Administrator\Helper\FinderHelperLanguage;
use Joomla\CMS\HTML\HTMLHelper;

JHtml::_('bootstrap.popover');

Expand All @@ -19,36 +20,7 @@

JText::script('COM_FINDER_INDEX_CONFIRM_PURGE_PROMPT');
JText::script('COM_FINDER_INDEX_CONFIRM_DELETE_PROMPT');

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

0 comments on commit 5982b99

Please sign in to comment.