svgedit/editor/jgraduate/jpicker.min.js

1 line
48 KiB
JavaScript

!function($,version){Math.precision=function(value,precision){return void 0===precision&&(precision=0),Math.round(value*Math.pow(10,precision))/Math.pow(10,precision)};var Slider=function(bar,options){var offset,timeout,$this=this,arrow=bar.find("img:first"),minX=0,maxX=100,rangeX=100,minY=0,maxY=100,rangeY=100,x=0,y=0,changeEvents=[],mouseDown=function(e){var off=bar.offset();offset={l:0|off.left,t:0|off.top},clearTimeout(timeout),timeout=setTimeout(function(){setValuesFromMousePosition.call($this,e)},0),$(document).bind("mousemove",mouseMove).bind("mouseup",mouseUp),e.preventDefault()},mouseMove=function(e){return clearTimeout(timeout),timeout=setTimeout(function(){setValuesFromMousePosition.call($this,e)},0),e.stopPropagation(),e.preventDefault(),!1},mouseUp=function(e){return $(document).unbind("mouseup",mouseUp).unbind("mousemove",mouseMove),e.stopPropagation(),e.preventDefault(),!1},setValuesFromMousePosition=function(e){var locX=e.pageX-offset.l,locY=e.pageY-offset.t,barW=bar.w,barH=bar.h;locX<0?locX=0:locX>barW&&(locX=barW),locY<0?locY=0:locY>barH&&(locY=barH),val.call($this,"xy",{x:locX/barW*rangeX+minX,y:locY/barH*rangeY+minY})},val=function(name,value,context){if(!(void 0!==value))switch(void 0!==name&&null!=name||(name="xy"),name.toLowerCase()){case"x":return x;case"y":return y;case"xy":default:return{x:x,y:y}}if(null==context||context!==$this){var newX,newY,changed=!1;switch(null==name&&(name="xy"),name.toLowerCase()){case"x":newX=value&&(value.x&&0|value.x||0|value)||0;break;case"y":newY=value&&(value.y&&0|value.y||0|value)||0;break;case"xy":default:newX=value&&value.x&&0|value.x||0,newY=value&&value.y&&0|value.y||0}null!=newX&&(newX<minX?newX=minX:newX>maxX&&(newX=maxX),x!==newX&&(x=newX,changed=!0)),null!=newY&&(newY<minY?newY=minY:newY>maxY&&(newY=maxY),y!==newY&&(y=newY,changed=!0)),changed&&function(context){for(var i=0;i<changeEvents.length;i++)changeEvents[i].call($this,$this,context)}.call($this,context||$this)}},bind=function(callback){$.isFunction(callback)&&changeEvents.push(callback)};$.extend(!0,$this,{val:val,range:function(name,value){var newMinX,newMaxX,newMinY,newMaxY;if(void 0===value)switch(void 0!==name&&null!=name||(name="all"),name.toLowerCase()){case"minx":return minX;case"maxx":return maxX;case"rangex":return{minX:minX,maxX:maxX,rangeX:rangeX};case"miny":return minY;case"maxy":return maxY;case"rangey":return{minY:minY,maxY:maxY,rangeY:rangeY};case"all":default:return{minX:minX,maxX:maxX,rangeX:rangeX,minY:minY,maxY:maxY,rangeY:rangeY}}switch(null==name&&(name="all"),name.toLowerCase()){case"minx":newMinX=value&&(value.minX&&0|value.minX||0|value)||0;break;case"maxx":newMaxX=value&&(value.maxX&&0|value.maxX||0|value)||0;break;case"rangex":newMinX=value&&value.minX&&0|value.minX||0,newMaxX=value&&value.maxX&&0|value.maxX||0;break;case"miny":newMinY=value&&(value.minY&&0|value.minY||0|value)||0;break;case"maxy":newMaxY=value&&(value.maxY&&0|value.maxY||0|value)||0;break;case"rangey":newMinY=value&&value.minY&&0|value.minY||0,newMaxY=value&&value.maxY&&0|value.maxY||0;break;case"all":default:newMinX=value&&value.minX&&0|value.minX||0,newMaxX=value&&value.maxX&&0|value.maxX||0,newMinY=value&&value.minY&&0|value.minY||0,newMaxY=value&&value.maxY&&0|value.maxY||0}null!=newMinX&&minX!==newMinX&&(rangeX=maxX-(minX=newMinX)),null!=newMaxX&&maxX!==newMaxX&&(rangeX=(maxX=newMaxX)-minX),null!=newMinY&&minY!==newMinY&&(rangeY=maxY-(minY=newMinY)),null!=newMaxY&&maxY!==newMaxY&&(rangeY=(maxY=newMaxY)-minY)},bind:bind,unbind:function(callback){if($.isFunction(callback))for(var i;(i=$.inArray(callback,changeEvents))>-1;)changeEvents.splice(i,1)},destroy:function(){$(document).unbind("mouseup",mouseUp).unbind("mousemove",mouseMove),bar.unbind("mousedown",mouseDown),bar=null,arrow=null,changeEvents=null}}),arrow.src=options.arrow&&options.arrow.image,arrow.w=options.arrow&&options.arrow.width||arrow.width(),arrow.h=options.arrow&&options.arrow.height||arrow.height(),bar.w=options.map&&options.map.width||bar.width(),bar.h=options.map&&options.map.height||bar.height(),bar.bind("mousedown",mouseDown),bind.call($this,function(){var arrowOffsetX=0,arrowOffsetY=0,barW=bar.w,barH=bar.h,arrowW=arrow.w,arrowH=arrow.h;setTimeout(function(){rangeX>0&&(arrowOffsetX=x===maxX?barW:x/rangeX*barW|0),rangeY>0&&(arrowOffsetY=y===maxY?barH:y/rangeY*barH|0),arrowW>=barW?arrowOffsetX=(barW>>1)-(arrowW>>1):arrowOffsetX-=arrowW>>1,arrowH>=barH?arrowOffsetY=(barH>>1)-(arrowH>>1):arrowOffsetY-=arrowH>>1,arrow.css({left:arrowOffsetX+"px",top:arrowOffsetY+"px"})},0)})};$.jPicker={List:[],Color:function(init){var r,g,b,a,h,s,v,$this=this,changeEvents=[],fireChangeEvents=function(context){for(var i=0;i<changeEvents.length;i++)changeEvents[i].call($this,$this,context)},val=function(name,value,context){var set=Boolean(value);if(set&&""===value.ahex&&(value.ahex="00000000"),!set){if(void 0!==name&&null!=name&&""!==name||(name="all"),null==r)return null;switch(name.toLowerCase()){case"ahex":return ColorMethods.rgbaToHex({r:r,g:g,b:b,a:a});case"hex":return val("ahex").substring(0,6);case"all":return{r:r,g:g,b:b,a:a,h:h,s:s,v:v,hex:val.call($this,"hex"),ahex:val.call($this,"ahex")};default:for(var ret={},i=0;i<name.length;i++)switch(name.charAt(i)){case"r":1===name.length?ret=r:ret.r=r;break;case"g":1===name.length?ret=g:ret.g=g;break;case"b":1===name.length?ret=b:ret.b=b;break;case"a":1===name.length?ret=a:ret.a=a;break;case"h":1===name.length?ret=h:ret.h=h;break;case"s":1===name.length?ret=s:ret.s=s;break;case"v":1===name.length?ret=v:ret.v=v}return name.length?ret:val.call($this,"all")}}if(null==context||context!==$this){var changed=!1;if(null==name&&(name=""),null==value)return null!=r&&(r=null,changed=!0),null!=g&&(g=null,changed=!0),null!=b&&(b=null,changed=!0),null!=a&&(a=null,changed=!0),null!=h&&(h=null,changed=!0),null!=s&&(s=null,changed=!0),null!=v&&(v=null,changed=!0),void(changed&&fireChangeEvents.call($this,context||$this));switch(name.toLowerCase()){case"ahex":case"hex":ret=ColorMethods.hexToRgba(value&&(value.ahex||value.hex)||value||"none");val.call($this,"rgba",{r:ret.r,g:ret.g,b:ret.b,a:"ahex"===name?ret.a:null!=a?a:255},context);break;default:if(value&&(null!=value.ahex||null!=value.hex))return void val.call($this,"ahex",value.ahex||value.hex||"00000000",context);var newV={},rgb=!1,hsv=!1;void 0!==value.r&&-1===!name.indexOf("r")&&(name+="r"),void 0!==value.g&&-1===!name.indexOf("g")&&(name+="g"),void 0!==value.b&&-1===!name.indexOf("b")&&(name+="b"),void 0!==value.a&&-1===!name.indexOf("a")&&(name+="a"),void 0!==value.h&&-1===!name.indexOf("h")&&(name+="h"),void 0!==value.s&&-1===!name.indexOf("s")&&(name+="s"),void 0!==value.v&&-1===!name.indexOf("v")&&(name+="v");for(i=0;i<name.length;i++)switch(name.charAt(i)){case"r":if(hsv)continue;rgb=!0,newV.r=value&&value.r&&0|value.r||value&&0|value||0,newV.r<0?newV.r=0:newV.r>255&&(newV.r=255),r!==newV.r&&(r=newV.r,changed=!0);break;case"g":if(hsv)continue;rgb=!0,newV.g=value&&value.g&&0|value.g||value&&0|value||0,newV.g<0?newV.g=0:newV.g>255&&(newV.g=255),g!==newV.g&&(g=newV.g,changed=!0);break;case"b":if(hsv)continue;rgb=!0,newV.b=value&&value.b&&0|value.b||value&&0|value||0,newV.b<0?newV.b=0:newV.b>255&&(newV.b=255),b!==newV.b&&(b=newV.b,changed=!0);break;case"a":newV.a=value&&null!=value.a?0|value.a:null!=value?0|value:255,newV.a<0?newV.a=0:newV.a>255&&(newV.a=255),a!==newV.a&&(a=newV.a,changed=!0);break;case"h":if(rgb)continue;hsv=!0,newV.h=value&&value.h&&0|value.h||value&&0|value||0,newV.h<0?newV.h=0:newV.h>360&&(newV.h=360),h!==newV.h&&(h=newV.h,changed=!0);break;case"s":if(rgb)continue;hsv=!0,newV.s=value&&null!=value.s?0|value.s:null!=value?0|value:100,newV.s<0?newV.s=0:newV.s>100&&(newV.s=100),s!==newV.s&&(s=newV.s,changed=!0);break;case"v":if(rgb)continue;hsv=!0,newV.v=value&&null!=value.v?0|value.v:null!=value?0|value:100,newV.v<0?newV.v=0:newV.v>100&&(newV.v=100),v!==newV.v&&(v=newV.v,changed=!0)}if(changed){if(rgb){r=r||0,g=g||0,b=b||0;ret=ColorMethods.rgbToHsv({r:r,g:g,b:b});h=ret.h,s=ret.s,v=ret.v}else if(hsv){h=h||0,s=null!=s?s:100,v=null!=v?v:100;ret=ColorMethods.hsvToRgb({h:h,s:s,v:v});r=ret.r,g=ret.g,b=ret.b}a=null!=a?a:255,fireChangeEvents.call($this,context||$this)}}}};$.extend(!0,$this,{val:val,bind:function(callback){$.isFunction(callback)&&changeEvents.push(callback)},unbind:function(callback){if($.isFunction(callback))for(var i;(i=$.inArray(callback,changeEvents))>-1;)changeEvents.splice(i,1)},destroy:function(){changeEvents=null}}),init&&(null!=init.ahex?val("ahex",init):null!=init.hex?val((null!=init.a?"a":"")+"hex",null!=init.a?{ahex:init.hex+ColorMethods.intToHex(init.a)}:init):null!=init.r&&null!=init.g&&null!=init.b?val("rgb"+(null!=init.a?"a":""),init):null!=init.h&&null!=init.s&&null!=init.v&&val("hsv"+(null!=init.a?"a":""),init))},ColorMethods:{hexToRgba:function(hex){if(""===hex||"none"===hex)return{r:null,g:null,b:null,a:null};var r="00",g="00",b="00",a="255";return 6===(hex=this.validateHex(hex)).length&&(hex+="ff"),hex.length>6?(r=hex.substring(0,2),g=hex.substring(2,4),b=hex.substring(4,6),a=hex.substring(6,hex.length)):(hex.length>4&&(r=hex.substring(4,hex.length),hex=hex.substring(0,4)),hex.length>2&&(g=hex.substring(2,hex.length),hex=hex.substring(0,2)),hex.length>0&&(b=hex.substring(0,hex.length))),{r:this.hexToInt(r),g:this.hexToInt(g),b:this.hexToInt(b),a:this.hexToInt(a)}},validateHex:function(hex){return(hex=hex.toLowerCase().replace(/[^a-f0-9]/g,"")).length>8&&(hex=hex.substring(0,8)),hex},rgbaToHex:function(rgba){return this.intToHex(rgba.r)+this.intToHex(rgba.g)+this.intToHex(rgba.b)+this.intToHex(rgba.a)},intToHex:function(dec){var result=(0|dec).toString(16);return 1===result.length&&(result="0"+result),result.toLowerCase()},hexToInt:function(hex){return parseInt(hex,16)},rgbToHsv:function(rgb){var delta,r=rgb.r/255,g=rgb.g/255,b=rgb.b/255,hsv={h:0,s:0,v:0},min=0,max=0;return r>=g&&r>=b?(max=r,min=g>b?b:g):g>=b&&g>=r?(max=g,min=r>b?b:r):(max=b,min=g>r?r:g),hsv.v=max,hsv.s=max?(max-min)/max:0,hsv.s?(delta=max-min,hsv.h=r===max?(g-b)/delta:g===max?2+(b-r)/delta:4+(r-g)/delta,hsv.h=parseInt(60*hsv.h),hsv.h<0&&(hsv.h+=360)):hsv.h=0,hsv.s=100*hsv.s|0,hsv.v=100*hsv.v|0,hsv},hsvToRgb:function(hsv){var rgb={r:0,g:0,b:0,a:100},h=hsv.h,s=hsv.s,v=hsv.v;if(0===s)rgb.r=rgb.g=rgb.b=0===v?0:255*v/100|0;else{360===h&&(h=0);var i=0|(h/=60),f=h-i,p=(v/=100)*(1-(s/=100)),q=v*(1-s*f),t=v*(1-s*(1-f));switch(i){case 0:rgb.r=v,rgb.g=t,rgb.b=p;break;case 1:rgb.r=q,rgb.g=v,rgb.b=p;break;case 2:rgb.r=p,rgb.g=v,rgb.b=t;break;case 3:rgb.r=p,rgb.g=q,rgb.b=v;break;case 4:rgb.r=t,rgb.g=p,rgb.b=v;break;case 5:rgb.r=v,rgb.g=p,rgb.b=q}rgb.r=255*rgb.r|0,rgb.g=255*rgb.g|0,rgb.b=255*rgb.b|0}return rgb}}};var Color=$.jPicker.Color,List=$.jPicker.List,ColorMethods=$.jPicker.ColorMethods;$.fn.jPicker=function(options){var $arguments=arguments;return this.each(function(){var $this=this,settings=$.extend(!0,{},$.fn.jPicker.defaults,options);"input"===$($this).get(0).nodeName.toLowerCase()&&($.extend(!0,settings,{window:{bindToInput:!0,expandable:!0,input:$($this)}}),""===$($this).val()?(settings.color.active=new Color({hex:null}),settings.color.current=new Color({hex:null})):ColorMethods.validateHex($($this).val())&&(settings.color.active=new Color({hex:$($this).val(),a:settings.color.active.val("a")}),settings.color.current=new Color({hex:$($this).val(),a:settings.color.active.val("a")}))),settings.window.expandable?$($this).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>'):settings.window.liveUpdate=!1;var isLessThanIE7=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,container=null,colorMapDiv=null,colorBarDiv=null,colorMapL1=null,colorMapL2=null,colorMapL3=null,colorBarL1=null,colorBarL2=null,colorBarL3=null,colorBarL4=null,colorBarL5=null,colorBarL6=null,colorMap=null,colorBar=null,colorPicker=null,elementStartX=null,elementStartY=null,pageStartX=null,pageStartY=null,activePreview=null,currentPreview=null,okButton=null,cancelButton=null,grid=null,iconColor=null,iconAlpha=null,iconImage=null,moveBar=null,setColorMode=function(colorMode){var rgbMap,rgbBar,active=color.active,hex=active.val("hex");switch(settings.color.mode=colorMode,colorMode){case"h":if(setTimeout(function(){setBG.call($this,colorMapDiv,"transparent"),setImgLoc.call($this,colorMapL1,0),setAlpha.call($this,colorMapL1,100),setImgLoc.call($this,colorMapL2,260),setAlpha.call($this,colorMapL2,100),setBG.call($this,colorBarDiv,"transparent"),setImgLoc.call($this,colorBarL1,0),setAlpha.call($this,colorBarL1,100),setImgLoc.call($this,colorBarL2,260),setAlpha.call($this,colorBarL2,100),setImgLoc.call($this,colorBarL3,260),setAlpha.call($this,colorBarL3,100),setImgLoc.call($this,colorBarL4,260),setAlpha.call($this,colorBarL4,100),setImgLoc.call($this,colorBarL6,260),setAlpha.call($this,colorBarL6,100)},0),colorMap.range("all",{minX:0,maxX:100,minY:0,maxY:100}),colorBar.range("rangeY",{minY:0,maxY:360}),null==active.val("ahex"))break;colorMap.val("xy",{x:active.val("s"),y:100-active.val("v")},colorMap),colorBar.val("y",360-active.val("h"),colorBar);break;case"s":if(setTimeout(function(){setBG.call($this,colorMapDiv,"transparent"),setImgLoc.call($this,colorMapL1,-260),setImgLoc.call($this,colorMapL2,-520),setImgLoc.call($this,colorBarL1,-260),setImgLoc.call($this,colorBarL2,-520),setImgLoc.call($this,colorBarL6,260),setAlpha.call($this,colorBarL6,100)},0),colorMap.range("all",{minX:0,maxX:360,minY:0,maxY:100}),colorBar.range("rangeY",{minY:0,maxY:100}),null==active.val("ahex"))break;colorMap.val("xy",{x:active.val("h"),y:100-active.val("v")},colorMap),colorBar.val("y",100-active.val("s"),colorBar);break;case"v":if(setTimeout(function(){setBG.call($this,colorMapDiv,"000000"),setImgLoc.call($this,colorMapL1,-780),setImgLoc.call($this,colorMapL2,260),setBG.call($this,colorBarDiv,hex),setImgLoc.call($this,colorBarL1,-520),setImgLoc.call($this,colorBarL2,260),setAlpha.call($this,colorBarL2,100),setImgLoc.call($this,colorBarL6,260),setAlpha.call($this,colorBarL6,100)},0),colorMap.range("all",{minX:0,maxX:360,minY:0,maxY:100}),colorBar.range("rangeY",{minY:0,maxY:100}),null==active.val("ahex"))break;colorMap.val("xy",{x:active.val("h"),y:100-active.val("s")},colorMap),colorBar.val("y",100-active.val("v"),colorBar);break;case"r":if(rgbMap=-1040,rgbBar=-780,colorMap.range("all",{minX:0,maxX:255,minY:0,maxY:255}),colorBar.range("rangeY",{minY:0,maxY:255}),null==active.val("ahex"))break;colorMap.val("xy",{x:active.val("b"),y:255-active.val("g")},colorMap),colorBar.val("y",255-active.val("r"),colorBar);break;case"g":if(rgbMap=-1560,rgbBar=-1820,colorMap.range("all",{minX:0,maxX:255,minY:0,maxY:255}),colorBar.range("rangeY",{minY:0,maxY:255}),null==active.val("ahex"))break;colorMap.val("xy",{x:active.val("b"),y:255-active.val("r")},colorMap),colorBar.val("y",255-active.val("g"),colorBar);break;case"b":if(rgbMap=-2080,rgbBar=-2860,colorMap.range("all",{minX:0,maxX:255,minY:0,maxY:255}),colorBar.range("rangeY",{minY:0,maxY:255}),null==active.val("ahex"))break;colorMap.val("xy",{x:active.val("r"),y:255-active.val("g")},colorMap),colorBar.val("y",255-active.val("b"),colorBar);break;case"a":if(setTimeout(function(){setBG.call($this,colorMapDiv,"transparent"),setImgLoc.call($this,colorMapL1,-260),setImgLoc.call($this,colorMapL2,-520),setImgLoc.call($this,colorBarL1,260),setImgLoc.call($this,colorBarL2,260),setAlpha.call($this,colorBarL2,100),setImgLoc.call($this,colorBarL6,0),setAlpha.call($this,colorBarL6,100)},0),colorMap.range("all",{minX:0,maxX:360,minY:0,maxY:100}),colorBar.range("rangeY",{minY:0,maxY:255}),null==active.val("ahex"))break;colorMap.val("xy",{x:active.val("h"),y:100-active.val("v")},colorMap),colorBar.val("y",255-active.val("a"),colorBar);break;default:throw new Error("Invalid Mode")}switch(colorMode){case"h":break;case"s":case"v":case"a":setTimeout(function(){setAlpha.call($this,colorMapL1,100),setAlpha.call($this,colorBarL1,100),setImgLoc.call($this,colorBarL3,260),setAlpha.call($this,colorBarL3,100),setImgLoc.call($this,colorBarL4,260),setAlpha.call($this,colorBarL4,100)},0);break;case"r":case"g":case"b":setTimeout(function(){setBG.call($this,colorMapDiv,"transparent"),setBG.call($this,colorBarDiv,"transparent"),setAlpha.call($this,colorBarL1,100),setAlpha.call($this,colorMapL1,100),setImgLoc.call($this,colorMapL1,rgbMap),setImgLoc.call($this,colorMapL2,rgbMap-260),setImgLoc.call($this,colorBarL1,rgbBar-780),setImgLoc.call($this,colorBarL2,rgbBar-520),setImgLoc.call($this,colorBarL3,rgbBar),setImgLoc.call($this,colorBarL4,rgbBar-260),setImgLoc.call($this,colorBarL6,260),setAlpha.call($this,colorBarL6,100)},0)}null!=active.val("ahex")&&activeColorChanged.call($this,active)},activeColorChanged=function(ui,context){(null==context||context!==colorBar&&context!==colorMap)&&positionMapAndBarArrows.call($this,ui,context),setTimeout(function(){updatePreview.call($this,ui),updateMapVisuals.call($this,ui),updateBarVisuals.call($this,ui)},0)},mapValueChanged=function(ui,context){var active=color.active;if(context===colorMap||null!=active.val()){var xy=ui.val("all");switch(settings.color.mode){case"h":active.val("sv",{s:xy.x,v:100-xy.y},context);break;case"s":case"a":active.val("hv",{h:xy.x,v:100-xy.y},context);break;case"v":active.val("hs",{h:xy.x,s:100-xy.y},context);break;case"r":active.val("gb",{g:255-xy.y,b:xy.x},context);break;case"g":active.val("rb",{r:255-xy.y,b:xy.x},context);break;case"b":active.val("rg",{r:xy.x,g:255-xy.y},context)}}},colorBarValueChanged=function(ui,context){var active=color.active;if(context===colorBar||null!=active.val())switch(settings.color.mode){case"h":active.val("h",{h:360-ui.val("y")},context);break;case"s":active.val("s",{s:100-ui.val("y")},context);break;case"v":active.val("v",{v:100-ui.val("y")},context);break;case"r":active.val("r",{r:255-ui.val("y")},context);break;case"g":active.val("g",{g:255-ui.val("y")},context);break;case"b":active.val("b",{b:255-ui.val("y")},context);break;case"a":active.val("a",255-ui.val("y"),context)}},positionMapAndBarArrows=function(ui,context){if(context!==colorMap)switch(settings.color.mode){case"h":var sv=ui.val("sv");colorMap.val("xy",{x:null!=sv?sv.s:100,y:100-(null!=sv?sv.v:100)},context);break;case"s":case"a":var hv=ui.val("hv");colorMap.val("xy",{x:hv&&hv.h||0,y:100-(null!=hv?hv.v:100)},context);break;case"v":var hs=ui.val("hs");colorMap.val("xy",{x:hs&&hs.h||0,y:100-(null!=hs?hs.s:100)},context);break;case"r":var bg=ui.val("bg");colorMap.val("xy",{x:bg&&bg.b||0,y:255-(bg&&bg.g||0)},context);break;case"g":var br=ui.val("br");colorMap.val("xy",{x:br&&br.b||0,y:255-(br&&br.r||0)},context);break;case"b":var rg=ui.val("rg");colorMap.val("xy",{x:rg&&rg.r||0,y:255-(rg&&rg.g||0)},context)}if(context!==colorBar)switch(settings.color.mode){case"h":colorBar.val("y",360-(ui.val("h")||0),context);break;case"s":var s=ui.val("s");colorBar.val("y",100-(null!=s?s:100),context);break;case"v":var v=ui.val("v");colorBar.val("y",100-(null!=v?v:100),context);break;case"r":colorBar.val("y",255-(ui.val("r")||0),context);break;case"g":colorBar.val("y",255-(ui.val("g")||0),context);break;case"b":colorBar.val("y",255-(ui.val("b")||0),context);break;case"a":var a=ui.val("a");colorBar.val("y",255-(null!=a?a:255),context)}},updatePreview=function(ui){try{var all=ui.val("all");activePreview.css({backgroundColor:all&&"#"+all.hex||"transparent"}),setAlpha.call($this,activePreview,all&&Math.precision(100*all.a/255,4)||0)}catch(e){}},updateMapVisuals=function(ui){switch(settings.color.mode){case"h":setBG.call($this,colorMapDiv,new Color({h:ui.val("h")||0,s:100,v:100}).val("hex"));break;case"s":case"a":var s=ui.val("s");setAlpha.call($this,colorMapL2,100-(null!=s?s:100));break;case"v":var v=ui.val("v");setAlpha.call($this,colorMapL1,null!=v?v:100);break;case"r":setAlpha.call($this,colorMapL2,Math.precision((ui.val("r")||0)/255*100,4));break;case"g":setAlpha.call($this,colorMapL2,Math.precision((ui.val("g")||0)/255*100,4));break;case"b":setAlpha.call($this,colorMapL2,Math.precision((ui.val("b")||0)/255*100))}var a=ui.val("a");setAlpha.call($this,colorMapL3,Math.precision(100*(255-(a||0))/255,4))},updateBarVisuals=function(ui){switch(settings.color.mode){case"h":var a=ui.val("a");setAlpha.call($this,colorBarL5,Math.precision(100*(255-(a||0))/255,4));break;case"s":var hva=ui.val("hva"),saturatedColor=new Color({h:hva&&hva.h||0,s:100,v:null!=hva?hva.v:100});setBG.call($this,colorBarDiv,saturatedColor.val("hex")),setAlpha.call($this,colorBarL2,100-(null!=hva?hva.v:100)),setAlpha.call($this,colorBarL5,Math.precision(100*(255-(hva&&hva.a||0))/255,4));break;case"v":var hsa=ui.val("hsa"),valueColor=new Color({h:hsa&&hsa.h||0,s:null!=hsa?hsa.s:100,v:100});setBG.call($this,colorBarDiv,valueColor.val("hex")),setAlpha.call($this,colorBarL5,Math.precision(100*(255-(hsa&&hsa.a||0))/255,4));break;case"r":case"g":case"b":var hValue=0,vValue=0,rgba=ui.val("rgba");"r"===settings.color.mode?(hValue=rgba&&rgba.b||0,vValue=rgba&&rgba.g||0):"g"===settings.color.mode?(hValue=rgba&&rgba.b||0,vValue=rgba&&rgba.r||0):"b"===settings.color.mode&&(hValue=rgba&&rgba.r||0,vValue=rgba&&rgba.g||0);var middle=vValue>hValue?hValue:vValue;setAlpha.call($this,colorBarL2,hValue>vValue?Math.precision((hValue-vValue)/(255-vValue)*100,4):0),setAlpha.call($this,colorBarL3,vValue>hValue?Math.precision((vValue-hValue)/(255-hValue)*100,4):0),setAlpha.call($this,colorBarL4,Math.precision(middle/255*100,4)),setAlpha.call($this,colorBarL5,Math.precision(100*(255-(rgba&&rgba.a||0))/255,4));break;case"a":a=ui.val("a");setBG.call($this,colorBarDiv,ui.val("hex")||"000000"),setAlpha.call($this,colorBarL5,null!=a?0:100),setAlpha.call($this,colorBarL6,null!=a?100:0)}},setBG=function(el,c){el.css({backgroundColor:c&&6===c.length&&"#"+c||"transparent"})},setImg=function(img,src){isLessThanIE7&&(src.indexOf("AlphaBar.png")>-1||src.indexOf("Bars.png")>-1||src.indexOf("Maps.png")>-1)?(img.attr("pngSrc",src),img.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')"})):img.css({backgroundImage:"url('"+src+"')"})},setImgLoc=function(img,y){img.css({top:y+"px"})},setAlpha=function(obj,alpha){if(obj.css({visibility:alpha>0?"visible":"hidden"}),alpha>0&&alpha<100)isLessThanIE7&&null!=(src=obj.attr("pngSrc"))&&(src.indexOf("AlphaBar.png")>-1||src.indexOf("Bars.png")>-1||src.indexOf("Maps.png")>-1)?obj.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+alpha+")"}):obj.css({opacity:Math.precision(alpha/100,4)});else if(0===alpha||100===alpha){var src;if(isLessThanIE7)null!=(src=obj.attr("pngSrc"))&&(src.indexOf("AlphaBar.png")>-1||src.indexOf("Bars.png")>-1||src.indexOf("Maps.png")>-1)?obj.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')"}):obj.css({opacity:""});else obj.css({opacity:""})}},revertColor=function(){color.active.val("ahex",color.current.val("ahex"))},radioClicked=function(e){$(this).parents("tbody:first").find('input:radio[value!="'+e.target.value+'"]').removeAttr("checked"),setColorMode.call($this,e.target.value)},currentClicked=function(){revertColor.call($this)},cancelClicked=function(){revertColor.call($this),settings.window.expandable&&hide.call($this),$.isFunction(cancelCallback)&&cancelCallback.call($this,color.active,cancelButton)},okClicked=function(){(function(){color.current.val("ahex",color.active.val("ahex"))}).call($this),settings.window.expandable&&hide.call($this),$.isFunction(commitCallback)&&commitCallback.call($this,color.active,okButton)},iconImageClicked=function(){show.call($this)},currentColorChanged=function(ui,context){var hex=ui.val("hex");currentPreview.css({backgroundColor:hex&&"#"+hex||"transparent"}),setAlpha.call($this,currentPreview,Math.precision(100*(ui.val("a")||0)/255,4))},expandableColorChanged=function(ui,context){var hex=ui.val("hex"),va=ui.val("va");iconColor.css({backgroundColor:hex&&"#"+hex||"transparent"}),setAlpha.call($this,iconAlpha,Math.precision(100*(255-(va&&va.a||0))/255,4)),settings.window.bindToInput&&settings.window.updateInputColor&&settings.window.input.css({backgroundColor:hex&&"#"+hex||"transparent",color:null==va||va.v>75?"#000000":"#ffffff"})},moveBarMouseDown=function(e){elementStartX=parseInt(container.css("left")),elementStartY=parseInt(container.css("top")),pageStartX=e.pageX,pageStartY=e.pageY,$(document).bind("mousemove",documentMouseMove).bind("mouseup",documentMouseUp),e.preventDefault()},documentMouseMove=function(e){return container.css({left:elementStartX-(pageStartX-e.pageX)+"px",top:elementStartY-(pageStartY-e.pageY)+"px"}),settings.window.expandable&&!$.support.boxModel&&container.prev().css({left:container.css("left"),top:container.css("top")}),e.stopPropagation(),e.preventDefault(),!1},documentMouseUp=function(e){return $(document).unbind("mousemove",documentMouseMove).unbind("mouseup",documentMouseUp),e.stopPropagation(),e.preventDefault(),!1},quickPickClicked=function(e){return e.preventDefault(),e.stopPropagation(),color.active.val("ahex",$(this).attr("title")||null,e.target),!1},commitCallback=$.isFunction($arguments[1])&&$arguments[1]||null,liveCallback=$.isFunction($arguments[2])&&$arguments[2]||null,cancelCallback=$.isFunction($arguments[3])&&$arguments[3]||null,show=function(){color.current.val("ahex",color.active.val("ahex"));var attachIFrame=function(){if(settings.window.expandable&&!$.support.boxModel){var table=container.find("table:first");container.before("<iframe/>"),container.prev().css({width:table.width(),height:container.height(),opacity:0,position:"absolute",left:container.css("left"),top:container.css("top")})}};switch(settings.window.expandable&&($(document.body).children("div.jPicker.Container").css({zIndex:10}),container.css({zIndex:20})),settings.window.effects.type){case"fade":container.fadeIn(settings.window.effects.speed.show,attachIFrame);break;case"slide":container.slideDown(settings.window.effects.speed.show,attachIFrame);break;case"show":default:container.show(settings.window.effects.speed.show,attachIFrame)}},hide=function(){var removeIFrame=function(){settings.window.expandable&&container.css({zIndex:10}),settings.window.expandable&&!$.support.boxModel&&container.prev().remove()};switch(settings.window.effects.type){case"fade":container.fadeOut(settings.window.effects.speed.hide,removeIFrame);break;case"slide":container.slideUp(settings.window.effects.speed.hide,removeIFrame);break;case"show":default:container.hide(settings.window.effects.speed.hide,removeIFrame)}},initialize=function(){var win=settings.window,popup=win.expandable?$($this).next().find(".Container:first"):null;(container=win.expandable?$("<div/>"):$($this)).addClass("jPicker Container"),win.expandable&&container.hide(),container.get(0).onselectstart=function(event){if("input"!==event.target.nodeName.toLowerCase())return!1};var all=color.active.val("all");win.alphaPrecision<0?win.alphaPrecision=0:win.alphaPrecision>2&&(win.alphaPrecision=2);var controlHtml='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(win.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(win.title||localization.text.title)+'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+images.clientPath+images.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><span class="Map4">&nbsp;</span><span class="Map5">&nbsp;</span><span class="Map6">&nbsp;</span><img src="'+images.clientPath+images.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="2" class="Preview">'+localization.text.newColor+'<div><span class="Active" title="'+localization.tooltips.colors.newColor+'">&nbsp;</span><span class="Current" title="'+localization.tooltips.colors.currentColor+'">&nbsp;</span></div>'+localization.text.currentColor+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+localization.text.ok+'" title="'+localization.tooltips.buttons.ok+'"/><input type="button" class="Cancel" value="'+localization.text.cancel+'" title="'+localization.tooltips.buttons.cancel+'"/><hr/><div class="Grid">&nbsp;</div></td></tr><tr class="Hue"><td class="Radio"><label title="'+localization.tooltips.hue.radio+'"><input type="radio" value="h"'+("h"===settings.color.mode?' checked="checked"':"")+'/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(null!=all?all.h:"")+'" title="'+localization.tooltips.hue.textbox+'"/>&nbsp;&deg;</td></tr><tr class="Saturation"><td class="Radio"><label title="'+localization.tooltips.saturation.radio+'"><input type="radio" value="s"'+("s"===settings.color.mode?' checked="checked"':"")+'/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(null!=all?all.s:"")+'" title="'+localization.tooltips.saturation.textbox+'"/>&nbsp;%</td></tr><tr class="Value"><td class="Radio"><label title="'+localization.tooltips.value.radio+'"><input type="radio" value="v"'+("v"===settings.color.mode?' checked="checked"':"")+'/>V:</label><br/><br/></td><td class="Text"><input type="text" maxlength="3" value="'+(null!=all?all.v:"")+'" title="'+localization.tooltips.value.textbox+'"/>&nbsp;%<br/><br/></td></tr><tr class="Red"><td class="Radio"><label title="'+localization.tooltips.red.radio+'"><input type="radio" value="r"'+("r"===settings.color.mode?' checked="checked"':"")+'/>R:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(null!=all?all.r:"")+'" title="'+localization.tooltips.red.textbox+'"/></td></tr><tr class="Green"><td class="Radio"><label title="'+localization.tooltips.green.radio+'"><input type="radio" value="g"'+("g"===settings.color.mode?' checked="checked"':"")+'/>G:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(null!=all?all.g:"")+'" title="'+localization.tooltips.green.textbox+'"/></td></tr><tr class="Blue"><td class="Radio"><label title="'+localization.tooltips.blue.radio+'"><input type="radio" value="b"'+("b"===settings.color.mode?' checked="checked"':"")+'/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(null!=all?all.b:"")+'" title="'+localization.tooltips.blue.textbox+'"/></td></tr><tr class="Alpha"><td class="Radio">'+(win.alphaSupport?'<label title="'+localization.tooltips.alpha.radio+'"><input type="radio" value="a"'+("a"===settings.color.mode?' checked="checked"':"")+"/>A:</label>":"&nbsp;")+'</td><td class="Text">'+(win.alphaSupport?'<input type="text" maxlength="'+(3+win.alphaPrecision)+'" value="'+(null!=all?Math.precision(100*all.a/255,win.alphaPrecision):"")+'" title="'+localization.tooltips.alpha.textbox+'"/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+localization.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(null!=all?all.hex:"")+'"/></label>'+(win.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(null!=all?all.ahex.substring(6):"")+'" title="'+localization.tooltips.hex.alpha+'"/></td>':"&nbsp;")+"</tr></tbody></table>";win.expandable?(container.html(controlHtml),0===$(document.body).children("div.jPicker.Container").length?$(document.body).prepend(container):$(document.body).children("div.jPicker.Container:last").after(container),container.mousedown(function(){$(document.body).children("div.jPicker.Container").css({zIndex:10}),container.css({zIndex:20})}),container.css({left:"left"===win.position.x?popup.offset().left-530-("center"===win.position.y?25:0)+"px":"center"===win.position.x?popup.offset().left-260+"px":"right"===win.position.x?popup.offset().left-10+("center"===win.position.y?25:0)+"px":"screenCenter"===win.position.x?($(document).width()>>1)-260+"px":popup.offset().left+parseInt(win.position.x)+"px",position:"absolute",top:"top"===win.position.y?popup.offset().top-312+"px":"center"===win.position.y?popup.offset().top-156+"px":"bottom"===win.position.y?popup.offset().top+25+"px":popup.offset().top+parseInt(win.position.y)+"px"})):(container=$($this)).html(controlHtml);var tbody=container.find("tbody:first");colorMapDiv=tbody.find("div.Map:first"),colorBarDiv=tbody.find("div.Bar:first");var MapMaps=colorMapDiv.find("span"),BarMaps=colorBarDiv.find("span");colorMapL1=MapMaps.filter(".Map1:first"),colorMapL2=MapMaps.filter(".Map2:first"),colorMapL3=MapMaps.filter(".Map3:first"),colorBarL1=BarMaps.filter(".Map1:first"),colorBarL2=BarMaps.filter(".Map2:first"),colorBarL3=BarMaps.filter(".Map3:first"),colorBarL4=BarMaps.filter(".Map4:first"),colorBarL5=BarMaps.filter(".Map5:first"),colorBarL6=BarMaps.filter(".Map6:first"),(colorMap=new Slider(colorMapDiv,{map:{width:images.colorMap.width,height:images.colorMap.height},arrow:{image:images.clientPath+images.colorMap.arrow.file,width:images.colorMap.arrow.width,height:images.colorMap.arrow.height}})).bind(mapValueChanged),(colorBar=new Slider(colorBarDiv,{map:{width:images.colorBar.width,height:images.colorBar.height},arrow:{image:images.clientPath+images.colorBar.arrow.file,width:images.colorBar.arrow.width,height:images.colorBar.arrow.height}})).bind(colorBarValueChanged),colorPicker=new function(picker,color,bindedHex,alphaPrecision){var $this=this,inputs=picker.find("td.Text input"),red=inputs.eq(3),green=inputs.eq(4),blue=inputs.eq(5),alpha=inputs.length>7?inputs.eq(6):null,hue=inputs.eq(0),saturation=inputs.eq(1),value=inputs.eq(2),hex=inputs.eq(inputs.length>7?7:6),ahex=inputs.length>7?inputs.eq(8):null,keyDown=function(e){if(""!==e.target.value||e.target===hex.get(0)||(null==bindedHex||e.target===bindedHex.get(0))&&null!=bindedHex){if(!validateKey(e))return e;switch(e.target){case red.get(0):switch(e.keyCode){case 38:return red.val(setValueInRange.call($this,1+(red.val()<<0),0,255)),color.val("r",red.val(),e.target),!1;case 40:return red.val(setValueInRange.call($this,(red.val()<<0)-1,0,255)),color.val("r",red.val(),e.target),!1}break;case green.get(0):switch(e.keyCode){case 38:return green.val(setValueInRange.call($this,1+(green.val()<<0),0,255)),color.val("g",green.val(),e.target),!1;case 40:return green.val(setValueInRange.call($this,(green.val()<<0)-1,0,255)),color.val("g",green.val(),e.target),!1}break;case blue.get(0):switch(e.keyCode){case 38:return blue.val(setValueInRange.call($this,1+(blue.val()<<0),0,255)),color.val("b",blue.val(),e.target),!1;case 40:return blue.val(setValueInRange.call($this,(blue.val()<<0)-1,0,255)),color.val("b",blue.val(),e.target),!1}break;case alpha&&alpha.get(0):switch(e.keyCode){case 38:return alpha.val(setValueInRange.call($this,parseFloat(alpha.val())+1,0,100)),color.val("a",Math.precision(255*alpha.val()/100,alphaPrecision),e.target),!1;case 40:return alpha.val(setValueInRange.call($this,parseFloat(alpha.val())-1,0,100)),color.val("a",Math.precision(255*alpha.val()/100,alphaPrecision),e.target),!1}break;case hue.get(0):switch(e.keyCode){case 38:return hue.val(setValueInRange.call($this,1+(hue.val()<<0),0,360)),color.val("h",hue.val(),e.target),!1;case 40:return hue.val(setValueInRange.call($this,(hue.val()<<0)-1,0,360)),color.val("h",hue.val(),e.target),!1}break;case saturation.get(0):switch(e.keyCode){case 38:return saturation.val(setValueInRange.call($this,1+(saturation.val()<<0),0,100)),color.val("s",saturation.val(),e.target),!1;case 40:return saturation.val(setValueInRange.call($this,(saturation.val()<<0)-1,0,100)),color.val("s",saturation.val(),e.target),!1}break;case value.get(0):switch(e.keyCode){case 38:return value.val(setValueInRange.call($this,1+(value.val()<<0),0,100)),color.val("v",value.val(),e.target),!1;case 40:return value.val(setValueInRange.call($this,(value.val()<<0)-1,0,100)),color.val("v",value.val(),e.target),!1}}}},keyUp=function(e){if(""!==e.target.value||e.target===hex.get(0)||(null==bindedHex||e.target===bindedHex.get(0))&&null!=bindedHex){if(!validateKey(e))return e;switch(e.target){case red.get(0):red.val(setValueInRange.call($this,red.val(),0,255)),color.val("r",red.val(),e.target);break;case green.get(0):green.val(setValueInRange.call($this,green.val(),0,255)),color.val("g",green.val(),e.target);break;case blue.get(0):blue.val(setValueInRange.call($this,blue.val(),0,255)),color.val("b",blue.val(),e.target);break;case alpha&&alpha.get(0):alpha.val(setValueInRange.call($this,alpha.val(),0,100)),color.val("a",Math.precision(255*alpha.val()/100,alphaPrecision),e.target);break;case hue.get(0):hue.val(setValueInRange.call($this,hue.val(),0,360)),color.val("h",hue.val(),e.target);break;case saturation.get(0):saturation.val(setValueInRange.call($this,saturation.val(),0,100)),color.val("s",saturation.val(),e.target);break;case value.get(0):value.val(setValueInRange.call($this,value.val(),0,100)),color.val("v",value.val(),e.target);break;case hex.get(0):hex.val(hex.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6)),bindedHex&&bindedHex.val(hex.val()),color.val("hex",""!==hex.val()?hex.val():null,e.target);break;case bindedHex&&bindedHex.get(0):bindedHex.val(bindedHex.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6)),hex.val(bindedHex.val()),color.val("hex",""!==bindedHex.val()?bindedHex.val():null,e.target);break;case ahex&&ahex.get(0):ahex.val(ahex.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2)),color.val("a",null!=ahex.val()?parseInt(ahex.val(),16):null,e.target)}}},blur=function(e){if(null!=color.val())switch(e.target){case red.get(0):red.val(color.val("r"));break;case green.get(0):green.val(color.val("g"));break;case blue.get(0):blue.val(color.val("b"));break;case alpha&&alpha.get(0):alpha.val(Math.precision(100*color.val("a")/255,alphaPrecision));break;case hue.get(0):hue.val(color.val("h"));break;case saturation.get(0):saturation.val(color.val("s"));break;case value.get(0):value.val(color.val("v"));break;case hex.get(0):case bindedHex&&bindedHex.get(0):hex.val(color.val("hex")),bindedHex&&bindedHex.val(color.val("hex"));break;case ahex&&ahex.get(0):ahex.val(color.val("ahex").substring(6))}},validateKey=function(e){switch(e.keyCode){case 9:case 16:case 29:case 37:case 39:return!1;case"c".charCodeAt():case"v".charCodeAt():if(e.ctrlKey)return!1}return!0},setValueInRange=function(value,min,max){return""===value||isNaN(value)?min:value>max?max:value<min?min:value},colorChanged=function(ui,context){var all=ui.val("all");context!==red.get(0)&&red.val(null!=all?all.r:""),context!==green.get(0)&&green.val(null!=all?all.g:""),context!==blue.get(0)&&blue.val(null!=all?all.b:""),alpha&&context!==alpha.get(0)&&alpha.val(null!=all?Math.precision(100*all.a/255,alphaPrecision):""),context!==hue.get(0)&&hue.val(null!=all?all.h:""),context!==saturation.get(0)&&saturation.val(null!=all?all.s:""),context!==value.get(0)&&value.val(null!=all?all.v:""),context!==hex.get(0)&&(bindedHex&&context!==bindedHex.get(0)||!bindedHex)&&hex.val(null!=all?all.hex:""),bindedHex&&context!==bindedHex.get(0)&&context!==hex.get(0)&&bindedHex.val(null!=all?all.hex:""),ahex&&context!==ahex.get(0)&&ahex.val(null!=all?all.ahex.substring(6):"")};$.extend(!0,$this,{destroy:function(){red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).add(hex).add(bindedHex).add(ahex).unbind("keyup",keyUp).unbind("blur",blur),red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).unbind("keydown",keyDown),color.unbind(colorChanged),red=null,green=null,blue=null,alpha=null,hue=null,saturation=null,value=null,hex=null,ahex=null}}),red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).add(hex).add(bindedHex).add(ahex).bind("keyup",keyUp).bind("blur",blur),red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).bind("keydown",keyDown),color.bind(colorChanged)}(tbody,color.active,win.expandable&&win.bindToInput?win.input:null,win.alphaPrecision);var hex=null!=all?all.hex:null,preview=tbody.find(".Preview"),button=tbody.find(".Button");if(activePreview=preview.find(".Active:first").css({backgroundColor:hex&&"#"+hex||"transparent"}),currentPreview=preview.find(".Current:first").css({backgroundColor:hex&&"#"+hex||"transparent"}).bind("click",currentClicked),setAlpha.call($this,currentPreview,Math.precision(100*color.current.val("a"))/255,4),okButton=button.find(".Ok:first").bind("click",okClicked),cancelButton=button.find(".Cancel:first").bind("click",cancelClicked),grid=button.find(".Grid:first"),setTimeout(function(){setImg.call($this,colorMapL1,images.clientPath+"Maps.png"),setImg.call($this,colorMapL2,images.clientPath+"Maps.png"),setImg.call($this,colorMapL3,images.clientPath+"map-opacity.png"),setImg.call($this,colorBarL1,images.clientPath+"Bars.png"),setImg.call($this,colorBarL2,images.clientPath+"Bars.png"),setImg.call($this,colorBarL3,images.clientPath+"Bars.png"),setImg.call($this,colorBarL4,images.clientPath+"Bars.png"),setImg.call($this,colorBarL5,images.clientPath+"bar-opacity.png"),setImg.call($this,colorBarL6,images.clientPath+"AlphaBar.png"),setImg.call($this,preview.find("div:first"),images.clientPath+"preview-opacity.png")},0),tbody.find("td.Radio input").bind("click",radioClicked),color.quickList&&color.quickList.length>0){for(var html="",i=0;i<color.quickList.length;i++){"string"===(typeof color.quickList[i]).toString().toLowerCase()&&(color.quickList[i]=new Color({hex:color.quickList[i]}));var alpha=color.quickList[i].val("a"),ahex=color.quickList[i].val("ahex");!win.alphaSupport&&ahex&&(ahex=ahex.substring(0,6)+"ff");var quickHex=color.quickList[i].val("hex");ahex||(ahex="00000000"),html+='<span class="QuickColor"'+(ahex&&' title="#'+ahex+'"'||"none")+' style="background-color:'+(quickHex&&"#"+quickHex||"")+";"+(quickHex?"":"background-image:url("+images.clientPath+"NoColor.png)")+(win.alphaSupport&&alpha&&alpha<255?";opacity:"+Math.precision(alpha/255,4)+";filter:Alpha(opacity="+Math.precision(alpha/2.55,4)+")":"")+'">&nbsp;</span>'}setImg.call($this,grid,images.clientPath+"bar-opacity.png"),grid.html(html),grid.find(".QuickColor").click(quickPickClicked)}setColorMode.call($this,settings.color.mode),color.active.bind(activeColorChanged),$.isFunction(liveCallback)&&color.active.bind(liveCallback),color.current.bind(currentColorChanged),win.expandable?($this.icon=popup.parents(".Icon:first"),iconColor=$this.icon.find(".Color:first").css({backgroundColor:hex&&"#"+hex||"transparent"}),iconAlpha=$this.icon.find(".Alpha:first"),setImg.call($this,iconAlpha,images.clientPath+"bar-opacity.png"),setAlpha.call($this,iconAlpha,Math.precision(100*(255-(null!=all?all.a:0))/255,4)),iconImage=$this.icon.find(".Image:first").css({backgroundImage:"url('"+images.clientPath+images.picker.file+"')"}).bind("click",iconImageClicked),win.bindToInput&&win.updateInputColor&&win.input.css({backgroundColor:hex&&"#"+hex||"transparent",color:null==all||all.v>75?"#000000":"#ffffff"}),moveBar=tbody.find(".Move:first").bind("mousedown",moveBarMouseDown),color.active.bind(expandableColorChanged)):show.call($this)},images=settings.images,localization=settings.localization,color={active:"string"===(typeof settings.color.active).toString().toLowerCase()?new Color({ahex:!settings.window.alphaSupport&&settings.color.active?settings.color.active.substring(0,6)+"ff":settings.color.active}):new Color({ahex:!settings.window.alphaSupport&&settings.color.active.val("ahex")?settings.color.active.val("ahex").substring(0,6)+"ff":settings.color.active.val("ahex")}),current:"string"===(typeof settings.color.active).toString().toLowerCase()?new Color({ahex:!settings.window.alphaSupport&&settings.color.active?settings.color.active.substring(0,6)+"ff":settings.color.active}):new Color({ahex:!settings.window.alphaSupport&&settings.color.active.val("ahex")?settings.color.active.val("ahex").substring(0,6)+"ff":settings.color.active.val("ahex")}),quickList:settings.color.quickList};$.extend(!0,$this,{commitCallback:commitCallback,liveCallback:liveCallback,cancelCallback:cancelCallback,color:color,show:show,hide:hide,destroy:function(){container.find("td.Radio input").unbind("click",radioClicked),currentPreview.unbind("click",currentClicked),cancelButton.unbind("click",cancelClicked),okButton.unbind("click",okClicked),settings.window.expandable&&(iconImage.unbind("click",iconImageClicked),moveBar.unbind("mousedown",moveBarMouseDown),$this.icon=null),container.find(".QuickColor").unbind("click",quickPickClicked),colorMapDiv=null,colorBarDiv=null,colorMapL1=null,colorMapL2=null,colorMapL3=null,colorBarL1=null,colorBarL2=null,colorBarL3=null,colorBarL4=null,colorBarL5=null,colorBarL6=null,colorMap.destroy(),colorMap=null,colorBar.destroy(),colorBar=null,colorPicker.destroy(),colorPicker=null,activePreview=null,currentPreview=null,okButton=null,cancelButton=null,grid=null,commitCallback=null,cancelCallback=null,liveCallback=null,container.html("");for(var i=0;i<List.length;i++)List[i]===$this&&List.splice(i,1)}}),List.push($this),setTimeout(function(){initialize.call($this)},0)})},$.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:!1,liveUpdate:!0,alphaSupport:!1,alphaPrecision:0,updateInputColor:!0},color:{mode:"h",active:new Color({ahex:"#ffcc00ff"}),quickList:[new Color({h:360,s:33,v:100}),new Color({h:360,s:66,v:100}),new Color({h:360,s:100,v:100}),new Color({h:360,s:100,v:75}),new Color({h:360,s:100,v:50}),new Color({h:180,s:0,v:100}),new Color({h:30,s:33,v:100}),new Color({h:30,s:66,v:100}),new Color({h:30,s:100,v:100}),new Color({h:30,s:100,v:75}),new Color({h:30,s:100,v:50}),new Color({h:180,s:0,v:90}),new Color({h:60,s:33,v:100}),new Color({h:60,s:66,v:100}),new Color({h:60,s:100,v:100}),new Color({h:60,s:100,v:75}),new Color({h:60,s:100,v:50}),new Color({h:180,s:0,v:80}),new Color({h:90,s:33,v:100}),new Color({h:90,s:66,v:100}),new Color({h:90,s:100,v:100}),new Color({h:90,s:100,v:75}),new Color({h:90,s:100,v:50}),new Color({h:180,s:0,v:70}),new Color({h:120,s:33,v:100}),new Color({h:120,s:66,v:100}),new Color({h:120,s:100,v:100}),new Color({h:120,s:100,v:75}),new Color({h:120,s:100,v:50}),new Color({h:180,s:0,v:60}),new Color({h:150,s:33,v:100}),new Color({h:150,s:66,v:100}),new Color({h:150,s:100,v:100}),new Color({h:150,s:100,v:75}),new Color({h:150,s:100,v:50}),new Color({h:180,s:0,v:50}),new Color({h:180,s:33,v:100}),new Color({h:180,s:66,v:100}),new Color({h:180,s:100,v:100}),new Color({h:180,s:100,v:75}),new Color({h:180,s:100,v:50}),new Color({h:180,s:0,v:40}),new Color({h:210,s:33,v:100}),new Color({h:210,s:66,v:100}),new Color({h:210,s:100,v:100}),new Color({h:210,s:100,v:75}),new Color({h:210,s:100,v:50}),new Color({h:180,s:0,v:30}),new Color({h:240,s:33,v:100}),new Color({h:240,s:66,v:100}),new Color({h:240,s:100,v:100}),new Color({h:240,s:100,v:75}),new Color({h:240,s:100,v:50}),new Color({h:180,s:0,v:20}),new Color({h:270,s:33,v:100}),new Color({h:270,s:66,v:100}),new Color({h:270,s:100,v:100}),new Color({h:270,s:100,v:75}),new Color({h:270,s:100,v:50}),new Color({h:180,s:0,v:10}),new Color({h:300,s:33,v:100}),new Color({h:300,s:66,v:100}),new Color({h:300,s:100,v:100}),new Color({h:300,s:100,v:75}),new Color({h:300,s:100,v:50}),new Color({h:180,s:0,v:0}),new Color({h:330,s:33,v:100}),new Color({h:330,s:66,v:100}),new Color({h:330,s:100,v:100}),new Color({h:330,s:100,v:75}),new Color({h:330,s:100,v:50}),new Color]},images:{clientPath:"/jPicker/images/",colorMap:{width:256,height:256,arrow:{file:"mappoint.gif",width:15,height:15}},colorBar:{width:20,height:256,arrow:{file:"rangearrows.gif",width:20,height:7}},picker:{file:"picker.gif",width:25,height:24}},localization:{text:{title:"Drag Markers To Pick A Color",newColor:"new",currentColor:"current",ok:"OK",cancel:"Cancel"},tooltips:{colors:{newColor:"New Color - Press &ldquo;OK&rdquo; To Commit",currentColor:"Click To Revert To Original Color"},buttons:{ok:"Commit To This Color Selection",cancel:"Cancel And Revert To Original Color"},hue:{radio:"Set To &ldquo;Hue&rdquo; Color Mode",textbox:"Enter A &ldquo;Hue&rdquo; Value (0-360&deg;)"},saturation:{radio:"Set To &ldquo;Saturation&rdquo; Color Mode",textbox:"Enter A &ldquo;Saturation&rdquo; Value (0-100%)"},value:{radio:"Set To &ldquo;Value&rdquo; Color Mode",textbox:"Enter A &ldquo;Value&rdquo; Value (0-100%)"},red:{radio:"Set To &ldquo;Red&rdquo; Color Mode",textbox:"Enter A &ldquo;Red&rdquo; Value (0-255)"},green:{radio:"Set To &ldquo;Green&rdquo; Color Mode",textbox:"Enter A &ldquo;Green&rdquo; Value (0-255)"},blue:{radio:"Set To &ldquo;Blue&rdquo; Color Mode",textbox:"Enter A &ldquo;Blue&rdquo; Value (0-255)"},alpha:{radio:"Set To &ldquo;Alpha&rdquo; Color Mode",textbox:"Enter A &ldquo;Alpha&rdquo; Value (0-100)"},hex:{textbox:"Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)",alpha:"Enter A &ldquo;Alpha&rdquo; Value (#00-#ff)"}}}}}(jQuery);