[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_menus/js/ -> admin-item-edit_container.js (source)

   1  /**
   2   * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   3   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   4   */
   5  (document => {
   6    const isChecked = element => element.checked;
   7  
   8    const getTreeElements = element => element.querySelectorAll('input[type="checkbox"]');
   9  
  10    const getTreeRoot = element => element.parentElement.nextElementSibling;
  11  
  12    const check = element => {
  13      element.checked = true;
  14    };
  15  
  16    const uncheck = element => {
  17      element.checked = false;
  18    };
  19  
  20    const disable = element => element.setAttribute('disabled', 'disabled');
  21  
  22    const enable = element => element.removeAttribute('disabled');
  23  
  24    const toggleState = (element, rootChecked) => {
  25      if (rootChecked === true) {
  26        disable(element);
  27        check(element);
  28        return;
  29      }
  30  
  31      enable(element);
  32      uncheck(element);
  33    };
  34  
  35    const switchState = ({
  36      target
  37    }) => {
  38      const root = getTreeRoot(target);
  39      const selfChecked = isChecked(target);
  40  
  41      if (root) {
  42        getTreeElements(root).map(element => toggleState(element, selfChecked));
  43      }
  44    };
  45  
  46    [].slice.call(document.querySelectorAll('.treeselect input[type="checkbox"]')).forEach(checkbox => {
  47      checkbox.addEventListener('click', switchState);
  48    });
  49  })(document);


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer