CoreFiles by mySites.guru
categories-default.es6.js49 lines, 1,534 bytes, from Joomla_4.0.0-alpha9-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha8
md5
4b93a99e24c565fcba5b4e3ffae1edce
sha1
da6acd946a5fc0f206f2096044887c459abd8a3a
sha256
c205f7af7bb64bd9e049948db20c01d9fa7f722a7082db3159c2ab354f8bcb71
/**
* 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
 */
(Joomla => {
  'use strict';

  if (!Joomla || typeof Joomla.JText !== 'function') {
    throw new Error('core.js was not properly initialised');
  } // 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 === Joomla.JText._('JGLOBAL_EXPAND_CATEGORIES') ? Joomla.JText._('JGLOBAL_COLLAPSE_CATEGORIES') : Joomla.JText._('JGLOBAL_EXPAND_CATEGORIES'));
  };
  /**
   * Script boot
   */


  const onBoot = () => {
    const buttons = [].slice.call(document.querySelectorAll(buttonsSelector));
    buttons.forEach(button => {
      button.addEventListener('click', handleCategoryToggleButtonClick);
    }); // Cleanup

    document.removeEventListener('DOMContentLoaded', onBoot);
  };

  document.addEventListener('DOMContentLoaded', onBoot);
})(Joomla);

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.