diff --git a/src/lib/inlet.min.js b/src/lib/inlet.min.js
index de4b11c..47ae4b9 100644
--- a/src/lib/inlet.min.js
+++ b/src/lib/inlet.min.js
@@ -1,1147 +1,2 @@
// Generated by CoffeeScript 1.10.0
-((function() {
- var HSLCircle, Picker, cssColorToRGB, fmod, hslToCSS, hslToRGB, hueToRGB, isValidCSSColor, map, normalizeColor, rgbToHSL, style, slice = [].slice;
- hueToRGB = function(m1, m2, h) {
- h = h < 0 ? h + 1 : h > 1 ? h - 1 : h;
- if (h * 6 < 1) {
- return m1 + (m2 - m1) * h * 6;
- }
- if (h * 2 < 1) {
- return m2;
- }
- if (h * 3 < 2) {
- return m1 + (m2 - m1) * (.66666 - h) * 6;
- }
- return m1;
- };
- hslToRGB = function(h, s, l) {
- var m1, m2;
- m2 = l <= .5 ? l * (s + 1) : l + s - l * s;
- m1 = l * 2 - m2;
- return {
- r: hueToRGB(m1, m2, h + .33333),
- g: hueToRGB(m1, m2, h),
- b: hueToRGB(m1, m2, h - .33333)
- };
- };
- rgbToHSL = function(r, g, b) {
- var diff, h, l, max, min, s, sum;
- max = Math.max(r, g, b);
- min = Math.min(r, g, b);
- diff = max - min;
- sum = max + min;
- h = min === max ? 0 : r === max ? (60 * (g - b) / diff + 360) % 360 : g === max ? 60 * (b - r) / diff + 120 : 60 * (r - g) / diff + 240;
- l = sum / 2;
- s = l === 0 ? 0 : l === 1 ? 1 : l <= .5 ? diff / sum : diff / (2 - sum);
- return {
- h: h,
- s: s,
- l: l
- };
- };
- hslToCSS = function(h, s, l, a) {
- if (a != null) {
- return "hsla(" + fmod(Math.round(h * 180 / Math.PI), 360) + "," + Math.round(s * 100) + "%," + Math.round(l * 100) + "%," + a + ")";
- } else {
- return "hsl(" + fmod(Math.round(h * 180 / Math.PI), 360) + "," + Math.round(s * 100) + "%," + Math.round(l * 100) + "%)";
- }
- };
- cssColorToRGB = function(cssColor) {
- var b, g, m, r, rgb, s;
- s = document.createElement("span");
- document.body.appendChild(s);
- s.style.backgroundColor = cssColor;
- rgb = getComputedStyle(s).backgroundColor;
- document.body.removeChild(s);
- m = /^rgb\((\d+), (\d+), (\d+)\)$/.exec(rgb);
- if (!m) {
- m = /^rgba\((\d+), (\d+), (\d+), ([\d.]+)\)$/.exec(rgb);
- }
- r = parseInt(m[1]);
- g = parseInt(m[2]);
- b = parseInt(m[3]);
- if (m[4]) {
- return {
- r: r / 255,
- g: g / 255,
- b: b / 255,
- a: parseFloat(m[4])
- };
- }
- return {
- r: r / 255,
- g: g / 255,
- b: b / 255
- };
- };
- isValidCSSColor = function(cssColor) {
- var ret, s;
- s = document.createElement("span");
- document.body.appendChild(s);
- s.style.backgroundColor = cssColor;
- ret = s.style.backgroundColor.length > 0;
- s.remove();
- return ret;
- };
- style = function(tag, styles) {
- var n, v;
- for (n in styles) {
- v = styles[n];
- tag.style[n] = v;
- }
- return tag;
- };
- fmod = function(x, m) {
- x = x % m;
- if (x < 0) {
- x += m;
- }
- return x;
- };
- map = function(v, min, max) {
- return min + (max - min) * Math.min(1, Math.max(0, v));
- };
- HSLCircle = function() {
- function HSLCircle(radius1, width1, lightness) {
- var b, canvas, ctx, d, data, dx, dy, g, h, i, imgdata, j, r, radius, ref, ref1, ref2, s, width, x, y;
- this.radius = radius1;
- this.width = width1;
- this.lightness = lightness;
- radius = this.radius;
- width = this.width;
- canvas = this.canvas = document.createElement("canvas");
- canvas.width = canvas.height = radius * 2;
- ctx = canvas.getContext("2d");
- imgdata = ctx.createImageData(canvas.width, canvas.height);
- data = imgdata.data;
- for (y = i = 0, ref = canvas.height; 0 <= ref ? i < ref : i > ref; y = 0 <= ref ? ++i : --i) {
- for (x = j = 0, ref1 = canvas.width; 0 <= ref1 ? j < ref1 : j > ref1; x = 0 <= ref1 ? ++j : --j) {
- dy = y - radius;
- dx = x - radius;
- d = Math.sqrt(dy * dy + dx * dx);
- if (d > radius + 1.5) {
- continue;
- }
- d -= 10;
- s = Math.max(0, Math.min(1, d / (radius - width / 2 - 10)));
- h = Math.atan2(dy, dx) / (Math.PI * 2);
- ref2 = hslToRGB(h, s, this.lightness), r = ref2.r, g = ref2.g, b = ref2.b;
- data[(y * canvas.width + x) * 4 + 0] = r * 255;
- data[(y * canvas.width + x) * 4 + 1] = g * 255;
- data[(y * canvas.width + x) * 4 + 2] = b * 255;
- data[(y * canvas.width + x) * 4 + 3] = 255;
- }
- }
- ctx.putImageData(imgdata, 0, 0);
- }
- HSLCircle.prototype.drawHSLCircle = function(canvas, saturation) {
- var ctx, highlighted_r, radius, width;
- canvas.width = canvas.height = 2 * this.radius;
- ctx = canvas.getContext("2d");
- width = this.width;
- radius = this.radius;
- highlighted_r = map(saturation, width, radius);
- ctx.save();
- ctx.fillStyle = "rgba(0,0,0,0.3)";
- ctx.beginPath();
- ctx.arc(radius, radius, radius, 0, Math.PI * 2);
- ctx.fill();
- ctx.fillStyle = "black";
- ctx.beginPath();
- ctx.arc(radius, radius, highlighted_r, 0, Math.PI * 2);
- ctx.arc(radius, radius, highlighted_r - width, 0, Math.PI * 2, true);
- ctx.fill();
- ctx.globalCompositeOperation = "source-in";
- ctx.drawImage(this.canvas, 0, 0);
- return ctx.restore();
- };
- return HSLCircle;
- }();
- normalizeColor = function(color) {
- if (typeof color === "string") {
- color = cssColorToRGB(color);
- }
- if (color.r != null && color.g != null && color.b != null) {
- color = rgbToHSL(color.r, color.g, color.b);
- color.h = color.h * Math.PI / 180;
- } else if (color.h != null && color.s != null && color.l != null) {
- color.h = color.h * Math.PI / 180;
- }
- return color;
- };
- Picker = function() {
- var attachEvents, makeCircle, makeColorPreview, makeKnob, makeLightnessSlider, makeRoot, radius, width;
- radius = 80;
- width = 25;
- function Picker(color) {
- this.color = normalizeColor(color);
- this.refColor = this.color;
- this.el = makeRoot();
- this.circleContainer = this.el.appendChild(makeCircle.call(this));
- this.lSlider = this.el.appendChild(makeLightnessSlider.call(this));
- this.colorPreview = this.el.appendChild(makeColorPreview.call(this));
- attachEvents.call(this);
- this.setLightness(this.color.l);
- }
- Picker.prototype.setHue = function(h) {
- var b, oR, r;
- this.color.h = h;
- r = map(this.color.s, width, radius) - width / 2;
- oR = radius - width / 2;
- style(this.hueKnob, {
- left: Math.round(oR + Math.cos(h) * r + 6 - 1) + "px",
- top: Math.round(oR + Math.sin(h) * r + 6 - 1) + "px"
- });
- this.colorPreview.style.backgroundColor = this.lKnob.style.backgroundColor = this.hueKnob.style.backgroundColor = hslToCSS(this.color.h, this.color.s, this.color.l);
- b = hslToCSS(this.color.h, this.color.s, .5);
- this.lSlider.style.backgroundImage = "-webkit-linear-gradient(bottom, black, " + b + " 50%, white)";
- this.lSlider.style.backgroundImage = "-moz-linear-gradient(bottom, black, " + b + " 50%, white)";
- return this.emit("changed");
- };
- Picker.prototype.setSaturation = function(s) {
- this.color.s = s;
- this.circle.drawHSLCircle(this.circleCanvas, s);
- return this.setHue(this.color.h);
- };
- Picker.prototype.setLightness = function(l) {
- this.color.l = l;
- this.circle = new HSLCircle(radius, width, l);
- this.lKnob.style.top = (1 - l) * this.lSlider._height - 11 + "px";
- return this.setSaturation(this.color.s);
- };
- Picker.prototype.setHSL = function(h, s, l) {
- this.color.h = fmod(h, 360) * Math.PI / 180;
- this.color.s = Math.max(0, Math.min(1, s));
- l = Math.max(0, Math.min(1, l));
- return this.setLightness(l);
- };
- Picker.prototype.getHSL = function() {
- return {
- h: fmod(this.color.h * 180 / Math.PI, 360),
- s: this.color.s,
- l: this.color.l
- };
- };
- Picker.prototype.setRGB = function(r, g, b) {
- var h, l, ref, s;
- ref = rgbToHSL(r, g, b), h = ref.h, s = ref.s, l = ref.l;
- return this.setHSL(h, s, l);
- };
- Picker.prototype.getRGB = function() {
- return hslToRGB(this.color.h / (Math.PI * 2), this.color.s, this.color.l);
- };
- Picker.prototype.getCSS = function() {
- return hslToCSS(this.color.h, this.color.s, this.color.l);
- };
- Picker.prototype.setCSS = function(css) {
- var b, g, r, ref;
- ref = cssColorToRGB(css), r = ref.r, g = ref.g, b = ref.b;
- return this.setRGB(r, g, b);
- };
- Picker.prototype.on = function(e, l) {
- var base;
- if (this._listeners == null) {
- this._listeners = {};
- }
- return ((base = this._listeners)[e] != null ? base[e] : base[e] = []).push(l);
- };
- Picker.prototype.emit = function() {
- var args, e, i, l, len, ref, ref1, results;
- e = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
- if (this._listeners) {
- ref1 = (ref = this._listeners[e]) != null ? ref : [];
- results = [];
- for (i = 0, len = ref1.length; i < len; i++) {
- l = ref1[i];
- results.push(l.call.apply(l, [ this ].concat(slice.call(args))));
- }
- return results;
- }
- };
- Picker.prototype.removeListener = function(e, l) {
- var k;
- if (this._listeners[e]) {
- return this._listeners[e] = function() {
- var i, len, ref, results;
- ref = this._listeners[e];
- results = [];
- for (i = 0, len = ref.length; i < len; i++) {
- k = ref[i];
- if (k !== l) {
- results.push(k);
- }
- }
- return results;
- }.call(this);
- }
- };
- attachEvents = function() {
- var c, updateCursor;
- this.lKnob.onmousedown = function(_this) {
- return function(e) {
- var move, up;
- document.documentElement.style.cursor = "pointer";
- window.addEventListener("mousemove", move = function(e) {
- var r, y;
- r = _this.lSlider.getBoundingClientRect();
- y = e.clientY - r.top;
- return _this.setLightness(Math.max(0, Math.min(1, 1 - y / _this.lSlider._height)));
- });
- window.addEventListener("mouseup", up = function(e) {
- window.removeEventListener("mousemove", move);
- window.removeEventListener("mouseup", up);
- window.removeEventListener("blur", up);
- return document.documentElement.style.cursor = "";
- });
- window.addEventListener("blur", up);
- e.preventDefault();
- return e.stopPropagation();
- };
- }(this);
- c = this.circleContainer;
- updateCursor = function(_this) {
- return function(e) {
- var d, dx, dy, r, t, x, y;
- x = e.layerX;
- y = e.layerY;
- dx = x - radius;
- dy = y - radius;
- d = Math.sqrt(dx * dx + dy * dy);
- t = Math.atan2(dy, dx);
- r = map(_this.color.s, width, radius);
- if (r - width < d && d < r) {
- if (-Math.PI / 8 < t && t < Math.PI / 8 || t >= 7 * Math.PI / 8 || t <= -7 * Math.PI / 8) {
- return c.style.cursor = "ew-resize";
- } else if (Math.PI / 8 <= t && t < 3 * Math.PI / 8 || -7 * Math.PI / 8 < t && t <= -5 * Math.PI / 8) {
- return c.style.cursor = "nwse-resize";
- } else if (3 * Math.PI / 8 <= t && t < 5 * Math.PI / 8 || -5 * Math.PI / 8 < t && t <= -3 * Math.PI / 8) {
- return c.style.cursor = "ns-resize";
- } else if (5 * Math.PI / 8 <= t && t < 7 * Math.PI / 8 || -3 * Math.PI / 8 < t && t <= -Math.PI / 8) {
- return c.style.cursor = "nesw-resize";
- }
- } else {
- return c.style.cursor = "";
- }
- };
- }(this);
- c.addEventListener("mouseover", function(e) {
- var move, out;
- updateCursor(e);
- c.addEventListener("mousemove", move = function(e) {
- return updateCursor(e);
- });
- c.addEventListener("mouseout", out = function(e) {
- c.style.cursor = "";
- c.removeEventListener("mousemove", move);
- c.removeEventListener("mouseout", out);
- return window.removeEventListener("blur", out);
- });
- return window.addEventListener("blur", out);
- });
- c.addEventListener("mousedown", function(_this) {
- return function(e) {
- var d, dx, dy, move, r, t, up, x, y;
- e.preventDefault();
- x = e.layerX;
- y = e.layerY;
- dx = x - radius;
- dy = y - radius;
- d = Math.sqrt(dx * dx + dy * dy);
- t = Math.atan2(dy, dx);
- r = map(_this.color.s, width, radius);
- if (!(r - width < d && d < r)) {
- return;
- }
- document.documentElement.style.cursor = c.style.cursor;
- window.addEventListener("mousemove", move = function(e) {
- var cx, cy, s;
- r = _this.circleCanvas.getBoundingClientRect();
- cx = r.left + r.width / 2;
- cy = r.top + r.height / 2;
- dx = e.clientX - cx;
- dy = e.clientY - cy;
- d = Math.sqrt(dx * dx + dy * dy);
- d -= 10;
- s = Math.max(0, Math.min(1, d / (radius - width / 2 - 10)));
- return _this.setSaturation(s);
- });
- window.addEventListener("mouseup", up = function(e) {
- window.removeEventListener("mousemove", move);
- window.removeEventListener("mouseup", up);
- window.removeEventListener("blur", up);
- return document.documentElement.style.cursor = "";
- });
- return window.addEventListener("blur", up);
- };
- }(this));
- return this.hueKnob.onmousedown = function(_this) {
- return function(e) {
- var move, up;
- document.documentElement.style.cursor = "pointer";
- window.addEventListener("mousemove", move = function(e) {
- var cx, cy, r;
- r = _this.circleCanvas.getBoundingClientRect();
- cx = r.left + r.width / 2;
- cy = r.top + r.height / 2;
- return _this.setHue(Math.atan2(e.clientY - cy, e.clientX - cx));
- });
- window.addEventListener("mouseup", up = function(e) {
- window.removeEventListener("mousemove", move);
- window.removeEventListener("mouseup", up);
- window.removeEventListener("blur", up);
- return document.documentElement.style.cursor = "";
- });
- window.addEventListener("blur", up);
- e.preventDefault();
- return e.stopPropagation();
- };
- }(this);
- };
- makeRoot = function() {
- var div;
- div = document.createElement("div");
- div.className = "picker";
- style(div, {
- display: "inline-block",
- background: "hsl(0, 0%, 97%)",
- padding: "6px",
- borderRadius: "6px",
- boxShadow: "1px 1px 5px hsla(0, 0%, 39%, 0.2), hsla(0, 0%, 100%, 0.9) 0px 0px 1em 0.3em inset",
- border: "1px solid hsla(0, 0%, 59%, 0.2)",
- position: "absolute",
- backgroundImage: "-webkit-linear-gradient(left top, hsla(0, 0%, 0%, 0.05) 25%, transparent 25%, transparent 50%, hsla(0, 0%, 0%, 0.05) 50%, hsla(0, 0%, 0%, 0.05) 75%, transparent 75%, transparent)",
- backgroundSize: "40px 40px"
- });
- style(div, {
- backgroundImage: "-moz-linear-gradient(left top, hsla(0, 0%, 0%, 0.05) 25%, transparent 25%, transparent 50%, hsla(0, 0%, 0%, 0.05) 50%, hsla(0, 0%, 0%, 0.05) 75%, transparent 75%, transparent)",
- zIndex: "1000"
- });
- return div;
- };
- makeCircle = function() {
- var circleContainer, k;
- circleContainer = document.createElement("div");
- style(circleContainer, {
- display: "inline-block",
- width: radius * 2 + "px",
- height: radius * 2 + "px",
- borderRadius: radius + "px",
- boxShadow: "0px 0px 7px rgba(0,0,0,0.3)"
- });
- circleContainer.appendChild(this.circleCanvas = document.createElement("canvas"));
- this.hueKnob = k = makeKnob(27);
- circleContainer.appendChild(k);
- return circleContainer;
- };
- makeLightnessSlider = function() {
- var k, lSlider;
- lSlider = document.createElement("div");
- style(lSlider, {
- display: "inline-block",
- width: "20px",
- height: radius * 2 - 22 + "px",
- marginLeft: "6px",
- borderRadius: "10px",
- boxShadow: "hsla(0, 100%, 100%, 0.1) 0 1px 2px 1px inset, hsla(0, 100%, 100%, 0.2) 0 1px inset, hsla(0, 0%, 0%, 0.4) 0 -1px 1px inset, hsla(0, 0%, 0%, 0.4) 0 1px 1px",
- position: "relative",
- top: "-11px"
- });
- lSlider._height = radius * 2 - 22;
- this.lKnob = k = makeKnob(22);
- style(k, {
- left: "-1px"
- });
- lSlider.appendChild(k);
- return lSlider;
- };
- makeColorPreview = function() {
- var colorPreview, originalColor, originalColorTransparent;
- colorPreview = document.createElement("div");
- originalColor = hslToCSS(this.refColor.h, this.refColor.s, this.refColor.l);
- originalColorTransparent = hslToCSS(this.refColor.h, this.refColor.s, this.refColor.l, 0);
- style(colorPreview, {
- boxShadow: "hsla(0, 0%, 0%, 0.5) 0 1px 5px, hsla(0, 100%, 100%, 0.4) 0 1px 1px inset, hsla(0, 0%, 0%, 0.3) 0 -1px 1px inset",
- height: "25px",
- marginTop: "6px",
- borderRadius: "3px",
- backgroundImage: "-webkit-linear-gradient(-20deg, " + originalColorTransparent + ", " + originalColorTransparent + " 69%, " + originalColor + " 70%, " + originalColor + ")"
- });
- style(colorPreview, {
- backgroundImage: "-moz-linear-gradient(-20deg, " + originalColorTransparent + ", " + originalColorTransparent + " 69%, " + originalColor + " 70%, " + originalColor + ")"
- });
- return colorPreview;
- };
- makeKnob = function(size) {
- var el;
- el = document.createElement("div");
- el.className = "knob";
- style(el, {
- position: "absolute",
- width: size + "px",
- height: size + "px",
- backgroundColor: "red",
- borderRadius: Math.floor(size / 2) + "px",
- cursor: "pointer",
- backgroundImage: "-webkit-gradient(radial, 50% 0%, 0, 50% 0%, 15, color-stop(0%, rgba(255, 255, 255, 0.8)), color-stop(100%, rgba(255, 255, 255, 0.2)))",
- boxShadow: "white 0px 1px 1px inset, rgba(0, 0, 0, 0.4) 0px -1px 1px inset, rgba(0, 0, 0, 0.4) 0px 1px 4px 0px, rgba(0, 0, 0, 0.6) 0 0 2px"
- });
- style(el, {
- backgroundImage: "radial-gradient(circle at center top, rgba(255,255,255,0.8), rgba(255, 255, 255, 0.2) 15px"
- });
- return el;
- };
- Picker.prototype.presentModal = function(x, y) {
- var modalFrame;
- style(this.el, {
- left: x + "px",
- top: y - 10 + "px",
- opacity: "0",
- webkitTransition: "0.15s",
- MozTransition: "0.15s"
- });
- modalFrame = document.createElement("div");
- modalFrame.style.position = "fixed";
- modalFrame.style.top = modalFrame.style.left = modalFrame.style.bottom = modalFrame.style.right = "0";
- modalFrame.style.zIndex = "999";
- modalFrame.onclick = function(_this) {
- return function() {
- var end;
- document.body.removeChild(modalFrame);
- _this.el.style.top = y + 10 + "px";
- _this.el.style.opacity = 0;
- end = function() {
- document.body.removeChild(_this.el);
- _this.el.removeEventListener("webkitTransitionEnd", end);
- return _this.el.removeEventListener("transitionend", end);
- };
- _this.el.addEventListener("webkitTransitionEnd", end);
- _this.el.addEventListener("transitionend", end);
- return _this.emit("closed");
- };
- }(this);
- document.body.appendChild(modalFrame);
- document.body.appendChild(this.el);
- this.el.offsetHeight;
- this.el.style.opacity = "1";
- this.el.style.top = y + "px";
- return this;
- };
- Picker.prototype.presentModalBeneath = function(el) {
- var elPos, x, y;
- elPos = el.getBoundingClientRect();
- x = elPos.left + window.scrollX;
- y = elPos.bottom + window.scrollY + 4;
- return this.presentModal(x, y);
- };
- return Picker;
- }();
- window.thistle = {
- Picker: Picker,
- isValidCSSColor: isValidCSSColor
- };
-})).call(this);
-
-if (typeof Color === "undefined") var Color = {};
-
-if (typeof Color.Space === "undefined") Color.Space = {};
-
-(function() {
- "use strict";
- var useEval = false;
- var functions = {};
- var shortcuts = {
- "HEX24>HSL": "HEX24>RGB>HSL",
- "HEX32>HSLA": "HEX32>RGBA>HSLA",
- "HEX24>CMYK": "HEX24>RGB>CMY>CMYK",
- "RGB>CMYK": "RGB>CMY>CMYK"
- };
- var root = Color.Space = function(color, route) {
- if (shortcuts[route]) {
- route = shortcuts[route];
- }
- var r = route.split(">");
- if (typeof color === "object" && color[0] >= 0) {
- var type = r[0];
- var tmp = {};
- for (var i = 0; i < type.length; i++) {
- var str = type.substr(i, 1);
- tmp[str] = color[i];
- }
- color = tmp;
- }
- if (functions[route]) {
- return functions[route](color);
- }
- var f = "color";
- for (var pos = 1, key = r[0]; pos < r.length; pos++) {
- if (pos > 1) {
- key = key.substr(key.indexOf("_") + 1);
- }
- key += (pos === 0 ? "" : "_") + r[pos];
- color = root[key](color);
- if (useEval) {
- f = "Color.Space." + key + "(" + f + ")";
- }
- }
- if (useEval) {
- functions[route] = eval("(function(color) { return " + f + " })");
- }
- return color;
- };
- root.RGB_W3 = function(o) {
- return "rgb(" + (o.R >> 0) + "," + (o.G >> 0) + "," + (o.B >> 0) + ")";
- };
- root.RGBA_W3 = function(o) {
- var alpha = typeof o.A === "number" ? o.A / 255 : 1;
- return "rgba(" + (o.R >> 0) + "," + (o.G >> 0) + "," + (o.B >> 0) + "," + alpha + ")";
- };
- root.W3_RGB = function(o) {
- o = o.substr(4, o.length - 5).split(",");
- return {
- R: parseInt(o[0], 10),
- G: parseInt(o[1], 10),
- B: parseInt(o[2], 10)
- };
- };
- root.W3_RGBA = function(o) {
- o = o.substr(5, o.length - 6).split(",");
- return {
- R: parseInt(o[0], 10),
- G: parseInt(o[1], 10),
- B: parseInt(o[2], 10),
- A: parseFloat(o[3]) * 255
- };
- };
- root.HSL_W3 = function(o) {
- return "hsl(" + (o.H + .5 >> 0) + "," + (o.S + .5 >> 0) + "%," + (o.L + .5 >> 0) + "%)";
- };
- root.HSLA_W3 = function(o) {
- var alpha = typeof o.A === "number" ? o.A / 255 : 1;
- return "hsla(" + (o.H + .5 >> 0) + "," + (o.S + .5 >> 0) + "%," + (o.L + .5 >> 0) + "%," + alpha + ")";
- };
- root.W3_HSL = function(o) {
- var start = o.indexOf("(") + 1;
- var end = o.indexOf(")");
- o = o.substr(start, end - start).split(",");
- return {
- H: parseInt(o[0], 10),
- S: parseInt(o[1], 10),
- L: parseInt(o[2], 10)
- };
- };
- root.W3_HSLA = function(o) {
- var start = o.indexOf("(") + 1;
- var end = o.indexOf(")");
- o = o.substr(start, end - start).split(",");
- return {
- H: parseInt(o[0], 10),
- S: parseInt(o[1], 10),
- L: parseInt(o[2], 10),
- A: parseFloat(o[3], 10) * 255
- };
- };
- root.W3_HEX = root.W3_HEX24 = function(o) {
- if (o.substr(0, 1) === "#") o = o.substr(1);
- if (o.length === 3) o = o[0] + o[0] + o[1] + o[1] + o[2] + o[2];
- return parseInt("0x" + o, 16);
- };
- root.W3_HEX32 = function(o) {
- if (o.substr(0, 1) === "#") o = o.substr(1);
- if (o.length === 6) {
- return parseInt("0xFF" + o, 10);
- } else {
- return parseInt("0x" + o, 16);
- }
- };
- root.HEX_W3 = root.HEX24_W3 = function(o, maxLength) {
- if (!maxLength) maxLength = 6;
- if (!o) o = 0;
- var n;
- var z = o.toString(16);
- n = z.length;
- while (n < maxLength) {
- z = "0" + z;
- n++;
- }
- n = z.length;
- while (n > maxLength) {
- z = z.substr(1);
- n--;
- }
- return "#" + z;
- };
- root.HEX32_W3 = function(o) {
- return root.HEX_W3(o, 8);
- };
- root.HEX_RGB = root.HEX24_RGB = function(o) {
- return {
- R: o >> 16,
- G: o >> 8 & 255,
- B: o & 255
- };
- };
- root.HEX32_RGBA = function(o) {
- return {
- R: o >>> 16 & 255,
- G: o >>> 8 & 255,
- B: o & 255,
- A: o >>> 24
- };
- };
- root.RGBA_HEX32 = function(o) {
- return (o.A << 24 | o.R << 16 | o.G << 8 | o.B) >>> 0;
- };
- root.RGB_HEX24 = root.RGB_HEX = function(o) {
- if (o.R < 0) o.R = 0;
- if (o.G < 0) o.G = 0;
- if (o.B < 0) o.B = 0;
- if (o.R > 255) o.R = 255;
- if (o.G > 255) o.G = 255;
- if (o.B > 255) o.B = 255;
- return o.R << 16 | o.G << 8 | o.B;
- };
- root.RGB_CMY = function(o) {
- return {
- C: 1 - o.R / 255,
- M: 1 - o.G / 255,
- Y: 1 - o.B / 255
- };
- };
- root.RGBA_HSLA = root.RGB_HSL = function(o) {
- var _R = o.R / 255, _G = o.G / 255, _B = o.B / 255, min = Math.min(_R, _G, _B), max = Math.max(_R, _G, _B), D = max - min, H, S, L = (max + min) / 2;
- if (D === 0) {
- H = 0;
- S = 0;
- } else {
- if (L < .5) S = D / (max + min); else S = D / (2 - max - min);
- var DR = ((max - _R) / 6 + D / 2) / D;
- var DG = ((max - _G) / 6 + D / 2) / D;
- var DB = ((max - _B) / 6 + D / 2) / D;
- if (_R === max) H = DB - DG; else if (_G === max) H = 1 / 3 + DR - DB; else if (_B === max) H = 2 / 3 + DG - DR;
- if (H < 0) H += 1;
- if (H > 1) H -= 1;
- }
- return {
- H: H * 360,
- S: S * 100,
- L: L * 100,
- A: o.A
- };
- };
- root.RGBA_HSVA = root.RGB_HSV = function(o) {
- var _R = o.R / 255, _G = o.G / 255, _B = o.B / 255, min = Math.min(_R, _G, _B), max = Math.max(_R, _G, _B), D = max - min, H, S, V = max;
- if (D === 0) {
- H = 0;
- S = 0;
- } else {
- S = D / max;
- var DR = ((max - _R) / 6 + D / 2) / D;
- var DG = ((max - _G) / 6 + D / 2) / D;
- var DB = ((max - _B) / 6 + D / 2) / D;
- if (_R === max) H = DB - DG; else if (_G === max) H = 1 / 3 + DR - DB; else if (_B === max) H = 2 / 3 + DG - DR;
- if (H < 0) H += 1;
- if (H > 1) H -= 1;
- }
- return {
- H: H * 360,
- S: S * 100,
- V: V * 100,
- A: o.A
- };
- };
- root.CMY_RGB = function(o) {
- return {
- R: Math.max(0, (1 - o.C) * 255),
- G: Math.max(0, (1 - o.M) * 255),
- B: Math.max(0, (1 - o.Y) * 255)
- };
- };
- root.CMY_CMYK = function(o) {
- var C = o.C;
- var M = o.M;
- var Y = o.Y;
- var K = Math.min(Y, Math.min(M, Math.min(C, 1)));
- C = Math.round((C - K) / (1 - K) * 100);
- M = Math.round((M - K) / (1 - K) * 100);
- Y = Math.round((Y - K) / (1 - K) * 100);
- K = Math.round(K * 100);
- return {
- C: C,
- M: M,
- Y: Y,
- K: K
- };
- };
- root.CMYK_CMY = function(o) {
- return {
- C: o.C * (1 - o.K) + o.K,
- M: o.M * (1 - o.K) + o.K,
- Y: o.Y * (1 - o.K) + o.K
- };
- };
- root.HSLA_RGBA = root.HSL_RGB = function(o) {
- var H = o.H / 360;
- var S = o.S / 100;
- var L = o.L / 100;
- var R, G, B;
- var temp1, temp2, temp3;
- if (S === 0) {
- R = G = B = L;
- } else {
- if (L < .5) temp2 = L * (1 + S); else temp2 = L + S - S * L;
- temp1 = 2 * L - temp2;
- temp3 = H + 1 / 3;
- if (temp3 < 0) temp3 += 1;
- if (temp3 > 1) temp3 -= 1;
- if (6 * temp3 < 1) R = temp1 + (temp2 - temp1) * 6 * temp3; else if (2 * temp3 < 1) R = temp2; else if (3 * temp3 < 2) R = temp1 + (temp2 - temp1) * (2 / 3 - temp3) * 6; else R = temp1;
- temp3 = H;
- if (temp3 < 0) temp3 += 1;
- if (temp3 > 1) temp3 -= 1;
- if (6 * temp3 < 1) G = temp1 + (temp2 - temp1) * 6 * temp3; else if (2 * temp3 < 1) G = temp2; else if (3 * temp3 < 2) G = temp1 + (temp2 - temp1) * (2 / 3 - temp3) * 6; else G = temp1;
- temp3 = H - 1 / 3;
- if (temp3 < 0) temp3 += 1;
- if (temp3 > 1) temp3 -= 1;
- if (6 * temp3 < 1) B = temp1 + (temp2 - temp1) * 6 * temp3; else if (2 * temp3 < 1) B = temp2; else if (3 * temp3 < 2) B = temp1 + (temp2 - temp1) * (2 / 3 - temp3) * 6; else B = temp1;
- }
- return {
- R: R * 255,
- G: G * 255,
- B: B * 255,
- A: o.A
- };
- };
- root.HSVA_RGBA = root.HSV_RGB = function(o) {
- var H = o.H / 360;
- var S = o.S / 100;
- var V = o.V / 100;
- var R, G, B, D, A, C;
- if (S === 0) {
- R = G = B = Math.round(V * 255);
- } else {
- if (H >= 1) H = 0;
- H = 6 * H;
- D = H - Math.floor(H);
- A = Math.round(255 * V * (1 - S));
- B = Math.round(255 * V * (1 - S * D));
- C = Math.round(255 * V * (1 - S * (1 - D)));
- V = Math.round(255 * V);
- switch (Math.floor(H)) {
- case 0:
- R = V;
- G = C;
- B = A;
- break;
- case 1:
- R = B;
- G = V;
- B = A;
- break;
- case 2:
- R = A;
- G = V;
- B = C;
- break;
- case 3:
- R = A;
- G = B;
- B = V;
- break;
- case 4:
- R = C;
- G = A;
- B = V;
- break;
- case 5:
- R = V;
- G = A;
- B = B;
- break;
- }
- }
- return {
- R: R,
- G: G,
- B: B,
- A: o.A
- };
- };
-})();
-
-Inlet = function() {
- function inlet(ed, options) {
- var editor = ed;
- var slider;
- var picker;
- var clicker;
- if (!options) options = {};
- if (!options.picker) options.picker = {};
- if (!options.slider) options.slider = {};
- if (!options.clicker) options.clicker = {};
- var container = options.container || document.body;
- var topOffset = options.picker.topOffset || 220;
- var bottomOffset = options.picker.bottomOffset || 16;
- var topBoundary = options.picker.topBoundary || 250;
- var leftOffset = options.picker.leftOffset || 75;
- var yOffset = options.slider.yOffset || 15;
- var xOffset = options.slider.xOffset || 0;
- var sliderWidth = options.slider.width;
- var horizontalMode = options.horizontalMode || "page";
- var fixedContainer = options.fixedContainer;
- var sliderCB = options.slider.callback || function(active) {};
- var pickerCB = options.picker.callback || function(active) {};
- var clickerCB = options.clicker.callback || function(active) {};
- var wrapper = editor.getWrapperElement();
- wrapper.addEventListener("mouseup", onClick);
- document.body.addEventListener("mouseup", windowOnClick);
- editor.setOption("onKeyEvent", onKeyDown);
- var clickerDiv = document.createElement("div");
- clickerDiv.className = "inlet_clicker";
- clickerDiv.style.visibility = "hidden";
- clickerDiv.style.position = "absolute";
- container.appendChild(clickerDiv);
- var clicker = document.createElement("input");
- clicker.className = "checkbox";
- clicker.setAttribute("type", "checkbox");
- clicker.addEventListener("change", onClicker);
- clickerDiv.appendChild(clicker);
- function onClicker(event) {
- var value = String(clicker.checked);
- var cursor = editor.getCursor(true);
- var boolean = getMatch(cursor, "boolean");
- if (!boolean) return;
- var start = {
- line: cursor.line,
- ch: boolean.start
- };
- var end = {
- line: cursor.line,
- ch: boolean.end
- };
- editor.replaceRange(value, start, end);
- }
- var sliderDiv = document.createElement("div");
- sliderDiv.className = "inlet_slider";
- sliderDiv.style.visibility = "hidden";
- if (sliderWidth) {
- sliderDiv.style.width = sliderWidth;
- }
- if (fixedContainer) {
- sliderDiv.style.position = "fixed";
- } else {
- sliderDiv.style.position = "absolute";
- }
- sliderDiv.style.top = 0;
- // container.appendChild(sliderDiv);
-
-
- var clickTarget;
- function windowOnClick(evt) {
- if (evt.target === clickTarget || evt.target === clickerDiv || evt.target === clicker) return;
- clickerDiv.style.visibility = "hidden";
- }
- var LEFT = 37;
- var UP = 38;
- var RIGHT = 39;
- var DOWN = 40;
- function onKeyDown() {
- if (arguments.length == 1) {
- event = arguments[0];
- } else {
- event = arguments[1];
- }
- if (event.keyCode == LEFT || event.keyCode == DOWN) {
- if (event.altKey) {
- onClick();
- } else {}
- } else if (event.keyCode == RIGHT || event.keyCode == UP) {
- if (event.altKey) {
- onClick();
- } else {}
- }
- }
- var pickerCallback = function(color, type) {
- var cursor = editor.getCursor();
- if (!type) return;
- var match = getMatch(cursor, type);
- var start = {
- line: cursor.line,
- ch: match.start
- };
- var end = {
- line: cursor.line,
- ch: match.end
- };
- editor.picking = true;
- editor.replaceRange(color, start, end);
- setTimeout(function() {
- editor.picking = false;
- }, 100);
- };
- picker = new thistle.Picker("#ffffff");
- function onClick(ev) {
- if (editor.somethingSelected()) {
- return;
- }
- clickTarget = ev.target;
- var cursor = editor.getCursor(true);
- var token = editor.getTokenAt(cursor);
- cursorOffset = editor.cursorCoords(true, "page");
- var leftBase = editor.cursorCoords(true, horizontalMode).left;
- var numberMatch = getMatch(cursor, "number");
- var hslMatch = getMatch(cursor, "hsl");
- var hexMatch = getMatch(cursor, "hex");
- var rgbMatch = getMatch(cursor, "rgb");
- var booleanMatch = getMatch(cursor, "boolean");
- var pickerTop = cursorOffset.top - topOffset;
- if (cursorOffset.top < topBoundary) {
- pickerTop = cursorOffset.top + bottomOffset;
- }
- var pickerLeft = leftBase - leftOffset;
- clickerDiv.style.visibility = "hidden";
- if (hexMatch) {
- var color = hexMatch.string;
- picker = new thistle.Picker(color);
- picker.setCSS(color);
- picker.presentModal(pickerLeft, pickerTop);
- picker.on("changed", function() {
- picked = picker.getCSS();
- picked = Color.Space(picked, "W3>HSL>RGB>HEX24>W3");
- pickerCallback(picked, "hex");
- });
- } else if (hslMatch) {
- var color = hslMatch.string;
- picker = new thistle.Picker(color);
- picker.setCSS(color);
- picker.presentModal(pickerLeft, pickerTop);
- picker.on("changed", function() {
- picked = picker.getCSS();
- pickerCallback(picked, "hsl");
- });
- } else if (rgbMatch) {
- var color = rgbMatch.string;
- picker = new thistle.Picker(color);
- picker.setCSS(color);
- picker.presentModal(pickerLeft, pickerTop);
- picker.on("changed", function() {
- picked = picker.getCSS();
- picked = Color.Space(picked, "W3>HSL>RGB>W3");
- pickerCallback(picked, "rgb");
- });
- } else if (booleanMatch) {
- var clickerTop = cursorOffset.top - yOffset;
- var clickerStyle = window.getComputedStyle(clickerDiv);
- var clickerWidth = getPixels(clickerStyle.width);
- var clickerLeft = leftBase - clickerWidth / 2 + xOffset;
- var value = JSON.parse(booleanMatch.string);
- if (value) {
- clickerDiv.removeChild(clicker);
- clicker = document.createElement("input");
- clicker.className = "checkbox";
- clicker.setAttribute("type", "checkbox");
- clicker.setAttribute("checked", "checked");
- clicker.addEventListener("change", onClicker);
- clickerDiv.appendChild(clicker);
- } else {
- clickerDiv.removeChild(clicker);
- clicker = document.createElement("input");
- clicker.className = "checkbox";
- clicker.setAttribute("type", "checkbox");
- clicker.addEventListener("change", onClicker);
- clickerDiv.appendChild(clicker);
- }
- clickerDiv.style.top = clickerTop - 3 + "px";
- clickerDiv.style.left = clickerLeft + "px";
- clickerDiv.style.visibility = "visible";
- } else {}
- }
- function getSliderRange(value) {
- var range, step, sliderMin, sliderMax;
- if (value === 0) {
- range = [ -100, 100 ];
- } else {
- range = [ -value * 3, value * 5 ];
- }
- if (range[0] < range[1]) {
- min = range[0];
- max = range[1];
- } else {
- min = range[1];
- max = range[0];
- }
- if (max - min > 20) {
- step = 1;
- } else {
- step = (max - min) / 200;
- }
- return {
- min: min,
- max: max,
- step: step
- };
- }
- function getMatch(cursor, type) {
- if (!type) return;
- var re;
- switch (type.toLowerCase()) {
- case "boolean":
- re = /true|false/g;
- break;
- case "hsl":
- re = /hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)/g;
- break;
- case "rgb":
- re = /rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)/g;
- break;
- case "hex":
- re = /#[a-fA-F0-9]{3,6}/g;
- break;
- case "number":
- re = /[-]?\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g;
- break;
- default:
- throw new Error("invalid match selection");
- return;
- }
- var line = editor.getLine(cursor.line);
- var match = re.exec(line);
- while (match) {
- var val = match[0];
- var len = val.length;
- var start = match.index;
- var end = match.index + len;
- if (cursor.ch >= start && cursor.ch <= end) {
- match = null;
- return {
- start: start,
- end: end,
- string: val
- };
- }
- match = re.exec(line);
- }
- return;
- }
- }
- function getPixels(style) {
- var pix = 0;
- if (style.length > 2) {
- pix = parseFloat(style.slice(0, style.length - 2));
- }
- if (!pix) pix = 0;
- return pix;
- }
- function getOffset(el) {
- var _x = 0;
- var _y = 0;
- while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) {
- _x += el.offsetLeft - el.scrollLeft;
- _y += el.offsetTop - el.scrollTop;
- el = el.offsetParent;
- }
- return {
- top: _y,
- left: _x
- };
- }
- return inlet;
-}();
+if(function(){var t,e,r,n,o,i,s,a,l,u,c,h,d=[].slice;s=function(t,e,r){return r=0>r?r+1:r>1?r-1:r,1>6*r?t+(e-t)*r*6:1>2*r?e:2>3*r?t+(e-t)*(.66666-r)*6:t},i=function(t,e,r){var n,o;return o=.5>=r?r*(e+1):r+e-r*e,n=2*r-o,{r:s(n,o,t+.33333),g:s(n,o,t),b:s(n,o,t-.33333)}},c=function(t,e,r){var n,o,i,s,a,l,u;return s=Math.max(t,e,r),a=Math.min(t,e,r),n=s-a,u=s+a,o=a===s?0:t===s?(60*(e-r)/n+360)%360:e===s?60*(r-t)/n+120:60*(t-e)/n+240,i=u/2,l=0===i?0:1===i?1:.5>=i?n/u:n/(2-u),{h:o,s:l,l:i}},o=function(t,e,r,o){return null!=o?"hsla("+n(Math.round(180*t/Math.PI),360)+","+Math.round(100*e)+"%,"+Math.round(100*r)+"%,"+o+")":"hsl("+n(Math.round(180*t/Math.PI),360)+","+Math.round(100*e)+"%,"+Math.round(100*r)+"%)"},r=function(t){var e,r,n,o,i,s;return s=document.createElement("span"),document.body.appendChild(s),s.style.backgroundColor=t,i=getComputedStyle(s).backgroundColor,document.body.removeChild(s),n=/^rgb\((\d+), (\d+), (\d+)\)$/.exec(i),n||(n=/^rgba\((\d+), (\d+), (\d+), ([\d.]+)\)$/.exec(i)),o=parseInt(n[1]),r=parseInt(n[2]),e=parseInt(n[3]),n[4]?{r:o/255,g:r/255,b:e/255,a:parseFloat(n[4])}:{r:o/255,g:r/255,b:e/255}},a=function(t){var e,r;return r=document.createElement("span"),document.body.appendChild(r),r.style.backgroundColor=t,e=r.style.backgroundColor.length>0,r.remove(),e},h=function(t,e){var r,n;for(r in e)n=e[r],t.style[r]=n;return t},n=function(t,e){return t%=e,0>t&&(t+=e),t},l=function(t,e,r){return e+(r-e)*Math.min(1,Math.max(0,t))},t=function(){function t(t,e,r){var n,o,s,a,l,u,c,h,d,p,f,m,v,g,b,y,x,M,w,C,k;for(this.radius=t,this.width=e,this.lightness=r,g=this.radius,w=this.width,o=this.canvas=document.createElement("canvas"),o.width=o.height=2*g,s=o.getContext("2d"),f=s.createImageData(o.width,o.height),l=f.data,k=p=0,b=o.height;b>=0?b>p:p>b;k=b>=0?++p:--p)for(C=m=0,y=o.width;y>=0?y>m:m>y;C=y>=0?++m:--m)c=k-g,u=C-g,a=Math.sqrt(c*c+u*u),a>g+1.5||(a-=10,M=Math.max(0,Math.min(1,a/(g-w/2-10))),d=Math.atan2(c,u)/(2*Math.PI),x=i(d,M,this.lightness),v=x.r,h=x.g,n=x.b,l[4*(k*o.width+C)+0]=255*v,l[4*(k*o.width+C)+1]=255*h,l[4*(k*o.width+C)+2]=255*n,l[4*(k*o.width+C)+3]=255);s.putImageData(f,0,0)}return t.prototype.drawHSLCircle=function(t,e){var r,n,o,i;return t.width=t.height=2*this.radius,r=t.getContext("2d"),i=this.width,o=this.radius,n=l(e,i,o),r.save(),r.fillStyle="rgba(0,0,0,0.3)",r.beginPath(),r.arc(o,o,o,0,2*Math.PI),r.fill(),r.fillStyle="black",r.beginPath(),r.arc(o,o,n,0,2*Math.PI),r.arc(o,o,n-i,0,2*Math.PI,!0),r.fill(),r.globalCompositeOperation="source-in",r.drawImage(this.canvas,0,0),r.restore()},t}(),u=function(t){return"string"==typeof t&&(t=r(t)),null!=t.r&&null!=t.g&&null!=t.b?(t=c(t.r,t.g,t.b),t.h=t.h*Math.PI/180):null!=t.h&&null!=t.s&&null!=t.l&&(t.h=t.h*Math.PI/180),t},e=function(){function e(t){this.color=u(t),this.refColor=this.color,this.el=v(),this.circleContainer=this.el.appendChild(a.call(this)),this.lSlider=this.el.appendChild(m.call(this)),this.colorPreview=this.el.appendChild(p.call(this)),s.call(this),this.setLightness(this.color.l)}var s,a,p,f,m,v,g,b;return g=80,b=25,e.prototype.setHue=function(t){var e,r,n;return this.color.h=t,n=l(this.color.s,b,g)-b/2,r=g-b/2,h(this.hueKnob,{left:Math.round(r+Math.cos(t)*n+6-1)+"px",top:Math.round(r+Math.sin(t)*n+6-1)+"px"}),this.colorPreview.style.backgroundColor=this.lKnob.style.backgroundColor=this.hueKnob.style.backgroundColor=o(this.color.h,this.color.s,this.color.l),e=o(this.color.h,this.color.s,.5),this.lSlider.style.backgroundImage="-webkit-linear-gradient(bottom, black, "+e+" 50%, white)",this.lSlider.style.backgroundImage="-moz-linear-gradient(bottom, black, "+e+" 50%, white)",this.emit("changed")},e.prototype.setSaturation=function(t){return this.color.s=t,this.circle.drawHSLCircle(this.circleCanvas,t),this.setHue(this.color.h)},e.prototype.setLightness=function(e){return this.color.l=e,this.circle=new t(g,b,e),this.lKnob.style.top=(1-e)*this.lSlider._height-11+"px",this.setSaturation(this.color.s)},e.prototype.setHSL=function(t,e,r){return this.color.h=n(t,360)*Math.PI/180,this.color.s=Math.max(0,Math.min(1,e)),r=Math.max(0,Math.min(1,r)),this.setLightness(r)},e.prototype.getHSL=function(){return{h:n(180*this.color.h/Math.PI,360),s:this.color.s,l:this.color.l}},e.prototype.setRGB=function(t,e,r){var n,o,i,s;return i=c(t,e,r),n=i.h,s=i.s,o=i.l,this.setHSL(n,s,o)},e.prototype.getRGB=function(){return i(this.color.h/(2*Math.PI),this.color.s,this.color.l)},e.prototype.getCSS=function(){return o(this.color.h,this.color.s,this.color.l)},e.prototype.setCSS=function(t){var e,n,o,i;return i=r(t),o=i.r,n=i.g,e=i.b,this.setRGB(o,n,e)},e.prototype.on=function(t,e){var r;return null==this._listeners&&(this._listeners={}),(null!=(r=this._listeners)[t]?r[t]:r[t]=[]).push(e)},e.prototype.emit=function(){var t,e,r,n,o,i,s,a;if(e=arguments[0],t=2<=arguments.length?d.call(arguments,1):[],this._listeners){for(s=null!=(i=this._listeners[e])?i:[],a=[],r=0,o=s.length;o>r;r++)n=s[r],a.push(n.call.apply(n,[this].concat(d.call(t))));return a}},e.prototype.removeListener=function(t,e){var r;return this._listeners[t]?this._listeners[t]=function(){var n,o,i,s;for(i=this._listeners[t],s=[],n=0,o=i.length;o>n;n++)r=i[n],r!==e&&s.push(r);return s}.call(this):void 0},s=function(){var t,e;return this.lKnob.onmousedown=function(t){return function(e){var r,n;return document.documentElement.style.cursor="pointer",window.addEventListener("mousemove",r=function(e){var r,n;return r=t.lSlider.getBoundingClientRect(),n=e.clientY-r.top,t.setLightness(Math.max(0,Math.min(1,1-n/t.lSlider._height)))}),window.addEventListener("mouseup",n=function(t){return window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n),window.removeEventListener("blur",n),document.documentElement.style.cursor=""}),window.addEventListener("blur",n),e.preventDefault(),e.stopPropagation()}}(this),t=this.circleContainer,e=function(e){return function(r){var n,o,i,s,a,u,c;return u=r.layerX,c=r.layerY,o=u-g,i=c-g,n=Math.sqrt(o*o+i*i),a=Math.atan2(i,o),s=l(e.color.s,b,g),n>s-b&&s>n?-Math.PI/8=7*Math.PI/8||a<=-7*Math.PI/8?t.style.cursor="ew-resize":Math.PI/8<=a&&a<3*Math.PI/8||-7*Math.PI/8a-b&&a>n?(document.documentElement.style.cursor=t.style.cursor,window.addEventListener("mousemove",s=function(t){var r,s,l;return a=e.circleCanvas.getBoundingClientRect(),r=a.left+a.width/2,s=a.top+a.height/2,o=t.clientX-r,i=t.clientY-s,n=Math.sqrt(o*o+i*i),n-=10,l=Math.max(0,Math.min(1,n/(g-b/2-10))),e.setSaturation(l)}),window.addEventListener("mouseup",c=function(t){return window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",c),window.removeEventListener("blur",c),document.documentElement.style.cursor=""}),window.addEventListener("blur",c)):void 0}}(this)),this.hueKnob.onmousedown=function(t){return function(e){var r,n;return document.documentElement.style.cursor="pointer",window.addEventListener("mousemove",r=function(e){var r,n,o;return o=t.circleCanvas.getBoundingClientRect(),r=o.left+o.width/2,n=o.top+o.height/2,t.setHue(Math.atan2(e.clientY-n,e.clientX-r))}),window.addEventListener("mouseup",n=function(t){return window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n),window.removeEventListener("blur",n),document.documentElement.style.cursor=""}),window.addEventListener("blur",n),e.preventDefault(),e.stopPropagation()}}(this)},v=function(){var t;return t=document.createElement("div"),t.className="picker",h(t,{display:"inline-block",background:"hsl(0, 0%, 97%)",padding:"6px",borderRadius:"6px",boxShadow:"1px 1px 5px hsla(0, 0%, 39%, 0.2), hsla(0, 0%, 100%, 0.9) 0px 0px 1em 0.3em inset",border:"1px solid hsla(0, 0%, 59%, 0.2)",position:"absolute",backgroundImage:"-webkit-linear-gradient(left top, hsla(0, 0%, 0%, 0.05) 25%, transparent 25%, transparent 50%, hsla(0, 0%, 0%, 0.05) 50%, hsla(0, 0%, 0%, 0.05) 75%, transparent 75%, transparent)",backgroundSize:"40px 40px"}),h(t,{backgroundImage:"-moz-linear-gradient(left top, hsla(0, 0%, 0%, 0.05) 25%, transparent 25%, transparent 50%, hsla(0, 0%, 0%, 0.05) 50%, hsla(0, 0%, 0%, 0.05) 75%, transparent 75%, transparent)",zIndex:"1000"}),t},a=function(){var t,e;return t=document.createElement("div"),h(t,{display:"inline-block",width:2*g+"px",height:2*g+"px",borderRadius:g+"px",boxShadow:"0px 0px 7px rgba(0,0,0,0.3)"}),t.appendChild(this.circleCanvas=document.createElement("canvas")),this.hueKnob=e=f(27),t.appendChild(e),t},m=function(){var t,e;return e=document.createElement("div"),h(e,{display:"inline-block",width:"20px",height:2*g-22+"px",marginLeft:"6px",borderRadius:"10px",boxShadow:"hsla(0, 100%, 100%, 0.1) 0 1px 2px 1px inset, hsla(0, 100%, 100%, 0.2) 0 1px inset, hsla(0, 0%, 0%, 0.4) 0 -1px 1px inset, hsla(0, 0%, 0%, 0.4) 0 1px 1px",position:"relative",top:"-11px"}),e._height=2*g-22,this.lKnob=t=f(22),h(t,{left:"-1px"}),e.appendChild(t),e},p=function(){var t,e,r;return t=document.createElement("div"),e=o(this.refColor.h,this.refColor.s,this.refColor.l),r=o(this.refColor.h,this.refColor.s,this.refColor.l,0),h(t,{boxShadow:"hsla(0, 0%, 0%, 0.5) 0 1px 5px, hsla(0, 100%, 100%, 0.4) 0 1px 1px inset, hsla(0, 0%, 0%, 0.3) 0 -1px 1px inset",height:"25px",marginTop:"6px",borderRadius:"3px",backgroundImage:"-webkit-linear-gradient(-20deg, "+r+", "+r+" 69%, "+e+" 70%, "+e+")"}),h(t,{backgroundImage:"-moz-linear-gradient(-20deg, "+r+", "+r+" 69%, "+e+" 70%, "+e+")"}),t},f=function(t){var e;return e=document.createElement("div"),e.className="knob",h(e,{position:"absolute",width:t+"px",height:t+"px",backgroundColor:"red",borderRadius:Math.floor(t/2)+"px",cursor:"pointer",backgroundImage:"-webkit-gradient(radial, 50% 0%, 0, 50% 0%, 15, color-stop(0%, rgba(255, 255, 255, 0.8)), color-stop(100%, rgba(255, 255, 255, 0.2)))",boxShadow:"white 0px 1px 1px inset, rgba(0, 0, 0, 0.4) 0px -1px 1px inset, rgba(0, 0, 0, 0.4) 0px 1px 4px 0px, rgba(0, 0, 0, 0.6) 0 0 2px"}),h(e,{backgroundImage:"radial-gradient(circle at center top, rgba(255,255,255,0.8), rgba(255, 255, 255, 0.2) 15px"}),e},e.prototype.presentModal=function(t,e){var r;return h(this.el,{left:t+"px",top:e-10+"px",opacity:"0",webkitTransition:"0.15s",MozTransition:"0.15s"}),r=document.createElement("div"),r.style.position="fixed",r.style.top=r.style.left=r.style.bottom=r.style.right="0",r.style.zIndex="999",r.onclick=function(t){return function(){var n;return document.body.removeChild(r),t.el.style.top=e+10+"px",t.el.style.opacity=0,n=function(){return document.body.removeChild(t.el),t.el.removeEventListener("webkitTransitionEnd",n),t.el.removeEventListener("transitionend",n)},t.el.addEventListener("webkitTransitionEnd",n),t.el.addEventListener("transitionend",n),t.emit("closed")}}(this),document.body.appendChild(r),document.body.appendChild(this.el),this.el.offsetHeight,this.el.style.opacity="1",this.el.style.top=e+"px",this},e.prototype.presentModalBeneath=function(t){var e,r,n;return e=t.getBoundingClientRect(),r=e.left+window.scrollX,n=e.bottom+window.scrollY+4,this.presentModal(r,n)},e}(),window.thistle={Picker:e,isValidCSSColor:a}}.call(this),"undefined"==typeof Color)var Color={};"undefined"==typeof Color.Space&&(Color.Space={}),function(){"use strict";var useEval=!1,functions={},shortcuts={"HEX24>HSL":"HEX24>RGB>HSL","HEX32>HSLA":"HEX32>RGBA>HSLA","HEX24>CMYK":"HEX24>RGB>CMY>CMYK","RGB>CMYK":"RGB>CMY>CMYK"},root=Color.Space=function(color,route){shortcuts[route]&&(route=shortcuts[route]);var r=route.split(">");if("object"==typeof color&&color[0]>=0){for(var type=r[0],tmp={},i=0;i1&&(key=key.substr(key.indexOf("_")+1)),key+=(0===pos?"":"_")+r[pos],color=root[key](color),useEval&&(f="Color.Space."+key+"("+f+")");return useEval&&(functions[route]=eval("(function(color) { return "+f+" })")),color};root.RGB_W3=function(t){return"rgb("+(t.R>>0)+","+(t.G>>0)+","+(t.B>>0)+")"},root.RGBA_W3=function(t){var e="number"==typeof t.A?t.A/255:1;return"rgba("+(t.R>>0)+","+(t.G>>0)+","+(t.B>>0)+","+e+")"},root.W3_RGB=function(t){return t=t.substr(4,t.length-5).split(","),{R:parseInt(t[0],10),G:parseInt(t[1],10),B:parseInt(t[2],10)}},root.W3_RGBA=function(t){return t=t.substr(5,t.length-6).split(","),{R:parseInt(t[0],10),G:parseInt(t[1],10),B:parseInt(t[2],10),A:255*parseFloat(t[3])}},root.HSL_W3=function(t){return"hsl("+(t.H+.5>>0)+","+(t.S+.5>>0)+"%,"+(t.L+.5>>0)+"%)"},root.HSLA_W3=function(t){var e="number"==typeof t.A?t.A/255:1;return"hsla("+(t.H+.5>>0)+","+(t.S+.5>>0)+"%,"+(t.L+.5>>0)+"%,"+e+")"},root.W3_HSL=function(t){var e=t.indexOf("(")+1,r=t.indexOf(")");return t=t.substr(e,r-e).split(","),{H:parseInt(t[0],10),S:parseInt(t[1],10),L:parseInt(t[2],10)}},root.W3_HSLA=function(t){var e=t.indexOf("(")+1,r=t.indexOf(")");return t=t.substr(e,r-e).split(","),{H:parseInt(t[0],10),S:parseInt(t[1],10),L:parseInt(t[2],10),A:255*parseFloat(t[3],10)}},root.W3_HEX=root.W3_HEX24=function(t){return"#"===t.substr(0,1)&&(t=t.substr(1)),3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),parseInt("0x"+t,16)},root.W3_HEX32=function(t){return"#"===t.substr(0,1)&&(t=t.substr(1)),6===t.length?parseInt("0xFF"+t,10):parseInt("0x"+t,16)},root.HEX_W3=root.HEX24_W3=function(t,e){e||(e=6),t||(t=0);var r,n=t.toString(16);for(r=n.length;e>r;)n="0"+n,r++;for(r=n.length;r>e;)n=n.substr(1),r--;return"#"+n},root.HEX32_W3=function(t){return root.HEX_W3(t,8)},root.HEX_RGB=root.HEX24_RGB=function(t){return{R:t>>16,G:t>>8&255,B:255&t}},root.HEX32_RGBA=function(t){return{R:t>>>16&255,G:t>>>8&255,B:255&t,A:t>>>24}},root.RGBA_HEX32=function(t){return(t.A<<24|t.R<<16|t.G<<8|t.B)>>>0},root.RGB_HEX24=root.RGB_HEX=function(t){return t.R<0&&(t.R=0),t.G<0&&(t.G=0),t.B<0&&(t.B=0),t.R>255&&(t.R=255),t.G>255&&(t.G=255),t.B>255&&(t.B=255),t.R<<16|t.G<<8|t.B},root.RGB_CMY=function(t){return{C:1-t.R/255,M:1-t.G/255,Y:1-t.B/255}},root.RGBA_HSLA=root.RGB_HSL=function(t){var e,r,n=t.R/255,o=t.G/255,i=t.B/255,s=Math.min(n,o,i),a=Math.max(n,o,i),l=a-s,u=(a+s)/2;if(0===l)e=0,r=0;else{r=.5>u?l/(a+s):l/(2-a-s);var c=((a-n)/6+l/2)/l,h=((a-o)/6+l/2)/l,d=((a-i)/6+l/2)/l;n===a?e=d-h:o===a?e=1/3+c-d:i===a&&(e=2/3+h-c),0>e&&(e+=1),e>1&&(e-=1)}return{H:360*e,S:100*r,L:100*u,A:t.A}},root.RGBA_HSVA=root.RGB_HSV=function(t){var e,r,n=t.R/255,o=t.G/255,i=t.B/255,s=Math.min(n,o,i),a=Math.max(n,o,i),l=a-s,u=a;if(0===l)e=0,r=0;else{r=l/a;var c=((a-n)/6+l/2)/l,h=((a-o)/6+l/2)/l,d=((a-i)/6+l/2)/l;n===a?e=d-h:o===a?e=1/3+c-d:i===a&&(e=2/3+h-c),0>e&&(e+=1),e>1&&(e-=1)}return{H:360*e,S:100*r,V:100*u,A:t.A}},root.CMY_RGB=function(t){return{R:Math.max(0,255*(1-t.C)),G:Math.max(0,255*(1-t.M)),B:Math.max(0,255*(1-t.Y))}},root.CMY_CMYK=function(t){var e=t.C,r=t.M,n=t.Y,o=Math.min(n,Math.min(r,Math.min(e,1)));return e=Math.round((e-o)/(1-o)*100),r=Math.round((r-o)/(1-o)*100),n=Math.round((n-o)/(1-o)*100),o=Math.round(100*o),{C:e,M:r,Y:n,K:o}},root.CMYK_CMY=function(t){return{C:t.C*(1-t.K)+t.K,M:t.M*(1-t.K)+t.K,Y:t.Y*(1-t.K)+t.K}},root.HSLA_RGBA=root.HSL_RGB=function(t){var e,r,n,o,i,s,a=t.H/360,l=t.S/100,u=t.L/100;return 0===l?e=r=n=u:(i=.5>u?u*(1+l):u+l-l*u,o=2*u-i,s=a+1/3,0>s&&(s+=1),s>1&&(s-=1),e=1>6*s?o+6*(i-o)*s:1>2*s?i:2>3*s?o+(i-o)*(2/3-s)*6:o,s=a,0>s&&(s+=1),s>1&&(s-=1),r=1>6*s?o+6*(i-o)*s:1>2*s?i:2>3*s?o+(i-o)*(2/3-s)*6:o,s=a-1/3,0>s&&(s+=1),s>1&&(s-=1),n=1>6*s?o+6*(i-o)*s:1>2*s?i:2>3*s?o+(i-o)*(2/3-s)*6:o),{R:255*e,G:255*r,B:255*n,A:t.A}},root.HSVA_RGBA=root.HSV_RGB=function(t){var e,r,n,o,i,s,a=t.H/360,l=t.S/100,u=t.V/100;if(0===l)e=r=n=Math.round(255*u);else switch(a>=1&&(a=0),a=6*a,o=a-Math.floor(a),i=Math.round(255*u*(1-l)),n=Math.round(255*u*(1-l*o)),s=Math.round(255*u*(1-l*(1-o))),u=Math.round(255*u),Math.floor(a)){case 0:e=u,r=s,n=i;break;case 1:e=n,r=u,n=i;break;case 2:e=i,r=u,n=s;break;case 3:e=i,r=n,n=u;break;case 4:e=s,r=i,n=u;break;case 5:e=u,r=i,n=n}return{R:e,G:r,B:n,A:t.A}}}(),Inlet=function(){function t(t,r){function n(t){var e=String(u.checked),r=c.getCursor(!0),n=a(r,"boolean");if(n){var o={line:r.line,ch:n.start},i={line:r.line,ch:n.end};c.replaceRange(e,o,i)}}function o(t){t.target!==k&&t.target!==w&&t.target!==u&&(w.style.visibility="hidden")}function i(){1==arguments.length?event=arguments[0]:event=arguments[1],event.keyCode==E||event.keyCode==I?event.altKey&&s():(event.keyCode==L||event.keyCode==S)&&event.altKey&&s()}function s(t){if(!c.somethingSelected()){k=t.target;var r=c.getCursor(!0);c.getTokenAt(r);cursorOffset=c.cursorCoords(!0,"page");var o=c.cursorCoords(!0,y).left,i=(a(r,"number"),a(r,"hsl")),s=a(r,"hex"),h=a(r,"rgb"),b=a(r,"boolean"),x=cursorOffset.top-d;cursorOffset.topHSL>RGB>HEX24>W3"),R(picked,"hex")})}else if(i){var C=i.string;l=new thistle.Picker(C),l.setCSS(C),l.presentModal(M,x),l.on("changed",function(){picked=l.getCSS(),R(picked,"hsl")})}else if(h){var C=h.string;l=new thistle.Picker(C),l.setCSS(C),l.presentModal(M,x),l.on("changed",function(){picked=l.getCSS(),picked=Color.Space(picked,"W3>HSL>RGB>W3"),R(picked,"rgb")})}else if(b){var E=cursorOffset.top-v,S=window.getComputedStyle(w),L=e(S.width),I=o-L/2+g,H=JSON.parse(b.string);H?(w.removeChild(u),u=document.createElement("input"),u.className="checkbox",u.setAttribute("type","checkbox"),u.setAttribute("checked","checked"),u.addEventListener("change",n),w.appendChild(u)):(w.removeChild(u),u=document.createElement("input"),u.className="checkbox",u.setAttribute("type","checkbox"),u.addEventListener("change",n),w.appendChild(u)),w.style.top=E-3+"px",w.style.left=I+"px",w.style.visibility="visible"}}}function a(t,e){if(e){var r;switch(e.toLowerCase()){case"boolean":r=/true|false/g;break;case"hsl":r=/hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)/g;break;case"rgb":r=/rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)/g;break;case"hex":r=/#[a-fA-F0-9]{3,6}/g;break;case"number":r=/[-]?\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g;break;default:throw new Error("invalid match selection")}for(var n=c.getLine(t.line),o=r.exec(n);o;){var i=o[0],s=i.length,a=o.index,l=o.index+s;if(t.ch>=a&&t.ch<=l)return o=null,{start:a,end:l,string:i};o=r.exec(n)}}}var l,u,c=t;r||(r={}),r.picker||(r.picker={}),r.slider||(r.slider={}),r.clicker||(r.clicker={});var h=r.container||document.body,d=r.picker.topOffset||220,p=r.picker.bottomOffset||16,f=r.picker.topBoundary||250,m=r.picker.leftOffset||75,v=r.slider.yOffset||15,g=r.slider.xOffset||0,b=r.slider.width,y=r.horizontalMode||"page",x=r.fixedContainer,M=(r.slider.callback||function(t){},r.picker.callback||function(t){},r.clicker.callback||function(t){},c.getWrapperElement());M.addEventListener("mouseup",s),document.body.addEventListener("mouseup",o),c.setOption("onKeyEvent",i);var w=document.createElement("div");w.className="inlet_clicker",w.style.visibility="hidden",w.style.position="absolute",h.appendChild(w);var u=document.createElement("input");u.className="checkbox",u.setAttribute("type","checkbox"),u.addEventListener("change",n),w.appendChild(u);var C=document.createElement("div");C.className="inlet_slider",C.style.visibility="hidden",b&&(C.style.width=b),x?C.style.position="fixed":C.style.position="absolute",C.style.top=0;var k,E=37,S=38,L=39,I=40,R=function(t,e){var r=c.getCursor();if(e){var n=a(r,e),o={line:r.line,ch:n.start},i={line:r.line,ch:n.end};c.picking=!0,c.replaceRange(t,o,i),setTimeout(function(){c.picking=!1},100)}};l=new thistle.Picker("#ffffff")}function e(t){var e=0;return t.length>2&&(e=parseFloat(t.slice(0,t.length-2))),e||(e=0),e}return t}();
\ No newline at end of file