//>>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,f,w,q,x){h=n(f("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;f("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(f("windows-theme"))b.set(this.domNode,"width","100%");else{var a=b.get(this.domNode,"width"),c=a+"px";a=a-b.get(this.knob,"width")+"px";b.set(this.left,"width",c);b.set(this.right,this.isLeftToRight()?{width:c,left:a}:{width:c});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,c){var d="on"===a;this.left.style.display="";this.right.style.display="";this.inner.style.left="";c&&g.add(this.switchNode,"mblSwitchAnimation");g.remove(this.switchNode,d?"mblSwitchOff":"mblSwitchOn");g.add(this.switchNode,d?"mblSwitchOn":"mblSwitchOff");l.set(this.switchNode,"aria-checked",d?"true":"false");d||f("windows-theme")||
(this.inner.style.left=(this.isLeftToRight()?-(b.get(this.domNode,"width")-b.get(this.knob,"width")):0)+"px");var e=this;e.defer(function(){e.left.style.display=d?"":"none";e.right.style.display=d?"none":"";g.remove(e.switchNode,"mblSwitchAnimation")},c?300:0)},_createMaskImage:function(){this._timer&&(this._timer.remove(),delete this._timer);if(!this._hasMaskImage){var a=b.get(this.domNode,"width"),c=b.get(this.domNode,"height");this._width=a-b.get(this.knob,"width");this._hasMaskImage=!0;if(f("mask-image")){var d=
b.get(this.left,"borderTopLeftRadius");if(d&&"0px"!=d){var e=d.split(" ");d=parseFloat(e[0]);e=1==e.length?d:parseFloat(e[1]);d&&e&&w.createRoundMask(this.switchNode,0,0,0,0,a,c,d,e,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")],f("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 c=this.innerStartX+a;c<=-(this._width-10)&&(c=-this._width);-10<=c&&(c=0);this.inner.style.left=c+"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?f("touch")&&f("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 f("dojo-bidi")?n("dojox.mobile.Switch",[h,x]):h});