CoreFiles by mySites.guru
categories-default.js49 lines, 1,587 bytes, from Joomla_4.0.0-alpha8-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha7
md5
2a01982a8bf9b51d178243eb9cb3984e
sha1
dd671374d1c9b8df0b580d8d2b2410c75a9e225e
sha256
3985fe71c547b76ee0ff6ea2abb8c56704f622e8c440c60b2f4214bf4a3875fe
/**
* 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
 */
(function (Joomla) {
  'use strict';

  if (!Joomla || typeof Joomla.JText !== 'function') {
    throw new Error('core.js was not properly initialised');
  } // Selectors used by this script


  var buttonsSelector = '[id^=category-btn-]';
  /**
   * Handle the category toggle button click event
   * @param event
   */

  var handleCategoryToggleButtonClick = function handleCategoryToggleButtonClick(event) {
    var button = event.currentTarget;
    var icon = button.querySelector('span'); // Toggle icon class

    icon.classList.toggle('icon-plus');
    icon.classList.toggle('icon-minus'); // Toggle aria label

    var 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
   */


  var onBoot = function onBoot() {
    var buttons = [].slice.call(document.querySelectorAll(buttonsSelector));
    buttons.forEach(function (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.