(function($){$.widget("lws.lws_switch",{_create:function(){this._createStructure();this.setState();this.element.change(this._bind(this.setState,this))},_bind:function(fn,me){return function(){return fn.apply(me,arguments)}},_createStructure:function(){if(this.element.data("left")!=undefined&&this.element.data("right")!=undefined){leftcolor=this.element.data("colorleft")!=undefined?"--left-color:"+this.element.data("colorleft")+";--left-light-color:"+this.element.data("colorleft")+"20;":"";rightcolor=this.element.data("colorright")!=undefined?"--right-color:"+this.element.data("colorright")+";--right-light-color:"+this.element.data("colorright")+"20;":"";this.container=$("<div>",{class:"lws-switch-bigwrapper",style:leftcolor+rightcolor}).append($("<div>",{class:"switch-left",html:this.element.data("left")})).append($("<div>",{class:"lws-switch-wrapper leftright"}).append($("<div>",{class:"knobs"})).append($("<div>",{class:"layer"}))).append($("<div>",{class:"switch-right",html:this.element.data("right")})).insertAfter(this.element);this.element.detach().prependTo(this.container.find(".lws-switch-wrapper"))}else{this.container=$("<div>",{class:"lws-switch-wrapper"}).append($("<div>",{class:"knobs"})).append($("<div>",{class:"layer"})).insertAfter(this.element);this.element.detach().prependTo(this.container)}},setState:function(){if(this.element.prop("checked")){this.container.addClass("checked")}else{this.container.removeClass("checked")}}})})(jQuery);jQuery(function($){$(".lws_switch").lws_switch()});
