[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_templates/js/ -> admin-template-toggle-switch.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  (() => {
   6  
   7    const showDiffChangedOff = () => {
   8      const diffMain = document.getElementById('diff-main');
   9  
  10      if (diffMain) {
  11        diffMain.classList.remove('active');
  12  
  13        if (typeof Storage !== 'undefined') {
  14          localStorage.removeItem('diffSwitchState');
  15        }
  16      }
  17    };
  18  
  19    const showDiffChangedOn = () => {
  20      const diffMain = document.getElementById('diff-main');
  21  
  22      if (diffMain) {
  23        diffMain.classList.add('active');
  24  
  25        if (typeof Storage !== 'undefined') {
  26          localStorage.setItem('diffSwitchState', 'checked');
  27        }
  28      }
  29    };
  30  
  31    const showCoreChangedOff = () => {
  32      const override = document.getElementById('override-pane');
  33      const corePane = document.getElementById('core-pane');
  34      const fieldset = override.parentElement.parentElement;
  35  
  36      if (corePane && override) {
  37        corePane.classList.remove('active');
  38  
  39        if (fieldset.classList.contains('options-grid-form-half')) {
  40          fieldset.classList.remove('options-grid-form-half');
  41          fieldset.classList.add('options-grid-form-full');
  42        }
  43  
  44        if (typeof Storage !== 'undefined') {
  45          localStorage.removeItem('coreSwitchState');
  46        }
  47      }
  48    };
  49  
  50    const showCoreChangedOn = () => {
  51      const override = document.getElementById('override-pane');
  52      const corePane = document.getElementById('core-pane');
  53      const fieldset = override.parentElement.parentElement;
  54  
  55      if (corePane && override) {
  56        corePane.classList.add('active');
  57  
  58        if (fieldset.classList.contains('options-grid-form-full')) {
  59          fieldset.classList.remove('options-grid-form-full');
  60          fieldset.classList.add('options-grid-form-half');
  61        }
  62  
  63        if (Joomla.editors.instances.jform_core) {
  64          Joomla.editors.instances.jform_core.refresh();
  65        }
  66  
  67        if (typeof Storage !== 'undefined') {
  68          localStorage.setItem('coreSwitchState', 'checked');
  69        }
  70      }
  71    };
  72  
  73    document.addEventListener('DOMContentLoaded', () => {
  74      const JformShowDiffOn = document.getElementById('jform_show_diff1');
  75      const JformShowDiffOff = document.getElementById('jform_show_diff0');
  76      const JformShowCoreOn = document.getElementById('jform_show_core1');
  77      const JformShowCoreOff = document.getElementById('jform_show_core0');
  78  
  79      if (JformShowDiffOn && JformShowDiffOff) {
  80        JformShowDiffOn.addEventListener('click', showDiffChangedOn);
  81        JformShowDiffOff.addEventListener('click', showDiffChangedOff);
  82      }
  83  
  84      if (JformShowCoreOn && JformShowCoreOff) {
  85        JformShowCoreOn.addEventListener('click', showCoreChangedOn);
  86        JformShowCoreOff.addEventListener('click', showCoreChangedOff);
  87      }
  88  
  89      if (typeof Storage !== 'undefined' && localStorage.getItem('coreSwitchState') && JformShowCoreOn) {
  90        JformShowCoreOn.checked = true;
  91        JformShowCoreOff.checked = false;
  92        showCoreChangedOn();
  93      }
  94  
  95      if (typeof Storage !== 'undefined' && localStorage.getItem('diffSwitchState') && JformShowDiffOn) {
  96        JformShowDiffOn.checked = true;
  97        JformShowDiffOff.checked = false;
  98        showDiffChangedOn();
  99      }
 100    });
 101  })();


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