!function(r){r.jqx.jqxWidget("jqxSwitchButton","",{}),r.extend(r.jqx._jqxSwitchButton.prototype,{defineInstance:function(){var t={disabled:!1,checked:!1,onLabel:"On",offLabel:"Off",toggleMode:"default",animationDuration:250,width:90,height:30,animationEnabled:!0,thumbSize:"40%",orientation:"horizontal",switchRatio:"50%",metroMode:!1,_isMouseDown:!1,rtl:!1,_dimensions:{horizontal:{size:"width",opSize:"height",oSize:"outerWidth",opOSize:"outerHeight",pos:"left",oPos:"top",opposite:"vertical"},vertical:{size:"height",opSize:"width",oSize:"outerHeight",opOSize:"outerWidth",pos:"top",oPos:"left",opposite:"horizontal"}},_touchEvents:{mousedown:"touchstart",click:"touchend",mouseup:"touchend",mousemove:"touchmove",mouseenter:"mouseenter",mouseleave:"mouseleave"},_borders:{},_isTouchDevice:!1,_distanceRequired:3,_isDistanceTraveled:!1,_thumb:void 0,_onLabel:void 0,_offLabel:void 0,_wrapper:void 0,_animationActive:!1,aria:{"aria-checked":{name:"checked",type:"boolean"},"aria-disabled":{name:"disabled",type:"boolean"}},_events:["checked","unchecked","change"]};return this===r.jqx._jqxSwitchButton.prototype||r.extend(!0,this,t),t},createInstance:function(t){if(this._createFromInput(),this.element.nodeName&&("INPUT"==this.element.nodeName||"BUTTON"==this.element.nodeName))throw"jqxSwitchButton can be rendered only from a DIV tag.";this.host.attr("role","checkbox"),r.jqx.aria(this),this.render();var e=this;e.element.tabIndex||e.host.attr("tabindex",0),r.jqx.utilities.resize(this.host,function(){e.element.innerHTML="",e.render()})},_createFromInput:function(){var t,e,i,s=this;"input"==s.element.nodeName.toLowerCase()&&(s.field=s.element,s.field.className&&(s._className=s.field.className),i={title:s.field.title},s.field.value&&(i.value=s.field.value),s.field.checked&&(i.checked=!0),s.field.id.length?i.id=s.field.id.replace(/[^\w]/g,"_")+"_jqxSwitchButton":i.id=r.jqx.utilities.createId()+"_jqxSwitchButton",(t=r("
",i))[0].style.cssText=s.field.style.cssText,s.width||(s.width=r(s.field).width()),s.height||(s.height=r(s.field).outerHeight()),r(s.field).hide().after(t),e=s.host.data(),s.host=t,s.host.data(e),s.element=t[0],s.element.id=s.field.id,s.field.id=i.id,s._className&&(s.host.addClass(s._className),r(s.field).removeClass(s._className)),s.field.tabIndex&&(i=s.field.tabIndex,s.field.tabIndex=-1,s.element.tabIndex=i))},resize:function(t,e){this.width=t,this.height=e,this.render()},render:function(){this.innerHTML="",!this.theme||""==this.theme||-1==this.theme.indexOf("metro")&&-1==this.theme.indexOf("windowsphone")&&-1==this.theme.indexOf("office")||("40%"==this.thumbSize&&(this.thumbSize=12),this.metroMode=!0);var t=r.data(document.body,"jqx-switchbutton")||1;this._idHandler(t),r.data(document.body,"jqx-draggables",++t),this._isTouchDevice=r.jqx.mobile.isTouchDevice(),this.switchRatio=parseInt(this.switchRatio,10),this._render(),this._addClasses(),this._performLayout(),this._removeEventHandlers(),this._addEventHandles(),this._disableSelection();var e=this;this.canRaiseEvents=!1,this.checked||this._switchButton(this.checked,0,!1),this.disabled&&(this.element.disabled=!0),setTimeout(function(){e.host.hide(),e.host.show(1)},250)},setOnLabel:function(t){this._onLabel.html(''+t+"
"),this._centerLabels()},setOffLabel:function(t){this._offLabel.html(''+t+"
"),this._centerLabels()},toggle:function(){this.checked?this.uncheck():this.check()},val:function(t){return 0==arguments.length||null!=t&&"object"==typeof t||("string"==typeof t?("true"==t&&this.check(),"false"==t&&this.uncheck(),""==t&&this.indeterminate()):(1==t&&this.check(),0==t&&this.uncheck(),null==t&&this.indeterminate())),this.checked},uncheck:function(){this._switchButton(!1),r.jqx.aria(this,"aria-checked",this.checked)},check:function(){this._switchButton(!0),r.jqx.aria(this,"aria-checked",this.checked)},_idHandler:function(t){this.element.id||(t="jqx-switchbutton-"+t,this.element.id=t)},_dir:function(t){return this._dimensions[this.orientation][t]},_getEvent:function(t){if(this._isTouchDevice){var e=this._touchEvents[t];return r.jqx.mobile.getTouchEventName(e)}return t},_render:function(){this._thumb=r(""),this._onLabel=r(""),this._offLabel=r(""),this._wrapper=r(""),this._onLabel.appendTo(this.host),this._thumb.appendTo(this.host),this._offLabel.appendTo(this.host),this.host.wrapInner(this._wrapper),this._wrapper=this.host.children(),this.setOnLabel(this.onLabel),this.setOffLabel(this.offLabel)},_addClasses:function(){var t=this._thumb,e=this._onLabel,i=this._offLabel;this.host.addClass(this.toThemeProperty("jqx-switchbutton")),this.host.addClass(this.toThemeProperty("jqx-widget")),this.host.addClass(this.toThemeProperty("jqx-widget-content")),this._wrapper.addClass(this.toThemeProperty("jqx-switchbutton-wrapper")),t.addClass(this.toThemeProperty("jqx-fill-state-normal")),t.addClass(this.toThemeProperty("jqx-switchbutton-thumb")),e.addClass(this.toThemeProperty("jqx-switchbutton-label-on")),e.addClass(this.toThemeProperty("jqx-switchbutton-label")),i.addClass(this.toThemeProperty("jqx-switchbutton-label-off")),i.addClass(this.toThemeProperty("jqx-switchbutton-label")),this.checked?this.host.addClass(this.toThemeProperty("jqx-switchbutton-on")):this.host.removeClass(this.toThemeProperty("jqx-switchbutton-on"))},_performLayout:function(){var t,e=this.host,i=this._dir("opSize"),s=this._dir("size"),h=this._wrapper;e.css({width:this.width,height:this.height}),h.css(i,e[i]()),this._thumbLayout(),this._labelsLayout(),t=this._borders[this._dir("opposite")],h.css(s,e[s]()+this._offLabel[this._dir("oSize")]()+t),h.css(i,e[i]()),(this.metroMode||this.theme&&""!=this.theme&&(-1!=this.theme.indexOf("metro")||-1!=this.theme.indexOf("office")))&&(this._thumb,h=this._onLabel,i=this._offLabel,h.css("position","relative"),h.css("top","1px"),h.css("margin-left","1px"),i.css("position","relative"),i.css("top","1px"),i.css("left","-2px"),i.css("margin-right","1px"),i.height(h.height()-2),i.width(h.width()-3),h.height(h.height()-2),h.width(h.width()-3),this._thumb[this._dir("size")](this.thumbSize+3),this._thumb.css("top","-1px"),this._thumb[this._dir("opSize")](e[this._dir("opSize")]()+2),this._thumb.css("position","relative"),this.host.css("overflow","hidden"),this.checked?(this._onLabel.css("visibility","visible"),this._offLabel.css("visibility","hidden"),this._thumb.css("left","0px")):(this._onLabel.css("visibility","hidden"),this._offLabel.css("visibility","visible"),this._thumb.css("left","-2px")))},_thumbLayout:function(){var t=this.thumbSize,e=this.host;0<=t.toString().indexOf("%")&&(t=e[this._dir("size")]()*parseInt(t,10)/100),this._thumb[this._dir("size")](t),this._thumb[this._dir("opSize")](e[this._dir("opSize")]()),this._handleThumbBorders()},_handleThumbBorders:function(){this._borders.horizontal=parseInt(this._thumb.css("border-left-width"),10)||0,this._borders.horizontal+=parseInt(this._thumb.css("border-right-width"),10)||0,this._borders.vertical=parseInt(this._thumb.css("border-top-width"),10)||0,this._borders.vertical+=parseInt(this._thumb.css("border-bottom-width"),10)||0;var t=this._borders[this._dir("opposite")];"horizontal"===this.orientation?(this._thumb.css("margin-top",-t/2),this._thumb.css("margin-left",0)):(this._thumb.css("margin-left",-t/2),this._thumb.css("margin-top",0))},_labelsLayout:function(){var t=this.host,e=this._thumb,i=this._dir("opSize"),s=this._dir("size"),h=this._dir("oSize"),e=t[s]()-e[h](),h=this._borders[this._dir("opposite")]/2;this._onLabel[s](e+h),this._offLabel[s](e+h),this.rtl&&this._onLabel[s](e+2*h),this._onLabel[i](t[i]()),this._offLabel[i](t[i]()),this._orderLabels(),this._centerLabels()},_orderLabels:function(){var t;"horizontal"===this.orientation?(t="left",this.rtl&&(t="right"),this._onLabel.css("float",t),this._thumb.css("float",t),this._offLabel.css("float",t)):(this._onLabel.css("display","block"),this._offLabel.css("display","block"))},_centerLabels:function(){var t=this._onLabel.children("div"),e=this._offLabel.children("div"),i=t.parent().height(),s=t.outerHeight(),h=this._borders[this.orientation]/2||0;0==s&&(s=14);h=Math.floor((i-s)/2)+h;t.css("margin-top",h),e.css("margin-top",h)},_removeEventHandlers:function(){var t="."+this.element.id;this.removeHandler(this._wrapper,this._getEvent("click")+t,this._clickHandle),this.removeHandler(this._thumb,this._getEvent("mousedown")+t,this._mouseDown),this.removeHandler(r(document),this._getEvent("mouseup")+t,this._mouseUp),this.removeHandler(r(document),this._getEvent("mousemove")+t,this._mouseMove),this.removeHandler(this._thumb,"mouseenter"+t),this.removeHandler(this._thumb,"mouseleave"+t),this.removeHandler(this._wrapper,"focus"+t),this.removeHandler(this._wrapper,"blur"+t)},_addEventHandles:function(){var t="."+this.element.id,e=this;this.addHandler(this.host,"focus"+t,function(t){return e.host.addClass(e.toThemeProperty("jqx-fill-state-focus")),!1}),this.addHandler(this.host,"blur"+t,function(){e.host.removeClass(e.toThemeProperty("jqx-fill-state-focus"))}),this.addHandler(this._thumb,"mouseenter"+t,function(){e._thumb.addClass(e.toThemeProperty("jqx-fill-state-hover"))}),this.addHandler(this._thumb,"mouseleave"+t,function(){e._thumb.removeClass(e.toThemeProperty("jqx-fill-state-hover"))}),this.addHandler(this._wrapper,this._getEvent("click")+t,this._clickHandle,{self:this}),this.addHandler(this._thumb,this._getEvent("mousedown")+t,this._mouseDown,{self:this}),this.addHandler(r(document),this._getEvent("mouseup")+t,this._mouseUp,{self:this}),this.addHandler(r(document),this._getEvent("mousemove")+t,this._mouseMove,{self:this})},enable:function(){this.disabled=!1,this.element.disabled=!1,r.jqx.aria(this,"aria-disabled",this.disabled)},disable:function(){this.disabled=!0,this.element.disabled=!0,r.jqx.aria(this,"aria-disabled",this.disabled)},_clickHandle:function(t){t=t.data.self;"click"!==t.toggleMode&&"default"!==t.toggleMode||t.disabled||t._isDistanceTraveled||t._dragged||(t._wrapper.stop(),t.toggle()),t._thumb.removeClass(t.toThemeProperty("jqx-fill-state-pressed"))},_mouseDown:function(t){var e=t.data.self,i=e._wrapper;e.metroMode&&(e.host.css("overflow","hidden"),e._onLabel.css("visibility","visible"),e._offLabel.css("visibility","visible")),e._mouseStartPosition=e._getMouseCoordinates(t),e._buttonStartPosition={left:parseInt(i.css("margin-left"),10)||0,top:parseInt(i.css("margin-top"),10)||0},e.disabled||"slide"!==e.toggleMode&&"default"!==e.toggleMode||(e._wrapper.stop(),e._isMouseDown=!0,e._isDistanceTraveled=!1,e._dragged=!1),e._thumb.addClass(e.toThemeProperty("jqx-fill-state-pressed"))},_mouseUp:function(t){var e=t.data.self;e.metroMode,e._isMouseDown=!1,e._thumb.removeClass(e.toThemeProperty("jqx-fill-state-pressed")),e._isDistanceTraveled&&(t=e._wrapper,t=parseInt(t.css("margin-"+e._dir("pos")),10)||0,e._dropHandler(t)?e._switchButton(!e.checked):e._switchButton(e.checked,null,!0),e._isDistanceTraveled=!1)},_mouseMove:function(t){var e=t.data.self,i=e._getMouseCoordinates(t);if(e._isMouseDown&&e._distanceTraveled(i)){var s=e._dir("pos"),t=e._wrapper,s=e._buttonStartPosition[s]+i[s]-e._mouseStartPosition[s],s=e._validatePosition(s);return e._dragged=!0,t.css("margin-"+e._dir("pos"),s),e._onLabel.css("visibility","visible"),e._offLabel.css("visibility","visible"),!1}},_distanceTraveled:function(t){if(this._isDistanceTraveled)return!0;if(this._isMouseDown){var e=this._mouseStartPosition,i=this._distanceRequired;return this._isDistanceTraveled=Math.abs(t.left-e.left)>=i||Math.abs(t.top-e.top)>=i,this._isDistanceTraveled}return!1},_validatePosition:function(t){var e=this._borders[this._dir("opposite")],e=-(this.host[this._dir("size")]()-this._thumb[this._dir("oSize")]())-e;return 0