define("qui/controls/buttons/Switch",["qui/controls/Control","css!qui/controls/buttons/Switch.css"],function(t){"use strict";return new Class({Extends:t,Type:"qui/controls/buttons/Switch",Binds:["toggle","$onInject","$onSetAttribute"],options:{name:"",title:"",styles:!1,status:!0,switchTextOn:"",switchTextOnIcon:"icon-ok",switchTextOff:"",switchTextOffIcon:"icon-remove"},initialize:function(t){this.parent(t),this.$Button=!1,this.$FxElm=!1,this.$FxButton=!1,this.$status=this.getAttribute("status"),this.$triggerEvents=!0,this.$disabled=!1,this.addEvents({onInject:this.$onInject,onSetAttribute:this.$onSetAttribute})},resize:function(){this.$Button.setStyle("width",this.$ButtonTextOff.getSize().x),this.$triggerEvents=!1,this.getStatus()?this.on():this.off(),this.$triggerEvents=!0,moofx(this.$Elm).animate({opacity:1})},create:function(){return this.$Elm=new Element("div",{"class":"qui-switch",html:'<div class="qui-switch-off"><div class="qui-switch-icon-off"></div><div class="qui-switch-text-off"></div></div><div class="qui-switch-on"><div class="qui-switch-icon-on"></div><div class="qui-switch-text-on"></div></div><div class="qui-switch-button"></div><input type="hidden" />',styles:{opacity:0},"data-quiid":this.getId()}),this.$InputStatus=this.$Elm.getElement("input"),this.$Button=this.$Elm.getElement(".qui-switch-button"),this.$ButtonTextOn=this.$Elm.getElement(".qui-switch-on"),this.$TextOn=this.$Elm.getElement(".qui-switch-text-on"),this.$ButtonTextOff=this.$Elm.getElement(".qui-switch-off"),this.$TextOff=this.$Elm.getElement(".qui-switch-text-off"),this.$IconOn=this.$Elm.getElement(".qui-switch-icon-on"),this.$IconOff=this.$Elm.getElement(".qui-switch-icon-off"),this.$IconOn.addClass(this.getAttribute("switchTextOnIcon")),this.$IconOff.addClass(this.getAttribute("switchTextOffIcon")),this.$TextOn.set("html",this.getAttribute("switchTextOn")),this.$TextOff.set("html",this.getAttribute("switchTextOff")),this.$Elm.addEvent("click",this.toggle),this.getAttribute("styles")&&this.$Elm.setStyles(this.getAttribute("styles")),""===this.getAttribute("switchTextOn")&&this.$TextOn.setStyles({textAlign:"center",width:"100%"}),""===this.getAttribute("switchTextOff")&&this.$TextOff.setStyles({textAlign:"center",width:"100%"}),this.getAttribute("title")&&this.$Elm.set("title",this.getAttribute("title")),this.$FxElm=moofx(this.$Elm),this.$FxButton=moofx(this.$Button),this.$InputStatus.set("name",this.getAttribute("name")),this.$Elm},$onInject:function(){var t=this;this.$Button.setStyle("left",0),this.$Elm.setStyle("background","#0069b4"),function(){t.resize()}.delay(100)},getStatus:function(){return this.$status?!0:!1},toggle:function(){this.$status?this.off():this.on()},on:function(){if(!this.$disabled&&(this.$status=1,this.$triggerEvents&&(this.fireEvent("statusOn",[this]),this.fireEvent("change",[this])),this.$Elm)){this.$InputStatus.addEvents("click",this.$InputStatus.set("value","1"));var t=this.$ButtonTextOff.getSize().x;this.$FxElm.animate({background:"#0069b4"},{duration:200,equation:"cubic-bezier(1,0,0,0)"}),this.$FxButton.animate({left:0,width:t},{duration:350,equation:"cubic-bezier(0.34,1.31,0.7,1)"})}},off:function(){if(!this.$disabled&&(this.$status=0,this.$triggerEvents&&(this.fireEvent("statusOff",[this]),this.fireEvent("change",[this])),this.$Elm)){this.$InputStatus.addEvents("click",this.$InputStatus.set("value","0"));var t=this.$ButtonTextOn.getSize().x,i=this.$ButtonTextOff.getSize().x;this.$FxElm.animate({background:"#fff"},{duration:10,equation:"cubic-bezier(0,0,1,1)"}),this.$FxButton.animate({left:i,width:t},{duration:350,equation:"cubic-bezier(0.34,1.31,0.7,1)"})}},setSilentOn:function(){this.$triggerEvents=!1,this.on(),this.$triggerEvents=!0},setSilentOff:function(){this.$triggerEvents=!1,this.off(),this.$triggerEvents=!0},enable:function(){this.$disabled=!1},disable:function(){this.$disabled=!0},$onSetAttribute:function(t,i){this.$Elm&&"title"==t&&this.$Elm.set("title",i)}})});
//# sourceMappingURL=Switch.js.map