2
* Copyright (c) 2021 Momo Bassit.
3
* Licensed under the MIT License (MIT)
4
* https://github.com/mdbassit/Coloris
7
(function (window, document, Math) {
8
var ctx = document.createElement('canvas').getContext('2d');
9
var currentColor = { r: 0, g: 0, b: 0, h: 0, s: 0, v: 0, a: 1 };
10
var picker, colorArea, colorAreaDims, colorMarker, colorPreview, colorValue, clearButton,
11
hueSlider, hueMarker, alphaSlider, alphaMarker, currentEl, currentFormat, oldColor;
33
open: 'Open color picker',
34
close: 'Close color picker',
35
marker: 'Saturation: {s}. Brightness: {v}.',
36
hueSlider: 'Hue slider',
37
alphaSlider: 'Opacity slider',
38
input: 'Color value field',
39
format: 'Color format',
40
swatch: 'Color swatch',
41
instruction: 'Saturation and brightness selector. Use up, down, left and right arrow keys to select.' } };
46
* Configure the color picker.
47
* @param {object} options Configuration options.
49
function configure(options) {
50
if (typeof options !== 'object') {
54
for (var key in options) {
57
bindFields(options.el);
58
if (options.wrap !== false) {
59
wrapFields(options.el);
63
settings.parent = document.querySelector(options.parent);
64
if (settings.parent) {
65
settings.parent.appendChild(picker);
69
settings.themeMode = options.themeMode;
70
if (options.themeMode === 'auto' && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
71
settings.themeMode = 'dark';
73
// The lack of a break statement is intentional
76
settings.theme = options.theme;
78
picker.className = "clr-picker clr-" + settings.theme + " clr-" + settings.themeMode;
82
settings.margin = !isNaN(options.margin) ? options.margin : settings.margin;
85
if (options.el && options.wrap) {
86
wrapFields(options.el);
90
getEl('clr-format').style.display = options.formatToggle ? 'block' : 'none';
91
if (options.formatToggle) {
92
settings.format = 'auto';
96
if (Array.isArray(options.swatches)) {(function () {
99
options.swatches.forEach(function (swatch, i) {
100
swatches.push("<button id=\"clr-swatch-" + i + "\" aria-labelledby=\"clr-swatch-label clr-swatch-" + i + "\" style=\"color: " + swatch + ";\">" + swatch + "</button>");
103
getEl('clr-swatches').innerHTML = swatches.length ? "<div>" + swatches.join('') + "</div>" : '';})();
107
settings.swatchesOnly = !!options.swatchesOnly;
108
picker.setAttribute('data-minimal', settings.swatchesOnly);
110
if (settings.swatchesOnly) {
111
settings.autoClose = true;
115
settings.alpha = !!options.alpha;
116
picker.setAttribute('data-alpha', settings.alpha);
119
var display = 'none';
121
if (options.clearButton.show) {
125
if (options.clearButton.label) {
126
clearButton.innerHTML = options.clearButton.label;
129
clearButton.style.display = display;
132
var labels = options.a11y;
135
if (typeof labels === 'object') {
136
for (var label in labels) {
137
if (labels[label] && settings.a11y[label]) {
138
settings.a11y[label] = labels[label];
145
var openLabel = getEl('clr-open-label');
146
var swatchLabel = getEl('clr-swatch-label');
148
openLabel.innerHTML = settings.a11y.open;
149
swatchLabel.innerHTML = settings.a11y.swatch;
150
colorPreview.setAttribute('aria-label', settings.a11y.close);
151
hueSlider.setAttribute('aria-label', settings.a11y.hueSlider);
152
alphaSlider.setAttribute('aria-label', settings.a11y.alphaSlider);
153
colorValue.setAttribute('aria-label', settings.a11y.input);
154
colorArea.setAttribute('aria-label', settings.a11y.instruction);
157
settings[key] = options[key];}
163
* Bind the color picker to input fields that match the selector.
164
* @param {string} selector One or more selectors pointing to input fields.
166
function bindFields(selector) {
167
// Show the color picker on click on the input fields that match the selector
168
addListener(document, 'click', selector, function (event) {
169
var parent = settings.parent;
170
var coords = event.target.getBoundingClientRect();
171
var scrollY = window.scrollY;
172
var reposition = { left: false, top: false };
173
var offset = { x: 0, y: 0 };
175
var top = scrollY + coords.y + coords.height + settings.margin;
177
currentEl = event.target;
178
oldColor = currentEl.value;
179
currentFormat = getColorFormatFromStr(oldColor);
180
picker.classList.add('clr-open');
182
var pickerWidth = picker.offsetWidth;
183
var pickerHeight = picker.offsetHeight;
185
// If the color picker is inside a custom container
186
// set the position relative to it
188
var style = window.getComputedStyle(parent);
189
var marginTop = parseFloat(style.marginTop);
190
var borderTop = parseFloat(style.borderTopWidth);
192
offset = parent.getBoundingClientRect();
193
offset.y += borderTop + scrollY;
197
if (left + pickerWidth > parent.clientWidth) {
198
left += coords.width - pickerWidth;
199
reposition.left = true;
202
if (top + pickerHeight > parent.clientHeight - marginTop) {
203
top -= coords.height + pickerHeight + settings.margin * 2;
204
reposition.top = true;
207
top += parent.scrollTop;
209
// Otherwise set the position relative to the whole document
211
if (left + pickerWidth > document.documentElement.clientWidth) {
212
left += coords.width - pickerWidth;
213
reposition.left = true;
216
if (top + pickerHeight - scrollY > document.documentElement.clientHeight) {
217
top = scrollY + coords.y - pickerHeight - settings.margin;
218
reposition.top = true;
222
picker.classList.toggle('clr-left', reposition.left);
223
picker.classList.toggle('clr-top', reposition.top);
224
picker.style.left = left + "px";
225
picker.style.top = top + "px";
227
width: colorArea.offsetWidth,
228
height: colorArea.offsetHeight,
229
x: picker.offsetLeft + colorArea.offsetLeft + offset.x,
230
y: picker.offsetTop + colorArea.offsetTop + offset.y };
233
setColorFromStr(oldColor);
235
if (settings.focusInput) {
236
colorValue.focus({ preventScroll: true });
240
// Update the color preview of the input fields that match the selector
241
addListener(document, 'input', selector, function (event) {
242
var parent = event.target.parentNode;
244
// Only update the preview if the field has been previously wrapped
245
if (parent.classList.contains('clr-field')) {
246
parent.style.color = event.target.value;
252
* Wrap the linked input fields in a div that adds a color preview.
253
* @param {string} selector One or more selectors pointing to input fields.
255
function wrapFields(selector) {
256
document.querySelectorAll(selector).forEach(function (field) {
257
var parentNode = field.parentNode;
259
if (!parentNode.classList.contains('clr-field')) {
260
var wrapper = document.createElement('div');
262
wrapper.innerHTML = "<button aria-labelledby=\"clr-open-label\"></button>";
263
parentNode.insertBefore(wrapper, field);
264
wrapper.setAttribute('class', 'clr-field');
265
wrapper.style.color = field.value;
266
wrapper.appendChild(field);
272
* Close the color picker.
273
* @param {boolean} [revert] If true, revert the color to the original value.
275
function closePicker(revert) {
277
// Revert the color to the original value if needed
278
if (revert && oldColor !== currentEl.value) {
279
currentEl.value = oldColor;
281
// Trigger an "input" event to force update the thumbnail next to the input field
282
currentEl.dispatchEvent(new Event('input', { bubbles: true }));
285
if (oldColor !== currentEl.value) {
286
currentEl.dispatchEvent(new Event('change', { bubbles: true }));
289
picker.classList.remove('clr-open');
291
if (settings.focusInput) {
292
currentEl.focus({ preventScroll: true });
300
* Set the active color from a string.
301
* @param {string} str String representing a color.
303
function setColorFromStr(str) {
304
var rgba = strToRGBA(str);
305
var hsva = RGBAtoHSVA(rgba);
307
updateMarkerA11yLabel(hsva.s, hsva.v);
308
updateColor(rgba, hsva);
311
hueSlider.value = hsva.h;
312
picker.style.color = "hsl(" + hsva.h + ", 100%, 50%)";
313
hueMarker.style.left = hsva.h / 360 * 100 + "%";
315
colorMarker.style.left = colorAreaDims.width * hsva.s / 100 + "px";
316
colorMarker.style.top = colorAreaDims.height - colorAreaDims.height * hsva.v / 100 + "px";
318
alphaSlider.value = hsva.a * 100;
319
alphaMarker.style.left = hsva.a * 100 + "%";
323
* Guess the color format from a string.
324
* @param {string} str String representing a color.
325
* @return {string} The color format.
327
function getColorFormatFromStr(str) {
328
var format = str.substring(0, 3).toLowerCase();
330
if (format === 'rgb' || format === 'hsl') {
338
* Copy the active color to the linked input field.
339
* @param {number} [color] Color value to override the active color.
341
function pickColor(color) {
343
currentEl.value = color !== undefined ? color : colorValue.value;
344
currentEl.dispatchEvent(new Event('input', { bubbles: true }));
349
* Set the active color based on a specific point in the color gradient.
350
* @param {number} x Left position.
351
* @param {number} y Top position.
353
function setColorAtPosition(x, y) {
355
h: hueSlider.value * 1,
356
s: x / colorAreaDims.width * 100,
357
v: 100 - y / colorAreaDims.height * 100,
358
a: alphaSlider.value / 100 };
360
var rgba = HSVAtoRGBA(hsva);
362
updateMarkerA11yLabel(hsva.s, hsva.v);
363
updateColor(rgba, hsva);
368
* Update the color marker's accessibility label.
369
* @param {number} saturation
370
* @param {number} value
372
function updateMarkerA11yLabel(saturation, value) {
373
var label = settings.a11y.marker;
375
saturation = saturation.toFixed(1) * 1;
376
value = value.toFixed(1) * 1;
377
label = label.replace('{s}', saturation);
378
label = label.replace('{v}', value);
379
colorMarker.setAttribute('aria-label', label);
384
* Get the pageX and pageY positions of the pointer.
385
* @param {object} event The MouseEvent or TouchEvent object.
386
* @return {object} The pageX and pageY positions.
388
function getPointerPosition(event) {
390
pageX: event.changedTouches ? event.changedTouches[0].pageX : event.pageX,
391
pageY: event.changedTouches ? event.changedTouches[0].pageY : event.pageY };
396
* Move the color marker when dragged.
397
* @param {object} event The MouseEvent object.
399
function moveMarker(event) {
400
var pointer = getPointerPosition(event);
401
var x = pointer.pageX - colorAreaDims.x;
402
var y = pointer.pageY - colorAreaDims.y;
404
if (settings.parent) {
405
y += settings.parent.scrollTop;
408
x = x < 0 ? 0 : x > colorAreaDims.width ? colorAreaDims.width : x;
409
y = y < 0 ? 0 : y > colorAreaDims.height ? colorAreaDims.height : y;
411
colorMarker.style.left = x + "px";
412
colorMarker.style.top = y + "px";
414
setColorAtPosition(x, y);
416
// Prevent scrolling while dragging the marker
417
event.preventDefault();
418
event.stopPropagation();
422
* Move the color marker when the arrow keys are pressed.
423
* @param {number} offsetX The horizontal amount to move.
424
* * @param {number} offsetY The vertical amount to move.
426
function moveMarkerOnKeydown(offsetX, offsetY) {
427
var x = colorMarker.style.left.replace('px', '') * 1 + offsetX;
428
var y = colorMarker.style.top.replace('px', '') * 1 + offsetY;
430
colorMarker.style.left = x + "px";
431
colorMarker.style.top = y + "px";
433
setColorAtPosition(x, y);
437
* Update the color picker's input field and preview thumb.
438
* @param {Object} rgba Red, green, blue and alpha values.
439
* @param {Object} [hsva] Hue, saturation, value and alpha values.
441
function updateColor(rgba, hsva) {if (rgba === void 0) {rgba = {};}if (hsva === void 0) {hsva = {};}
442
var format = settings.format;
444
for (var key in rgba) {
445
currentColor[key] = rgba[key];
448
for (var _key in hsva) {
449
currentColor[_key] = hsva[_key];
452
var hex = RGBAToHex(currentColor);
453
var opaqueHex = hex.substring(0, 7);
455
colorMarker.style.color = opaqueHex;
456
alphaMarker.parentNode.style.color = opaqueHex;
457
alphaMarker.style.color = hex;
458
colorPreview.style.color = hex;
460
// Force repaint the color and alpha gradients as a workaround for a Google Chrome bug
461
colorArea.style.display = 'none';
462
colorArea.offsetHeight;
463
colorArea.style.display = '';
464
alphaMarker.nextElementSibling.style.display = 'none';
465
alphaMarker.nextElementSibling.offsetHeight;
466
alphaMarker.nextElementSibling.style.display = '';
468
if (format === 'mixed') {
469
format = currentColor.a === 1 ? 'hex' : 'rgb';
470
} else if (format === 'auto') {
471
format = currentFormat;
476
colorValue.value = hex;
479
colorValue.value = RGBAToStr(currentColor);
482
colorValue.value = HSLAToStr(HSVAtoHSLA(currentColor));
486
// Select the current format in the format switcher
487
document.querySelector(".clr-format [value=\"" + format + "\"]").checked = true;
491
* Set the hue when its slider is moved.
494
var hue = hueSlider.value * 1;
495
var x = colorMarker.style.left.replace('px', '') * 1;
496
var y = colorMarker.style.top.replace('px', '') * 1;
498
picker.style.color = "hsl(" + hue + ", 100%, 50%)";
499
hueMarker.style.left = hue / 360 * 100 + "%";
501
setColorAtPosition(x, y);
505
* Set the alpha when its slider is moved.
507
function setAlpha() {
508
var alpha = alphaSlider.value / 100;
510
alphaMarker.style.left = alpha * 100 + "%";
511
updateColor({ a: alpha });
516
* Convert HSVA to RGBA.
517
* @param {object} hsva Hue, saturation, value and alpha values.
518
* @return {object} Red, green, blue and alpha values.
520
function HSVAtoRGBA(hsva) {
521
var saturation = hsva.s / 100;
522
var value = hsva.v / 100;
523
var chroma = saturation * value;
524
var hueBy60 = hsva.h / 60;
525
var x = chroma * (1 - Math.abs(hueBy60 % 2 - 1));
526
var m = value - chroma;
531
var index = Math.floor(hueBy60) % 6;
532
var red = [chroma, x, m, m, x, chroma][index];
533
var green = [x, chroma, chroma, x, m, m][index];
534
var blue = [m, m, x, chroma, chroma, x][index];
537
r: Math.round(red * 255),
538
g: Math.round(green * 255),
539
b: Math.round(blue * 255),
545
* Convert HSVA to HSLA.
546
* @param {object} hsva Hue, saturation, value and alpha values.
547
* @return {object} Hue, saturation, lightness and alpha values.
549
function HSVAtoHSLA(hsva) {
550
var value = hsva.v / 100;
551
var lightness = value * (1 - hsva.s / 100 / 2);
554
if (lightness > 0 && lightness < 1) {
555
saturation = Math.round((value - lightness) / Math.min(lightness, 1 - lightness) * 100);
561
l: Math.round(lightness * 100),
567
* Convert RGBA to HSVA.
568
* @param {object} rgba Red, green, blue and alpha values.
569
* @return {object} Hue, saturation, value and alpha values.
571
function RGBAtoHSVA(rgba) {
572
var red = rgba.r / 255;
573
var green = rgba.g / 255;
574
var blue = rgba.b / 255;
575
var xmax = Math.max(red, green, blue);
576
var xmin = Math.min(red, green, blue);
577
var chroma = xmax - xmin;
583
if (xmax === red) {hue = (green - blue) / chroma;}
584
if (xmax === green) {hue = 2 + (blue - red) / chroma;}
585
if (xmax === blue) {hue = 4 + (red - green) / chroma;}
586
if (xmax) {saturation = chroma / xmax;}
589
hue = Math.floor(hue * 60);
592
h: hue < 0 ? hue + 360 : hue,
593
s: Math.round(saturation * 100),
594
v: Math.round(value * 100),
600
* Parse a string to RGBA.
601
* @param {string} str String representing a color.
602
* @return {object} Red, green, blue and alpha values.
604
function strToRGBA(str) {
605
var regex = /^((rgba)|rgb)[\D]+([\d.]+)[\D]+([\d.]+)[\D]+([\d.]+)[\D]*?([\d.]+|$)/i;
608
// Default to black for invalid color strings
609
ctx.fillStyle = '#000';
611
// Use canvas to convert the string to a valid color string
613
match = regex.exec(ctx.fillStyle);
623
// Workaround to mitigate a Chromium bug where the alpha value is rounded incorrectly
624
rgba.a = +rgba.a.toFixed(2);
627
match = ctx.fillStyle.replace('#', '').match(/.{2}/g).map(function (h) {return parseInt(h, 16);});
640
* Convert RGBA to Hex.
641
* @param {object} rgba Red, green, blue and alpha values.
642
* @return {string} Hex color string.
644
function RGBAToHex(rgba) {
645
var R = rgba.r.toString(16);
646
var G = rgba.g.toString(16);
647
var B = rgba.b.toString(16);
662
if (settings.alpha && rgba.a < 1) {
663
var alpha = rgba.a * 255 | 0;
664
A = alpha.toString(16);
671
return '#' + R + G + B + A;
675
* Convert RGBA values to a CSS rgb/rgba string.
676
* @param {object} rgba Red, green, blue and alpha values.
677
* @return {string} CSS color string.
679
function RGBAToStr(rgba) {
680
if (!settings.alpha || rgba.a === 1) {
681
return "rgb(" + rgba.r + ", " + rgba.g + ", " + rgba.b + ")";
683
return "rgba(" + rgba.r + ", " + rgba.g + ", " + rgba.b + ", " + rgba.a + ")";
688
* Convert HSLA values to a CSS hsl/hsla string.
689
* @param {object} hsla Hue, saturation, lightness and alpha values.
690
* @return {string} CSS color string.
692
function HSLAToStr(hsla) {
693
if (!settings.alpha || hsla.a === 1) {
694
return "hsl(" + hsla.h + ", " + hsla.s + "%, " + hsla.l + "%)";
696
return "hsla(" + hsla.h + ", " + hsla.s + "%, " + hsla.l + "%, " + hsla.a + ")";
701
* Init the color picker.
705
picker = document.createElement('div');
706
picker.setAttribute('id', 'clr-picker');
707
picker.className = 'clr-picker';
709
"<input id=\"clr-color-value\" class=\"clr-color\" type=\"text\" value=\"\" spellcheck=\"false\" aria-label=\"" + settings.a11y.input + "\">" + ("<div id=\"clr-color-area\" class=\"clr-gradient\" role=\"application\" aria-label=\"" +
710
settings.a11y.instruction + "\">") +
711
'<div id="clr-color-marker" class="clr-marker" tabindex="0"></div>' +
713
'<div class="clr-hue">' + ("<input id=\"clr-hue-slider\" type=\"range\" min=\"0\" max=\"360\" step=\"1\" aria-label=\"" +
714
settings.a11y.hueSlider + "\">") +
715
'<div id="clr-hue-marker"></div>' +
717
'<div class="clr-alpha">' + ("<input id=\"clr-alpha-slider\" type=\"range\" min=\"0\" max=\"100\" step=\"1\" aria-label=\"" +
718
settings.a11y.alphaSlider + "\">") +
719
'<div id="clr-alpha-marker"></div>' +
722
'<div id="clr-format" class="clr-format">' +
723
'<fieldset class="clr-segmented">' + ("<legend>" +
724
settings.a11y.format + "</legend>") +
725
'<input id="clr-f1" type="radio" name="clr-format" value="hex">' +
726
'<label for="clr-f1">Hex</label>' +
727
'<input id="clr-f2" type="radio" name="clr-format" value="rgb">' +
728
'<label for="clr-f2">RGB</label>' +
729
'<input id="clr-f3" type="radio" name="clr-format" value="hsl">' +
730
'<label for="clr-f3">HSL</label>' +
734
'<div id="clr-swatches" class="clr-swatches"></div>' + ("<button id=\"clr-clear\" class=\"clr-clear\">" +
735
settings.clearButton.label + "</button>") + ("<button id=\"clr-color-preview\" class=\"clr-preview\" aria-label=\"" +
736
settings.a11y.close + "\"></button>") + ("<span id=\"clr-open-label\" hidden>" +
737
settings.a11y.open + "</span>") + ("<span id=\"clr-swatch-label\" hidden>" +
738
settings.a11y.swatch + "</span>");
740
// Append the color picker to the DOM
741
document.body.appendChild(picker);
743
// Reference the UI elements
744
colorArea = getEl('clr-color-area');
745
colorMarker = getEl('clr-color-marker');
746
clearButton = getEl('clr-clear');
747
colorPreview = getEl('clr-color-preview');
748
colorValue = getEl('clr-color-value');
749
hueSlider = getEl('clr-hue-slider');
750
hueMarker = getEl('clr-hue-marker');
751
alphaSlider = getEl('clr-alpha-slider');
752
alphaMarker = getEl('clr-alpha-marker');
754
// Bind the picker to the default selector
755
bindFields(settings.el);
756
wrapFields(settings.el);
758
addListener(picker, 'mousedown', function (event) {
759
picker.classList.remove('clr-keyboard-nav');
760
event.stopPropagation();
763
addListener(colorArea, 'mousedown', function (event) {
764
addListener(document, 'mousemove', moveMarker);
767
addListener(colorArea, 'touchstart', function (event) {
768
document.addEventListener('touchmove', moveMarker, { passive: false });
771
addListener(colorMarker, 'mousedown', function (event) {
772
addListener(document, 'mousemove', moveMarker);
775
addListener(colorMarker, 'touchstart', function (event) {
776
document.addEventListener('touchmove', moveMarker, { passive: false });
779
addListener(colorValue, 'change', function (event) {
780
setColorFromStr(colorValue.value);
784
addListener(clearButton, 'click', function (event) {
789
addListener(colorPreview, 'click', function (event) {
794
addListener(document, 'click', '.clr-format input', function (event) {
795
currentFormat = event.target.value;
800
addListener(picker, 'click', '.clr-swatches button', function (event) {
801
setColorFromStr(event.target.textContent);
804
if (settings.autoClose) {
809
addListener(document, 'mouseup', function (event) {
810
document.removeEventListener('mousemove', moveMarker);
813
addListener(document, 'touchend', function (event) {
814
document.removeEventListener('touchmove', moveMarker);
817
addListener(document, 'mousedown', function (event) {
818
picker.classList.remove('clr-keyboard-nav');
822
addListener(document, 'keydown', function (event) {
823
if (event.key === 'Escape') {
825
} else if (event.key === 'Tab') {
826
picker.classList.add('clr-keyboard-nav');
830
addListener(document, 'click', '.clr-field button', function (event) {
831
event.target.nextElementSibling.dispatchEvent(new Event('click', { bubbles: true }));
834
addListener(colorMarker, 'keydown', function (event) {
839
ArrowRight: [1, 0] };
842
if (Object.keys(movements).indexOf(event.key) !== -1) {
843
moveMarkerOnKeydown.apply(void 0, movements[event.key]);
844
event.preventDefault();
848
addListener(colorArea, 'click', moveMarker);
849
addListener(hueSlider, 'input', setHue);
850
addListener(alphaSlider, 'input', setAlpha);
854
* Shortcut for getElementById to optimize the minified JS.
855
* @param {string} id The element id.
856
* @return {object} The DOM element with the provided id.
859
return document.getElementById(id);
863
* Shortcut for addEventListener to optimize the minified JS.
864
* @param {object} context The context to which the listener is attached.
865
* @param {string} type Event type.
866
* @param {(string|function)} selector Event target if delegation is used, event handler if not.
867
* @param {function} [fn] Event handler if delegation is used.
869
function addListener(context, type, selector, fn) {
870
var matches = Element.prototype.matches || Element.prototype.msMatchesSelector;
872
// Delegate event to the target of the selector
873
if (typeof selector === 'string') {
874
context.addEventListener(type, function (event) {
875
if (matches.call(event.target, selector)) {
876
fn.call(event.target, event);
880
// If the selector is not a string then it's a function
881
// in which case we need regular event listener
884
context.addEventListener(type, fn);
889
* Call a function only when the DOM is ready.
890
* @param {function} fn The function to call.
891
* @param {array} [args] Arguments to pass to the function.
893
function DOMReady(fn, args) {
894
args = args !== undefined ? args : [];
896
if (document.readyState !== 'loading') {
897
fn.apply(void 0, args);
899
document.addEventListener('DOMContentLoaded', function () {
900
fn.apply(void 0, args);
905
// Polyfill for Nodelist.forEach
906
if (NodeList !== undefined && NodeList.prototype && !NodeList.prototype.forEach) {
907
NodeList.prototype.forEach = Array.prototype.forEach;
910
// Expose the color picker to the global scope
911
window.Coloris = function () {
915
close: closePicker };
918
function Coloris(options) {
919
DOMReady(function () {
921
if (typeof options === 'string') {
928
}var _loop = function _loop(
931
Coloris[key] = function () {for (var _len = arguments.length, args = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {args[_key2] = arguments[_key2];}
932
DOMReady(methods[key], args);
933
};};for (var key in methods) {_loop(key);
939
// Init the color picker when the DOM is ready
942
})(window, document, Math);
b'\\ No newline at end of file'