Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions build/media/com_newsfeeds/js/categories-default.js

This file was deleted.

46 changes: 46 additions & 0 deletions build/media_src/com_newsfeeds/js/categories-default.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
((JText) => {
'use strict';

// Selectors used by this script
const buttonsSelector = '[id^=category-btn-]';

/**
* Handle the category toggle button click event
* @param event
*/
const handleCategoryToggleButtonClick = (event) => {
const button = event.currentTarget;
const icon = button.querySelector('span');

// Toggle icon class
icon.classList.toggle('icon-plus');
icon.classList.toggle('icon-minus');

// Toggle aria label
const ariaLabel = button.getAttribute('aria-label');
button.setAttribute(
'aria-label',
(ariaLabel === JText._('JGLOBAL_COLLAPSE_CATEGORIES')
|| JText._('JGLOBAL_EXPAND_CATEGORIES'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing comma comma-dangle

);
};

/**
* Register the events
*/
const registerEvents = () => {
const buttons = [].slice.call(document.querySelectorAll(buttonsSelector));
buttons.forEach((button) => {
button.addEventListener('click', handleCategoryToggleButtonClick);
});

// Cleanup
document.removeEventListener('DOMContentLoaded', registerEvents);
};

document.addEventListener('DOMContentLoaded', registerEvents);
})(Joomla.JText);