Skip to content

Commit 043b646

Browse files
dGrammatikowilsonge
authored andcommitted
[4.0] ES6 please, com newsfeed (#21433)
* com_newsfeed * woof * woof ?
1 parent 6753221 commit 043b646

File tree

2 files changed

+46
-43
lines changed

2 files changed

+46
-43
lines changed

build/media/com_newsfeeds/js/categories-default.js

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
3+
* @license GNU General Public License version 2 or later; see LICENSE.txt
4+
*/
5+
((JText) => {
6+
'use strict';
7+
8+
// Selectors used by this script
9+
const buttonsSelector = '[id^=category-btn-]';
10+
11+
/**
12+
* Handle the category toggle button click event
13+
* @param event
14+
*/
15+
const handleCategoryToggleButtonClick = (event) => {
16+
const button = event.currentTarget;
17+
const icon = button.querySelector('span');
18+
19+
// Toggle icon class
20+
icon.classList.toggle('icon-plus');
21+
icon.classList.toggle('icon-minus');
22+
23+
// Toggle aria label
24+
const ariaLabel = button.getAttribute('aria-label');
25+
button.setAttribute(
26+
'aria-label',
27+
(ariaLabel === JText._('JGLOBAL_COLLAPSE_CATEGORIES')
28+
|| JText._('JGLOBAL_EXPAND_CATEGORIES')),
29+
);
30+
};
31+
32+
/**
33+
* Register the events
34+
*/
35+
const registerEvents = () => {
36+
const buttons = [].slice.call(document.querySelectorAll(buttonsSelector));
37+
buttons.forEach((button) => {
38+
button.addEventListener('click', handleCategoryToggleButtonClick);
39+
});
40+
41+
// Cleanup
42+
document.removeEventListener('DOMContentLoaded', registerEvents);
43+
};
44+
45+
document.addEventListener('DOMContentLoaded', registerEvents);
46+
})(Joomla.JText);

0 commit comments

Comments
 (0)