////////////////////////////////////////////// 
//         SoundOutTheBox checkbox          // 
//  Copyright © SoundOutTheBox 2012-2013    // 
//           License-CC-BY-NC-ND            // 
////////////////////////////////////////////// 
(function(d){d.widget("mui.checkbox",{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:100,type:"IntegerData",dynamic:!1},Height:{value:20,type:"IntegerData",dynamic:!1},Text:{value:"checkbox",type:"StringData",write:!0,dynamic:!0},TextColor:{value:"255,255,255",type:"StringData",subtype:"Color",write:!0,dynamic:!0},TextFont:{value:"Tahoma, 10",type:"StringData",dynamic:!1},
Checked:{value:["false","true"],type:"EnumData",defaultvalue:"false",write:!0,dynamic:!0},Visible:{value:["no","yes"],type:"EnumData",defaultvalue:"yes",write:!0,dynamic:!0}},privateVariables:{pageNumber:0,motifType:0,userScreen:0,checkboxObj:null,labelObj:null,font:null},config:{main:"checkbox.js",description:"One checkbox can be easily designed by defining Text, Font, Color, Default state options.",author:"SoundOutTheBox",version:"1.0.0.0.Final",dependencies:"",widgetID:"696b67676b9e6c6a63639568686c966b99686635686a6a67686e9d9465356668",
widgetPackages:["6671686b946f6b94683497996899656c71656033686966996b9b9b689630686c"]}},_create:function(){this.options.privateVariables.font=new goFont},_init:function(){},_destroy:function(){},_setOption:function(){d.Widget.prototype._setOption.apply(this,arguments)},_render:function(){var b=this,a=b.options.publicVariables,c=b.options.privateVariables,f=b.element,g=a.Top.value,e=a.Height.value,h=a.Left.value,i=a.Width.value,j=a.TextColor.value;console.log("_render()  object="+a.Name.value);f.disableSelection();f.css({position:"absolute",
left:h+"px",top:g+"px",width:i+"px",height:e+"px",zIndex:10});f.addClass("dynamicObject");g=d('<input type="checkbox"/>');g.appendTo(f);c.checkboxObj=d(g);e=d("<label/>");e.css({color:j,fontFamily:c.font._name,fontSize:c.font._height+"pt",fontStyle:c.font._italic===!1?"normal":"italic",fontWeight:c.font._bold===!1?"normal":"bold",textDecoration:c.font._underline!==!1?"underline":c.font._strikeOut===!1?"none":"line-through"});e.appendTo(f);c.labelObj=d(e);d(g).click(function(){b.setChecked(a.Checked.value===
"true"?"false":"true",!1)});d(e).click(function(){b.setChecked(a.Checked.value==="true"?"false":"true",!1)});b.setMyText(a.Text.value,!0);b.setChecked(a.Checked.value,!1);b.setVisible(a.Visible.value)},internalSetChecked:function(b,a){var c=this.options.publicVariables;c.Checked.value=b;a&&this._trigger("propertyChange",null,Object({name:this.options.publicVariables.Name.value+".Checked",property:"Checked",value:c.Checked.value}));d(this.options.privateVariables.checkboxObj).attr("checked",eval(b))},
setChecked:function(b,a){var c=this.options.publicVariables;privateVariables=this.options.privateVariables;sChecked=b==="true"?"true":"false";currentDate=new Date;iCurrentTimeMs=currentDate.getTime();iDeltaMs=iCurrentTimeMs-privateVariables.lastClick;sendToClient=a===!1||a===void 0;if(a){if(console.log("setStatus object="+c.Name.value+" value="+sChecked+" delta="+iDeltaMs+" BEFORE"),iDeltaMs<250){console.log("setStatus object="+c.Name.value+" value="+sChecked+" delta="+iDeltaMs+" IGNORED");return}}else privateVariables.lastClick=
iCurrentTimeMs;this.internalSetChecked(sChecked,sendToClient)},setMyText:function(b,a){var c=this.options.privateVariables.labelObj;if(this.options.publicVariables.Text.value!==b||a===!0)this.options.publicVariables.Text.value=b,d(c).text(b)},setTextColor:function(b){d(this.options.privateVariables.labelObj).css({color:b})},setVisible:function(b){var a=this.options.publicVariables,c=this.element;if(b!==a.Visible.value)a.Visible.value=b;a.Visible.value!=="no"?UTIL.setOpacity(c,1):UTIL.setOpacity(c,
0)},readFromXML:function(b){var a=this.options.publicVariables,c=this.options.privateVariables,b=d(b);a.Name.value=UTIL.getStringAttr(b,"Name",a.Name.value);a.Text.value=UTIL.getStringAttr(b,"Text",a.Text.value);a.TextColor.value=UTIL.getColorAttr(b,"TextColor",a.TextColor.value);a.TextFont.value=UTIL.getStringAttr(b,"TextFont",a.TextFont.value);a.Checked.value=UTIL.getStringAttr(b,"Checked",a.Checked.value);a.Visible.value=UTIL.getStringAttr(b,"Visible",a.Visible.value);c.font.readFromText(a.TextFont.value);
UTIL.readPositionFromXML(b,a)},onPropertyChange:function(b,a){switch(b){case "Checked":this.setChecked(a,!0);break;case "Text":this.setMyText(a);break;case "TextColor":this.setTextColor(UTIL.defineColorEmbossed(a));break;case "Visible":this.setVisible(a)}},onReleaseCapture:function(){}})})(jQuery);
