//>>built
define("dojox/calendar/ViewBase","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/window dojo/_base/event dojo/_base/html dojo/sniff dojo/query dojo/dom dojo/dom-style dojo/dom-class dojo/dom-construct dojo/dom-geometry dojo/on dojo/date dojo/date/locale dojo/when dijit/_WidgetBase dojox/widget/_Invalidating dojox/widget/Selection ./time ./StoreMixin ./StoreManager ./RendererManager".split(" "),function(A,h,q,x,B,J,r,K,L,t,C,D,u,M,v,w,E,F,G,H,p,I,y,z){return A("dojox.calendar.ViewBase",
[F,I,G,H],{datePackage:v,_calendar:"gregorian",viewKind:null,_layoutStep:1,_layoutUnit:"day",resizeCursor:"n-resize",formatItemTimeFunc:null,_cssDays:"Sun Mon Tue Wed Thu Fri Sat".split(" "),_getFormatItemTimeFuncAttr:function(){if(this.formatItemTimeFunc)return this.formatItemTimeFunc;if(null!=this.owner)return this.owner.get("formatItemTimeFunc")},_viewHandles:null,doubleTapDelay:300,constructor:function(a){a=a||{};this._calendar=a.datePackage?a.datePackage.substr(a.datePackage.lastIndexOf(".")+
1):this._calendar;this.dateModule=a.datePackage?h.getObject(a.datePackage,!1):v;this.dateClassObj=this.dateModule.Date||Date;this.dateLocaleModule=a.datePackage?h.getObject(a.datePackage+".locale",!1):w;this._viewHandles=[];this.storeManager=new y({owner:this,_ownerItemsProperty:"items"});this.storeManager.on("layoutInvalidated",h.hitch(this,this._refreshItemsRendering));this.storeManager.on("dataLoaded",h.hitch(this,function(a){this.set("items",a)}));this.storeManager.on("renderersInvalidated",h.hitch(this,
function(a){this.updateRenderers(a)}));this.rendererManager=new z({owner:this});this.rendererManager.on("rendererCreated",h.hitch(this,this._onRendererCreated));this.rendererManager.on("rendererReused",h.hitch(this,this._onRendererReused));this.rendererManager.on("rendererRecycled",h.hitch(this,this._onRendererRecycled));this.rendererManager.on("rendererDestroyed",h.hitch(this,this._onRendererDestroyed));this.decorationStoreManager=new y({owner:this,_ownerItemsProperty:"decorationItems"});this.decorationStoreManager.on("layoutInvalidated",
h.hitch(this,this._refreshDecorationItemsRendering));this.decorationStoreManager.on("dataLoaded",h.hitch(this,function(a){this.set("decorationItems",a)}));this.decorationRendererManager=new z({owner:this});this._setupDayRefresh()},destroy:function(a){this.rendererManager.destroy();for(this.decorationRendererManager.destroy();0<this._viewHandles.length;)this._viewHandles.pop().remove();this.inherited(arguments)},_setupDayRefresh:function(){var a=this.newDate(new Date),b=p.floor(a,"day",1,this.dateClassObj),
b=this.dateModule.add(b,"day",1),b=23==b.getHours()?this.dateModule.add(b,"hour",2):p.floorToDay(b,!0,this.dateClassObj);setTimeout(h.hitch(this,function(){this._isEditing||this.refreshRendering(!0);this._setupDayRefresh()}),b.getTime()-a.getTime()+5E3)},resize:function(a){a&&u.setMarginBox(this.domNode,a)},beforeActivate:function(){},afterActivate:function(){},beforeDeactivate:function(){},afterDeactivate:function(){},_getTopOwner:function(){for(var a=this;void 0!=a.owner;)a=a.owner;return a},_createRenderData:function(){},
_validateProperties:function(){},_setText:function(a,b,c){if(null!=b)if(!c&&a.hasChildNodes())a.childNodes[0].childNodes[0].nodeValue=b;else{for(;a.hasChildNodes();)a.removeChild(a.lastChild);var e=x.doc.createElement("span");r("dojo-bidi")&&this.applyTextDir(e,b);c?e.innerHTML=b:e.appendChild(x.doc.createTextNode(b));a.appendChild(e)}},isAscendantHasClass:function(a,b,c){for(;a!=b&&a!=document;){if(C.contains(a,c))return!0;a=a.parentNode}return!1},isWeekEnd:function(a){return w.isWeekend(a)},getWeekNumberLabel:function(a){a.toGregorian&&
(a=a.toGregorian());return w.format(a,{selector:"date",datePattern:"w"})},addAndFloor:function(a,b,c){a=this.dateModule.add(a,b,c);return a=23==a.getHours()?this.dateModule.add(a,"hour",2):p.floorToDay(a,!0,this.dateClassObj)},floorToDay:function(a,b){return p.floorToDay(a,b,this.dateClassObj)},floorToMonth:function(a,b){return p.floorToMonth(a,b,this.dateClassObj)},floorDate:function(a,b,c,e){return p.floor(a,b,c,e,this.dateClassObj)},isToday:function(a){return p.isToday(a,this.dateClassObj)},isStartOfDay:function(a){return p.isStartOfDay(a,
this.dateClassObj,this.dateModule)},isOverlapping:function(a,b,c,e,d,f){return p.isOverlapping(a,b,c,e,d,f)},computeRangeOverlap:function(a,b,c,e,d,f){var g=a.dateModule;if(null==b||null==e||null==c||null==d)return null;var h=g.compare(b,d),k=g.compare(e,c);if(f){if(0==h||1==h||0==k||1==k)return null}else if(1==h||1==k)return null;return[this.newDate(0<g.compare(b,e)?b:e,a),this.newDate(0<g.compare(c,d)?d:c,a)]},isSameDay:function(a,b){return null==a||null==b?!1:a.getFullYear()==b.getFullYear()&&
a.getMonth()==b.getMonth()&&a.getDate()==b.getDate()},computeProjectionOnDate:function(a,b,c,e){var d=a.dateModule,f=a.minHours,g=a.maxHours;if(0>=e||-1==d.compare(c,b))return 0;var n=function(a){return 3600*a.getHours()+60*a.getMinutes()+a.getSeconds()},k=this.floorToDay(b,!1,a);if(c.getDate()!=k.getDate())if(c.getMonth()==k.getMonth()){if(c.getDate()<k.getDate())return 0;if(c.getDate()>k.getDate()&&24>g)return e}else if(c.getFullYear()==k.getFullYear()){if(c.getMonth()<k.getMonth())return 0;if(c.getMonth()>
k.getMonth())return e}else{if(c.getFullYear()<k.getFullYear())return 0;if(c.getFullYear()>k.getFullYear())return e}if(this.isSameDay(b,c)||24<g){d=h.clone(b);a=0;null!=f&&0!=f&&(d.setHours(f),a=n(d));d=h.clone(b);d.setHours(g);d=null==g||24==g?86400:24<g?86400+n(d):n(d);f=0;f=24<g&&b.getDate()!=c.getDate()?86400+n(c):n(c);if(f<a)return 0;if(f>d)return e;b=e*(f-a)/(d-a)}else{if(c.getDate()<b.getDate()&&c.getMonth()==b.getMonth())return 0;c=this.floorToDay(c);g=a.dateModule.add(b,"day",1);g=this.floorToDay(g,
!1,a);b=1==d.compare(c,b)&&0==d.compare(c,g)||1==d.compare(c,g)?e:0}return b},getTime:function(a,b,c,e){return null},getSubColumn:function(a,b,c,e){return null},getSubColumnIndex:function(a){if(this.subColumns)for(var b=0;b<this.subColumns.length;b++)if(this.subColumns[b]==a)return b;return-1},newDate:function(a){return p.newDate(a,this.dateClassObj)},_isItemInView:function(a){var b=this.renderData,c=b.dateModule;return-1==c.compare(a.startTime,b.startTime)?!1:1!=c.compare(a.endTime,b.endTime)},_ensureItemInView:function(a){var b=
this.renderData,c=b.dateModule,e=Math.abs(c.difference(a.startTime,a.endTime,"millisecond")),d=!1;-1==c.compare(a.startTime,b.startTime)?(a.startTime=b.startTime,a.endTime=c.add(a.startTime,"millisecond",e),d=!0):1==c.compare(a.endTime,b.endTime)&&(a.endTime=b.endTime,a.startTime=c.add(a.endTime,"millisecond",-e),d=!0);return d},scrollable:!0,autoScroll:!0,_autoScroll:function(a,b,c){return!1},scrollMethod:"auto",_setScrollMethodAttr:function(a){this.scrollMethod!=a&&(this.scrollMethod=a,void 0!==
this._domScroll&&(this._domScroll?t.set(this.sheetContainer,this._cssPrefix+"transform","translateY(0px)"):this.scrollContainer.scrollTop=0),delete this._domScroll,a=this._getScrollPosition(),delete this._scrollPos,this._setScrollPosition(a))},_startAutoScroll:function(a){var b=this._scrollProps;b||(b=this._scrollProps={});b.scrollStep=a;b.isScrolling||(b.isScrolling=!0,b.scrollTimer=setInterval(h.hitch(this,this._onScrollTimer_tick),10))},_stopAutoScroll:function(){var a=this._scrollProps;a&&a.isScrolling&&
(clearInterval(a.scrollTimer),a.scrollTimer=null);this._scrollProps=null},_onScrollTimer_tick:function(a){},_scrollPos:0,_hscrollPos:0,getCSSPrefix:function(){return r("ie")?"-ms-":r("webkit")?"-webkit-":r("mozilla")?"-moz-":r("opera")?"-o-":""},_hScrollNodes:null,_setScrollPositionBase:function(a,b){if(!(b&&this._scrollPos==a||!b&&this._hScrollPos==a)){if(void 0===this._domScroll){var c=this.get("scrollMethod");this._domScroll="auto"===c?!r("ios")&&!r("android")&&!r("webkit"):"dom"===c}c=0;b?(c=
u.getMarginBox(this.scrollContainer),c=u.getMarginBox(this.sheetContainer).h-c.h):(c=u.getMarginBox(this.grid),c=u.getMarginBox(this.gridTable).w-c.w);0>a?a=0:a>c&&(a=c);b?this._scrollPos=a:this._hScrollPos=a;var e=!this.isLeftToRight();if(this._domScroll)b?this.scrollContainer.scrollTop=a:q.forEach(this._hScrollNodes,function(b){t.set(b,"left",(e?1:-1)*a+"px")},this);else{this._cssPrefix||(this._cssPrefix=this.getCSSPrefix());var d=this._cssPrefix+"transform";if(b)t.set(this.sheetContainer,d,"translateY(-"+
a+"px)");else{var f="translateX("+(e?"":"-")+a+"px)";q.forEach(this._hScrollNodes,function(a){t.set(a,d,f)},this)}}}},_setScrollPosition:function(a){this._setScrollPositionBase(a,!0)},_getScrollPosition:function(){return this._scrollPos},_setHScrollPosition:function(a){this._setScrollPositionBase(a,!1)},_setHScrollPositionImpl:function(a,b,c){var e=b?null:"translateX(-"+a+"px)";q.forEach(this._hScrollNodes,function(c){b?(c.scrollLeft=a,t.set(c,"left",-a+"px")):t.set(c,cssProp,e)},this)},_hScrollPos:0,
_getHScrollPosition:function(){return this._hScrollPos},scrollView:function(a){},ensureVisibility:function(a,b,c,e,d){},_getStoreAttr:function(){return this.owner?this.owner.get("store"):this.store},_setItemsAttr:function(a){this._set("items",a);this.displayedItemsInvalidated=!0},_refreshItemsRendering:function(){var a=this.renderData;this._computeVisibleItems(a);this._layoutRenderers(a)},_refreshDecorationItemsRendering:function(){var a=this.renderData;this._computeVisibleItems(a);this._layoutDecorationRenderers(a)},
invalidateLayout:function(){this._layoutRenderers(this.renderData);this._layoutDecorationRenderers(this.renderData)},_setDecorationItemsAttr:function(a){this._set("decorationItems",a);this.displayedDecorationItemsInvalidated=!0},_getDecorationStoreAttr:function(){return this.owner?this.owner.get("decorationStore"):this.decorationStore},_setDecorationStoreAttr:function(a){this.decorationStore=a;this.decorationStoreManager.set("store",a)},computeOverlapping:function(a,b){if(0==a.length)return{numLanes:0,
addedPassRes:[1]};for(var c=[],e=0;e<a.length;e++)this._layoutPass1(a[e],c);e=null;b&&(e=h.hitch(this,b)(c));return{numLanes:c.length,addedPassRes:e}},_layoutPass1:function(a,b){for(var c=!0,e=0;e<b.length;e++){for(var d=b[e],c=!1,f=0;f<d.length&&!c;f++)d[f].start<a.end&&a.start<d[f].end&&(c=!0,d[f].extent=1);if(!c){a.lane=e;a.extent=-1;d.push(a);return}}b.push([a]);a.lane=b.length-1;a.extent=-1},_layoutInterval:function(a,b,c,e,d){},layoutPriorityFunction:null,_sortItemsFunction:function(a,b){var c=
this.dateModule.compare(a.startTime,b.startTime);0==c&&(c=-1*this.dateModule.compare(a.endTime,b.endTime));return c},_layoutRenderers:function(a){this._layoutRenderersImpl(a,this.rendererManager,a.items,"dataItems")},_layoutDecorationRenderers:function(a){this._layoutRenderersImpl(a,this.decorationRendererManager,a.decorationItems,"decorationItems")},_layoutRenderersImpl:function(a,b,c,e){if(c){b.recycleItemRenderers();b=a.dateModule;var d=this.newDate(a.startTime),f=h.clone(d);c=c.concat();for(var g=
[],n,k={},l=0;-1==b.compare(d,a.endTime)&&0<c.length;){var d=this.addAndFloor(d,this._layoutUnit,this._layoutStep),m=h.clone(d);a.minHours&&f.setHours(a.minHours);void 0!=a.maxHours&&24!=a.maxHours&&(24>a.maxHours&&(m=b.add(d,"day",-1)),m=this.floorToDay(m,!0,a),m.setHours(a.maxHours-(24>a.maxHours?0:24)));n=q.filter(c,function(b){var c=this.isOverlapping(a,b.startTime,b.endTime,f,m);c?(k[b.id]=!0,g.push(b)):k[b.id]?delete k[b.id]:g.push(b);return c},this);c=g;g=[];0<n.length&&(n.sort(h.hitch(this,
this.layoutPriorityFunction?this.layoutPriorityFunction:this._sortItemsFunction)),this._layoutInterval(a,l,f,m,n,e));f=h.clone(d);l++}this._onRenderersLayoutDone(this)}},_recycleItemRenderers:function(a){this.rendererManager.recycleItemRenderers(a)},getRenderers:function(a){return this.rendererManager.getRenderers(a)},itemToRendererKindFunc:null,_itemToRendererKind:function(a){return this.itemToRendererKindFunc?this.itemToRendererKindFunc(a):this._defaultItemToRendererKindFunc(a)},_defaultItemToRendererKindFunc:function(a){return null},
_createRenderer:function(a,b,c,e){return this.rendererManager.createRenderer(a,b,c,e)},_onRendererCreated:function(a){if(a.source==this)this.onRendererCreated(a);null!=this.owner&&this.owner._onRendererCreated(a)},onRendererCreated:function(a){},_onRendererRecycled:function(a){if(a.source==this)this.onRendererRecycled(a);null!=this.owner&&this.owner._onRendererRecycled(a)},onRendererRecycled:function(a){},_onRendererReused:function(a){if(a.source==this)this.onRendererReused(a);null!=this.owner&&this.owner._onRendererReused(a)},
onRendererReused:function(a){},_onRendererDestroyed:function(a){if(a.source==this)this.onRendererDestroyed(a);null!=this.owner&&this.owner._onRendererDestroyed(a)},onRendererDestroyed:function(a){},_onRenderersLayoutDone:function(a){this.onRenderersLayoutDone(a);null!=this.owner&&this.owner._onRenderersLayoutDone(a)},onRenderersLayoutDone:function(a){},_recycleRenderer:function(a,b){this.rendererManager.recycleRenderer(a,b)},_destroyRenderer:function(a){this.rendererManager.destroyRenderer(a)},_destroyRenderersByKind:function(a){this.rendererManager.destroyRenderersByKind(a)},
_updateEditingCapabilities:function(a,b){var c=this.isItemMoveEnabled(a,b.rendererKind),e=this.isItemResizeEnabled(a,b.rendererKind),d=!1;c!=b.get("moveEnabled")&&(b.set("moveEnabled",c),d=!0);e!=b.get("resizeEnabled")&&(b.set("resizeEnabled",e),d=!0);d&&b.updateRendering()},updateRenderers:function(a,b){if(null!=a)for(var c=h.isArray(a)?a:[a],e=0;e<c.length;e++){var d=c[e];if(null!=d&&null!=d.id){var f=this.rendererManager.itemToRenderer[d.id];if(null!=f)for(var g=this.isItemSelected(d),n=this.isItemHovered(d),
k=this.isItemBeingEdited(d),l=this.showFocus?this.isItemFocused(d):!1,m=0;m<f.length;m++){var p=f[m].renderer;p.set("hovered",n);p.set("selected",g);p.set("edited",k);p.set("focused",l);p.set("storeState",this.getItemStoreState(d));this.applyRendererZIndex(d,f[m],n,g,k,l);b||(p.set("item",d),p.updateRendering&&p.updateRendering())}}}},applyRendererZIndex:function(a,b,c,e,d,f){t.set(b.container,{zIndex:d||e?20:void 0==a.lane?0:a.lane})},getIdentity:function(a){return this.owner?this.owner.getIdentity(a):
a.id},_setHoveredItem:function(a,b){if(this.owner)this.owner._setHoveredItem(a,b);else if(this.hoveredItem&&a&&this.hoveredItem.id!=a.id||null==a||null==this.hoveredItem){var c=this.hoveredItem;this.hoveredItem=a;this.updateRenderers([c,this.hoveredItem],!0);a&&b&&this._updateEditingCapabilities(a._item?a._item:a,b)}},hoveredItem:null,isItemHovered:function(a){return this._isEditing&&this._edProps?a.id==this._edProps.editedItem.id:this.owner?this.owner.isItemHovered(a):null!=this.hoveredItem&&this.hoveredItem.id==
a.id},isItemFocused:function(a){return this._isItemFocused?this._isItemFocused(a):!1},_setSelectionModeAttr:function(a){this.owner?this.owner.set("selectionMode",a):this.inherited(arguments)},_getSelectionModeAttr:function(a){return this.owner?this.owner.get("selectionMode"):this.inherited(arguments)},_setSelectedItemAttr:function(a){this.owner?this.owner.set("selectedItem",a):this.inherited(arguments)},_getSelectedItemAttr:function(a){return this.owner?this.owner.get("selectedItem"):this.selectedItem},
_setSelectedItemsAttr:function(a){this.owner?this.owner.set("selectedItems",a):this.inherited(arguments)},_getSelectedItemsAttr:function(){return this.owner?this.owner.get("selectedItems"):this.inherited(arguments)},isItemSelected:function(a){return this.owner?this.owner.isItemSelected(a):this.inherited(arguments)},selectFromEvent:function(a,b,c,e){this.owner?this.owner.selectFromEvent(a,b,c,e):this.inherited(arguments)},setItemSelected:function(a,b){this.owner?this.owner.setItemSelected(a,b):this.inherited(arguments)},
createItemFunc:null,_getCreateItemFuncAttr:function(){return this.owner?this.owner.get("createItemFunc"):this.createItemFunc},createOnGridClick:!1,_getCreateOnGridClickAttr:function(){return this.owner?this.owner.get("createOnGridClick"):this.createOnGridClick},_gridMouseDown:!1,_tempIdCount:0,_tempItemsMap:null,_onGridMouseDown:function(a){this._gridMouseDown=!0;this.showFocus=!1;this._isEditing&&this._endItemEditing("mouse",!1);this._doEndItemEditing(this.owner,"mouse");this.set("focusedItem",null);
this.selectFromEvent(a,null,null,!0);this._setTabIndexAttr&&this[this._setTabIndexAttr].focus();if(this._onRendererHandleMouseDown){var b=this.get("createItemFunc");if(b){var b=this._createdEvent=b(this,this.getTime(a),a,this.getSubColumn(a)),c=this.get("store");if(b&&null!=c){if(void 0==c.getIdentity(b)){var e="_tempId_"+this._tempIdCount++;b[c.idProperty]=e;null==this._tempItemsMap&&(this._tempItemsMap={});this._tempItemsMap[e]=!0}c=this.itemToRenderItem(b,c);c._item=b;this._setItemStoreState(b,
"unstored");var e=this._getTopOwner(),d=e.get("items");e.set("items",d?d.concat([c]):[c]);this._refreshItemsRendering();(b=this.getRenderers(b))&&0<b.length&&(b=b[0])&&(this._onRendererHandleMouseDown(a,b.renderer,"resizeEnd"),this._startItemEditing(c,"mouse"))}}}},_onGridMouseMove:function(a){},_onGridMouseUp:function(a){},_onGridTouchStart:function(a){var b=this._edProps;this._gridProps={event:a,fromItem:this.isAscendantHasClass(a.target,this.eventContainer,"dojoxCalendarEvent")};this._isEditing&&
(this._gridProps&&(this._gridProps.editingOnStart=!0),h.mixin(b,this._getTouchesOnRenderers(a,b.editedItem)),0==b.touchesLen&&(b&&b.endEditingTimer&&(clearTimeout(b.endEditingTimer),b.endEditingTimer=null),this._endItemEditing("touch",!1)));this._doEndItemEditing(this.owner,"touch");B.stop(a)},_doEndItemEditing:function(a,b){if(a&&a._isEditing){var c=a._edProps;c&&c.endEditingTimer&&(clearTimeout(c.endEditingTimer),c.endEditingTimer=null);a._endItemEditing(b,!1)}},_onGridTouchEnd:function(a){},_onGridTouchMove:function(a){},
__fixEvt:function(a){return a},_dispatchCalendarEvt:function(a,b){a=this.__fixEvt(a);this[b](a);if(this.owner)this.owner[b](a);return a},_onGridClick:function(a){a.triggerEvent||(a={date:this.getTime(a),triggerEvent:a});this._dispatchCalendarEvt(a,"onGridClick")},onGridClick:function(a){},_onGridDoubleClick:function(a){a.triggerEvent||(a={date:this.getTime(a),triggerEvent:a});this._dispatchCalendarEvt(a,"onGridDoubleClick")},onGridDoubleClick:function(a){},_onItemClick:function(a){this._dispatchCalendarEvt(a,
"onItemClick")},onItemClick:function(a){},_onItemDoubleClick:function(a){this._dispatchCalendarEvt(a,"onItemDoubleClick")},onItemDoubleClick:function(a){},_onItemContextMenu:function(a){this._dispatchCalendarEvt(a,"onItemContextMenu")},onItemContextMenu:function(a){},_getStartEndRenderers:function(a){a=this.rendererManager.itemToRenderer[a.id];if(null==a)return null;if(1==a.length)return a=a[0].renderer,[a,a];for(var b=this.renderData,c=!1,e=!1,d=[],f=0;f<a.length;f++){var g=a[f].renderer;c||(c=0==
b.dateModule.compare(g.item.range[0],g.item.startTime),d[0]=g);e||(e=0==b.dateModule.compare(g.item.range[1],g.item.endTime),d[1]=g);if(c&&e)break}return d},editable:!0,moveEnabled:!0,resizeEnabled:!0,isItemEditable:function(a,b){return"storing"!=this.getItemStoreState(a)&&this.editable&&(this.owner?this.owner.isItemEditable(a,b):!0)},isItemMoveEnabled:function(a,b){return this.isItemEditable(a,b)&&this.moveEnabled&&(this.owner?this.owner.isItemMoveEnabled(a,b):!0)},isItemResizeEnabled:function(a,
b){return this.isItemEditable(a,b)&&this.resizeEnabled&&(this.owner?this.owner.isItemResizeEnabled(a,b):!0)},_isEditing:!1,isItemBeingEdited:function(a){return this._isEditing&&this._edProps&&this._edProps.editedItem&&this._edProps.editedItem.id==a.id},_setEditingProperties:function(a){this._edProps=a},_startItemEditing:function(a,b){this._isEditing=!0;this._getTopOwner()._isEditing=!0;var c=this._edProps;c.editedItem=a;c.storeItem=a._item;c.eventSource=b;c.secItem=this._secondarySheet?this._findRenderItem(a.id,
this._secondarySheet.renderData.items):null;c.ownerItem=this.owner?this._findRenderItem(a.id,this.items):null;if(!c.liveLayout){c.editSaveStartTime=a.startTime;c.editSaveEndTime=a.endTime;c.editItemToRenderer=this.rendererManager.itemToRenderer;c.editItems=this.renderData.items;c.editRendererList=this.rendererManager.rendererList;this.renderData.items=[c.editedItem];var e=c.editedItem.id;this.rendererManager.itemToRenderer={};this.rendererManager.rendererList=[];var d=c.editItemToRenderer[e];c.editRendererIndices=
[];q.forEach(d,h.hitch(this,function(a,b){null==this.rendererManager.itemToRenderer[e]?this.rendererManager.itemToRenderer[e]=[a]:this.rendererManager.itemToRenderer[e].push(a);this.rendererManager.rendererList.push(a)}));c.editRendererList=q.filter(c.editRendererList,function(a){return null!=a&&a.renderer.item.id!=e});delete c.editItemToRenderer[e]}this._layoutRenderers(this.renderData);this._onItemEditBegin({item:a,storeItem:c.storeItem,eventSource:b})},_onItemEditBegin:function(a){this._editStartTimeSave=
this.newDate(a.item.startTime);this._editEndTimeSave=this.newDate(a.item.endTime);this._dispatchCalendarEvt(a,"onItemEditBegin")},onItemEditBegin:function(a){},_endItemEditing:function(a,b){this._editingGesture&&this._endItemEditingGesture(a);this._isEditing=!1;this._getTopOwner()._isEditing=!1;var c=this._edProps;q.forEach(c.handles,function(a){a.remove()});c.liveLayout||(this.renderData.items=c.editItems,this.rendererManager.rendererList=c.editRendererList.concat(this.rendererManager.rendererList),
h.mixin(this.rendererManager.itemToRenderer,c.editItemToRenderer));this._onItemEditEnd(h.mixin(this._createItemEditEvent(),{item:c.editedItem,storeItem:c.storeItem,eventSource:a,completed:!b}));this._layoutRenderers(this.renderData);this._edProps=null},_onItemEditEnd:function(a){this._dispatchCalendarEvt(a,"onItemEditEnd");if(!a.isDefaultPrevented()){var b=this.get("store"),c=this.renderItemToItem(a.item,b),e=this._getItemStoreStateObj(a.item);if(null!=e&&"unstored"==e.state)if(a.completed){c=h.mixin(e.item,
c);this._setItemStoreState(c,"storing");var d=b.getIdentity(c);a=null;this._tempItemsMap&&this._tempItemsMap[d]&&(a={temporaryId:d},delete this._tempItemsMap[d],delete c[b.idProperty]);E(b.add(c,a),h.hitch(this,function(a){(h.isObject(a)?b.getIdentity(a):a)!=d&&this._removeRenderItem(d)}))}else this._removeRenderItem(e.id);else a.completed?(this._setItemStoreState(c,"storing"),b.put(c)):(a.item.startTime=this._editStartTimeSave,a.item.endTime=this._editEndTimeSave)}},_removeRenderItem:function(a){for(var b=
this._getTopOwner(),c=b.get("items"),e=!1,d=c.length-1;0<=d;d--)if(c[d].id==a){c.splice(d,1);e=!0;break}this._cleanItemStoreState(a);e&&(b.set("items",c),this.invalidateLayout())},onItemEditEnd:function(a){},_createItemEditEvent:function(){return{cancelable:!0,bubbles:!1,__defaultPrevent:!1,preventDefault:function(){this.__defaultPrevented=!0},isDefaultPrevented:function(){return this.__defaultPrevented}}},_startItemEditingGesture:function(a,b,c,e){var d=this._edProps;if(d&&null!=d.editedItem){this._editingGesture=
!0;var f=d.editedItem;d.editKind=b;this._onItemEditBeginGesture(this.__fixEvt(h.mixin(this._createItemEditEvent(),{item:f,storeItem:d.storeItem,startTime:f.startTime,endTime:f.endTime,editKind:b,rendererKind:d.rendererKind,triggerEvent:e,dates:a,eventSource:c})));d.itemBeginDispatched=!0}},_onItemEditBeginGesture:function(a){var b=this._edProps,c=b.editedItem,e=a.dates;b.editingTimeFrom=[];b.editingTimeFrom[0]=e[0];b.editingItemRefTime=[];b.editingItemRefTime[0]=this.newDate("resizeEnd"==b.editKind?
c.endTime:c.startTime);"resizeBoth"==b.editKind&&(b.editingTimeFrom[1]=e[1],b.editingItemRefTime[1]=this.newDate(c.endTime));e=this.renderData.dateModule;b.inViewOnce=this._isItemInView(c);if("label"==b.rendererKind||this.roundToDay)b._itemEditBeginSave=this.newDate(c.startTime),b._itemEditEndSave=this.newDate(c.endTime);b._initDuration=e.difference(c.startTime,c.endTime,c.allDay?"day":"millisecond");this._dispatchCalendarEvt(a,"onItemEditBeginGesture");a.isDefaultPrevented()||"mouse"!=a.eventSource||
(b.editLayer=D.create("div",{style:"position: absolute; left:0; right:0; bottom:0; top:0; z-index:30; tabIndex:-1; background-image:url('"+this._blankGif+"'); cursor: "+("move"==a.editKind?"move":this.resizeCursor),onresizestart:function(a){return!1},onselectstart:function(a){return!1}},this.domNode),b.editLayer.focus())},onItemEditBeginGesture:function(a){},_waDojoxAddIssue:function(a,b,c){var e=this.renderData.dateModule;return"gregorian"!=this._calendar&&0>c?(a=a.toGregorian(),a=v.add(a,b,c),new this.renderData.dateClassObj(a)):
e.add(a,b,c)},_computeItemEditingTimes:function(a,b,c,e,d){c=this.renderData.dateModule;a=this._edProps;"move"==b&&(b=c.difference(a.editingTimeFrom[0],e[0],"millisecond"),e[0]=this._waDojoxAddIssue(a.editingItemRefTime[0],"millisecond",b));return e},_moveOrResizeItemGesture:function(a,b,c,e){if(this._isEditing&&null!=a[0]){var d=this._edProps,f=d.editedItem,g=this.renderData.dateModule,n=d.editKind,k=[a[0]];"resizeBoth"==n&&(k[1]=a[1]);var k=this._computeItemEditingTimes(f,d.editKind,d.rendererKind,
k,b),l=k[0],m=!1;a=h.clone(f.startTime);var p=h.clone(f.endTime),r=f.subColumn,q="keyboard"==d.eventSource?!1:this.allowStartEndSwap;if("move"==n)null!=e&&f.subColumn!=e&&this.allowSubColumnMove&&(f.subColumn=e,m=this.get("store"),k=this.renderItemToItem(f,m),h.mixin(f,this.itemToRenderItem(k,m)),m=!0),0!=g.compare(f.startTime,l)&&(m=g.difference(f.startTime,f.endTime,"millisecond"),f.startTime=this.newDate(l),f.endTime=g.add(f.startTime,"millisecond",m),m=!0);else if("resizeStart"==n)0!=g.compare(f.startTime,
l)&&(-1!=g.compare(f.endTime,l)?f.startTime=this.newDate(l):q?(f.startTime=this.newDate(f.endTime),f.endTime=this.newDate(l),d.editKind=n="resizeEnd","touch"==b&&(d.resizeEndTouchIndex=d.resizeStartTouchIndex,d.resizeStartTouchIndex=-1)):(f.startTime=this.newDate(f.endTime),f.startTime.setHours(l.getHours()),f.startTime.setMinutes(l.getMinutes()),f.startTime.setSeconds(l.getSeconds())),m=!0);else if("resizeEnd"==n)0!=g.compare(f.endTime,l)&&(1!=g.compare(f.startTime,l)?f.endTime=this.newDate(l):q?
(f.endTime=this.newDate(f.startTime),f.startTime=this.newDate(l),d.editKind=n="resizeStart","touch"==b&&(d.resizeStartTouchIndex=d.resizeEndTouchIndex,d.resizeEndTouchIndex=-1)):(f.endTime=this.newDate(f.startTime),f.endTime.setHours(l.getHours()),f.endTime.setMinutes(l.getMinutes()),f.endTime.setSeconds(l.getSeconds())),m=!0);else if("resizeBoth"==n)m=!0,l=this.newDate(l),k=this.newDate(k[1]),-1!=g.compare(l,k)&&(q?(q=l,l=k,k=q):m=!1),m&&(f.startTime=l,f.endTime=k);else return!1;if(!m)return!1;b=
h.mixin(this._createItemEditEvent(),{item:f,storeItem:d.storeItem,startTime:f.startTime,endTime:f.endTime,editKind:n,rendererKind:d.rendererKind,triggerEvent:c,eventSource:b});"move"==n?this._onItemEditMoveGesture(b):this._onItemEditResizeGesture(b);1==g.compare(f.startTime,f.endTime)&&(n=f.startTime,f.startTime=f.endTime,f.endTime=n);m=r!=f.subColumn||0!=g.compare(a,f.startTime)||0!=g.compare(p,f.endTime);if(!m)return!1;this._layoutRenderers(this.renderData);d.liveLayout&&null!=d.secItem?(d.secItem.startTime=
f.startTime,d.secItem.endTime=f.endTime,this._secondarySheet._layoutRenderers(this._secondarySheet.renderData)):null!=d.ownerItem&&this.owner.liveLayout&&(d.ownerItem.startTime=f.startTime,d.ownerItem.endTime=f.endTime,this.owner._layoutRenderers(this.owner.renderData));return!0}},_findRenderItem:function(a,b){b=b||this.renderData.items;for(var c=0;c<b.length;c++)if(b[c].id==a)return b[c];return null},_onItemEditMoveGesture:function(a){this._dispatchCalendarEvt(a,"onItemEditMoveGesture");if(!a.isDefaultPrevented()){var b=
a.source._edProps,c=this.renderData,e=c.dateModule;"label"==b.rendererKind||this.roundToDay&&!a.item.allDay?(c=this.floorToDay(a.item.startTime,!1,c),c.setHours(b._itemEditBeginSave.getHours()),c.setMinutes(b._itemEditBeginSave.getMinutes()),e=e.add(c,"millisecond",b._initDuration)):a.item.allDay?(c=this.floorToDay(a.item.startTime,!0),e=e.add(c,"day",b._initDuration)):(c=this.floorDate(a.item.startTime,this.snapUnit,this.snapSteps),e=e.add(c,"millisecond",b._initDuration));a.item.startTime=c;a.item.endTime=
e;b.inViewOnce||(b.inViewOnce=this._isItemInView(a.item));b.inViewOnce&&this.stayInView&&this._ensureItemInView(a.item)}},_DAY_IN_MILLISECONDS:864E5,onItemEditMoveGesture:function(a){},_onItemEditResizeGesture:function(a){this._dispatchCalendarEvt(a,"onItemEditResizeGesture");if(!a.isDefaultPrevented()){var b=a.source._edProps,c=this.renderData,e=c.dateModule,d=a.item.startTime,f=a.item.endTime;"resizeStart"==a.editKind?a.item.allDay?d=this.floorToDay(a.item.startTime,!1,this.renderData):this.roundToDay?
(d=this.floorToDay(a.item.startTime,!1,c),d.setHours(b._itemEditBeginSave.getHours()),d.setMinutes(b._itemEditBeginSave.getMinutes())):d=this.floorDate(a.item.startTime,this.snapUnit,this.snapSteps):"resizeEnd"==a.editKind?a.item.allDay?this.isStartOfDay(a.item.endTime)||(f=this.floorToDay(a.item.endTime,!1,this.renderData),f=e.add(f,"day",1)):this.roundToDay?(f=this.floorToDay(a.item.endTime,!1,c),f.setHours(b._itemEditEndSave.getHours()),f.setMinutes(b._itemEditEndSave.getMinutes())):(f=this.floorDate(a.item.endTime,
this.snapUnit,this.snapSteps),"mouse"==a.eventSource&&(f=e.add(f,this.snapUnit,this.snapSteps))):(d=this.floorDate(a.item.startTime,this.snapUnit,this.snapSteps),f=this.floorDate(a.item.endTime,this.snapUnit,this.snapSteps),f=e.add(f,this.snapUnit,this.snapSteps));a.item.startTime=d;a.item.endTime=f;c=a.item.allDay||b._initDuration>=this._DAY_IN_MILLISECONDS&&!this.allowResizeLessThan24H;this.ensureMinimalDuration(this.renderData,a.item,c?"day":this.minDurationUnit,c?1:this.minDurationSteps,a.editKind);
b.inViewOnce||(b.inViewOnce=this._isItemInView(a.item));b.inViewOnce&&this.stayInView&&this._ensureItemInView(a.item)}},onItemEditResizeGesture:function(a){},_endItemEditingGesture:function(a,b){if(this._isEditing){this._editingGesture=!1;var c=this._edProps,e=c.editedItem;c.itemBeginDispatched=!1;this._onItemEditEndGesture(h.mixin(this._createItemEditEvent(),{item:e,storeItem:c.storeItem,startTime:e.startTime,endTime:e.endTime,editKind:c.editKind,rendererKind:c.rendererKind,triggerEvent:b,eventSource:a}))}},
_onItemEditEndGesture:function(a){var b=this._edProps;delete b._itemEditBeginSave;delete b._itemEditEndSave;this._dispatchCalendarEvt(a,"onItemEditEndGesture");!a.isDefaultPrevented()&&b.editLayer&&(r("ie")&&(b.editLayer.style.cursor="default"),setTimeout(h.hitch(this,function(){this.domNode&&(this.domNode.focus(),b.editLayer.parentNode.removeChild(b.editLayer),b.editLayer=null)}),10))},onItemEditEndGesture:function(a){},ensureMinimalDuration:function(a,b,c,e,d){a=a.dateModule;"resizeStart"==d?(c=
a.add(b.endTime,c,-e),1==a.compare(b.startTime,c)&&(b.startTime=c)):(c=a.add(b.startTime,c,e),-1==a.compare(b.endTime,c)&&(b.endTime=c))},doubleTapDelay:300,snapUnit:"minute",snapSteps:15,minDurationUnit:"hour",minDurationSteps:1,liveLayout:!1,stayInView:!0,allowStartEndSwap:!0,allowResizeLessThan24H:!1,allowSubColumnMove:!0})});