CoreFiles by mySites.guru
categories-default.js51 lines, 1,461 bytes, from Joomla_4.0.0-alpha5-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha3
md5
4831748378d80fb88b5ad4cba5426c26
sha1
02115d662b8b23e506917bd9e633fd2a0ef33f92
sha256
57a60b4bf892f23700b88bfb2bbadc35c4cd11f97a4bd060635a9642b30366c3
/**
 * @copyright  Copyright (C) 2005 - 2018 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);

No other release has this exact content. See every version of this file.