////////////////////////////////////////////// 
//        SoundOutTheBox colorPicker        // 
//  Copyright © SoundOutTheBox 2012-2013    // 
//           License-CC-BY-NC-ND            // 
////////////////////////////////////////////// 
(function(e){e.widget("mui.colorPicker",{options:{publicVariables:{Name:{value:"no name",type:"StringData",dynamic:!1},Left:{value:0,type:"IntegerData",dynamic:!1},Top:{value:0,type:"IntegerData",dynamic:!1},Width:{value:545,type:"IntegerData",dynamic:!1},Height:{value:334,type:"IntegerData",dynamic:!1},NewRed:{value:255,type:"IntegerData",dynamic:!0},NewGreen:{value:255,type:"IntegerData",dynamic:!0},NewBlue:{value:255,type:"IntegerData",dynamic:!0},NewRGB:{value:"255,255,255",type:"StringData",
subtype:"Color",dynamic:!0},NewHex:{value:"FFFFFF",type:"StringData",dynamic:!0},CurrentRed:{value:255,type:"IntegerData",dynamic:!0},CurrentGreen:{value:255,type:"IntegerData",dynamic:!0},CurrentBlue:{value:255,type:"IntegerData",dynamic:!0},CurrentRGB:{value:"255,255,255",type:"StringData",subtype:"Color",dynamic:!0},CurrentHex:{value:"FFFFFF",type:"StringData",dynamic:!0},AllowChangeOnTransparentClick:{value:["no","yes"],type:"EnumData",defaultvalue:"no",dynamic:!1},Visible:{value:["no","yes"],
type:"EnumData",defaultvalue:"yes",write:!0,dynamic:!0}},privateVariables:{pageNumber:0,motifType:0,userScreen:0},config:{main:"colorPicker.js",description:"colorPicker is a color selector which allows to know the RGB values of the new color and the current color already validated.",author:"SoundOutTheBox",version:"1.0.0.0.Final",dependencies:["./js/jPicker116.js","./css/jPicker116.css"],widgetID:"63689a95629569949f9b3964666b9464936062726e36676572626a63606a6e67",widgetPackages:["666b6d6a9268639271696692669f64646b62616c6c3163987194946796617069"]}},_create:function(){},
_init:function(){},_destroy:function(){},_setOption:function(){e.Widget.prototype._setOption.apply(this,arguments)},_render:function(){var a=this,b=a.options.publicVariables,c=a.element,i=b.Top.value,j=b.Height.value,k=b.Left.value,l=b.Width.value,f=b.NewHex.value;console.log("_render()  object="+b.Name.value);c.disableSelection();c.css({position:"absolute",left:k+"px",top:i+"px",width:l+"px",height:j+"px",zIndex:10});c.addClass("dynamicObject");e(c).attr("id",a.options.publicVariables.Name.value);
f===""&&(f="FFFFFF");e(c).bind("onNotifyOkButtonClicked",function(c,d){if(UTIL.isNull(d))b.AllowChangeOnTransparentClick.value==="yes"&&(a.internalSetCurrentRed(-1,!0),a.internalSetCurrentGreen(-1,!0),a.internalSetCurrentBlue(-1,!0),a.internalSetCurrentRGB("",!0),a.internalSetCurrentHex("",!0));else{var e=d.r+","+d.g+","+d.b,f=d.g,g=d.b,h=d.hex;a.internalSetCurrentRed(d.r,!0);a.internalSetCurrentGreen(f,!0);a.internalSetCurrentBlue(g,!0);a.internalSetCurrentRGB(e,!0);a.internalSetCurrentHex(h,!0)}});
e(c).bind("onNotifyNewColorChanged",function(c,d){if(UTIL.isNull(d))b.AllowChangeOnTransparentClick.value==="yes"&&(a.internalSetNewRed(-1,!0),a.internalSetNewGreen(-1,!0),a.internalSetNewBlue(-1,!0),a.internalSetNewRGB("",!0),a.internalSetNewHex("",!0));else{var e=d.r+","+d.g+","+d.b,f=d.g,g=d.b,h=d.hex;a.internalSetNewRed(d.r,!0);a.internalSetNewGreen(f,!0);a.internalSetNewBlue(g,!0);a.internalSetNewRGB(e,!0);a.internalSetNewHex(h,!0)}});e(c).jPicker({window:{title:"Color Selector"},color:{active:new e.jPicker.Color({ahex:f})}},
function(a){var a=a.val("all"),b=e(this).parent();e(b.context).trigger("onNotifyOkButtonClicked",[a])},function(b){var b=b.val("all"),c=document.getElementById(a.options.publicVariables.Name.value);e(c).trigger("onNotifyNewColorChanged",[b])},function(){});a.setVisible(b.Visible.value)},readFromXML:function(a){var b=this.options.publicVariables,a=e(a);b.Name.value=UTIL.getStringAttr(a,"Name",b.Name.value);b.NewRed.value=UTIL.getIntAttr(a,"NewRed",b.NewRed.value);b.NewGreen.value=UTIL.getIntAttr(a,
"NewGreen",b.NewGreen.value);b.NewBlue.value=UTIL.getIntAttr(a,"NewBlue",b.NewBlue.value);b.NewRGB.value=UTIL.getStringAttr(a,"NewRGB",b.NewRGB.value);b.NewHex.value=UTIL.getStringAttr(a,"NewHex",b.NewHex.value);b.CurrentRed.value=UTIL.getIntAttr(a,"CurrentRed",b.CurrentRed.value);b.CurrentGreen.value=UTIL.getIntAttr(a,"CurrentGreen",b.CurrentGreen.value);b.CurrentBlue.value=UTIL.getIntAttr(a,"CurrentBlue",b.CurrentBlue.value);b.CurrentRGB.value=UTIL.getStringAttr(a,"CurrentRGB",b.CurrentRGB.value);
b.CurrentHex.value=UTIL.getStringAttr(a,"CurrentHex",b.CurrentHex.value);b.AllowChangeOnTransparentClick.value=UTIL.getStringAttr(a,"AllowChangeOnTransparentClick",b.AllowChangeOnTransparentClick.value);b.Visible.value=UTIL.getStringAttr(a,"Visible",b.Visible.value);UTIL.readPositionFromXML(a,b)},internalSetCurrentRed:function(a,b){var c=this.options.publicVariables;if(a!==c.CurrentRed.value)c.CurrentRed.value=a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+
".CurrentRed",property:"CurrentRed",value:c.CurrentRed.value}))},internalSetCurrentGreen:function(a,b){var c=this.options.publicVariables;if(a!==c.CurrentGreen.value)c.CurrentGreen.value=a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".CurrentGreen",property:"CurrentGreen",value:c.CurrentGreen.value}))},internalSetCurrentBlue:function(a,b){var c=this.options.publicVariables;if(a!==c.CurrentBlue.value)c.CurrentBlue.value=a,b&&this._trigger("propertyChange",
null,Object({name:this.options.publicVariables.Name.value+".CurrentBlue",property:"CurrentBlue",value:c.CurrentBlue.value}))},internalSetCurrentRGB:function(a,b){var c=this.options.publicVariables;if(a!==c.CurrentRGB.value)c.CurrentRGB.value=a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".CurrentRGB",property:"CurrentRGB",value:c.CurrentRGB.value}))},internalSetCurrentHex:function(a,b){var c=this.options.publicVariables;if(a!==c.CurrentHex.value)c.CurrentHex.value=
a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".CurrentHex",property:"CurrentHex",value:c.CurrentHex.value}))},internalSetNewRed:function(a,b){var c=this.options.publicVariables;if(a!==c.NewRed.value)c.NewRed.value=a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".NewRed",property:"NewRed",value:c.NewRed.value}))},internalSetNewGreen:function(a,b){var c=this.options.publicVariables;if(a!==c.NewGreen.value)c.NewGreen.value=
a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".NewGreen",property:"NewGreen",value:c.NewGreen.value}))},internalSetNewBlue:function(a,b){var c=this.options.publicVariables;if(a!==c.NewBlue.value)c.NewBlue.value=a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".NewBlue",property:"NewBlue",value:c.NewBlue.value}))},internalSetNewRGB:function(a,b){var c=this.options.publicVariables;if(a!==c.NewRGB.value)c.NewRGB.value=
a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".NewRGB",property:"NewRGB",value:c.NewRGB.value}))},internalSetNewHex:function(a,b){var c=this.options.publicVariables;if(a!==c.NewHex.value)c.NewHex.value=a,b&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".NewHex",property:"NewHex",value:c.NewHex.value}))},setVisible:function(a){var b=this.options.publicVariables,c=this.element;if(a!==b.Visible.value)b.Visible.value=
a;b.Visible.value!=="no"?UTIL.setOpacity(c,1):UTIL.setOpacity(c,0)},onPropertyChange:function(a,b){switch(a){case "Visible":this.setVisible(b)}},onReleaseCapture:function(){}})})(jQuery);
