CoreFiles by mySites.guru
categories-default.es6.js44 lines, 1,390 bytes, from Joomla_4.0.0-alpha7-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha6
md5
c5603f8ce62a9fd5028addbf4de34e1e
sha1
7e148f05326d7985885ca2cd61c6991928b192a5
sha256
fed5fcb2586e91363edf06e8bea6389f692ceac7949191a49085a83877ba410f
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright  Copyright (C) 2005 - 2019 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'));
  };
  /**
   * 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);

The same content is in 6 releases, Joomla 4.0.0-alpha7 to 4.0.0-alpha12. See them all, or every version of this file.