//>>built
define("dojox/grid/enhanced/plugins/AutoScroll","dojo/_base/declare dojo/_base/array dojo/_base/lang dojo/_base/html dojo/_base/window ../_Plugin ../../_RowSelector ../../EnhancedGrid".split(" "),function(p,q,r,n,t,u,v,w){p=p("dojox.grid.enhanced.plugins.AutoScroll",u,{name:"autoScroll",autoScrollInterval:1E3,autoScrollMargin:30,constructor:function(c,a){this.grid=c;this._scrolling=this.readyForAutoScroll=!1;a=r.isObject(a)?a:{};"interval"in a&&(this.autoScrollInterval=a.interval);"margin"in a&&(this.autoScrollMargin=
a.margin);this._initEvents();this._mixinGrid()},_initEvents:function(){var c=this.grid;this.connect(c,"onCellMouseDown",function(){this.readyForAutoScroll=!0});this.connect(c,"onHeaderCellMouseDown",function(){this.readyForAutoScroll=!0});this.connect(c,"onRowSelectorMouseDown",function(){this.readyForAutoScroll=!0});this.connect(t.doc,"onmouseup",function(a){this._manageAutoScroll(!0);this.readyForAutoScroll=!1});this.connect(t.doc,"onmousemove",function(a){if(this.readyForAutoScroll){this._event=
a;var b=n.position(c.domNode),f=c._getHeaderHeight(),e=this.autoScrollMargin,g=a.clientY,d=a.clientX;a=b.y;var k=b.x,h=b.h;b=b.w;if(d>=k&&d<=k+b){if(g>=a+f&&g<a+f+e){this._manageAutoScroll(!1,!0,!1);return}if(g>a+h-e&&g<=a+h){this._manageAutoScroll(!1,!0,!0);return}if(g>=a&&g<=a+h&&q.some(c.views.views,function(l,x){if(l instanceof v)return!1;var m=n.position(l.domNode);return d<m.x+e&&d>=m.x?(this._manageAutoScroll(!1,!1,!1,l),!0):d>m.x+m.w-e&&d<m.x+m.w?(this._manageAutoScroll(!1,!1,!0,l),!0):!1},
this))return}this._manageAutoScroll(!0)}})},_mixinGrid:function(){var c=this.grid;c.onStartAutoScroll=function(){};c.onEndAutoScroll=function(){}},_fireEvent:function(c,a){var b=this.grid;switch(c){case "start":b.onStartAutoScroll.apply(b,a);break;case "end":b.onEndAutoScroll.apply(b,a)}},_manageAutoScroll:function(c,a,b,f){c?(this._scrolling=!1,clearInterval(this._handler)):this._scrolling||(this._scrolling=!0,this._fireEvent("start",[a,b,f]),this._autoScroll(a,b,f),this._handler=setInterval(r.hitch(this,
"_autoScroll",a,b,f),this.autoScrollInterval))},_autoScroll:function(c,a,b){var f=this.grid,e=null;if(c){var g=f.scroller.firstVisibleRow+(a?1:-1);0<=g&&g<f.rowCount&&(f.scrollToRow(g),e=g)}else e=this._scrollColumn(a,b);null!==e&&this._fireEvent("end",[c,a,b,e,this._event])},_scrollColumn:function(c,a){var b=a.scrollboxNode,f=null;if(b.clientWidth<b.scrollWidth){var e=q.filter(this.grid.layout.cells,function(l){return!l.hidden}),g=n.position(a.domNode),d;if(c){var k=b.clientWidth;for(d=0;d<e.length;++d){var h=
n.position(e[d].getHeaderNode());h=h.x-g.x+h.w;if(h>k){f=e[d].index;b.scrollLeft+=h-k+10;break}}}else for(k=0,d=e.length-1;0<=d;--d)if(h=n.position(e[d].getHeaderNode()),h=h.x-g.x,h<k){f=e[d].index;b.scrollLeft+=h-k-10;break}}return f}});w.registerPlugin(p);return p});