CoreFiles by mySites.guru
admin-item-edit_container.js37 lines, 1,239 bytes, from Joomla_5.3.2-Stable-Full_Package.zip
Raw History Compare with 5.3.1
md5
dee9583fba299a6a4ef4669e0b9c8473
sha1
7a91ae2039181023aef5906f84b44d2b5b3f3b79
sha256
3b520207429ec8c2c8ff7ee03520239d5e57a37e55b22446884c498ba358002b
/**
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

(document => {
  const isChecked = element => element.checked;
  const getTreeElements = element => element.querySelectorAll('input[type="checkbox"]');
  const getTreeRoot = element => element.parentElement.nextElementSibling;
  const check = element => {
    element.checked = true;
  };
  const uncheck = element => {
    element.checked = false;
  };
  const disable = element => element.setAttribute('disabled', 'disabled');
  const enable = element => element.removeAttribute('disabled');
  const toggleState = (element, rootChecked) => {
    if (rootChecked === true) {
      disable(element);
      check(element);
      return;
    }
    enable(element);
    uncheck(element);
  };
  const switchState = ({
    target
  }) => {
    const root = getTreeRoot(target);
    const selfChecked = isChecked(target);
    if (root) {
      getTreeElements(root).forEach(element => toggleState(element, selfChecked));
    }
  };
  document.querySelectorAll('.treeselect input[type="checkbox"]').forEach(checkbox => checkbox.addEventListener('click', switchState));
})(document);

The same content is in 108 releases, Joomla 5.2.2-rc1 to 6.3.0-alpha1. See them all, or every version of this file.