CoreFiles by mySites.guru
select-colour.js48 lines, 1,623 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
6cf270fd036d71b1ae577e60fcaf7c14
sha1
63f0c8f682e475da365b0ce47025c7b1f9f29404
sha256
f8118ac0a0c69f78ac64254bb083bc95f570faa93729cdd87972c4ce14d34aee
/**
* 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
 */
(function () {
  'use strict';

  var onChange = function onChange(_ref) {
    var target = _ref.target;
    var self = target;
    var 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');
    }
  };

  var updateSelectboxColour = function updateSelectboxColour() {
    var colourSelects = [].slice.call(document.querySelectorAll('.custom-select-color-state'));
    colourSelects.forEach(function (colourSelect) {
      var 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.