[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_categories/js/ -> shared-categories-accordion-es5.js (source)

   1  (function () {
   2    'use strict';
   3  
   4    /**
   5     * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   6     * @license    GNU General Public License version 2 or later; see LICENSE.txt
   7     */
   8    if (!Joomla || !Joomla.Text) {
   9      throw new Error('core.js was not properly initialised');
  10    } // Selectors used by this script
  11  
  12  
  13    var buttonsSelector = '[id^=category-btn-]';
  14    /**
  15     * Handle the category toggle button click event
  16     * @param event
  17     */
  18  
  19    var handleCategoryToggleButtonClick = function handleCategoryToggleButtonClick(_ref) {
  20      var currentTarget = _ref.currentTarget;
  21      var button = currentTarget;
  22      var icon = button.querySelector('span'); // Toggle icon class
  23  
  24      icon.classList.toggle('icon-plus');
  25      icon.classList.toggle('icon-minus'); // Toggle aria label, aria-expanded
  26  
  27      var ariaLabel = button.getAttribute('aria-label');
  28      var ariaExpanded = button.getAttribute('aria-expanded');
  29      button.setAttribute('aria-label', ariaLabel === Joomla.Text._('JGLOBAL_EXPAND_CATEGORIES') ? Joomla.Text._('JGLOBAL_COLLAPSE_CATEGORIES') : Joomla.Text._('JGLOBAL_EXPAND_CATEGORIES'));
  30      button.setAttribute('aria-expanded', ariaExpanded === 'false' ? 'true' : 'false');
  31      var categoryId = button.dataset.categoryId;
  32      var target = document.getElementById("category-" + categoryId);
  33      target.toggleAttribute('hidden');
  34    };
  35  
  36    Array.from(document.querySelectorAll(buttonsSelector)).forEach(function (button) {
  37      button.addEventListener('click', handleCategoryToggleButtonClick);
  38    });
  39  
  40  })();


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer