[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 /** 2 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 3 * @license GNU General Public License version 2 or later; see LICENSE.txt 4 */ 5 if (!Joomla || !Joomla.Text) { 6 throw new Error('core.js was not properly initialised'); 7 } // Selectors used by this script 8 9 10 const buttonsSelector = '[id^=category-btn-]'; 11 /** 12 * Handle the category toggle button click event 13 * @param event 14 */ 15 16 const handleCategoryToggleButtonClick = ({ 17 currentTarget 18 }) => { 19 const button = currentTarget; 20 const icon = button.querySelector('span'); // Toggle icon class 21 22 icon.classList.toggle('icon-plus'); 23 icon.classList.toggle('icon-minus'); // Toggle aria label, aria-expanded 24 25 const ariaLabel = button.getAttribute('aria-label'); 26 const ariaExpanded = button.getAttribute('aria-expanded'); 27 button.setAttribute('aria-label', ariaLabel === Joomla.Text._('JGLOBAL_EXPAND_CATEGORIES') ? Joomla.Text._('JGLOBAL_COLLAPSE_CATEGORIES') : Joomla.Text._('JGLOBAL_EXPAND_CATEGORIES')); 28 button.setAttribute('aria-expanded', ariaExpanded === 'false' ? 'true' : 'false'); 29 const { 30 categoryId 31 } = button.dataset; 32 const target = document.getElementById(`category-$categoryId}`); 33 target.toggleAttribute('hidden'); 34 }; 35 36 Array.from(document.querySelectorAll(buttonsSelector)).forEach(button => { 37 button.addEventListener('click', handleCategoryToggleButtonClick); 38 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |