CoreFiles by mySites.guru
admin-template-toggle-switch.es6.js107 lines, 3,380 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
6142aa3bc9d9f0f01abd9a980ace6d1e
sha1
331547e8e5c3a5bdf565fcd80fc2489771ed2ec9
sha256
f41c1d84492881b22addaeac0e6cba10cf3e1f9122fecfd7d15bc71777efed95
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
(() => {
  'use strict';

  const showDiffChangedOff = () => {
    const diffMain = document.getElementById('diff-main');

    if (diffMain) {
      diffMain.classList.remove('active');

      if (typeof Storage !== 'undefined') {
        localStorage.removeItem('diffSwitchState');
      }
    }
  };

  const showDiffChangedOn = () => {
    const diffMain = document.getElementById('diff-main');

    if (diffMain) {
      diffMain.classList.add('active');

      if (typeof Storage !== 'undefined') {
        localStorage.setItem('diffSwitchState', 'checked');
      }
    }
  };

  const showCoreChangedOff = () => {
    const override = document.getElementById('override-pane');
    const corePane = document.getElementById('core-pane');
    const fieldset = override.parentElement.parentElement;

    if (corePane && override) {
      corePane.classList.remove('active');

      if (fieldset.classList.contains('options-grid-form-half')) {
        fieldset.classList.remove('options-grid-form-half');
        fieldset.classList.add('options-grid-form-full');
      }

      if (typeof Storage !== 'undefined') {
        localStorage.removeItem('coreSwitchState');
      }
    }
  };

  const showCoreChangedOn = () => {
    const override = document.getElementById('override-pane');
    const corePane = document.getElementById('core-pane');
    const fieldset = override.parentElement.parentElement;

    if (corePane && override) {
      corePane.classList.add('active');

      if (fieldset.classList.contains('options-grid-form-full')) {
        fieldset.classList.remove('options-grid-form-full');
        fieldset.classList.add('options-grid-form-half');
      }

      if (Joomla.editors.instances.jform_core) {
        Joomla.editors.instances.jform_core.refresh();
      }

      if (typeof Storage !== 'undefined') {
        localStorage.setItem('coreSwitchState', 'checked');
      }
    }
  };

  document.addEventListener('DOMContentLoaded', () => {
    const JformShowDiffOn = document.getElementById('jform_show_diff1');
    const JformShowDiffOff = document.getElementById('jform_show_diff0');
    const JformShowCoreOn = document.getElementById('jform_show_core1');
    const JformShowCoreOff = document.getElementById('jform_show_core0');

    if (JformShowDiffOn && JformShowDiffOff) {
      JformShowDiffOn.addEventListener('click', showDiffChangedOn);
      JformShowDiffOff.addEventListener('click', showDiffChangedOff);
    }

    if (JformShowCoreOn && JformShowCoreOff) {
      JformShowCoreOn.addEventListener('click', showCoreChangedOn);
      JformShowCoreOff.addEventListener('click', showCoreChangedOff);
    }

    if (typeof Storage !== 'undefined' && localStorage.getItem('coreSwitchState') && JformShowCoreOn) {
      JformShowCoreOn.checked = true;
      JformShowCoreOff.checked = false;
      showCoreChangedOn();
    }

    if (typeof Storage !== 'undefined' && localStorage.getItem('diffSwitchState') && JformShowDiffOn) {
      JformShowDiffOn.checked = true;
      JformShowDiffOff.checked = false;
      showDiffChangedOn();
    }
  });
})();

The same content is in 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.