//>>built
define("dojox/mobile/Switch","dojo/_base/array dojo/_base/connect dojo/_base/declare dojo/_base/event dojo/_base/window dojo/dom-class dojo/dom-construct dojo/dom-style dojo/dom-attr dojo/touch dijit/_Contained dijit/_WidgetBase ./sniff ./_maskUtils ./common dojo/has!dojo-bidi?dojox/mobile/bidi/Switch".split(" "),function(r,t,n,u,p,g,k,b,l,m,h,v,e,w,q,x){h=n(e("dojo-bidi")?"dojox.mobile.NonBidiSwitch":"dojox.mobile.Switch",[v,h],{value:"on",name:"",leftLabel:"ON",rightLabel:"OFF",shape:"mblSwDefaultShape",
tabIndex:"0",_setTabIndexAttr:"",baseClass:"mblSwitch",role:"",buildRendering:function(){this.templateString||(this.domNode=this.srcNodeRef&&"SPAN"===this.srcNodeRef.tagName?this.srcNodeRef:k.create("span"));q._setTouchAction(this.domNode,"none");this.inherited(arguments);if(!this.templateString){var a=this.srcNodeRef&&this.srcNodeRef.className||this.className||this["class"];if(a=a.match(/mblSw.*Shape\d*/))this.shape=a;g.add(this.domNode,this.shape);this.domNode.innerHTML='\x3cdiv class\x3d"mblSwitchInner"\x3e\x3cdiv class\x3d"mblSwitchBg mblSwitchBgLeft"\x3e\x3cdiv class\x3d"mblSwitchText mblSwitchTextLeft"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class\x3d"mblSwitchBg mblSwitchBgRight"\x3e\x3cdiv class\x3d"mblSwitchText mblSwitchTextRight"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class\x3d"mblSwitchKnob"\x3e\x3c/div\x3e\x3cinput type\x3d"hidden"'+
(this.name?' name\x3d"'+this.name+'"':"")+' value\x3d"'+this.value+'"\x3e\x3c/div\x3e\x3c/div\x3e';a=this.inner=this.domNode.firstChild;this.left=a.childNodes[0];this.right=a.childNodes[1];this.knob=a.childNodes[2];this.input=a.childNodes[3]}l.set(this.domNode,"role","checkbox");l.set(this.domNode,"aria-checked","on"===this.value?"true":"false");this.switchNode=this.domNode;e("windows-theme")&&(a=k.create("div",{className:"mblSwitchContainer"}),this.labelNode=k.create("label",{"class":"mblSwitchLabel",
"for":this.id},a),a.appendChild(this.domNode.cloneNode(!0)),this.domNode=a,this.focusNode=a.childNodes[1],this.labelNode.innerHTML="off"==this.value?this.rightLabel:this.leftLabel,this.switchNode=this.domNode.childNodes[1],a=this.inner=this.domNode.childNodes[1].firstChild,this.left=a.childNodes[0],this.right=a.childNodes[1],this.knob=a.childNodes[2],this.input=a.childNodes[3])},postCreate:function(){this.connect(this.switchNode,"onclick","_onClick");this.connect(this.switchNode,"onkeydown","_onClick");
this._startHandle=this.connect(this.switchNode,m.press,"onTouchStart");this._initialValue=this.value},startup:function(){var a=this._started;this.inherited(arguments);a||this.resize()},resize:function(){if(e("windows-theme"))b.set(this.domNode,"width","100%");else{var a=b.get(this.domNode,"width"),f=a+"px",a=a-b.get(this.knob,"width")+"px";b.set(this.left,"width",f);b.set(this.right,this.isLeftToRight()?{width:f,left:a}:{width:f});b.set(this.left.firstChild,"width",a);b.set(this.right.firstChild,
"width",a);b.set(this.knob,"left",a);"off"==this.value&&b.set(this.inner,"left",this.isLeftToRight()?"-"+a:0);this._hasMaskImage=!1;this._createMaskImage()}},_changeState:function(a,f){var c="on"===a;this.left.style.display="";this.right.style.display="";this.inner.style.left="";f&&g.add(this.switchNode,"mblSwitchAnimation");g.remove(this.switchNode,c?"mblSwitchOff":"mblSwitchOn");g.add(this.switchNode,c?"mblSwitchOn":"mblSwitchOff");l.set(this.switchNode,"aria-checked",c?"true":"false");c||e("windows-theme")||
(this.inner.style.left=(this.isLeftToRight()?-(b.get(this.domNode,"width")-b.get(this.knob,"width")):0)+"px");var d=this;d.defer(function(){d.left.style.display=c?"":"none";d.right.style.display=c?"none":"";g.remove(d.switchNode,"mblSwitchAnimation")},f?300:0)},_createMaskImage:function(){this._timer&&(this._timer.remove(),delete this._timer);if(!this._hasMaskImage){var a=b.get(this.domNode,"width"),f=b.get(this.domNode,"height");this._width=a-b.get(this.knob,"width");this._hasMaskImage=!0;if(e("mask-image")){var c=
b.get(this.left,"borderTopLeftRadius");if("0px"!=c){var d=c.split(" "),c=parseFloat(d[0]),d=1==d.length?c:parseFloat(d[1]);(this.shape+"Mask"+a+f+c+d).replace(/\./,"_");w.createRoundMask(this.switchNode,0,0,0,0,a,f,c,d,1)}}}},_onClick:function(a){a&&"keydown"===a.type&&13!==a.keyCode||!1===this.onClick(a)||this._moved||(this._set("value",this.input.value="on"==this.value?"off":"on"),this._changeState(this.value,!0),this.onStateChanged(this.value))},onClick:function(){},onTouchStart:function(a){this._moved=
!1;this.innerStartX=this.inner.offsetLeft;this._conn||(this._conn=[this.connect(this.inner,m.move,"onTouchMove"),this.connect(p.doc,m.release,"onTouchEnd")],e("windows-theme")&&this._conn.push(this.connect(p.doc,"MSPointerCancel","onTouchEnd")));this.touchStartX=a.touches?a.touches[0].pageX:a.clientX;this.left.style.display="";this.right.style.display="";u.stop(a);this._createMaskImage()},onTouchMove:function(a){a.preventDefault();if(a.targetTouches){if(1!=a.targetTouches.length)return;a=a.targetTouches[0].clientX-
this.touchStartX}else a=a.clientX-this.touchStartX;var b=this.innerStartX+a;b<=-(this._width-10)&&(b=-this._width);-10<=b&&(b=0);this.inner.style.left=b+"px";10<Math.abs(a)&&(this._moved=!0)},onTouchEnd:function(a){r.forEach(this._conn,t.disconnect);this._conn=null;this.innerStartX==this.inner.offsetLeft?e("touch")&&e("clicks-prevented")&&q._sendClick(this.inner,a):(a=this.inner.offsetLeft<-(this._width/2)?"off":"on",a=this._newState(a),this._changeState(a,!0),a!=this.value&&(this._set("value",this.input.value=
a),this.onStateChanged(a)))},_newState:function(a){return a},onStateChanged:function(a){this.labelNode&&(this.labelNode.innerHTML="off"==a?this.rightLabel:this.leftLabel)},_setValueAttr:function(a){this._changeState(a,!1);this.value!=a&&(this._set("value",this.input.value=a),this.onStateChanged(a))},_setLeftLabelAttr:function(a){this.leftLabel=a;this.left.firstChild.innerHTML=this._cv?this._cv(a):a},_setRightLabelAttr:function(a){this.rightLabel=a;this.right.firstChild.innerHTML=this._cv?this._cv(a):
a},reset:function(){this.set("value",this._initialValue)}});return e("dojo-bidi")?n("dojox.mobile.Switch",[h,x]):h});