//>>built
define("dojox/calendar/Keyboard","dojo/_base/array dojo/_base/lang dojo/_base/declare dojo/on dojo/_base/event dojo/keys".split(" "),function(q,p,r,t,l,e){return r("dojox.calendar.Keyboard",null,{keyboardUpDownUnit:"minute",keyboardUpDownSteps:15,keyboardLeftRightUnit:"day",keyboardLeftRightSteps:1,allDayKeyboardUpDownUnit:"day",allDayKeyboardUpDownSteps:7,allDayKeyboardLeftRightUnit:"day",allDayKeyboardLeftRightSteps:1,postCreate:function(){this.inherited(arguments);this._viewHandles.push(t(this.domNode,
"keydown",p.hitch(this,this._onKeyDown)))},resizeModifier:"ctrl",maxScrollAnimationDuration:1E3,tabIndex:"0",focusedItem:null,_isItemFocused:function(b){return null!=this.focusedItem&&this.focusedItem.id==b.id},_setFocusedItemAttr:function(b){if(b!=this.focusedItem){var a=this.focusedItem;this._set("focusedItem",b);this.updateRenderers([a,this.focusedItem],!0);this.onFocusChange({oldValue:a,newValue:b})}null!=b&&(null!=this.owner&&null!=this.owner.get("focusedItem")&&this.owner.set("focusedItem",
null),null!=this._secondarySheet&&null!=this._secondarySheet.set("focusedItem")&&this._secondarySheet.set("focusedItem",null))},onFocusChange:function(b){},showFocus:!1,_focusNextItem:function(b){if(!this.renderData||!this.renderData.items||0==this.renderData.items.length)return null;var a=-1,c=this.renderData.items,h=c.length-1,f=this.get("focusedItem");null==f?a=0<b?0:h:(q.some(c,p.hitch(this,function(b,c){var d=b.id==f.id;d&&(a=c);return d})),a=this._focusNextItemImpl(b,a,h));for(var g=!1,d=-1;d!=
a&&(!g||0!=a);){g||0!=a||(g=!0);d=c[a];if(null!=this.rendererManager.itemToRenderer[d.id]){this.set("focusedItem",d);break}d=a;a=this._focusNextItemImpl(b,a,h)}},_focusNextItemImpl:function(b,a,c){if(-1==a)a=0<b?0:c;else{if(0==a&&-1==b||a==c&&1==b)return a;a=0<b?++a:--a}return a},_handlePrevNextKeyCode:function(b,a){this.isLeftToRight()||(a=1==a?-1:1);this.showFocus=!0;this._focusNextItem(a);var c=this.get("focusedItem");!b.ctrlKey&&c&&this.set("selectedItem",c);c&&this.ensureVisibility(c.startTime,
c.endTime,"both",void 0,this.maxScrollAnimationDuration)},_checkDir:function(b,a){return this.isLeftToRight()&&b==a||!this.isLeftToRight()&&b==("left"==a?"right":"left")},_keyboardItemEditing:function(b,a){l.stop(b);var c=this._edProps,h,f;c.editedItem.allDay||this.roundToDay||"label"==c.rendererKind?(h="up"==a||"down"==a?this.allDayKeyboardUpDownUnit:this.allDayKeyboardLeftRightUnit,f="up"==a||"down"==a?this.allDayKeyboardUpDownSteps:this.allDayKeyboardLeftRightSteps):(h="up"==a||"down"==a?this.keyboardUpDownUnit:
this.keyboardLeftRightUnit,f="up"==a||"down"==a?this.keyboardUpDownSteps:this.keyboardLeftRightSteps);if("up"==a||this._checkDir(a,"left"))f=-f;var g=b[this.resizeModifier+"Key"]?"resizeEnd":"move",d="resizeEnd"==g?c.editedItem.endTime:c.editedItem.startTime,e=d,k=c.editedItem.subColumn;if("move"==g&&this.subColumns&&1<this.subColumns.length){var m=this.getSubColumnIndex(k),n=!0;-1!=m&&(this._checkDir(a,"left")?0==m?k=this.subColumns[this.subColumns.length-1]:(n=!1,k=this.subColumns[m-1]):this._checkDir(a,
"right")&&(m==this.subColumns.length-1?k=this.subColumns[0]:(n=!1,k=this.subColumns[m+1])),n&&(e=this.renderData.dateModule.add(d,h,f)))}else e=this.renderData.dateModule.add(d,h,f);this._startItemEditingGesture([d],g,"keyboard",b);this._moveOrResizeItemGesture([e],"keyboard",b,k);this._endItemEditingGesture(g,"keyboard",b,!1);"move"==g?-1==this.renderData.dateModule.compare(e,d)?this.ensureVisibility(c.editedItem.startTime,c.editedItem.endTime,"start"):this.ensureVisibility(c.editedItem.startTime,
c.editedItem.endTime,"end"):this.ensureVisibility(c.editedItem.startTime,c.editedItem.endTime,"end")},_onKeyDown:function(b){var a=this.get("focusedItem");switch(b.keyCode){case e.ESCAPE:this._isEditing&&(this._editingGesture&&this._endItemEditingGesture("keyboard",b,!0),this._endItemEditing("keyboard",!0),this._edProps=null);break;case e.SPACE:l.stop(b);null!=a&&this.setItemSelected(a,b.ctrlKey?!this.isItemSelected(a):!0);break;case e.ENTER:l.stop(b);null!=a&&(this._isEditing?this._endItemEditing("keyboard",
!1):(b=this.rendererManager.itemToRenderer[a.id])&&0<b.length&&this.isItemEditable(a,b[0].kind)&&(this._edProps={renderer:b[0],rendererKind:b[0].kind,tempEditedItem:a,liveLayout:this.liveLayout},this.set("selectedItem",a),this._startItemEditing(a,"keyboard")));break;case e.LEFT_ARROW:l.stop(b);this._isEditing?this._keyboardItemEditing(b,"left"):this._handlePrevNextKeyCode(b,-1);break;case e.RIGHT_ARROW:l.stop(b);this._isEditing?this._keyboardItemEditing(b,"right"):this._handlePrevNextKeyCode(b,1);
break;case e.UP_ARROW:this._isEditing?this._keyboardItemEditing(b,"up"):this.scrollable&&this.scrollView(-1);break;case e.DOWN_ARROW:this._isEditing?this._keyboardItemEditing(b,"down"):this.scrollable&&this.scrollView(1)}}})});