CoreFiles by mySites.guru
select-colour.es6.js49 lines, 1,562 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
0b67be31b2f0504368adcee41a0fbdf3
sha1
339a14de483408dec5798cc71a10705cf697bbce
sha256
33c5f0540fdc1d7add572acb01176c22b1d3b4468495f68e2e50e4d94046ddac
/**
* 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 onChange = ({
    target
  }) => {
    const self = target;
    const value = parseInt(self.value, 10);
    self.classList.remove('custom-select-success', 'custom-select-danger');

    if (value === 1) {
      self.classList.add('custom-select-success');
    } else if (value === 0 || value === -2) {
      self.classList.add('custom-select-danger');
    }
  };

  const updateSelectboxColour = () => {
    const colourSelects = [].slice.call(document.querySelectorAll('.custom-select-color-state'));
    colourSelects.forEach(colourSelect => {
      const value = parseInt(colourSelect.value, 10); // Add class on page load

      if (value === 1) {
        colourSelect.classList.add('custom-select-success');
      } else if (value === 0 || value === -2) {
        colourSelect.classList.add('custom-select-danger');
      } // Add class when value is changed


      colourSelect.addEventListener('change', onChange);
    }); // Cleanup

    document.removeEventListener('DOMContentLoaded', updateSelectboxColour, true);
  }; // On docunment loaded


  document.addEventListener('DOMContentLoaded', updateSelectboxColour, true); // On Joomla updated

  document.addEventListener('joomla:updated', updateSelectboxColour, true);
})();

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