Skip to content

Commit

Permalink
Merge pull request #69 from joomla-projects/remove-inline-scripts/com…
Browse files Browse the repository at this point in the history
…ponents/com_tags/tmpl/tags/default_items.php

remove-inline-scripts/components/com_tags/tmpl/tags/default_items.php
  • Loading branch information
dneukirchen authored Feb 25, 2018
2 parents 6397b5d + e9b57f9 commit 2b8f269
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
16 changes: 7 additions & 9 deletions components/com_tags/tmpl/tags/default_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');

JHtml::_('behavior.core');

HTMLHelper::_('script', 'com_tags/tags-default.js', ['relative' => true, 'version' => 'auto']);

// Get the user object.
$user = JFactory::getUser();

Expand All @@ -39,12 +43,6 @@
$bscolumns = min($columns, floor(12 / $bsspans));
$n = count($this->items);

JFactory::getDocument()->addScriptDeclaration("
var resetFilter = function() {
document.getElementById('filter-search').value = '';
}
");

?>

<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm">
Expand All @@ -55,12 +53,12 @@
<label class="filter-search-lbl sr-only" for="filter-search">
<?php echo JText::_('COM_TAGS_TITLE_FILTER_LABEL') . '&#160;'; ?>
</label>
<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="form-control" onchange="document.adminForm.submit();" title="<?php echo JText::_('COM_TAGS_FILTER_SEARCH_DESC'); ?>" placeholder="<?php echo JText::_('COM_TAGS_TITLE_FILTER_LABEL'); ?>">
<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="form-control" title="<?php echo JText::_('COM_TAGS_FILTER_SEARCH_DESC'); ?>" placeholder="<?php echo JText::_('COM_TAGS_TITLE_FILTER_LABEL'); ?>">
<span class="input-group-append">
<button type="button" name="filter-search-button" title="<?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?>" onclick="document.adminForm.submit();" class="btn btn-secondary">
<button type="submit" name="filter-search-button" title="<?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?>" class="btn btn-secondary">
<span class="fa fa-search" aria-hidden="true"></span>
</button>
<button type="reset" name="filter-clear-button" title="<?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?>" class="btn btn-secondary" onclick="resetFilter(); document.adminForm.submit();">
<button type="reset" name="filter-clear-button" title="<?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?>" class="btn btn-secondary">
<span class="fa fa-times" aria-hidden="true"></span>
</button>
</span>
Expand Down
19 changes: 19 additions & 0 deletions media/com_tags/js/tags-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(function (document) {
'use strict';

// selectors used in this scirpt
var formId = 'adminForm';
var searchFilterId = 'filter-search';

document.addEventListener('DOMContentLoaded', function () {
var form = document.getElementById(formId);
form.querySelector('button[type="reset"]').addEventListener('click', function(event) {
document.getElementById(searchFilterId).value = '';
form.submit();
})
});
})(document);

0 comments on commit 2b8f269

Please sign in to comment.