//>>built
define("dojox/av/widget/VolumeButton",["dojo","dijit","dijit/_Widget","dijit/_TemplatedMixin","dijit/form/Button"],function(a,g,e,f,h){return a.declare("dojox.av.widget.VolumeButton",[e,f],{templateString:a.cache("dojox.av.widget","resources/VolumeButton.html"),postCreate:function(){this.handleWidth=a.marginBox(this.handle).w;this.width=a.marginBox(this.volumeSlider).w;this.slotWidth=100;a.setSelectable(this.handle,!1);this.volumeSlider=this.domNode.removeChild(this.volumeSlider)},setMedia:function(b){this.media=
b;this.updateIcon()},updateIcon:function(b){b=void 0===b?this.media.volume():b;0===b?a.attr(this.domNode,"class","Volume mute"):.334>b?a.attr(this.domNode,"class","Volume low"):.667>b?a.attr(this.domNode,"class","Volume med"):a.attr(this.domNode,"class","Volume high")},onShowVolume:function(b){void 0==this.showing&&(a.body().appendChild(this.volumeSlider),this.showing=!1);if(this.showing)this.onHideVolume();else{var c=this.media.volume(),d=this._getVolumeDim();b=this._getHandleDim();this.x=d.x-this.width;
a.style(this.volumeSlider,"display","");a.style(this.volumeSlider,"top",d.y+"px");a.style(this.volumeSlider,"left",this.x+"px");c*=this.slotWidth;a.style(this.handle,"top",2+b.w/2+"px");a.style(this.handle,"left",c+7+b.h/2+"px");this.showing=!0;this.clickOff=a.connect(a.doc,"onmousedown",this,"onDocClick")}},onDocClick:function(b){if(!a.isDescendant(b.target,this.domNode)&&!a.isDescendant(b.target,this.volumeSlider))this.onHideVolume()},onHideVolume:function(){this.endDrag();a.style(this.volumeSlider,
"display","none");this.showing=!1},onDrag:function(b){var c=this.handleWidth/2,d=c+this.slotWidth;b=b.clientX-this.x;b<c&&(b=c);b>d&&(b=d);a.style(this.handle,"left",b+"px");c=(b-c)/(d-c);this.media.volume(c);this.updateIcon(c)},startDrag:function(){this.isDragging=!0;this.cmove=a.connect(a.doc,"mousemove",this,"onDrag");this.cup=a.connect(a.doc,"mouseup",this,"endDrag")},endDrag:function(){this.isDragging=!1;this.cmove&&a.disconnect(this.cmove);this.cup&&a.disconnect(this.cup);this.handleOut()},
handleOver:function(){a.addClass(this.handle,"over")},handleOut:function(){this.isDragging||a.removeClass(this.handle,"over")},_getVolumeDim:function(){return this._domCoords?this._domCoords:this._domCoords=a.coords(this.domNode)},_getHandleDim:function(){return this._handleCoords?this._handleCoords:this._handleCoords=a.marginBox(this.handle)},onResize:function(b){this.onHideVolume();this._domCoords=null}})});