CoreFiles by mySites.guru
select-colour.js44 lines, 1,233 bytes, from Joomla_4.0.0-alpha3-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha2
md5
f0b2fffa07f2fc37dd3d57dc1d39cd75
sha1
78326cc84eebe458785161d5c1c89826c4032157
sha256
d78125d4dcd97658f2548b23c404ea0d687ab24f5c8b80af62d1c2682265fef5
/**
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * Update colour for selectbox
 */
Joomla = window.Joomla || {};

(function(Joomla) {
	'use strict';

	Joomla.updateSelectboxColour = function () {
		var colourSelects = document.querySelectorAll('.custom-select-color-state');
		for (var i = 0, l = colourSelects.length; i < l; i++) {
			// Add class on page load
			var selectBox = colourSelects[i];
			if (selectBox.value == 1) {
				selectBox.classList.add('custom-select-success');
			}
			else if (selectBox.value == 0) {
				selectBox.classList.add('custom-select-danger');
			}

			// Add class when value is changed
			selectBox.addEventListener('change', function() {
				var self = this;
				self.classList.remove('custom-select-success', 'custom-select-danger');
				if (self.value == 1) {
					self.classList.add('custom-select-success');
				}
				else if (self.value == 0 || self.value == parseInt(-2)) {
					self.classList.add('custom-select-danger');
				}
			});
		}
	};

	document.addEventListener('DOMContentLoaded', function() {
		Joomla.updateSelectboxColour();
	});

})(Joomla);

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