mirror of
https://github.com/chinchang/web-maker.git
synced 2025-06-19 06:01:50 +02:00
2 lines
20 KiB
JavaScript
2 lines
20 KiB
JavaScript
// Generated by CoffeeScript 1.10.0
|
|
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<a&&a<Math.PI/8||a>=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/8<a&&a<=-5*Math.PI/8?t.style.cursor="nwse-resize":3*Math.PI/8<=a&&a<5*Math.PI/8||-5*Math.PI/8<a&&a<=-3*Math.PI/8?t.style.cursor="ns-resize":5*Math.PI/8<=a&&a<7*Math.PI/8||-3*Math.PI/8<a&&a<=-Math.PI/8?t.style.cursor="nesw-resize":void 0:t.style.cursor=""}}(this),t.addEventListener("mouseover",function(r){var n,o;return e(r),t.addEventListener("mousemove",n=function(t){return e(t)}),t.addEventListener("mouseout",o=function(e){return t.style.cursor="",t.removeEventListener("mousemove",n),t.removeEventListener("mouseout",o),window.removeEventListener("blur",o)}),window.addEventListener("blur",o)}),t.addEventListener("mousedown",function(e){return function(r){var n,o,i,s,a,u,c,h,d;return r.preventDefault(),h=r.layerX,d=r.layerY,o=h-g,i=d-g,n=Math.sqrt(o*o+i*i),u=Math.atan2(i,o),a=l(e.color.s,b,g),n>a-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;i<type.length;i++){var str=type.substr(i,1);tmp[str]=color[i]}color=tmp}if(functions[route])return functions[route](color);for(var f="color",pos=1,key=r[0];pos<r.length;pos++)pos>1&&(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.top<f&&(x=cursorOffset.top+p);var M=o-m;if(w.style.visibility="hidden",s){var C=s.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>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}(); |