//>>built
define("dgrid/Keyboard",["dojo/_base/declare","dojo/aspect","dojo/on","./List","dojo/_base/lang","dojo/has","put-selector/put","dojo/_base/Deferred","dojo/_base/sniff"],function(_1,_2,on,_3,_4,_5,_6,_7){var _8={checkbox:1,radio:1,button:1},_9=/\bdgrid-cell\b/,_a=/\bdgrid-row\b/;_5.add("dom-contains",function(){return !!document.createElement("a").contains;});function _b(_c,_d){if(_5("dom-contains")){return _c.contains(_d);}else{return _c.compareDocumentPosition(_d)&8;}};return _1("dgrid.Keyboard",null,{pageSkip:10,tabIndex:0,postCreate:function(){this.inherited(arguments);var _e=this;function _f(_10){var _11=_10.target;return _11.type&&(!_8[_11.type]||_10.keyCode==32);};function _12(_13){var _14=_e.cellNavigation?_9:_a,_15=_13,_16;function _17(_18,_19,_1a){var _1b=_e.cellNavigation?"cell":"row",_1c=_e[_1b](_18);_18=_1c&&_1c.element;if(!_18){return;}_19=_4.mixin({grid:_e},_19);if(_19.type){_19.parentType=_19.type;}if(!_19.bubbles){_19.bubbles=true;}_6(_15,"!dgrid-focus[!tabIndex]");if(_15){if(_5("ie")<8){_15.style.position="";}_19[_1b]=_e[_1b](_15);on.emit(_18,"dgrid-cellfocusout",_19);}_15=_18;_19[_1b]=_1c;if(!_1a){if(_5("ie")<8){_18.style.position="relative";}_18.tabIndex=_e.tabIndex;_18.focus();}_6(_18,".dgrid-focus");on.emit(_15,"dgrid-cellfocusin",_19);};while((_16=_15.firstChild)&&!_14.test(_16.className)){_15=_16;}if(_16){_15=_16;}if(_13===_e.contentNode){_2.after(_e,"renderArray",function(ret){return _7.when(ret,function(ret){if(_14.test(_15.className)&&_b(_13,_15)){return ret;}for(var i=0,_1d=_13.getElementsByTagName("*"),_1e;(_1e=_1d[i]);++i){if(_14.test(_1e.className)){_15=_1e;break;}}_15.tabIndex=_e.tabIndex;return ret;});});}else{if(_14.test(_15.className)){_15.tabIndex=_e.tabIndex;}}on(_13,"mousedown",function(_1f){if(!_f(_1f)){_17(_1f.target,_1f);}});on(_13,"keydown",function(_20){if(_20.metaKey||_20.altKey){return;}var _21=_20.target;var _22=_20.keyCode;if(_f(_20)){return;}var _23={32:0,33:-_e.pageSkip,34:_e.pageSkip,37:-1,38:-1,39:1,40:1,35:10000,36:-10000}[_22];if(isNaN(_23)){return;}var _24,_25,_26=_e.cell(_15);var _27;if(_22==37||_22==39){if(!_e.cellNavigation){return;}_27="right";}else{_27="down";_25=_26&&_26.column&&_26.column.id;_26=_e.row(_15);}if(_23){_26=_26&&_e[_27](_26,_23,true);}var _28=_26&&_26.element;if(_28){if(_25){_28=_e.cell(_28,_25).element;}if(_e.cellNavigation){var _29=_28.getElementsByTagName("input");var _2a;for(var i=0;i<_29.length;i++){var _2b=_29[i];if((_2b.tabIndex!=-1||"lastValue" in _2b)&&!_2b.disabled){if(_5("ie")<8){_2b.style.position="relative";}_2b.focus();if(_5("ie")<8){_2b.style.position="";}_2a=true;break;}}}_17(_28,_20,_2a);}_20.preventDefault();});return function(_2c){_2c=_2c||_15;_17(_2c,{target:_2c});};};if(this.tabableHeader){this.focusHeader=_12(this.headerNode);}this.focus=_12(this.contentNode);}});});