<commit_before>/**
 * Generates universal unique id
 * @see https://gist.github.com/gordonbrander/2230317#gistcomment-1618310
 * @returns {String}
 */
function uuid() {
	'use strict';

	var chr4 = function chr4() {
		return Math.random().toString(16).slice(-4);
	};
	return chr4() + chr4() + "-" + chr4() + "-" + chr4() + "-" + chr4() + "-" + (chr4() + chr4() + chr4());
}


/**
 * @copyright Devexperts
 *
 * @requires DX
 * @requires DX.Dom
 * @requires DX.Bem
 * @requires DX.Event
 * @requires DX.Tmpl
 * @requires DropDown
 * @namespace
 */
var Colorpicker = (function(DX) {
	'use strict';

	var event = DX.Event,
		CN_COLORPICKER = 'colorPicker',
		M_OPEN = 'opened',
		M_DISABLED = 'disabled',
		CN_COLORPICKER_LABEL = CN_COLORPICKER + '--label',
		CN_COLORPICKER_VALUE = CN_COLORPICKER + '--value',
		defaultColors = {
			colorList: ['#511717', '#d90100', '#ff504f', '#dddddd']
		},
		allColors = [],
		defaults = {
			BUTTON_TMPL: [
				'<button class="button" type="button">',
				'<span>',
				'<i class="' + CN_COLORPICKER_VALUE + '"></i>',
				'</span>',
				'</button>'
			].join(''),
			ARROW_TMPL: '',
			INNER_TMPL: [
				'<div class="' + CN_COLORPICKER_LABEL + '">',
				'{%= BUTTON_TMPL %}',
				'{%= ARROW_TMPL %}',
				'</div>'
			].join(''),
			OPTION_TMPL: '<li class="{%= classNames %}" style="background-color: {%= value %}"></li>'
		};


	/**
	 * Check is object variable
	 * @param {*} param
	 * @returns {boolean}
	 */
	function isObject(param) {
		var type = typeof param;
		return type === 'object' && !Array.isArray(param);
	}

	/**
	 * Check is string variable
	 * @param {*} param
	 * @returns {boolean}
	 */
	function isString(param) {
		return Object.prototype.toString.call(param) === '[object String]';
	}


	/**
	 * Creates new Colorpicker
	 * @constructor Colorpicker
	 * @param {HTMLInputElement} input
	 * @param {Array} colorList
	 * @param {Object} customTemplateConfig
	 */
	return function Colorpicker(input, colorList, customTemplateConfig) {
		var block, valueElement, dropDown, config, disabled = input.disabled;

		function init() {
			config = Object.assign({}, defaults, customTemplateConfig);
			initAppearance();
			dropDown = new DropDown(block, {
				optionTmpl: config.OPTION_TMPL,
				modifiers: [CN_COLORPICKER],
				animationTime: 0.3
			});
			initListeners();
			setColorListHandler();
			if (disabled) {
				setDisabled();
			}
			DX.Event.trigger(input, Colorpicker.E_CREATED, {
				detail: {
					block: block,
					eventTarget: input
				}
			});
		}

		function initListeners() {
			var dropDownEventTarget = dropDown.getEventTarget();

			block.addEventListener(DX.Event.TOUCH_CLICK, toggleDropDown, true);

			dropDownEventTarget.addEventListener(DropDown.E_SHOWN, setOpenedState, true);
			dropDownEventTarget.addEventListener(DropDown.E_HIDDEN, removeOpenedState, true);
			dropDownEventTarget.addEventListener(DropDown.E_CHANGED, dropDownIndexChangeHandler, true);

			input.addEventListener(Colorpicker.E_SET_COLOR_LIST, setColorListHandler);<commit_msg>Moved animationTime to default config.<commit_after>/**
 * Generates universal unique id
 * @see https://gist.github.com/gordonbrander/2230317#gistcomment-1618310
 * @returns {String}
 */
function uuid() {
	'use strict';

	var chr4 = function chr4() {
		return Math.random().toString(16).slice(-4);
	};
	return chr4() + chr4() + "-" + chr4() + "-" + chr4() + "-" + chr4() + "-" + (chr4() + chr4() + chr4());
}


/**
 * @copyright Devexperts
 *
 * @requires DX
 * @requires DX.Dom
 * @requires DX.Bem
 * @requires DX.Event
 * @requires DX.Tmpl
 * @requires DropDown
 * @namespace
 */
var Colorpicker = (function(DX) {
	'use strict';

	var event = DX.Event,
		CN_COLORPICKER = 'colorPicker',
		M_OPEN = 'opened',
		M_DISABLED = 'disabled',
		CN_COLORPICKER_LABEL = CN_COLORPICKER + '--label',
		CN_COLORPICKER_VALUE = CN_COLORPICKER + '--value',
		defaultColors = {
			colorList: ['#511717', '#d90100', '#ff504f', '#dddddd']
		},
		allColors = [],
		defaults = {
			BUTTON_TMPL: [
				'<button class="button" type="button">',
				'<span>',
				'<i class="' + CN_COLORPICKER_VALUE + '"></i>',
				'</span>',
				'</button>'
			].join(''),
			ARROW_TMPL: '',
			INNER_TMPL: [
				'<div class="' + CN_COLORPICKER_LABEL + '">',
				'{%= BUTTON_TMPL %}',
				'{%= ARROW_TMPL %}',
				'</div>'
			].join(''),
			OPTION_TMPL: '<li class="{%= classNames %}" style="background-color: {%= value %}"></li>',
			animationTime: 0.3
		};


	/**
	 * Check is object variable
	 * @param {*} param
	 * @returns {boolean}
	 */
	function isObject(param) {
		var type = typeof param;
		return type === 'object' && !Array.isArray(param);
	}

	/**
	 * Check is string variable
	 * @param {*} param
	 * @returns {boolean}
	 */
	function isString(param) {
		return Object.prototype.toString.call(param) === '[object String]';
	}


	/**
	 * Creates new Colorpicker
	 * @constructor Colorpicker
	 * @param {HTMLInputElement} input
	 * @param {Array} colorList
	 * @param {Object} customTemplateConfig
	 */
	return function Colorpicker(input, colorList, customTemplateConfig) {
		var block, valueElement, dropDown, config, disabled = input.disabled;

		function init() {
			config = Object.assign({}, defaults, customTemplateConfig);
			initAppearance();
			dropDown = new DropDown(block, {
				optionTmpl: config.OPTION_TMPL,
				modifiers: [CN_COLORPICKER],
				animationTime: config.animationTime
			});
			initListeners();
			setColorListHandler();
			if (disabled) {
				setDisabled();
			}
			DX.Event.trigger(input, Colorpicker.E_CREATED, {
				detail: {
					block: block,
					eventTarget: input
				}
			});
		}

		function initListeners() {
			var dropDownEventTarget = dropDown.getEventTarget();

			block.addEventListener(DX.Event.TOUCH_CLICK, toggleDropDown, true);

			dropDownEventTarget.addEventListener(DropDown.E_SHOWN, setOpenedState, true);
			dropDownEventTarget.addEventListener(DropDown.E_HIDDEN, removeOpenedState, true);
			dropDownEventTarget.addEventListener(DropDown.E_CHANGED, dropDownIndexChangeHandler, true);

			input.addEventListener(Colorpicker.E_SET_COLOR_LIST, setColorListHandler);
{'fraction_non_alphanumeric': 0.16642144842242929, 'fraction_numerical': 0.014059179336275953, 'mean_word_length': 3.863275039745628, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5485853', 'n_tokens_mistral': 2432, 'n_tokens_neox': 2072, 'n_words': 413}