whisper.cat/weboasis/js/jscolor.min.js
2023-10-05 23:28:32 +11:00

1 line
28 KiB
JavaScript

"use strict";window.jscolor||(window.jscolor=function(){var d={register:function(){d.attachDOMReadyEvent(d.init),d.attachEvent(document,"mousedown",d.onDocumentMouseDown),d.attachEvent(document,"touchstart",d.onDocumentTouchStart),d.attachEvent(window,"resize",d.onWindowResize)},init:function(){d.jscolor.lookupClass&&d.jscolor.installByClassName(d.jscolor.lookupClass)},tryInstallOnElements:function(a,b){for(var c=new RegExp("(^|\\s)("+b+")(\\s*(\\{[^}]*\\})|\\s|$)","i"),e=0;e<a.length;e+=1)if(!(void 0!==a[e].type&&"color"==a[e].type.toLowerCase()&&d.isColorAttrSupported)){var f;if(!a[e].jscolor&&a[e].className&&(f=a[e].className.match(c))){var g=a[e],h=null,j=d.getDataAttr(g,"jscolor");null===j?f[4]&&(h=f[4]):h=j;var k={};if(h)try{k=new Function("return ("+h+")")()}catch(a){d.warn("Error parsing jscolor options: "+a+":\n"+h)}g.jscolor=new d.jscolor(g,k)}}},isColorAttrSupported:function(){var a=document.createElement("input");return!!(a.setAttribute&&(a.setAttribute("type","color"),"color"==a.type.toLowerCase()))}(),isCanvasSupported:function(){var a=document.createElement("canvas");return!!(a.getContext&&a.getContext("2d"))}(),fetchElement:function(a){return"string"==typeof a?document.getElementById(a):a},isElementType:function(a,b){return a.nodeName.toLowerCase()===b.toLowerCase()},getDataAttr:function(a,b){var c=a.getAttribute("data-"+b);return null===c?null:c},attachEvent:function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},detachEvent:function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)},_attachedGroupEvents:{},attachGroupEvent:function(a,b,c,e){d._attachedGroupEvents.hasOwnProperty(a)||(d._attachedGroupEvents[a]=[]),d._attachedGroupEvents[a].push([b,c,e]),d.attachEvent(b,c,e)},detachGroupEvents:function(a){if(d._attachedGroupEvents.hasOwnProperty(a)){for(var b,c=0;c<d._attachedGroupEvents[a].length;c+=1)b=d._attachedGroupEvents[a][c],d.detachEvent(b[0],b[1],b[2]);delete d._attachedGroupEvents[a]}},attachDOMReadyEvent:function(a){var b=!1,c=function(){b||(b=!0,a())};if("complete"===document.readyState)return void setTimeout(c,1);if(document.addEventListener)document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1);else if(document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&(document.detachEvent("onreadystatechange",arguments.callee),c())}),window.attachEvent("onload",c),document.documentElement.doScroll&&window==window.top)){var d=function(){if(document.body)try{document.documentElement.doScroll("left"),c()}catch(a){setTimeout(d,1)}};d()}},warn:function(a){window.console&&window.console.warn&&window.console.warn(a)},preventDefault:function(a){a.preventDefault&&a.preventDefault(),a.returnValue=!1},captureTarget:function(a){a.setCapture&&(d._capturedTarget=a,d._capturedTarget.setCapture())},releaseTarget:function(){d._capturedTarget&&(d._capturedTarget.releaseCapture(),d._capturedTarget=null)},fireEvent:function(a,b){if(a)if(document.createEvent){var c=document.createEvent("HTMLEvents");c.initEvent(b,!0,!0),a.dispatchEvent(c)}else if(document.createEventObject){var c=document.createEventObject();a.fireEvent("on"+b,c)}else a["on"+b]&&a["on"+b]()},classNameToList:function(a){return a.replace(/^\s+|\s+$/g,"").split(/\s+/)},hasClass:function(a,b){return!!b&&-1!=(" "+a.className.replace(/\s+/g," ")+" ").indexOf(" "+b+" ")},setClass:function(a,b){for(var c=d.classNameToList(b),e=0;e<c.length;e+=1)d.hasClass(a,c[e])||(a.className+=(a.className?" ":"")+c[e])},unsetClass:function(a,b){for(var c,e=d.classNameToList(b),f=0;f<e.length;f+=1)c=new RegExp("^\\s*"+e[f]+"\\s*|\\s*"+e[f]+"\\s*$|\\s+"+e[f]+"(\\s+)","g"),a.className=a.className.replace(c,"$1")},getStyle:function(a){return window.getComputedStyle?window.getComputedStyle(a):a.currentStyle},setStyle:function(){var a=document.createElement("div"),b=function(b){for(var c=0;c<b.length;c+=1)if(b[c]in a.style)return b[c]},c={borderRadius:b(["borderRadius","MozBorderRadius","webkitBorderRadius"]),boxShadow:b(["boxShadow","MozBoxShadow","webkitBoxShadow"])};return function(a,b,d){switch(b.toLowerCase()){case"opacity":var e=Math.round(100*parseFloat(d));a.style.opacity=d,a.style.filter="alpha(opacity="+e+")";break;default:a.style[c[b]]=d;}}}(),setBorderRadius:function(a,b){d.setStyle(a,"borderRadius",b||"0")},setBoxShadow:function(a,b){d.setStyle(a,"boxShadow",b||"none")},getElementPos:function(a,b){var c=0,e=0,f=a.getBoundingClientRect();if(c=f.left,e=f.top,!b){var g=d.getViewPos();c+=g[0],e+=g[1]}return[c,e]},getElementSize:function(a){return[a.offsetWidth,a.offsetHeight]},getAbsPointerPos:function(a){a||(a=window.event);var b=0,c=0;return"undefined"!=typeof a.changedTouches&&a.changedTouches.length?(b=a.changedTouches[0].clientX,c=a.changedTouches[0].clientY):"number"==typeof a.clientX&&(b=a.clientX,c=a.clientY),{x:b,y:c}},getRelPointerPos:function(a){a||(a=window.event);var b=a.target||a.srcElement,c=b.getBoundingClientRect(),d=0,f=0,g=0,h=0;return"undefined"!=typeof a.changedTouches&&a.changedTouches.length?(g=a.changedTouches[0].clientX,h=a.changedTouches[0].clientY):"number"==typeof a.clientX&&(g=a.clientX,h=a.clientY),d=g-c.left,f=h-c.top,{x:d,y:f}},getViewPos:function(){var a=document.documentElement;return[(window.pageXOffset||a.scrollLeft)-(a.clientLeft||0),(window.pageYOffset||a.scrollTop)-(a.clientTop||0)]},getViewSize:function(){var a=document.documentElement;return[window.innerWidth||a.clientWidth,window.innerHeight||a.clientHeight]},redrawPosition:function(){if(d.picker&&d.picker.owner){var e,f,g=d.picker.owner;g.fixed?(e=d.getElementPos(g.targetElement,!0),f=[0,0]):(e=d.getElementPos(g.targetElement),f=d.getViewPos());var h,i,j,k=d.getElementSize(g.targetElement),m=d.getViewSize(),n=d.getPickerOuterDims(g);switch(g.position.toLowerCase()){case"left":h=1,i=0,j=-1;break;case"right":h=1,i=0,j=1;break;case"top":h=0,i=1,j=-1;break;default:h=0,i=1,j=1;}var o=(k[i]+n[i])/2;if(!g.smartPosition)var l=[e[h],e[i]+k[i]-o+o*j];else var l=[-f[h]+e[h]+n[h]>m[h]?-f[h]+e[h]+k[h]/2>m[h]/2&&0<=e[h]+k[h]-n[h]?e[h]+k[h]-n[h]:e[h]:e[h],-f[i]+e[i]+k[i]+n[i]-o+o*j>m[i]?-f[i]+e[i]+k[i]/2>m[i]/2&&0<=e[i]+k[i]-o-o*j?e[i]+k[i]-o-o*j:e[i]+k[i]-o+o*j:0<=e[i]+k[i]-o+o*j?e[i]+k[i]-o+o*j:e[i]+k[i]-o-o*j];var p=l[h],q=l[i],r=g.fixed?"fixed":"absolute",s=(l[0]+n[0]>e[0]||l[0]<e[0]+k[0])&&l[1]+n[1]<e[1]+k[1];d._drawPosition(g,p,q,r,s)}},_drawPosition:function(a,b,c,e,f){var g=f?0:a.shadowBlur;d.picker.wrap.style.position=e,d.picker.wrap.style.left=b+"px",d.picker.wrap.style.top=c+"px",d.setBoxShadow(d.picker.boxS,a.shadow?new d.BoxShadow(0,g,a.shadowBlur,0,a.shadowColor):null)},getPickerDims:function(a){var b=!!d.getSliderComponent(a),c=[2*a.insetWidth+2*a.padding+a.width+(b?2*a.insetWidth+d.getPadToSliderPadding(a)+a.sliderSize:0),2*a.insetWidth+2*a.padding+a.height+(a.closable?2*a.insetWidth+a.padding+a.buttonHeight:0)];return c},getPickerOuterDims:function(a){var b=d.getPickerDims(a);return[b[0]+2*a.borderWidth,b[1]+2*a.borderWidth]},getPadToSliderPadding:function(a){return Math.max(a.padding,1.5*(2*a.pointerBorderWidth+a.pointerThickness))},getPadYComponent:function(a){switch(a.mode.charAt(1).toLowerCase()){case"v":return"v";}return"s"},getSliderComponent:function(a){if(2<a.mode.length)switch(a.mode.charAt(2).toLowerCase()){case"s":return"s";break;case"v":return"v";}return null},onDocumentMouseDown:function(a){a||(a=window.event);var b=a.target||a.srcElement;b._jscLinkedInstance?b._jscLinkedInstance.showOnClick&&b._jscLinkedInstance.show():b._jscControlName?d.onControlPointerStart(a,b,b._jscControlName,"mouse"):d.picker&&d.picker.owner&&d.picker.owner.hide()},onDocumentTouchStart:function(a){a||(a=window.event);var b=a.target||a.srcElement;b._jscLinkedInstance?b._jscLinkedInstance.showOnClick&&b._jscLinkedInstance.show():b._jscControlName?d.onControlPointerStart(a,b,b._jscControlName,"touch"):d.picker&&d.picker.owner&&d.picker.owner.hide()},onWindowResize:function(){d.redrawPosition()},onParentScroll:function(){d.picker&&d.picker.owner&&d.picker.owner.hide()},_pointerMoveEvent:{mouse:"mousemove",touch:"touchmove"},_pointerEndEvent:{mouse:"mouseup",touch:"touchend"},_pointerOrigin:null,_capturedTarget:null,onControlPointerStart:function(a,b,c,e){var f=b._jscInstance;d.preventDefault(a),d.captureTarget(b);var g=function(f,g){d.attachGroupEvent("drag",f,d._pointerMoveEvent[e],d.onDocumentPointerMove(a,b,c,e,g)),d.attachGroupEvent("drag",f,d._pointerEndEvent[e],d.onDocumentPointerEnd(a,b,c,e))};if(g(document,[0,0]),window.parent&&window.frameElement){var h=window.frameElement.getBoundingClientRect(),i=[-h.left,-h.top];g(window.parent.window.document,i)}var j=d.getAbsPointerPos(a),k=d.getRelPointerPos(a);switch(d._pointerOrigin={x:j.x-k.x,y:j.y-k.y},c){case"pad":switch(d.getSliderComponent(f)){case"s":0===f.hsv[1]&&f.fromHSV(null,100,null);;break;case"v":0===f.hsv[2]&&f.fromHSV(null,null,100);;}d.setPad(f,a,0,0);break;case"sld":d.setSld(f,a,0);}d.dispatchFineChange(f)},onDocumentPointerMove:function(a,b,c,e,f){return function(a){var g=b._jscInstance;"pad"===c?(a||(a=window.event),d.setPad(g,a,f[0],f[1]),d.dispatchFineChange(g)):"sld"===c?(a||(a=window.event),d.setSld(g,a,f[1]),d.dispatchFineChange(g)):void 0}},onDocumentPointerEnd:function(a,b){return function(){var a=b._jscInstance;d.detachGroupEvents("drag"),d.releaseTarget(),d.dispatchChange(a)}},dispatchChange:function(a){a.valueElement&&d.isElementType(a.valueElement,"input")&&d.fireEvent(a.valueElement,"change")},dispatchFineChange:function(a){if(a.onFineChange){var b;b="string"==typeof a.onFineChange?new Function(a.onFineChange):a.onFineChange,b.call(a)}},setPad:function(a,b,c,e){var f=d.getAbsPointerPos(b),g=c+f.x-d._pointerOrigin.x-a.padding-a.insetWidth,h=e+f.y-d._pointerOrigin.y-a.padding-a.insetWidth,i=g*(360/(a.width-1)),j=100-h*(100/(a.height-1));switch(d.getPadYComponent(a)){case"s":a.fromHSV(i,j,null,d.leaveSld);break;case"v":a.fromHSV(i,null,j,d.leaveSld);}},setSld:function(a,b,c){var e=d.getAbsPointerPos(b),f=c+e.y-d._pointerOrigin.y-a.padding-a.insetWidth,g=100-f*(100/(a.height-1));switch(d.getSliderComponent(a)){case"s":a.fromHSV(null,g,null,d.leavePad);break;case"v":a.fromHSV(null,null,g,d.leavePad);}},_vmlNS:"jsc_vml_",_vmlCSS:"jsc_vml_css_",_vmlReady:!1,initVML:function(){if(!d._vmlReady){var a=document;if(a.namespaces[d._vmlNS]||a.namespaces.add(d._vmlNS,"urn:schemas-microsoft-com:vml"),!a.styleSheets[d._vmlCSS]){var b=["shape","shapetype","group","background","path","formulas","handles","fill","stroke","shadow","textbox","textpath","imagedata","line","polyline","curve","rect","roundrect","oval","arc","image"],c=a.createStyleSheet();c.owningElement.id=d._vmlCSS;for(var e=0;e<b.length;e+=1)c.addRule(d._vmlNS+"\\:"+b[e],"behavior:url(#default#VML);")}d._vmlReady=!0}},createPalette:function(){var a={elm:null,draw:null};if(d.isCanvasSupported){var b=document.createElement("canvas"),c=b.getContext("2d"),e=function(a,d,e){b.width=a,b.height=d,c.clearRect(0,0,b.width,b.height);var f=c.createLinearGradient(0,0,b.width,0);f.addColorStop(0,"#F00"),f.addColorStop(1/6,"#FF0"),f.addColorStop(2/6,"#0F0"),f.addColorStop(3/6,"#0FF"),f.addColorStop(4/6,"#00F"),f.addColorStop(5/6,"#F0F"),f.addColorStop(1,"#F00"),c.fillStyle=f,c.fillRect(0,0,b.width,b.height);var g=c.createLinearGradient(0,0,0,b.height);switch(e.toLowerCase()){case"s":g.addColorStop(0,"rgba(255,255,255,0)"),g.addColorStop(1,"rgba(255,255,255,1)");break;case"v":g.addColorStop(0,"rgba(0,0,0,0)"),g.addColorStop(1,"rgba(0,0,0,1)");}c.fillStyle=g,c.fillRect(0,0,b.width,b.height)};a.elm=b,a.draw=e}else{d.initVML();var f=document.createElement("div");f.style.position="relative",f.style.overflow="hidden";var g=document.createElement(d._vmlNS+":fill");g.type="gradient",g.method="linear",g.angle="90",g.colors="16.67% #F0F, 33.33% #00F, 50% #0FF, 66.67% #0F0, 83.33% #FF0";var h=document.createElement(d._vmlNS+":rect");h.style.position="absolute",h.style.left="-1px",h.style.top="-1px",h.stroked=!1,h.appendChild(g),f.appendChild(h);var i=document.createElement(d._vmlNS+":fill");i.type="gradient",i.method="linear",i.angle="180",i.opacity="0";var j=document.createElement(d._vmlNS+":rect");j.style.position="absolute",j.style.left="-1px",j.style.top="-1px",j.stroked=!1,j.appendChild(i),f.appendChild(j);var e=function(a,b,c){switch(f.style.width=a+"px",f.style.height=b+"px",h.style.width=j.style.width=a+1+"px",h.style.height=j.style.height=b+1+"px",g.color="#F00",g.color2="#F00",c.toLowerCase()){case"s":i.color=i.color2="#FFF";break;case"v":i.color=i.color2="#000";}};a.elm=f,a.draw=e}return a},createSliderGradient:function(){var a={elm:null,draw:null};if(d.isCanvasSupported){var b=document.createElement("canvas"),c=b.getContext("2d"),e=function(a,d,e,f){b.width=a,b.height=d,c.clearRect(0,0,b.width,b.height);var g=c.createLinearGradient(0,0,0,b.height);g.addColorStop(0,e),g.addColorStop(1,f),c.fillStyle=g,c.fillRect(0,0,b.width,b.height)};a.elm=b,a.draw=e}else{d.initVML();var f=document.createElement("div");f.style.position="relative",f.style.overflow="hidden";var g=document.createElement(d._vmlNS+":fill");g.type="gradient",g.method="linear",g.angle="180";var h=document.createElement(d._vmlNS+":rect");h.style.position="absolute",h.style.left="-1px",h.style.top="-1px",h.stroked=!1,h.appendChild(g),f.appendChild(h);var e=function(a,b,c,d){f.style.width=a+"px",f.style.height=b+"px",h.style.width=a+1+"px",h.style.height=b+1+"px",g.color=c,g.color2=d};a.elm=f,a.draw=e}return a},leaveValue:1,leaveStyle:2,leavePad:4,leaveSld:8,BoxShadow:function(){var a=function(a,b,c,d,e,f){this.hShadow=a,this.vShadow=b,this.blur=c,this.spread=d,this.color=e,this.inset=!!f};return a.prototype.toString=function(){var a=[Math.round(this.hShadow)+"px",Math.round(this.vShadow)+"px",Math.round(this.blur)+"px",Math.round(this.spread)+"px",this.color];return this.inset&&a.push("inset"),a.join(" ")},a}(),jscolor:function(a,b){function c(a,c,d){a/=255,c/=255,d/=255;var e=Math.min(Math.min(a,c),d),f=Math.max(Math.max(a,c),d),i=f-e;if(0===i)return[null,0,100*f];var j=a===e?3+(d-c)/i:c===e?5+(a-d)/i:1+(c-a)/i;return[60*(6==j?0:j),100*(i/f),100*f]}function e(a,b,c){var d=255*(c/100);if(null===a)return[d,d,d];a/=60,b/=100;var e=Math.floor(a),g=e%2?a-e:1-(a-e),f=d*(1-b),i=d*(1-b*g);return 6===e||0===e?[d,i,f]:1===e?[i,d,f]:2===e?[f,d,i]:3===e?[f,i,d]:4===e?[i,f,d]:5===e?[d,f,i]:void 0}function f(){d.unsetClass(o.targetElement,o.activeClass),d.picker.wrap.parentNode.removeChild(d.picker.wrap),delete d.picker.owner}function g(){o._processParentElementsInDOM(),d.picker||(d.picker={owner:null,wrap:document.createElement("div"),box:document.createElement("div"),boxS:document.createElement("div"),boxB:document.createElement("div"),pad:document.createElement("div"),padB:document.createElement("div"),padM:document.createElement("div"),padPal:d.createPalette(),cross:document.createElement("div"),crossBY:document.createElement("div"),crossBX:document.createElement("div"),crossLY:document.createElement("div"),crossLX:document.createElement("div"),sld:document.createElement("div"),sldB:document.createElement("div"),sldM:document.createElement("div"),sldGrad:d.createSliderGradient(),sldPtrS:document.createElement("div"),sldPtrIB:document.createElement("div"),sldPtrMB:document.createElement("div"),sldPtrOB:document.createElement("div"),btn:document.createElement("div"),btnT:document.createElement("span")},d.picker.pad.appendChild(d.picker.padPal.elm),d.picker.padB.appendChild(d.picker.pad),d.picker.cross.appendChild(d.picker.crossBY),d.picker.cross.appendChild(d.picker.crossBX),d.picker.cross.appendChild(d.picker.crossLY),d.picker.cross.appendChild(d.picker.crossLX),d.picker.padB.appendChild(d.picker.cross),d.picker.box.appendChild(d.picker.padB),d.picker.box.appendChild(d.picker.padM),d.picker.sld.appendChild(d.picker.sldGrad.elm),d.picker.sldB.appendChild(d.picker.sld),d.picker.sldB.appendChild(d.picker.sldPtrOB),d.picker.sldPtrOB.appendChild(d.picker.sldPtrMB),d.picker.sldPtrMB.appendChild(d.picker.sldPtrIB),d.picker.sldPtrIB.appendChild(d.picker.sldPtrS),d.picker.box.appendChild(d.picker.sldB),d.picker.box.appendChild(d.picker.sldM),d.picker.btn.appendChild(d.picker.btnT),d.picker.box.appendChild(d.picker.btn),d.picker.boxB.appendChild(d.picker.box),d.picker.wrap.appendChild(d.picker.boxS),d.picker.wrap.appendChild(d.picker.boxB));var a=d.picker,b=!!d.getSliderComponent(o),c=d.getPickerDims(o),e=2*o.pointerBorderWidth+o.pointerThickness+2*o.crossSize,f=d.getPadToSliderPadding(o),g=Math.min(o.borderRadius,Math.round(o.padding*Math.PI));a.wrap.style.clear="both",a.wrap.style.width=c[0]+2*o.borderWidth+"px",a.wrap.style.height=c[1]+2*o.borderWidth+"px",a.wrap.style.zIndex=o.zIndex,a.box.style.width=c[0]+"px",a.box.style.height=c[1]+"px",a.boxS.style.position="absolute",a.boxS.style.left="0",a.boxS.style.top="0",a.boxS.style.width="100%",a.boxS.style.height="100%",d.setBorderRadius(a.boxS,g+"px"),a.boxB.style.position="relative",a.boxB.style.border=o.borderWidth+"px solid",a.boxB.style.borderColor=o.borderColor,a.boxB.style.background=o.backgroundColor,d.setBorderRadius(a.boxB,g+"px"),a.padM.style.background=a.sldM.style.background="#FFF",d.setStyle(a.padM,"opacity","0"),d.setStyle(a.sldM,"opacity","0"),a.pad.style.position="relative",a.pad.style.width=o.width+"px",a.pad.style.height=o.height+"px",a.padPal.draw(o.width,o.height,d.getPadYComponent(o)),a.padB.style.position="absolute",a.padB.style.left=o.padding+"px",a.padB.style.top=o.padding+"px",a.padB.style.border=o.insetWidth+"px solid",a.padB.style.borderColor=o.insetColor,a.padM._jscInstance=o,a.padM._jscControlName="pad",a.padM.style.position="absolute",a.padM.style.left="0",a.padM.style.top="0",a.padM.style.width=o.padding+2*o.insetWidth+o.width+f/2+"px",a.padM.style.height=c[1]+"px",a.padM.style.cursor="crosshair",a.cross.style.position="absolute",a.cross.style.left=a.cross.style.top="0",a.cross.style.width=a.cross.style.height=e+"px",a.crossBY.style.position=a.crossBX.style.position="absolute",a.crossBY.style.background=a.crossBX.style.background=o.pointerBorderColor,a.crossBY.style.width=a.crossBX.style.height=2*o.pointerBorderWidth+o.pointerThickness+"px",a.crossBY.style.height=a.crossBX.style.width=e+"px",a.crossBY.style.left=a.crossBX.style.top=Math.floor(e/2)-Math.floor(o.pointerThickness/2)-o.pointerBorderWidth+"px",a.crossBY.style.top=a.crossBX.style.left="0",a.crossLY.style.position=a.crossLX.style.position="absolute",a.crossLY.style.background=a.crossLX.style.background=o.pointerColor,a.crossLY.style.height=a.crossLX.style.width=e-2*o.pointerBorderWidth+"px",a.crossLY.style.width=a.crossLX.style.height=o.pointerThickness+"px",a.crossLY.style.left=a.crossLX.style.top=Math.floor(e/2)-Math.floor(o.pointerThickness/2)+"px",a.crossLY.style.top=a.crossLX.style.left=o.pointerBorderWidth+"px",a.sld.style.overflow="hidden",a.sld.style.width=o.sliderSize+"px",a.sld.style.height=o.height+"px",a.sldGrad.draw(o.sliderSize,o.height,"#000","#000"),a.sldB.style.display=b?"block":"none",a.sldB.style.position="absolute",a.sldB.style.right=o.padding+"px",a.sldB.style.top=o.padding+"px",a.sldB.style.border=o.insetWidth+"px solid",a.sldB.style.borderColor=o.insetColor,a.sldM._jscInstance=o,a.sldM._jscControlName="sld",a.sldM.style.display=b?"block":"none",a.sldM.style.position="absolute",a.sldM.style.right="0",a.sldM.style.top="0",a.sldM.style.width=o.sliderSize+f/2+o.padding+2*o.insetWidth+"px",a.sldM.style.height=c[1]+"px",a.sldM.style.cursor="default",a.sldPtrIB.style.border=a.sldPtrOB.style.border=o.pointerBorderWidth+"px solid "+o.pointerBorderColor,a.sldPtrOB.style.position="absolute",a.sldPtrOB.style.left=-(2*o.pointerBorderWidth+o.pointerThickness)+"px",a.sldPtrOB.style.top="0",a.sldPtrMB.style.border=o.pointerThickness+"px solid "+o.pointerColor,a.sldPtrS.style.width=o.sliderSize+"px",a.sldPtrS.style.height=r+"px",a.btn.style.display=o.closable?"block":"none",a.btn.style.position="absolute",a.btn.style.left=o.padding+"px",a.btn.style.bottom=o.padding+"px",a.btn.style.padding="0 15px",a.btn.style.height=o.buttonHeight+"px",a.btn.style.border=o.insetWidth+"px solid",function(){var b=o.insetColor.split(/\s+/),c=2>b.length?b[0]:b[1]+" "+b[0]+" "+b[0]+" "+b[1];a.btn.style.borderColor=c}(),a.btn.style.color=o.buttonColor,a.btn.style.font="12px sans-serif",a.btn.style.textAlign="center";try{a.btn.style.cursor="pointer"}catch(b){a.btn.style.cursor="hand"}a.btn.onmousedown=function(){o.hide()},a.btnT.style.lineHeight=o.buttonHeight+"px",a.btnT.innerHTML="",a.btnT.appendChild(document.createTextNode(o.closeText)),h(),i(),d.picker.owner&&d.picker.owner!==o&&d.unsetClass(d.picker.owner.targetElement,o.activeClass),d.picker.owner=o,d.isElementType(q,"body")?d.redrawPosition():d._drawPosition(o,0,0,"relative",!1),a.wrap.parentNode!=q&&q.appendChild(a.wrap),d.setClass(o.targetElement,o.activeClass)}function h(){switch(d.getPadYComponent(o)){case"s":var a=1;break;case"v":var a=2;}var b=Math.round(o.hsv[0]/360*(o.width-1)),c=Math.round((1-o.hsv[a]/100)*(o.height-1)),f=2*o.pointerBorderWidth+o.pointerThickness+2*o.crossSize,g=-Math.floor(f/2);switch(d.picker.cross.style.left=b+g+"px",d.picker.cross.style.top=c+g+"px",d.getSliderComponent(o)){case"s":var h=e(o.hsv[0],100,o.hsv[2]),i=e(o.hsv[0],0,o.hsv[2]),j="rgb("+Math.round(h[0])+","+Math.round(h[1])+","+Math.round(h[2])+")",k="rgb("+Math.round(i[0])+","+Math.round(i[1])+","+Math.round(i[2])+")";d.picker.sldGrad.draw(o.sliderSize,o.height,j,k);break;case"v":var l=e(o.hsv[0],o.hsv[1],100),j="rgb("+Math.round(l[0])+","+Math.round(l[1])+","+Math.round(l[2])+")",k="#000";d.picker.sldGrad.draw(o.sliderSize,o.height,j,k);}}function i(){var a=d.getSliderComponent(o);if(a){switch(a){case"s":var b=1;break;case"v":var b=2;}var c=Math.round((1-o.hsv[b]/100)*(o.height-1));d.picker.sldPtrOB.style.top=c-(2*o.pointerBorderWidth+o.pointerThickness)-Math.floor(r/2)+"px"}}function j(){return d.picker&&d.picker.owner===o}function k(){o.importColor()}for(var l in this.value=null,this.valueElement=a,this.styleElement=a,this.required=!0,this.refine=!0,this.hash=!1,this.uppercase=!0,this.onFineChange=null,this.activeClass="jscolor-active",this.overwriteImportant=!1,this.minS=0,this.maxS=100,this.minV=0,this.maxV=100,this.hsv=[0,0,100],this.rgb=[255,255,255],this.width=181,this.height=101,this.showOnClick=!0,this.mode="HSV",this.position="bottom",this.smartPosition=!0,this.sliderSize=16,this.crossSize=8,this.closable=!1,this.closeText="Close",this.buttonColor="#000000",this.buttonHeight=18,this.padding=12,this.backgroundColor="#FFFFFF",this.borderWidth=1,this.borderColor="#BBBBBB",this.borderRadius=8,this.insetWidth=1,this.insetColor="#BBBBBB",this.shadow=!0,this.shadowBlur=15,this.shadowColor="rgba(0,0,0,0.2)",this.pointerColor="#4C4C4C",this.pointerBorderColor="#FFFFFF",this.pointerBorderWidth=1,this.pointerThickness=2,this.zIndex=1e3,this.container=null,b)b.hasOwnProperty(l)&&(this[l]=b[l]);if(this.hide=function(){j()&&f()},this.show=function(){g()},this.redraw=function(){j()&&g()},this.importColor=function(){this.valueElement?d.isElementType(this.valueElement,"input")?this.refine?!this.required&&/^\s*$/.test(this.valueElement.value)?(this.valueElement.value="",this.styleElement&&(this.styleElement.style.backgroundImage=this.styleElement._jscOrigStyle.backgroundImage,this.styleElement.style.backgroundColor=this.styleElement._jscOrigStyle.backgroundColor,this.styleElement.style.color=this.styleElement._jscOrigStyle.color),this.exportColor(d.leaveValue|d.leaveStyle)):this.fromString(this.valueElement.value)||this.exportColor():!this.fromString(this.valueElement.value,d.leaveValue)&&(this.styleElement&&(this.styleElement.style.backgroundImage=this.styleElement._jscOrigStyle.backgroundImage,this.styleElement.style.backgroundColor=this.styleElement._jscOrigStyle.backgroundColor,this.styleElement.style.color=this.styleElement._jscOrigStyle.color),this.exportColor(d.leaveValue|d.leaveStyle)):this.exportColor():this.exportColor()},this.exportColor=function(a){if(!(a&d.leaveValue)&&this.valueElement){var b=this.toString();this.uppercase&&(b=b.toUpperCase()),this.hash&&(b="#"+b),d.isElementType(this.valueElement,"input")?this.valueElement.value=b:this.valueElement.innerHTML=b}if(!(a&d.leaveStyle)&&this.styleElement){var c="#"+this.toString(),e=this.isLight()?"#000":"#FFF";this.styleElement.style.backgroundImage="none",this.styleElement.style.backgroundColor=c,this.styleElement.style.color=e,this.overwriteImportant&&this.styleElement.setAttribute("style","background: "+c+" !important; color: "+e+" !important;")}!(a&d.leavePad)&&j()&&h(),!(a&d.leaveSld)&&j()&&i()},this.fromHSV=function(a,b,c,d){if(null!==a){if(isNaN(a))return!1;a=Math.max(0,Math.min(360,a))}if(null!==b){if(isNaN(b))return!1;b=Math.max(0,Math.min(100,this.maxS,b),this.minS)}if(null!==c){if(isNaN(c))return!1;c=Math.max(0,Math.min(100,this.maxV,c),this.minV)}this.rgb=e(null===a?this.hsv[0]:this.hsv[0]=a,null===b?this.hsv[1]:this.hsv[1]=b,null===c?this.hsv[2]:this.hsv[2]=c),this.exportColor(d)},this.fromRGB=function(a,d,f,h){if(null!==a){if(isNaN(a))return!1;a=Math.max(0,Math.min(255,a))}if(null!==d){if(isNaN(d))return!1;d=Math.max(0,Math.min(255,d))}if(null!==f){if(isNaN(f))return!1;f=Math.max(0,Math.min(255,f))}var i=c(null===a?this.rgb[0]:a,null===d?this.rgb[1]:d,null===f?this.rgb[2]:f);null!==i[0]&&(this.hsv[0]=Math.max(0,Math.min(360,i[0]))),0!==i[2]&&(this.hsv[1]=null===i[1]?null:Math.max(0,this.minS,Math.min(100,this.maxS,i[1]))),this.hsv[2]=null===i[2]?null:Math.max(0,this.minV,Math.min(100,this.maxV,i[2]));var j=e(this.hsv[0],this.hsv[1],this.hsv[2]);this.rgb[0]=j[0],this.rgb[1]=j[1],this.rgb[2]=j[2],this.exportColor(h)},this.fromString=function(a,c){var d;if(d=a.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i))return 6===d[1].length?this.fromRGB(parseInt(d[1].substr(0,2),16),parseInt(d[1].substr(2,2),16),parseInt(d[1].substr(4,2),16),c):this.fromRGB(parseInt(d[1].charAt(0)+d[1].charAt(0),16),parseInt(d[1].charAt(1)+d[1].charAt(1),16),parseInt(d[1].charAt(2)+d[1].charAt(2),16),c),!0;if(d=a.match(/^\W*rgba?\(([^)]*)\)\W*$/i)){var e,f,h,i=d[1].split(","),j=/^\s*(\d*)(\.\d+)?\s*$/;if(3<=i.length&&(e=i[0].match(j))&&(f=i[1].match(j))&&(h=i[2].match(j))){var k=parseFloat((e[1]||"0")+(e[2]||"")),l=parseFloat((f[1]||"0")+(f[2]||"")),g=parseFloat((h[1]||"0")+(h[2]||""));return this.fromRGB(k,l,g,c),!0}}return!1},this.toString=function(){return(256|Math.round(this.rgb[0])).toString(16).substr(1)+(256|Math.round(this.rgb[1])).toString(16).substr(1)+(256|Math.round(this.rgb[2])).toString(16).substr(1)},this.toHEXString=function(){return"#"+this.toString().toUpperCase()},this.toRGBString=function(){return"rgb("+Math.round(this.rgb[0])+","+Math.round(this.rgb[1])+","+Math.round(this.rgb[2])+")"},this.isLight=function(){return .213*this.rgb[0]+.715*this.rgb[1]+.072*this.rgb[2]>255/2},this._processParentElementsInDOM=function(){if(!this._linkedElementsProcessed){this._linkedElementsProcessed=!0;var a=this.targetElement;do{var b=d.getStyle(a);b&&"fixed"===b.position.toLowerCase()&&(this.fixed=!0),a===this.targetElement||a._jscEventsAttached||(d.attachEvent(a,"scroll",d.onParentScroll),a._jscEventsAttached=!0)}while((a=a.parentNode)&&!d.isElementType(a,"body"))}},"string"==typeof a){var m=a,n=document.getElementById(m);n?this.targetElement=n:d.warn("Could not find target element with ID '"+m+"'")}else a?this.targetElement=a:d.warn("Invalid target element: '"+a+"'");if(this.targetElement._jscLinkedInstance)return void d.warn("Cannot link jscolor twice to the same element. Skipping.");this.targetElement._jscLinkedInstance=this,this.valueElement=d.fetchElement(this.valueElement),this.styleElement=d.fetchElement(this.styleElement);var o=this,q=this.container?d.fetchElement(this.container):document.getElementsByTagName("body")[0],r=3;if(d.isElementType(this.targetElement,"button"))if(this.targetElement.onclick){var s=this.targetElement.onclick;this.targetElement.onclick=function(a){return s.call(this,a),!1}}else this.targetElement.onclick=function(){return!1};if(this.valueElement&&d.isElementType(this.valueElement,"input")){var t=function(){o.fromString(o.valueElement.value,d.leaveValue),d.dispatchFineChange(o)};d.attachEvent(this.valueElement,"keyup",t),d.attachEvent(this.valueElement,"input",t),d.attachEvent(this.valueElement,"blur",k),this.valueElement.setAttribute("autocomplete","off")}this.styleElement&&(this.styleElement._jscOrigStyle={backgroundImage:this.styleElement.style.backgroundImage,backgroundColor:this.styleElement.style.backgroundColor,color:this.styleElement.style.color}),this.value?this.fromString(this.value)||this.exportColor():this.importColor()}};return d.jscolor.lookupClass="jscolor",d.jscolor.installByClassName=function(a){var b=document.getElementsByTagName("input"),c=document.getElementsByTagName("button");d.tryInstallOnElements(b,a),d.tryInstallOnElements(c,a)},d.register(),d.jscolor}());