CoreFiles by mySites.guru
categories-default.es6.js46 lines, 1,310 bytes, from Joomla_4.0.0-alpha5-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha3
md5
aa5a6ec70a67e384586652b8f670cfff
sha1
66f2800c55361c5caf3baa7f0a8b059676a58184
sha256
aad09aa1278d048f115b934bccf476dc431f5a50de53b1294692f97817152369
/**
 * @copyright  Copyright (C) 2005 - 2018 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 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.