//>>built define("dojo/_base/declare dojo/aspect dojo/dom-class dojo/on dojo/_base/lang dojo/has ./util/misc dojo/_base/sniff".split(" "),function(q,n,r,p,t,v,E){function w(a){a.preventDefault()}var F={checkbox:1,radio:1,button:1},x=/\bdgrid-cell\b/,y=/\bdgrid-row\b/,d=q(null,{pageSkip:10,tabIndex:0,keyMap:null,headerKeyMap:null,postMixInProperties:function(){this.inherited(arguments);this.keyMap||(this.keyMap=t.mixin({},d.defaultKeyMap));this.headerKeyMap||(this.headerKeyMap=t.mixin({},d.defaultHeaderKeyMap))}, postCreate:function(){function a(a){var b=a.target;return b.type&&(!F[b.type]||32===a.keyCode)}function c(c){function e(){b._focusedHeaderNode&&(b._focusedHeaderNode.tabIndex=-1);if(b.showHeader){if(d)for(var a=b.headerNode.getElementsByTagName("th"),c=0,e;e=a[c];++c){if(k.test(e.className)){b._focusedHeaderNode=l=e;break}}else b._focusedHeaderNode=l=b.headerNode;l&&(l.tabIndex=b.tabIndex)}}function f(){var a=b._focusedNode||l;if(!k.test(a.className)||!c.contains(a)){for(var e=c.getElementsByTagName("*"), d=0,u;u=e[d];++d)if(k.test(u.className)){a=b._focusedNode=u;break}l.tabIndex=-1;a.tabIndex=b.tabIndex}}var d=b.cellNavigation,k=d?x:y,m=c===b.headerNode,l=c;m?(e(),n.after(b,"renderHeader",e,!0)):(n.after(b,"renderArray",f,!0),n.after(b,"_onNotification",function(a,b){0===b.totalLength?c.tabIndex=0:1===b.totalLength&&"add"===b.type&&f()},!0));b._listeners.push(p(c,"mousedown",function(c){a(c)||b._focusOnNode(c.target,m,c)}));b._listeners.push(p(c,"keydown",function(c){if(!c.metaKey&&!c.altKey){var e= b[m?"headerKeyMap":"keyMap"][c.keyCode];e&&!a(c)&&e.call(b,c)}}))}this.inherited(arguments);var b=this;this.tabableHeader&&(c(this.headerNode),p(this.headerNode,"dgrid-cellfocusin",function(){b.scrollTo({x:this.scrollLeft})}));c(this.contentNode);this._debouncedEnsureScroll=E.debounce(this._ensureScroll,this)},_pruneRow:function(){var a=this._focusedNode;this._focusedNode=null;this.inherited(arguments);this._focusedNode=a},removeRow:function(a){if(!this._focusedNode)return this.inherited(arguments); var c=this,b=document.activeElement===this._focusedNode,e=this[this.cellNavigation?"cell":"row"](this._focusedNode),d=e.row||e,f;a=a.element||a;a===d.element&&((f=this.down(d,1,!0))&&f.element!==a||(f=this.up(d,1,!0)),this._removedFocus={active:b,rowId:d.id,columnId:e.column&&e.column.id,siblingId:f&&f.element!==a?f.id:void 0},setTimeout(function(){c._removedFocus&&c._restoreFocus(d.id)},0),this._focusedNode=null);this.inherited(arguments)},insertRow:function(){var a=this.inherited(arguments);this._removedFocus&& !this._removedFocus.wait&&this._restoreFocus(a);return a},_restoreFocus:function(a){var c=this._removedFocus,b;if((a=(a=a&&this.row(a))&&a.element&&a.id===c.rowId?a:"undefined"!==typeof c.siblingId&&this.row(c.siblingId))&&a.element){if(!a.element.parentNode.parentNode){c.wait=!0;return}"undefined"!==typeof c.columnId&&(b=this.cell(a,c.columnId))&&b.element&&(a=b);c.active&&0!==a.element.offsetHeight?this._focusOnNode(a,!1,null):(r.add(a.element,"dgrid-focus"),a.element.tabIndex=this.tabIndex,this._focusedNode= a.element)}delete this._removedFocus},addKeyHandler:function(a,c,b){return n.after(this[b?"headerKeyMap":"keyMap"],a,c,!0)},_ensureRowScroll:function(a){var c=this.getScrollPosition().y;c>a.offsetTop?this.scrollTo({y:a.offsetTop}):c+this.contentNode.offsetHeightb)this.scrollTo({x:b});else{var e=this.bodyNode.clientWidth; a=a.offsetWidth;var d=b+a;c+ea?d-e:b})}},_ensureScroll:function(a,c){!a.column&&!a.row&&a.data&&a.element?this._ensureRowScroll(a.element):(this.cellNavigation&&(this.columnSets||1g.className.indexOf("dgrid-row");)g=g[(c?"next":"previous")+"Sibling"];if(!g)return}!f||1>d.offsetHeight?(b&&(g=this.cell(g,this.cell(a).column.id)),this._focusOnNode(g,!1,a)):k=n.after(this,"renderArray",function(d){var e=d[c?0:d.length-1];b&&(e=this.cell(e,this.cell(a).column.id));this._focusOnNode(e,!1,a);k.remove();return d})},J=d.moveFocusHome=function(a){D.call(this,a,!0)};d.defaultKeyMap={32:w,33:G,34:H,35:D,36:J,37:A,38:q,39:B,40:v};d.defaultHeaderKeyMap={32:w,35:C,36:I,37:A, 39:B};return d});