/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */
//>>built
define("esri/MouseEvents",["dojo/_base/declare","dojo/_base/html","dojo/_base/lang","dojo/_base/sniff","dojo/_base/connect","dojo/_base/event","esri/kernel","esri/Evented","esri/geometry/Point","esri/geometry/ScreenPoint"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a){var _b=_5.connect,_c=_5.disconnect;var _d=_1([_8],{declaredClass:"esri.MouseEvents",doubleClickDuration:300,minWheelValue:1,maxWheelValue:1,mozWheelDivisor:_4("mac")!==-1?1:3,wheelDivisor:_4("chrome")<2?360:120,preventPageScroll:true,map:null,constructor:function(_e,_f){this.node=_e;_3.mixin(this,_f);var _10=function(evt){_6.stop(evt);return false;};if(_4("mozilla")){_2.style(_e,"MozUserSelect","none");}this._handles=[_b(_e,"onselectstart",_10),_b(_e,"ondragstart",_10),_b(_e,"onmouseenter",this,this._onMouseEnterHandler),_b(_e,"onmouseleave",this,this._onMouseLeaveHandler),_b(_e,"onmousedown",this,this._onMouseDownHandler),_b(_e,"onclick",this,this._onClickHandler),_b(_e,"ondblclick",this,this._onDblClickHandler)];this._onMouseMoveHandler_connect=_b(_e,"onmousemove",this,this._onMouseMoveHandler);this._onMouseUpHandler_connect=_b(_e,"onmouseup",this,this._onMouseUpHandler);this._fireClickEvent=_3.hitch(this,this._fireClickEvent);this._initialDuration=this.doubleClickDuration;var map=this.map;this.preventPageScroll=map?(map.isScrollWheelZoom||map.isScrollWheelPan):this.preventPageScroll;this.enableMouseWheel(false);},_fire:function(_11,evt){if(this[_11]){this[_11](evt);}if(this.map){if(this.map[_11]){this.map[_11](evt);}}},_processEvent:function(evt){evt=_6.fix(evt,evt.target);var map=this.map,pos=map&&map.position;if(pos){if(evt.type==="DOMMouseScroll"&&_4("ff")<3){evt.screenPoint=new _a(window.scrollX+evt.screenX-pos.x,window.scrollY+evt.screenY-pos.y);}else{evt.screenPoint=new _a(evt.pageX-pos.x,evt.pageY-pos.y);}evt.mapPoint=map.extent?map.toMap(evt.screenPoint):new _9();}evt.numPoints=0;return evt;},_onMouseEnterHandler:function(evt){_c(this._onKeyDown_connect);_c(this._onKeyUp_connect);this._onKeyDown_connect=_b(document,"onkeydown",this,this._onKeyDownHandler);this._onKeyUp_connect=_b(document,"onkeyup",this,this._onKeyUpHandler);this._fire("onMouseOver",this._processEvent(evt));},_onMouseLeaveHandler:function(evt){_c(this._onKeyDown_connect);_c(this._onKeyUp_connect);this._onKeyDown_connect=this._onKeyUp_connect=null;this._fire("onMouseOut",this._processEvent(evt));},_onMouseMoveHandler:function(evt){if(this._dragEnd){this._dragEnd=false;return;}this._fire("onMouseMove",this._processEvent(evt));},_onMouseDownHandler:function(evt){_c(this._onMouseMoveHandler_connect);this._onMouseMoveHandler_connect=null;if(this.node.setCapture){this.node.setCapture(false);}this._onMouseDragHandler_connect=_b(document,"onmousemove",this,this._onMouseDragHandler);this._startX=evt.pageX;this._startY=evt.pageY;this._fire("onMouseDown",this._processEvent(evt));},_onMouseUpHandler:function(evt){var _12=this.node;if(_12.releaseCapture){_12.releaseCapture();}_c(this._onMouseDragHandler_connect);this._onMouseDragHandler_connect=null;_c(this._onMouseMoveHandler_connect);this._onMouseMoveHandler_connect=_b(_12,"onmousemove",this,this._onMouseMoveHandler);this._fire("onMouseUp",this._processEvent(evt));},_onMouseDragHandler:function(evt){_c(this._onMouseDragHandler_connect);this._onMouseDragHandler_connect=_b(document,"onmousemove",this,this._onMouseDraggingHandler);_c(this._onMouseUpHandler_connect);this._onMouseUpHandler_connect=_b(document,"onmouseup",this,this._onDragMouseUpHandler);this._docLeaveConnect=_b(document,"onmouseout",this,this._onDocMouseOut);this._fire("onMouseDragStart",this._processEvent(evt));},_onMouseDraggingHandler:function(evt){_6.stop(evt);this._fire("onMouseDrag",this._processEvent(evt));},_onDragMouseUpHandler:function(evt){var _13=this.node;if(_13.releaseCapture){_13.releaseCapture();}this._dragEnd=true;_c(this._docLeaveConnect);_c(this._onMouseDragHandler_connect);_c(this._onMouseUpHandler_connect);this._docLeaveConnect=this._onMouseDragHandler_connect=null;this._onMouseMoveHandler_connect=_b(_13,"onmousemove",this,this._onMouseMoveHandler);this._onMouseUpHandler_connect=_b(_13,"onmouseup",this,this._onMouseUpHandler);evt=this._processEvent(evt);this._fire("onMouseDragEnd",evt);this._fire("onMouseUp",evt);},_onDocMouseOut:function(evt){var _14=evt.relatedTarget,_15=evt.relatedTarget&&evt.relatedTarget.nodeName.toLowerCase();if(!_14||(_4("chrome")&&_15==="html")){this._onDragMouseUpHandler(evt);}},_onClickHandler:function(evt){evt=this._processEvent(evt);if(evt.pageX!==this._startX||evt.pageY!==this._startY){return;}clearTimeout(this._clickTimer);this._clickEvent=_3.mixin({},evt);this._clickTimer=setTimeout(this._fireClickEvent,this.doubleClickDuration);},_fireClickEvent:function(){clearTimeout(this._clickTimer);if(_4("ie")<9){this._clickEvent.graphic=_7._ieGraphic;delete _7._ieGraphic;}this._fire("onClick",this._clickEvent);},_onDblClickHandler:function(evt){clearTimeout(this._clickTimer);this._fire("onDblClick",this._processEvent(evt));},_onMouseWheelHandler:function(evt){var map=this.map,_16=map?(map.isScrollWheelZoom||map.isScrollWheelPan):this.preventPageScroll;if(_16){_6.stop(evt);}var _17=_4("ie")||_4("webkit")?evt.wheelDelta/this.wheelDivisor:-evt.detail/this.mozWheelDivisor,_18=Math.abs(_17);if(_18<=this.minWheelValue){_18=this.minWheelValue;}else{_18=this.maxWheelValue;}evt.value=_17<0?-_18:_18;this._fire("onMouseWheel",this._processEvent(evt));},_onKeyDownHandler:function(evt){this._fire("onKeyDown",evt);},_onKeyUpHandler:function(evt){this._fire("onKeyUp",evt);},enableMouseWheel:function(_19){_c(this._scrollHandle);this._scrollHandle=_b(this.node,(_4("ff")||_4("mozilla"))?(_19?"MozMousePixelScroll":"DOMMouseScroll"):"onmousewheel",this,this._onMouseWheelHandler);},setImmediateClick:function(_1a){this.doubleClickDuration=_1a?0:this._initialDuration;},destroy:function(){var _1b=this._handles.concat([this._onMouseMoveHandler_connect,this._onMouseUpHandler_connect,this._onMouseDragHandler_connect,this._scrollHandle,this._onKeyDown_connect,this._onKeyUp_connect,this._docLeaveConnect]),i;for(i=0;i<_1b.length;i++){_c(_1b[i]);}clearTimeout(this._clickTimer);this.node=this.map=this._handles=this._clickEvent=this._onMouseMoveHandler_connect=this._onMouseUpHandler_connect=this._onMouseDragHandler_connect=this._scrollHandle=this._onKeyDown_connect=this._onKeyUp_connect=this._docLeaveConnect=null;}});if(_4("extend-esri")){_7.MouseEvents=_d;}return _d;});