PageSourceSearch

https://kingfisherboats.com/wp-content/plugins/gf-color-picker/js/colorjoe.js?ver=1.2.13

js kingfisherboats.com collected 2026-09-28 12:49:11 UTC 30,667 bytes, 829 lines download raw bytes

vendor: 5,619 bytes, lines 1-199
1/*! colorjoe - v4.1.0 - Juho Vepsalainen <[email protected]> - MIT
2https://bebraw.github.com/colorjoe - 2018-07-03 */
3(function (global, factory) {
4	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
5	typeof define === 'function' && define.amd ? define(factory) :
6	(global.colorjoe = factory());
7}(this, (function () { 'use strict';
8
9	var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
11	function createCommonjsModule(fn, module) {
12		return module = { exports: {} }, fn(module, module.exports), module.exports;
13	}
14
15	var dragjs_umd = createCommonjsModule(function (module, exports) {
16	(function (root, factory) {
17
18	        {
19	            module.exports = factory();
20	        }
21
22	    }(commonjsGlobal, function () {
23
24	        /*! dragjs - v0.8.0 - Juho Vepsalainen <[email protected]> - MIT
25	https://bebraw.github.com/dragjs - 2018-07-03 */
26	var drag = (function() {
27	    function drag(elem, cbs) {
28	        if(!elem) {
29	            console.warn('drag is missing elem!');
30	            return;
31	        }
32
33	        dragTemplate(elem, cbs, 'touchstart', 'touchmove', 'touchend');
34	        dragTemplate(elem, cbs, 'mousedown', 'mousemove', 'mouseup');
35	    }
36
37	    function xyslider(o) {
38	        var twod = div(o['class'] || '', o.parent);
39	        var pointer = div('pointer', twod);
40	        div('shape shape1', pointer);
41	        div('shape shape2', pointer);
42	        div('bg bg1', twod);
43	        div('bg bg2', twod);
44
45	        drag(twod, attachPointer(o.cbs, pointer));
46
47	        return {
48	            background: twod,
49	            pointer: pointer
50	        };
51	    }
52
53	    function slider(o) {
54	        var oned = div(o['class'], o.parent);
55	        var pointer = div('pointer', oned);
56	        div('shape', pointer);
57	        div('bg', oned);
58
59	        drag(oned, attachPointer(o.cbs, pointer));
60
61	        return {
62	            background: oned,
63	            pointer: pointer
64	        };
65	    }
66
67	    drag.xyslider = xyslider;
68	    drag.slider = slider;
69
70	    return drag;
71
72	    function attachPointer(cbs, pointer) {
73	        var ret = {};
74
75	        for(var n in cbs) {
76	          ret[n] = wrap(cbs[n]);
77	        }
78
79	        function wrap(fn) {
80	            return function(p) {
81	                p.pointer = pointer;
82	                fn(p);
83	            };
84	        }
85
86	        return ret;
87	    }
88
89	    // move to elemutils lib?
90	    function div(klass, p) {
91	        return e('div', klass, p);
92	    }
93
94	    function e(type, klass, p) {
95	        var elem = document.createElement(type);
96	        if(klass) {
97	          elem.className = klass;
98	        }
99	        p.appendChild(elem);
100
101	        return elem;
102	    }
103
104	    function dragTemplate(elem, cbs, down, move, up) {
105
106	        cbs = getCbs(cbs);
107
108	        var beginCb = cbs.begin;
109	        var changeCb = cbs.change;
110	        var endCb = cbs.end;
111
112	        on(elem, down, function(e) {
113
114	            var moveHandler = partial(callCb, changeCb, elem);
115	            function upHandler() {
116
117	                off(document, move, moveHandler);
118	                off(document, up, upHandler);
119
120	                callCb(endCb, elem, e);
121	            }
122
123	            on(document, move, moveHandler);
124	            on(document, up, upHandler);
125
126	            callCb(beginCb, elem, e);
127	        });
128	    }
129
130	    // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection
131	    function on(elem, evt, handler) {
132	        // Test via a getter in the options object to see if the passive property is accessed
133	        var supportsPassive = false;
134	        try {
135	        var opts = Object.defineProperty({}, 'passive', {
136	            get: function() {
137	            supportsPassive = true;
138	            }
139	        });
140	        window.addEventListener("testPassive", null, opts);
141	        window.removeEventListener("testPassive", null, opts);
142	        } catch (e) {}
143
144	        elem.addEventListener(evt, handler, supportsPassive ? { passive: false } : false);
145	    }
146
147	    function off(elem, evt, handler) {
148	      elem.removeEventListener(evt, handler, false);
149	    }
150
151	    function getCbs(cbs) {
152	        if(!cbs) {
153	            var initialOffset;
154	            var initialPos;
155
156	            return {
157	                begin: function(c) {
158	                    initialOffset = {x: c.elem.offsetLeft, y: c.elem.offsetTop};
159	                    initialPos = c.cursor;
160	                },
161	                change: function(c) {
162	                    style(c.elem, 'left', (initialOffset.x + c.cursor.x - initialPos.x) + 'px');
163	                    style(c.elem, 'top', (initialOffset.y + c.cursor.y - initialPos.y) + 'px');
164	                },
165	                end: empty
166	            };
167	        }
168	        else {
169	            return {
170	                begin: cbs.begin || empty,
171	                change: cbs.change || empty,
172	                end: cbs.end || empty
173	            };
174	        }
175	    }
176
177	    // TODO: set draggable class (handy for fx)
178	    function style(e, prop, value) {
179	        e.style[prop] = value;
180	    }
181
182	    function empty() {}
183
184	    function callCb(cb, elem, e) {
185	        e.preventDefault();
186
187	        var offset = findPos(elem);
188	        var width = elem.clientWidth;
189	        var height = elem.clientHeight;
190	        var cursor = {
191	            x: cursorX(elem, e),
192	            y: cursorY(elem, e)
193	        };
194	        var x = (cursor.x - offset.x) / width;
195	        var y = (cursor.y - offset.y) / height;
196
197	        cb({
198	            x: isNaN(x)? 0: x,
199	            y: isNaN(y)? 0: y,
200	            cursor: cursor,
201	            elem: elem,
202	            e: e
203	        });
204	    }
205
206	    // http://stackoverflow.com/questions/4394747/javascript-curry-function
207	    function partial(fn) {
208	        var slice = Array.prototype.slice;
209	        var args = slice.apply(arguments, [1]);
210
211	        return function() {
212	            return fn.apply(null, args.concat(slice.apply(arguments)));
213	        };
214	    }
215
216	    // http://www.quirksmode.org/js/findpos.html
217	    function findPos(e) {
218	        var r = e.getBoundingClientRect();
219
220	        return {
221	            x: r.left,
222	            y: r.top
223	        };
224	    }
225
226	    // http://javascript.about.com/library/blmousepos.htm
227	    function cursorX(elem, evt) {
228	        var evtPos = evt.touches ? evt.touches[evt.touches.length -1] : evt;
229	        return evtPos.clientX;
230	    }
231	    function cursorY(elem, evt) {
232	        var evtPos = evt.touches ? evt.touches[evt.touches.length -1] : evt;
233	        return evtPos.clientY;
234	    }
235	})();
236	        return drag;
vendor: 17,561 bytes, lines 237-528
237
238	    }));
239	});
240
241	var oneColorAll = createCommonjsModule(function (module, exports) {
242	!function(e,a){module.exports=a();}(commonjsGlobal,function(){function e(a){if(Array.isArray(a)){if("string"==typeof a[0]&&"function"==typeof e[a[0]])return new e[a[0]](a.slice(1,a.length));if(4===a.length)return new e.RGB(a[0]/255,a[1]/255,a[2]/255,a[3]/255)}else if("string"==typeof a){var r=a.toLowerCase();e.namedColors[r]&&(a="#"+e.namedColors[r]),"transparent"===r&&(a="rgba(0,0,0,0)");var o=a.match(i);if(o){var s=o[1].toUpperCase(),f=t(o[8])?o[8]:parseFloat(o[8]),u="H"===s[0],l=o[3]?100:u?360:255,h=o[5]||u?100:255,c=o[7]||u?100:255;if(t(e[s]))throw new Error("color."+s+" is not installed.");return new e[s](parseFloat(o[2])/l,parseFloat(o[4])/h,parseFloat(o[6])/c,f)}a.length<6&&(a=a.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,"$1$1$2$2$3$3"));var d=a.match(/^#?([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/i);if(d)return new e.RGB(parseInt(d[1],16)/255,parseInt(d[2],16)/255,parseInt(d[3],16)/255);if(e.CMYK){var b=a.match(new RegExp("^cmyk\\("+n.source+","+n.source+","+n.source+","+n.source+"\\)$","i"));if(b)return new e.CMYK(parseFloat(b[1])/100,parseFloat(b[2])/100,parseFloat(b[3])/100,parseFloat(b[4])/100)}}else if("object"==typeof a&&a.isColor)return a;return !1}var a=[],t=function(e){return void 0===e},r=/\s*(\.\d+|\d+(?:\.\d+)?)(%)?\s*/,n=/\s*(\.\d+|100|\d?\d(?:\.\d+)?)%\s*/,i=new RegExp("^(rgb|hsl|hsv)a?\\("+r.source+","+r.source+","+r.source+"(?:,"+/\s*(\.\d+|\d+(?:\.\d+)?)\s*/.source+")?\\)$","i");e.namedColors={},e.installColorSpace=function(r,n,i){function o(a,t){var r={};r[t.toLowerCase()]=function(){return this.rgb()[t.toLowerCase()]()},e[t].propertyNames.forEach(function(e){var a="black"===e?"k":e.charAt(0);r[e]=r[a]=function(a,r){return this[t.toLowerCase()]()[e](a,r)};});for(var n in r)r.hasOwnProperty(n)&&void 0===e[a].prototype[n]&&(e[a].prototype[n]=r[n]);}e[r]=function(e){var a=Array.isArray(e)?e:arguments;n.forEach(function(e,t){var i=a[t];if("alpha"===e)this._alpha=isNaN(i)||i>1?1:i<0?0:i;else{if(isNaN(i))throw new Error("["+r+"]: Invalid color: ("+n.join(",")+")");"hue"===e?this._hue=i<0?i-Math.floor(i):i%1:this["_"+e]=i<0?0:i>1?1:i;}},this);},e[r].propertyNames=n;var s=e[r].prototype;["valueOf","hex","hexa","css","cssa"].forEach(function(e){s[e]=s[e]||("RGB"===r?s.hex:function(){return this.rgb()[e]()});}),s.isColor=!0,s.equals=function(e,a){t(a)&&(a=1e-10),e=e[r.toLowerCase()]();for(var i=0;i<n.length;i+=1)if(Math.abs(this["_"+n[i]]-e["_"+n[i]])>a)return !1;return !0},s.toJSON=function(){return [r].concat(n.map(function(e){return this["_"+e]},this))};for(var f in i)if(i.hasOwnProperty(f)){var u=f.match(/^from(.*)$/);u?e[u[1].toUpperCase()].prototype[r.toLowerCase()]=i[f]:s[f]=i[f];}return s[r.toLowerCase()]=function(){return this},s.toString=function(){return "["+r+" "+n.map(function(e){return this["_"+e]},this).join(", ")+"]"},n.forEach(function(e){var a="black"===e?"k":e.charAt(0);s[e]=s[a]=function(a,t){return void 0===a?this["_"+e]:t?new this.constructor(n.map(function(t){return this["_"+t]+(e===t?a:0)},this)):new this.constructor(n.map(function(t){return e===t?a:this["_"+t]},this))};}),a.forEach(function(e){o(r,e),o(e,r);}),a.push(r),e},e.pluginList=[],e.use=function(a){return -1===e.pluginList.indexOf(a)&&(this.pluginList.push(a),a(e)),e},e.installMethod=function(t,r){return a.forEach(function(a){e[a].prototype[t]=r;}),this},e.installColorSpace("RGB",["red","green","blue","alpha"],{hex:function(){var e=(65536*Math.round(255*this._red)+256*Math.round(255*this._green)+Math.round(255*this._blue)).toString(16);return "#"+"00000".substr(0,6-e.length)+e},hexa:function(){var e=Math.round(255*this._alpha).toString(16);return "#"+"00".substr(0,2-e.length)+e+this.hex().substr(1,6)},css:function(){return "rgb("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+")"},cssa:function(){return "rgba("+Math.round(255*this._red)+","+Math.round(255*this._green)+","+Math.round(255*this._blue)+","+this._alpha+")"}});var o=e,s=function(e){e.installColorSpace("XYZ",["x","y","z","alpha"],{fromRgb:function(){var a=function(e){return e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92},t=a(this._red),r=a(this._green),n=a(this._blue);return new e.XYZ(.4124564*t+.3575761*r+.1804375*n,.2126729*t+.7151522*r+.072175*n,.0193339*t+.119192*r+.9503041*n,this._alpha)},rgb:function(){var a=this._x,t=this._y,r=this._z,n=function(e){return e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e};return new e.RGB(n(3.2404542*a+-1.5371385*t+-.4985314*r),n(-.969266*a+1.8760108*t+.041556*r),n(.0556434*a+-.2040259*t+1.0572252*r),this._alpha)},lab:function(){var a=function(e){return e>.008856?Math.pow(e,1/3):7.787037*e+4/29},t=a(this._x/95.047),r=a(this._y/100),n=a(this._z/108.883);return new e.LAB(116*r-16,500*(t-r),200*(r-n),this._alpha)}});},f=function(e){e.use(s),e.installColorSpace("LAB",["l","a","b","alpha"],{fromRgb:function(){return this.xyz().lab()},rgb:function(){return this.xyz().rgb()},xyz:function(){var a=function(e){var a=Math.pow(e,3);return a>.008856?a:(e-16/116)/7.87},t=(this._l+16)/116,r=this._a/500+t,n=t-this._b/200;return new e.XYZ(95.047*a(r),100*a(t),108.883*a(n),this._alpha)}});},u=function(e){e.installColorSpace("HSV",["hue","saturation","value","alpha"],{rgb:function(){var a,t,r,n=this._hue,i=this._saturation,o=this._value,s=Math.min(5,Math.floor(6*n)),f=6*n-s,u=o*(1-i),l=o*(1-f*i),h=o*(1-(1-f)*i);switch(s){case 0:a=o,t=h,r=u;break;case 1:a=l,t=o,r=u;break;case 2:a=u,t=o,r=h;break;case 3:a=u,t=l,r=o;break;case 4:a=h,t=u,r=o;break;case 5:a=o,t=u,r=l;}return new e.RGB(a,t,r,this._alpha)},hsl:function(){var a,t=(2-this._saturation)*this._value,r=this._saturation*this._value,n=t<=1?t:2-t;return a=n<1e-9?0:r/n,new e.HSL(this._hue,a,t/2,this._alpha)},fromRgb:function(){var a,t=this._red,r=this._green,n=this._blue,i=Math.max(t,r,n),o=Math.min(t,r,n),s=i-o,f=0===i?0:s/i,u=i;if(0===s)a=0;else switch(i){case t:a=(r-n)/s/6+(r<n?1:0);break;case r:a=(n-t)/s/6+1/3;break;case n:a=(t-r)/s/6+2/3;}return new e.HSV(a,f,u,this._alpha)}});},l=function(e){e.use(u),e.installColorSpace("HSL",["hue","saturation","lightness","alpha"],{hsv:function(){var a,t=2*this._lightness,r=this._saturation*(t<=1?t:2-t);return a=t+r<1e-9?0:2*r/(t+r),new e.HSV(this._hue,a,(t+r)/2,this._alpha)},rgb:function(){return this.hsv().rgb()},fromRgb:function(){return this.hsv().hsl()}});},h=function(e){e.installColorSpace("CMYK",["cyan","magenta","yellow","black","alpha"],{rgb:function(){return new e.RGB(1-this._cyan*(1-this._black)-this._black,1-this._magenta*(1-this._black)-this._black,1-this._yellow*(1-this._black)-this._black,this._alpha)},fromRgb:function(){var a=this._red,t=this._green,r=this._blue,n=1-a,i=1-t,o=1-r,s=1;return a||t||r?(s=Math.min(n,Math.min(i,o)),n=(n-s)/(1-s),i=(i-s)/(1-s),o=(o-s)/(1-s)):s=1,new e.CMYK(n,i,o,s,this._alpha)}});},c=function(e){e.namedColors={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgrey:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",grey:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};},d=function(e){e.installMethod("clearer",function(e){return this.alpha(isNaN(e)?-.1:-e,!0)});},b=function(e){e.use(l),e.installMethod("darken",function(e){return this.lightness(isNaN(e)?-.1:-e,!0)});},p=function(e){e.use(l),e.installMethod("desaturate",function(e){return this.saturation(isNaN(e)?-.1:-e,!0)});},g=function(e){function a(){var a=this.rgb(),t=.3*a._red+.59*a._green+.11*a._blue;return new e.RGB(t,t,t,a._alpha)}e.installMethod("greyscale",a).installMethod("grayscale",a);},_=function(e){e.use(l),e.installMethod("lighten",function(e){return this.lightness(isNaN(e)?.1:e,!0)});},m=function(e){e.installMethod("mix",function(a,t){a=e(a).rgb(),t=1-(isNaN(t)?.5:t);var r=2*t-1,n=this._alpha-a._alpha,i=((r*n==-1?r:(r+n)/(1+r*n))+1)/2,o=1-i,s=this.rgb();return new e.RGB(s._red*i+a._red*o,s._green*i+a._green*o,s._blue*i+a._blue*o,s._alpha*t+a._alpha*(1-t))});},w=function(e){e.installMethod("negate",function(){var a=this.rgb();return new e.RGB(1-a._red,1-a._green,1-a._blue,this._alpha)});},y=function(e){e.installMethod("opaquer",function(e){return this.alpha(isNaN(e)?.1:e,!0)});},v=function(e){e.use(l),e.installMethod("rotate",function(e){return this.hue((e||0)/360,!0)});},k=function(e){e.use(l),e.installMethod("saturate",function(e){return this.saturation(isNaN(e)?.1:e,!0)});},M=function(e){e.installMethod("toAlpha",function(e){var a=this.rgb(),t=e(e).rgb(),r=new e.RGB(0,0,0,a._alpha),n=["_red","_green","_blue"];return n.forEach(function(e){a[e]<1e-10?r[e]=a[e]:a[e]>t[e]?r[e]=(a[e]-t[e])/(1-t[e]):a[e]>t[e]?r[e]=(t[e]-a[e])/t[e]:r[e]=0;}),r._red>r._green?r._red>r._blue?a._alpha=r._red:a._alpha=r._blue:r._green>r._blue?a._alpha=r._green:a._alpha=r._blue,a._alpha<1e-10?a:(n.forEach(function(e){a[e]=(a[e]-t[e])/a._alpha+t[e];}),a._alpha*=r._alpha,a)});};return o.use(s).use(f).use(u).use(l).use(h).use(c).use(d).use(b).use(p).use(g).use(_).use(m).use(w).use(y).use(v).use(k).use(M)});
243
244	});
245
246	var div = partial(e, 'div');
247
248	function e(type, klass, p) {
249	    var elem = document.createElement(type);
250	    elem.className = klass;
251	    p.appendChild(elem);
252
253	    return elem;
254	}
255
256	// http://stackoverflow.com/questions/4394747/javascript-curry-function
257	function partial(fn) {
258	    var slice = Array.prototype.slice;
259	    var args = slice.apply(arguments, [1]);
260
261	    return function() {
262	        return fn.apply(null, args.concat(slice.apply(arguments)));
263	    };
264	}
265
266	function labelInput(klass, n, p, maxLen) {
267	    var id = "colorPickerInput" + Math.floor(Math.random() * 1001);
268	    var d = div(klass, p);
269	    var l = label(n, d, id);
270	    var i = input('text', d, maxLen, id);
271
272	    return {
273	        label: l, 
274	        input: i
275	    };
276	}
277
278	function label(c, p, id) {
279	    var elem = e('label', '', p);
280	    elem.innerHTML = c;
281
282	    if (id) {
283	        elem.setAttribute('for', id);
284	    }
285
286	    return elem;
287	}
288
289	function input(t, p, maxLen, id) {
290	    var elem = e('input', '', p);
291	    elem.type = t;
292
293	    if(maxLen) { 
294	        elem.maxLength = maxLen;
295	    }
296
297	    if (id) {
298	        elem.setAttribute('id', id);
299	    }
300
301	    if(maxLen) {
302	        elem.maxLength = maxLen;
303	    }
304
305	    return elem;
306	}
307
308	function X(p, a) {
309	    p.style.left = clamp(a * 100, 0, 100) + '%';
310	}
311	function Y(p, a) {
312	    p.style.top = clamp(a * 100, 0, 100) + '%';
313	}
314	function BG(e, c) {
315	    e.style.background = c;
316	}
317
318	function clamp(a, minValue, maxValue) {
319	    return Math.min(Math.max(a, minValue), maxValue);
320	}
321
322	var utils = {
323	    clamp: clamp,
324	    e: e,
325	    div: div,
326	    partial: partial,
327	    labelInput: labelInput,
328	    X: X,
329	    Y: Y,
330	    BG: BG
331	};
332
333	function currentColor(p) {
334	    var e1 = utils.div('currentColorContainer', p);
335	    var e = utils.div('currentColor', e1);
336
337	    return {
338	        change: function(col) {
339	            utils.BG(e, col.cssa());
340	        }
341	    };
342	}
343
344	function fields(p, joe, o) {
345	    var cs = o.space;
346	    var fac = o.limit || 255;
347	    var fix = o.fix >= 0? o.fix: 0;
348	    var inputLen = ('' + fac).length + fix;
349	    inputLen = fix? inputLen + 1: inputLen;
350
351	    var initials = cs.split('');
352	    var useAlpha = cs[cs.length - 1] == 'A';
353	    cs = useAlpha? cs.slice(0, -1): cs;
354
355	    if(['RGB', 'HSL', 'HSV', 'CMYK'].indexOf(cs) < 0) {
356	        return console.warn('Invalid field names', cs);
357	    }
358
359	    var c = utils.div('colorFields', p);
360	    var elems = initials.map(function(n) {
361	        n = n.toLowerCase();
362
363	        var e = utils.labelInput('color ' + n, n, c, inputLen);
364	        e.input.onblur = done;
365	        e.input.onkeydown = validate;
366	        e.input.onkeyup = update;
367
368	        return {
369	            name: n, 
370	            e: e
371	        };
372	    });
373
374	    function done() {
375	        joe.done();
376	    }
377
378	    function validate(e) {
379	        if (!(e.ctrlKey || e.altKey) && /^[a-zA-Z]$/.test(e.key)) {
380	            e.preventDefault();
381	        }
382	    }
383
384	    function update() {
385	        var col = [cs];
386
387	        elems.forEach(function(o) {col.push(o.e.input.value / fac);});
388
389	        if(!useAlpha) {
390	            col.push(joe.getAlpha());
391	        }
392
393	        joe.set(col);
394	    }
395
396	    return {
397	        change: function(col) {
398	            elems.forEach(function(o) {
399	                o.e.input.value = (col[o.name]() * fac).toFixed(fix);
400	            });
401	        }
402	    };
403	}
404
405	function alpha(p, joe) {
406	    var e = dragjs_umd.slider({
407	        parent: p,
408	        'class': 'oned alpha',
409	        cbs: {
410	            begin: change,
411	            change: change,
412	            end: done
413	        }
414	    });
415
416	    function done() {
417	        joe.done();
418	    }
419
420	    function change(p) {
421	        var val = utils.clamp(p.y, 0, 1);
422
423	        utils.Y(p.pointer, val);
424	        joe.setAlpha(1 - val);
425	    }
426
427	    return {
428	        change: function(col) {
429	            utils.Y(e.pointer, 1 - col.alpha());
430	        }
431	    };
432	}
433
434	function hex(p, joe, o) {
435	    var e = utils.labelInput('hex', o.label || '', p, 7);
436	    e.input.value = '#';
437
438	    e.input.onkeyup = function(elem) {
439	        var key = elem.keyCode || elem.which;
440	        var val = elem.target.value;
441	        val = val[0] == '#'? val: '#' + val;
442	        val = pad(val, 7, '0');
443
444	        if(key == 13) {
445	            joe.set(val);
446	        }
447	    };
448
449	    e.input.onblur = function(elem) {
450	        joe.set(elem.target.value);
451	        joe.done();
452	    };
453
454	    return {
455	        change: function(col) {
456	            e.input.value = e.input.value[0] == '#'? '#': '';
457	            e.input.value += col.hex().slice(1);
458	        }
459	    };
460	}
461
462	function close(p, joe, o) {
463	    var elem = utils.e('a', o['class'] || 'close', p);
464	    elem.href = '#';
465	    elem.innerHTML = o.label || 'Close';
466
467	    elem.onclick = function(e) {
468	        e.preventDefault();
469
470	        joe.hide();
471	    };
472	}
473
474	function pad(a, n, c) {
475	    var ret = a;
476
477	    for(var i = a.length; i < n; i++) {
478	        ret += c;
479	    }
480
481	    return ret;
482	}
483
484	var extras = {
485	    currentColor: currentColor,
486	    fields: fields,
487	    hex: hex,
488	    alpha: alpha,
489	    close: close
490	};
491
492	// Use the all build with cmyk and everything
493
494
495
496	var colorjoe = function(cbs) {
497	    if (!all(isFunction, [cbs.init, cbs.xy, cbs.z])) {
498	        return console.warn("colorjoe: missing cb");
499	    }
500
501	    return function(element, initialColor, extras$$1) {
502	        return setup({
503	            e: element,
504	            color: initialColor,
505	            cbs: cbs,
506	            extras: extras$$1,
507	        });
508	    };
509	};
510
511	/* pickers */
512	colorjoe.rgb = colorjoe({
513	    init: function(col, xy, z) {
514	        var ret = oneColorAll(col).hsv();
515
516	        this.xy(ret, { x: ret.saturation(), y: 1 - ret.value() }, xy, z);
517	        this.z(ret, ret.hue(), xy, z);
518
519	        return ret;
520	    },
521	    xy: function(col, p, xy) {
522	        utils.X(xy.pointer, p.x);
523	        utils.Y(xy.pointer, p.y);
524
525	        return col.saturation(p.x).value(1 - p.y);
526	    },
527	    z: function(col, v, xy, z) {
528	        
vendor: 4,462 bytes, lines 528-719
528// utils.Y(z.pointer, v);
529	        utils.X(z.pointer, v);
530	        RGB_BG(xy.background, v);
531
532	        return col.hue(v);
533	    },
534	});
535
536	colorjoe.hsl = colorjoe({
537	    init: function(col, xy, z) {
538	        var ret = oneColorAll(col).hsl();
539
540	        this.xy(ret, { x: ret.hue(), y: 1 - ret.saturation() }, xy, z);
541	        this.z(ret, 1 - ret.lightness(), xy, z);
542
543	        return ret;
544	    },
545	    xy: function(col, p, xy, z) {
546	        utils.X(xy.pointer, p.x);
547	        utils.Y(xy.pointer, p.y);
548	        RGB_BG(z.background, p.x);
549
550	        return col.hue(p.x).saturation(1 - p.y);
551	    },
552	    z: function(col, v, xy, z) {
553	        utils.Y(z.pointer, v);
554
555	        return col.lightness(1 - v);
556	    },
557	});
558
559	colorjoe.extras = {};
560
561	colorjoe.registerExtra = function(name, fn) {
562	    if (name in colorjoe.extras) {
563	        console.warn('Extra "' + name + '"has been registered already!');
564	    }
565
566	    colorjoe.extras[name] = fn;
567	};
568
569	for (var k in extras) {
570	    colorjoe.registerExtra(k, extras[k]);
571	}
572
573	function RGB_BG(e, h) {
574	    utils.BG(e, new oneColorAll.HSV(h, 1, 1).cssa());
575	}
576
577	function setup(o) {
578	    if (!o.e) {
579	        return console.warn("colorjoe: missing element");
580	    }
581
582	    var e = isString(o.e) ? document.getElementById(o.e) : o.e;
583	    e.className = "colorPicker";
584
585	    var cbs = o.cbs;
586
587	    var xy = dragjs_umd.xyslider({
588	        parent: e,
589	        class: "twod",
590	        cbs: {
591	            begin: changeXY,
592	            change: changeXY,
593	            end: done,
594	        },
595	    });
596
597	    function changeXY(p) {
598	        col = cbs.xy(
599	            col,
600	            {
601	                x: utils.clamp(p.x, 0, 1),
602	                y: utils.clamp(p.y, 0, 1),
603	            },
604	            xy,
605	            z
606	        );
607	        changed();
608	    }
609
610	    var z = dragjs_umd.slider({
611	        parent: e,
612	        class: "oned",
613	        cbs: {
614	            begin: changeZ,
615	            change: changeZ,
616	            end: done,
617	        },
618	    });
619
620	    function changeZ(p) {
621	        //col = cbs.z(col, utils.clamp(p.y, 0, 1), xy, z);
622	        col = cbs.z(col, utils.clamp(p.x, 0, 1), xy, z);
623	        changed();
624	    }
625
626	    // Initial color
627	    var previous = getColor(o.color);
628	    var col = cbs.init(previous, xy, z);
629	    var listeners = { change: [], done: [] };
630
631	    function changed(skip) {
632	        skip = isArray(skip) ? skip : [];
633
634	        var li = listeners.change;
635	        var v;
636
637	        for (var i = 0, len = li.length; i < len; i++) {
638	            v = li[i];
639	            if (skip.indexOf(v.name) == -1) {
640	                v.fn(col);
641	            }
642	        }
643	    }
644
645	    function done() {
646	        // Do not call done callback if the color did not change
647	        if (previous.equals(col)) {
648	            return;
649	        }
650
651	        for (var i = 0, len = listeners.done.length; i < len; i++) {
652	            listeners.done[i].fn(col);
653	        }
654
655	        previous = col;
656	    }
657
658	    var ob = {
659	        e: e,
660	        done: function() {
661	            done();
662
663	            return this;
664	        },
665	        update: function(skip) {
666	            changed(skip);
667
668	            return this;
669	        },
670	        hide: function() {
671	            e.style.display = "none";
672
673	            return this;
674	        },
675	        show: function() {
676	            e.style.display = "";
677
678	            return this;
679	        },
680	        get: function() {
681	            return col;
682	        },
683	        set: function(c) {
684	            var oldCol = this.get();
685	            col = cbs.init(getColor(c), xy, z);
686
687	            if (!oldCol.equals(col)) {
688	                this.update();
689	            }
690
691	            return this;
692	        },
693	        getAlpha: function() {
694	            return col.alpha();
695	        },
696	        setAlpha: function(v) {
697	            col = col.alpha(v);
698
699	            this.update();
700
701	            return this;
702	        },
703	        on: function(evt, cb, name) {
704	            if (evt == "change" || evt == "done") {
705	                listeners[evt].push({ name: name, fn: cb });
706	            } else {
707	                console.warn(
708	                    'Passed invalid evt name "' + evt + '" to colorjoe.on'
709	                );
710	            }
711
712	            return this;
713	        },
714	        removeAllListeners: function(evt) {
715	            if (evt) {
716	                delete listeners[evt];
717	            } else {
718	                for (var key in listeners) {
719	                    delete listeners[key
vendor: 2,013 bytes, lines 719-829
719];
720	                }
721	            }
722
723	            return this;
724	        },
725	    };
726
727	    setupExtras(e, ob, o.extras);
728	    changed();
729
730	    return ob;
731	}
732
733	function getColor(c) {
734	    if (!isDefined(c)) {
735	        return oneColorAll("#000");
736	    }
737	    if (c.isColor) {
738	        return c;
739	    }
740
741	    var ret = oneColorAll(c);
742
743	    if (ret) {
744	        return ret;
745	    }
746
747	    if (isDefined(c)) {
748	        console.warn("Passed invalid color to colorjoe, using black instead");
749	    }
750
751	    return oneColorAll("#000");
752	}
753
754	function setupExtras(p, joe, extras$$1) {
755	    if (!extras$$1) {
756	        return;
757	    }
758
759	    var c = utils.div("extras", p);
760	    var cbs;
761	    var name;
762	    var params;
763
764	    extras$$1.forEach(function(e, i) {
765	        if (isArray(e)) {
766	            name = e[0];
767	            params = e.length > 1 ? e[1] : {};
768	        } else {
769	            name = e;
770	            params = {};
771	        }
772	        var extra = name in colorjoe.extras ? colorjoe.extras[name] : null;
773
774	        if (extra) {
775	            cbs = extra(c, extraProxy(joe, name + i), params);
776	            for (var k in cbs) {
777	                joe.on(k, cbs[k], name);
778	            }
779	        }
780	    });
781	}
782
783	function extraProxy(joe, name) {
784	    var ret = copy(joe);
785
786	    ret.update = function() {
787	        joe.update([name]);
788	    };
789
790	    return ret;
791	}
792
793	function copy(o) {
794	    // returns a shallow copy
795	    var ret = {};
796
797	    for (var k in o) {
798	        ret[k] = o[k];
799	    }
800
801	    return ret;
802	}
803
804	function all(cb, a) {
805	    return a.map(cb).filter(id).length == a.length;
806	}
807
808	function isArray(o) {
809	    return Object.prototype.toString.call(o) === "[object Array]";
810	}
811	function isString(o) {
812	    return typeof o === "string";
813	}
814	function isDefined(input) {
815	    return typeof input !== "undefined";
816	}
817	function isFunction(input) {
818	    return typeof input === "function";
819	}
820	function id(a) {
821	    return a;
822	}
823
824	var colorjoe_1 = colorjoe;
825
826	return colorjoe_1;
827
828})));
829//# sourceMappingURL=colorjoe.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.