/* @license dhtmlxScheduler v.4.4.0 Stardard This software is covered by GPL license. You also can obtain Commercial or Enterprise license to use it in non-GPL project - please contact sales@dhtmlx.com. Usage without proper license is prohibited. (c) Dinamenta, UAB. */ !function(){function e(e){function t(t){var a={minicalButton:e.$keyboardNavigation.MinicalButton,minicalDate:e.$keyboardNavigation.MinicalCell,scheduler:e.$keyboardNavigation.SchedulerNode,dataArea:e.$keyboardNavigation.DataArea,timeSlot:e.$keyboardNavigation.TimeSlot,event:e.$keyboardNavigation.Event};return a[t]||a.scheduler}e.config.key_nav=!0,e.config.key_nav_step=30,e.addShortcut=function(e,a,i){var r=t(i);r&&r.prototype.bind(e,a)},e.removeShortcut=function(e,a){var i=t(a);i&&i.prototype.unbind(e); },e.focus=function(){if(e.config.key_nav){var t=e.$keyboardNavigation.dispatcher;t.enable();var a=t.getActiveNode();!a||a instanceof e.$keyboardNavigation.MinicalButton||a instanceof e.$keyboardNavigation.MinicalCell?t.setDefaultNode():t.focusNode(t.getActiveNode())}},e.$keyboardNavigation={},e._compose=function(){for(var e=Array.prototype.slice.call(arguments,0),t={},a=0;a=n?i[i.length-1]:n-1,o=i[d])return o.focus(),a.preventDefault(),!0}else if(d=n>=i.length-1?0:n+1,o=i[d])return o.focus(), a.preventDefault(),!0;return!1}}(),e.$keyboardNavigation.marker={clear:function(){for(var t=e.$container.querySelectorAll(".dhx_focus_slot"),a=0;a=0;d--)if(r[d].offsetWidth)return r[d];return null},addDataAttributes:function(t,a,i,r){for(var n=e.date.date_to_str(e.config.api_date),s=n(a),d=n(i),o=0;oe._max_date.valueOf()&&(o=new Date(e._max_date)),!r._trace_x)return s;for(var l=0;ld&&o>t))return s;var h=this.createElement(),_=e._timeline_getX({start_date:t},!1,r)-1,u=e._timeline_getX({start_date:a},!1,r)-1,v=r._section_height[i]-1||r.dy-1,g=0;e._isRender("cell")&&(g=c.offsetTop,_+=r.dx,u+=r.dx,c=e.$container.querySelector(".dhx_cal_data"));var f=Math.max(1,u-_-1);return h.style.cssText="height: "+v+"px; left: "+_+"px; width: "+f+"px; top: "+g+"px;",c.insertBefore(h,c.firstChild),s.push(h),s},renderMonthCell:function(t){for(var a=e.$container.querySelectorAll(".dhx_month_head"),i=[],r=0;r1?r=e.locate_holder_day(t)+l:(r=l,o.size&&r>o.position+o.size&&(r=0))}if(s=e.locate_holder(r), !s||s.querySelector(".dhx_scale_hour"))return document.createElement("div");var c=Math.max(60*t.getHours()+t.getMinutes(),60*d.first_hour),h=Math.min(60*a.getHours()+a.getMinutes(),60*d.last_hour);if(!h&&e.date.day_start(new Date(a)).valueOf()>e.date.day_start(new Date(t)).valueOf()&&(h=60*d.last_hour),c>=h)return[];var _=this.createElement(),u=e.config.hour_size_px*d.last_hour+1,v=36e5;return _.style.top=Math.round((60*c*1e3-e.config.first_hour*v)*e.config.hour_size_px/v)%u+"px",_.style.lineHeight=_.style.height=Math.max(Math.round(60*(h-c)*1e3*e.config.hour_size_px/v)%u,1)+"px", _.style.width="100%",s.appendChild(_),n.push(_),n[0]}},e.$keyboardNavigation.SchedulerNode=function(){},e.$keyboardNavigation.SchedulerNode.prototype=e._compose(e.$keyboardNavigation.EventHandler,{getDefaultNode:function(){var t=new e.$keyboardNavigation.TimeSlot;return t.isValid()||(t=t.fallback()),t},_modes:{month:"month",year:"year",dayColumns:"dayColumns",timeline:"timeline",units:"units",weekAgenda:"weekAgenda",list:"list"},getMode:function(){var t=e.getState(),a=t.mode;return e.matrix&&e.matrix[a]?this._modes.timeline:e._props&&e._props[a]?this._modes.units:"month"==a?this._modes.month:"year"==a?this._modes.year:"week_agenda"==a?this._modes.weekAgenda:"map"==a||"agenda"==a||e._grid&&e["grid_"+a]?this._modes.list:this._modes.dayColumns; },focus:function(){e.focus()},blur:function(){},disable:function(){e.$container.setAttribute("tabindex","0")},enable:function(){e.$container&&e.$container.removeAttribute("tabindex")},isEnabled:function(){return e.$container.hasAttribute("tabindex")},_compareEvents:function(e,t){return e.start_date.valueOf()==t.start_date.valueOf()?e.id>t.id?1:-1:e.start_date.valueOf()>t.start_date.valueOf()?1:-1},_pickEvent:function(t,a,i,r){var n=e.getState();t=new Date(Math.max(n.min_date.valueOf(),t.valueOf())), a=new Date(Math.min(n.max_date.valueOf(),a.valueOf()));var s=e.getEvents(t,a);s.sort(this._compareEvents),r&&(s=s.reverse());for(var d=!!i,o=0;ot&&(t=this.getNodes().length-1),this.moveTo(new e.$keyboardNavigation.HeaderCell(t))},right:function(){var t=this.index+1;t>=this.getNodes().length&&(t=0),this.moveTo(new e.$keyboardNavigation.HeaderCell(t))},down:function(){this.moveTo(new e.$keyboardNavigation.TimeSlot)},enter:function(){var e=this.getNode();e&&e.click()}}}),e.$keyboardNavigation.HeaderCell.prototype.bindAll(e.$keyboardNavigation.HeaderCell.prototype.keys), e.$keyboardNavigation.Event=function(t){if(this.eventId=null,e.getEvent(t)){var a=e.getEvent(t);this.start=new Date(a.start_date),this.end=new Date(a.end_date),this.section=this._getSection(a),this.eventId=t}},e.$keyboardNavigation.Event.prototype=e._compose(e.$keyboardNavigation.KeyNavNode,{_getNodes:function(){return Array.prototype.slice.call(e.$container.querySelectorAll("[event_id]"))},_modes:e.$keyboardNavigation.SchedulerNode.prototype._modes,getMode:e.$keyboardNavigation.SchedulerNode.prototype.getMode, _handlers:null,isValid:function(){return!(!e.getEvent(this.eventId)||!this.getNode())},fallback:function(){var t=this._getNodes()[0],a=null;if(t&&e._locate_event(t)){var i=e._locate_event(t);a=new e.$keyboardNavigation.Event(i)}else a=new e.$keyboardNavigation.TimeSlot;return a},getNode:function(){return e.$container.querySelector("[event_id='"+this.eventId+"']")},focus:function(){var t=e.getEvent(this.eventId),a=e.getState();(t.start_date.valueOf()>a.max_date.valueOf()||t.end_date.valueOf()<=a.min_date.valueOf())&&e.setCurrentView(t.start_date), e.$keyboardNavigation.KeyNavNode.prototype.focus.apply(this)},blur:function(){e.$keyboardNavigation.KeyNavNode.prototype.blur.apply(this)},_getSection:function(t){var a=null,i=e.getState().mode;if(e.matrix&&e.matrix[i]){var r=e.matrix[e.getState().mode];a=t[r.y_property]}else if(e._props&&e._props[i]){var n=e._props[i];a=t[n.map_to]}return a},_moveToSlot:function(t){var a=e.getEvent(this.eventId);if(a){var i=this._getSection(a),r=new e.$keyboardNavigation.TimeSlot(a.start_date,null,i);this.moveTo(r.nextSlot(r,t)); }else this.moveTo(new e.$keyboardNavigation.TimeSlot)},keys:{left:function(){this._moveToSlot("left")},right:function(){this._moveToSlot("right")},down:function(){this.getMode()==this._modes.list?e.$keyboardNavigation.SchedulerNode.prototype.nextEventHandler():this._moveToSlot("down")},space:function(){var t=this.getNode();t&&t.click?t.click():this.moveTo(new e.$keyboardNavigation.TimeSlot)},up:function(){this.getMode()==this._modes.list?e.$keyboardNavigation.SchedulerNode.prototype.prevEventHandler():this._moveToSlot("up"); },"delete":function(){e.getEvent(this.eventId)?e._click.buttons["delete"](this.eventId):this.moveTo(new e.$keyboardNavigation.TimeSlot)},enter:function(){e.getEvent(this.eventId)?e.showLightbox(this.eventId):this.moveTo(new e.$keyboardNavigation.TimeSlot)}}}),e.$keyboardNavigation.Event.prototype.bindAll(e.$keyboardNavigation.Event.prototype.keys),e.$keyboardNavigation.TimeSlot=function(t,a,i,r){var n=e.getState(),s=e.matrix&&e.matrix[n.mode];t||(s?(t=e.date[s.name+"_start"](new Date(n.date)),t=this.findVisibleColumn(t)):(t=new Date(e.getState().min_date), t=this.findVisibleColumn(t),t.setHours(e.config.first_hour))),a||(a=s?e.date.add(t,s.x_step,s.x_unit):e.date.add(t,e.config.key_nav_step,"minute")),this.section=i||this._getDefaultSection(),this.start_date=new Date(t),this.end_date=new Date(a),this.movingDate=r||null},e.$keyboardNavigation.TimeSlot.prototype=e._compose(e.$keyboardNavigation.KeyNavNode,{_handlers:null,clone:function(t){return new e.$keyboardNavigation.TimeSlot(t.start_date,t.end_date,t.section,t.movingDate)},_getMultisectionView:function(){ var t,a=e.getState();return e._props&&e._props[a.mode]?t=e._props[a.mode]:e.matrix&&e.matrix[a.mode]&&(t=e.matrix[a.mode]),t},_getDefaultSection:function(){var e=null,t=this._getMultisectionView();return t&&!e&&(e=this._getNextSection()),e},_getNextSection:function(e,t){var a=this._getMultisectionView(),i=a.order[e],r=i;r=void 0!==i?i+t:a.size&&a.position?a.position:0,r=0>r?r=(a.options||a.y_unit).length-1:r;var n=a.options||a.y_unit;return n[r]?n[r].key:null},isValid:function(){var t=e.getState(),a=!(this.start_date.valueOf()=t.max_date.valueOf()); if(!a)return!1;if(!this.isVisible(this.start_date,this.end_date))return!1;var i=this._getMultisectionView();return i?void 0!==i.order[this.section]:!0},fallback:function(){var t=new e.$keyboardNavigation.TimeSlot;return t.isValid()?t:new e.$keyboardNavigation.DataArea},getNodes:function(){return Array.prototype.slice.call(e.$container.querySelectorAll(".dhx_focus_slot"))},getNode:function(){return this.getNodes()[0]},focus:function(){e.$keyboardNavigation.marker.render(this.start_date,this.end_date,this.section), e.$keyboardNavigation.KeyNavNode.prototype.focus.apply(this),e.$keyboardNavigation._pasteDate=this.start_date,e.$keyboardNavigation._pasteSection=this.section},blur:function(){e.$keyboardNavigation.KeyNavNode.prototype.blur.apply(this),e.$keyboardNavigation.marker.clear()},_modes:e.$keyboardNavigation.SchedulerNode.prototype._modes,_getMode:e.$keyboardNavigation.SchedulerNode.prototype.getMode,addMonthDate:function(t,a,i){var r;switch(a){case"up":r=e.date.add(t,-1,"week");break;case"down":r=e.date.add(t,1,"week"); break;case"left":r=e.date.day_start(e.date.add(t,-1,"day")),r=this.findVisibleColumn(r,-1);break;case"right":r=e.date.day_start(e.date.add(t,1,"day")),r=this.findVisibleColumn(r,1);break;default:r=e.date.day_start(new Date(t))}var n=e.getState();return(t.valueOf()=n.max_date.valueOf())&&(r=new Date(n.min_date)),r},nextMonthSlot:function(t,a,i){var r,n;return r=this.addMonthDate(t.start_date,a,i),r.setHours(e.config.first_hour),n=new Date(r),n.setHours(e.config.last_hour), {start_date:r,end_date:n}},_alignTimeSlot:function(t,a,i,r){for(var n=new Date(a);n.valueOf()t.valueOf()&&(n=e.date.add(n,-r,i)),n},nextTimelineSlot:function(t,a,i){var r=e.getState(),n=e.matrix[r.mode],s=this._alignTimeSlot(t.start_date,e.date[n.name+"_start"](new Date(t.start_date)),n.x_unit,n.x_step),d=this._alignTimeSlot(t.end_date,e.date[n.name+"_start"](new Date(t.end_date)),n.x_unit,n.x_step);d.valueOf()<=s.valueOf()&&(d=e.date.add(s,n.x_step,n.x_unit)); var o=this.clone(t);switch(o.start_date=s,o.end_date=d,o.section=t.section||this._getNextSection(),a){case"up":o.section=this._getNextSection(t.section,-1);break;case"down":o.section=this._getNextSection(t.section,1);break;case"left":o.start_date=this.findVisibleColumn(e.date.add(o.start_date,-n.x_step,n.x_unit),-1),o.end_date=e.date.add(o.start_date,n.x_step,n.x_unit);break;case"right":o.start_date=this.findVisibleColumn(e.date.add(o.start_date,n.x_step,n.x_unit),1),o.end_date=e.date.add(o.start_date,n.x_step,n.x_unit); }return(o.start_date.valueOf()=r.max_date.valueOf())&&(i&&o.start_date.valueOf()>=r.max_date.valueOf()?o.start_date=new Date(r.max_date):(o.start_date=e.date[r.mode+"_start"](e.date.add(r.date,"left"==a?-1:1,r.mode)),o.end_date=e.date.add(o.start_date,n.x_step,n.x_unit))),o},nextUnitsSlot:function(t,a,i){var r=this.clone(t);r.section=t.section||this._getNextSection();var n=t.section||this._getNextSection(),s=e.getState(),d=e._props[s.mode];switch(a){case"left": n=this._getNextSection(t.section,-1);var o=d.size?d.size-1:d.options.length;d.days>1&&d.order[n]==o-1&&e.date.add(t.start_date,-1,"day").valueOf()>=s.min_date.valueOf()&&(r=this.nextDaySlot(t,a,i));break;case"right":n=this._getNextSection(t.section,1),d.days>1&&!d.order[n]&&e.date.add(t.start_date,1,"day").valueOf()r||!a&&(24==n||r==n)&&!i},isAfterFirstHour:function(t,a){var i=t.getMinutes(),r=t.getHours(),n=e.config.first_hour,s=e.config.last_hour;return r>=n||!a&&!i&&(!r&&24==s||r==s)},isInVisibleDayTime:function(e,t){return this.isBeforeLastHour(e,t)&&this.isAfterFirstHour(e,t)},nextDaySlot:function(t,a,i){var r,n,s=e.config.key_nav_step,d=this._alignTimeSlot(t.start_date,e.date.day_start(new Date(t.start_date)),"minute",s),o=t.start_date; switch(a){case"up":if(r=e.date.add(d,-s,"minute"),!this.isInVisibleDayTime(r,!0)&&(!i||this.isInVisibleDayTime(o,!0))){var l=!0;i&&e.date.date_part(new Date(r)).valueOf()!=e.date.date_part(new Date(o)).valueOf()&&(l=!1),l&&(r=this.findVisibleColumn(e.date.add(t.start_date,-1,"day"),-1)),r.setHours(e.config.last_hour),r.setMinutes(0),r=e.date.add(r,-s,"minute")}n=e.date.add(r,s,"minute");break;case"down":r=e.date.add(d,s,"minute");var c=i?r:e.date.add(r,s,"minute");if(!this.isInVisibleDayTime(c,!1)&&(!i||this.isInVisibleDayTime(o,!1)))if(i){ var l=!0;e.date.date_part(new Date(o)).valueOf()==o.valueOf()&&(l=!1),l&&(r=this.findVisibleColumn(e.date.add(t.start_date,1,"day"),1)),r.setHours(e.config.first_hour),r.setMinutes(0),r=e.date.add(r,s,"minute")}else r=this.findVisibleColumn(e.date.add(t.start_date,1,"day"),1),r.setHours(e.config.first_hour),r.setMinutes(0);n=e.date.add(r,s,"minute");break;case"left":r=this._moveDate(t.start_date,-1),n=this._moveDate(t.end_date,-1);break;case"right":r=this._moveDate(t.start_date,1),n=this._moveDate(t.end_date,1); break;default:r=d,n=e.date.add(r,s,"minute")}return{start_date:r,end_date:n}},nextWeekAgendaSlot:function(t,a){var i,r,n=e.getState();switch(a){case"down":case"left":i=e.date.day_start(e.date.add(t.start_date,-1,"day")),i=this.findVisibleColumn(i,-1);break;case"up":case"right":i=e.date.day_start(e.date.add(t.start_date,1,"day")),i=this.findVisibleColumn(i,1);break;default:i=e.date.day_start(t.start_date)}return(t.start_date.valueOf()=n.max_date.valueOf())&&(i=new Date(n.min_date)), r=new Date(i),r.setHours(e.config.last_hour),{start_date:i,end_date:r}},nextAgendaSlot:function(e,t){return{start_date:e.start_date,end_date:e.end_date}},isDateVisible:function(t){if(!e._ignores_detected)return!0;var a,i=e.matrix&&e.matrix[e.getState().mode];return a=i?e._get_date_index(i,t):e.locate_holder_day(t),!e._ignores[a]},findVisibleColumn:function(t,a){var i=t;a=a||1;for(var r=e.getState();!this.isDateVisible(i)&&(a>0&&i.valueOf()<=r.max_date.valueOf()||0>a&&i.valueOf()>=r.min_date.valueOf());)i=this.nextDateColumn(i,a); return i},nextDateColumn:function(t,a){a=a||1;var i,r=e.matrix&&e.matrix[e.getState().mode];return i=r?e.date.add(t,a*r.x_step,r.x_unit):e.date.day_start(e.date.add(t,a,"day"))},isVisible:function(t,a){if(!e._ignores_detected)return!0;for(var i=new Date(t);i.valueOf()=n.end_date.valueOf()&&(n=this.nextSlot(n,a,i)),e.$keyboardNavigation.TimeSlot.prototype.clone(n)},extendSlot:function(t,a){ var i,r=this._getMode();switch(r){case this._modes.units:i="left"==a||"right"==a?this.nextUnitsSlot(t,a):this.extendUnitsSlot(t,a);break;case this._modes.timeline:i="down"==a||"up"==a?this.nextTimelineSlot(t,a):this.extendTimelineSlot(t,a);break;case this._modes.year:i=this.extendMonthSlot(t,a);break;case this._modes.month:i=this.extendMonthSlot(t,a);break;case this._modes.dayColumns:i=this.extendDaySlot(t,a);break;case this._modes.weekAgenda:i=this.extendWeekAgendaSlot(t,a);break;default:i=t}var n=e.getState(); return i.start_date.valueOf()n.max_date.valueOf()&&(i.end_date=this.findVisibleColumn(n.max_date,-1)),e.$keyboardNavigation.TimeSlot.prototype.clone(i)},extendTimelineSlot:function(e,t){return this.extendGenericSlot({left:"start_date",right:"end_date"},e,t,"timeline")},extendWeekAgendaSlot:function(e,t){return this.extendGenericSlot({left:"start_date",right:"end_date" },e,t,"weekAgenda")},extendGenericSlot:function(t,a,i,r){var n,s=a.movingDate;if(s||(s=t[i]),!s||!t[i])return a;if(!i)return e.$keyboardNavigation.TimeSlot.prototype.clone(a);n=this.nextSlot({start_date:a[s],section:a.section},i,r,!0),n.start_date.valueOf()==a.start_date.valueOf()&&(n=this.nextSlot({start_date:n.start_date,section:n.section},i,r,!0)),n.movingDate=s;var d=this.extendSlotDates(a,n,n.movingDate);return d.end_date.valueOf()<=d.start_date.valueOf()&&(n.movingDate="end_date"==n.movingDate?"start_date":"end_date"), d=this.extendSlotDates(a,n,n.movingDate),n.start_date=d.start_date,n.end_date=d.end_date,n},extendSlotDates:function(e,t,a){var i={start_date:null,end_date:null};return"start_date"==a?(i.start_date=t.start_date,i.end_date=e.end_date):(i.start_date=e.start_date,i.end_date=t.start_date),i},extendMonthSlot:function(t,a){var t=this.extendGenericSlot({up:"start_date",down:"end_date",left:"start_date",right:"end_date"},t,a,"month");return t.start_date.setHours(e.config.first_hour),t.end_date=e.date.add(t.end_date,-1,"day"), t.end_date.setHours(e.config.last_hour),t},extendUnitsSlot:function(e,t){var a;switch(t){case"down":case"up":a=this.extendDaySlot(e,t);break;default:a=e}return a.section=e.section,a},extendDaySlot:function(e,t){return this.extendGenericSlot({up:"start_date",down:"end_date",left:"start_date",right:"end_date"},e,t,"dayColumns")},scrollSlot:function(t){var a=e.getState(),i=this.nextSlot(this,t);(i.start_date.valueOf()=a.max_date.valueOf())&&e.setCurrentView(new Date(i.start_date)), this.moveTo(i)},keys:{left:function(){this.scrollSlot("left")},right:function(){this.scrollSlot("right")},down:function(){var t=this._getMode();t==this._modes.list?e.$keyboardNavigation.SchedulerNode.prototype.nextEventHandler():this.scrollSlot("down")},up:function(){var t=this._getMode();t==this._modes.list?e.$keyboardNavigation.SchedulerNode.prototype.prevEventHandler():this.scrollSlot("up")},"shift+down":function(){this.moveTo(this.extendSlot(this,"down"))},"shift+up":function(){this.moveTo(this.extendSlot(this,"up")); },"shift+right":function(){this.moveTo(this.extendSlot(this,"right"))},"shift+left":function(){this.moveTo(this.extendSlot(this,"left"))},enter:function(){var t={start_date:new Date(this.start_date),end_date:new Date(this.end_date)},a=e.getState().mode;if(e.matrix&&e.matrix[a]){var i=e.matrix[e.getState().mode];t[i.y_property]=this.section}else if(e._props&&e._props[a]){var r=e._props[a];t[r.map_to]=this.section}e.addEventNow(t)}}}),e.$keyboardNavigation.TimeSlot.prototype.bindAll(e.$keyboardNavigation.TimeSlot.prototype.keys), e.$keyboardNavigation.MinicalButton=function(e,t){this.container=e,this.index=t||0},e.$keyboardNavigation.MinicalButton.prototype=e._compose(e.$keyboardNavigation.KeyNavNode,{isValid:function(){return!0},focus:function(){e.$keyboardNavigation.dispatcher.globalNode.disable(),this.container.removeAttribute("tabindex"),e.$keyboardNavigation.KeyNavNode.prototype.focus.apply(this)},blur:function(){this.container.setAttribute("tabindex","0"),e.$keyboardNavigation.KeyNavNode.prototype.blur.apply(this)}, getNode:function(){return this.index?this.container.querySelector(".dhx_cal_next_button"):this.container.querySelector(".dhx_cal_prev_button")},keys:{right:function(t){this.moveTo(new e.$keyboardNavigation.MinicalButton(this.container,this.index?0:1))},left:function(t){this.moveTo(new e.$keyboardNavigation.MinicalButton(this.container,this.index?0:1))},down:function(){var t=new e.$keyboardNavigation.MinicalCell(this.container,0,0);t&&!t.isValid()&&(t=t.fallback()),this.moveTo(t)},enter:function(e){ this.getNode().click()}}}),e.$keyboardNavigation.MinicalButton.prototype.bindAll(e.$keyboardNavigation.MinicalButton.prototype.keys),e.$keyboardNavigation.MinicalCell=function(e,t,a){this.container=e,this.row=t||0,this.col=a||0},e.$keyboardNavigation.MinicalCell.prototype=e._compose(e.$keyboardNavigation.KeyNavNode,{isValid:function(){var e=this._getGrid();return!(!e[this.row]||!e[this.row][this.col])},fallback:function(){var t=this.row,a=this.col,i=this._getGrid();i[t]||(t=0);var r=!0;if(t>i.length/2&&(r=!1), r){for(var n=a;n-1||l.indexOf("dhx_before")>-1||l.indexOf("dhx_scale_ignore")>-1)&&(o=!1),a[i][s]=o}}return a},keys:{right:function(t){var a=this._getGrid(),i=this.row,r=this.col+1;a[i]&&a[i][r]||(a[i+1]?(i+=1,r=0):r=this.col);var n=new e.$keyboardNavigation.MinicalCell(this.container,i,r);n.isValid()||(n=n.fallback()),this.moveTo(n)},left:function(t){var a=this._getGrid(),i=this.row,r=this.col-1;a[i]&&a[i][r]||(a[i-1]?(i-=1,r=a[i].length-1):r=this.col);var n=new e.$keyboardNavigation.MinicalCell(this.container,i,r); n.isValid()||(n=n.fallback()),this.moveTo(n)},down:function(){var t=this._getGrid(),a=this.row+1,i=this.col;t[a]&&t[a][i]||(a=this.row);var r=new e.$keyboardNavigation.MinicalCell(this.container,a,i);r.isValid()||(r=r.fallback()),this.moveTo(r)},up:function(){var t=this._getGrid(),a=this.row-1,i=this.col;if(t[a]&&t[a][i]){var r=new e.$keyboardNavigation.MinicalCell(this.container,a,i);r.isValid()||(r=r.fallback()),this.moveTo(r)}else{var n=0;this.col>t[this.row].length/2&&(n=1),this.moveTo(new e.$keyboardNavigation.MinicalButton(this.container,n)); }},enter:function(e){this.getNode().querySelector(".dhx_month_head").click()}}}),e.$keyboardNavigation.MinicalCell.prototype.bindAll(e.$keyboardNavigation.MinicalCell.prototype.keys),e.$keyboardNavigation.DataArea=function(e){this.index=e||0},e.$keyboardNavigation.DataArea.prototype=e._compose(e.$keyboardNavigation.KeyNavNode,{getNode:function(t){return e.$container.querySelector(".dhx_cal_data")},_handlers:null,isValid:function(){return!0},fallback:function(){return this},keys:{"up,down,right,left":function(){ this.moveTo(new e.$keyboardNavigation.TimeSlot)}}}),e.$keyboardNavigation.DataArea.prototype.bindAll(e.$keyboardNavigation.DataArea.prototype.keys),dhtmlx._modalsStack||(dhtmlx._modalsStack=[]),function(){function t(){return!(!l.length&&!dhtmlx._modalsStack.length)}function a(e,t){for(;e&&e!=t;)e=e.parentNode;return!(e!=t)}function i(i){setTimeout(function(){t()||a(document.activeElement,e.$container)||e.focus()},1)}function r(t){e.eventRemove(t,"keydown",d),e.event(t,"keydown",d),l.push(t)}function n(){ var t=l.pop();t&&e.eventRemove(t,"keydown",d),i(t)}function s(e){return dhtmlx._modalsStack.length?e==dhtmlx._modalsStack[dhtmlx._modalsStack.length-1]:e==l[l.length-1]}function d(t){var t=t||window.event,a=t.currentTarget;s(a)&&e.$keyboardNavigation.trapFocus(a,t)}function o(){r(e.getLightbox())}var l=[];if(e.attachEvent("onLightbox",o),e.attachEvent("onAfterLightbox",n),e.attachEvent("onAfterQuickInfo",function(){i()}),!dhtmlx._keyNavMessagePopup){dhtmlx._keyNavMessagePopup=!0;var c=null,h=null; dhtmlx.attachEvent("onMessagePopup",function(t){for(c=document.activeElement,h=c;h&&e._getClassName(h).indexOf("dhx_cal_data")<0;)h=h.parentNode;h&&(h=h.parentNode),e.eventRemove(t,"keydown",d),e.event(t,"keydown",d),dhtmlx._modalsStack.push(t)}),dhtmlx.attachEvent("onAfterMessagePopup",function(){var t=dhtmlx._modalsStack.pop();t&&e.eventRemove(t,"keydown",d),setTimeout(function(){for(var t=document.activeElement;t&&e._getClassName(t).indexOf("dhx_cal_light")<0;)t=t.parentNode;t||(c&&c.parentNode?c.focus():h&&h.parentNode&&h.focus(), c=null,h=null)},1)})}e.$keyboardNavigation.isModal=t}(),e.$keyboardNavigation.dispatcher={isActive:!1,activeNode:null,globalNode:new e.$keyboardNavigation.SchedulerNode,enable:function(){this.isActive=!0,this.globalNode.enable(),this.setActiveNode(this.getActiveNode())},disable:function(){this.isActive=!1,this.globalNode.disable()},isEnabled:function(){return!!this.isActive},getDefaultNode:function(){return this.globalNode.getDefaultNode()},setDefaultNode:function(){this.setActiveNode(this.getDefaultNode()); },getActiveNode:function(){var e=this.activeNode;return e&&!e.isValid()&&(e=e.fallback()),e},focusGlobalNode:function(){this.blurNode(this.globalNode),this.focusNode(this.globalNode)},setActiveNode:function(e){e&&e.isValid()&&(this.activeNode&&this.activeNode.compareTo(e)||this.isEnabled()&&(this.blurNode(this.activeNode),this.activeNode=e,this.focusNode(this.activeNode)))},focusNode:function(t){t&&t.focus&&(t.focus(),t.getNode&&document.activeElement!=t.getNode()&&this.setActiveNode(new e.$keyboardNavigation.DataArea)); },blurNode:function(e){e&&e.blur&&e.blur()},keyDownHandler:function(t){var a=this.getActiveNode();if((!e.$keyboardNavigation.isModal()||a&&a.container&&e._locate_css({target:a.container},"dhx_minical_popup",!1))&&this.isEnabled()){t=t||window.event;var i=this.globalNode,r=e.$keyboardNavigation.shortcuts.getCommandFromEvent(t);a?a.findHandler(r)?a.doAction(r,t):i.findHandler(r)&&i.doAction(r,t):this.setDefaultNode()}}},e._temp_key_scope=function(){function t(e){e=e||window.event,s.x=e.clientX,s.y=e.clientY; }function a(){for(var t=!1,a=!1,i=document.elementFromPoint(s.x,s.y);i&&i!=e._obj;)i=i.parentNode;return t=!(i!=e._obj),a=e.$keyboardNavigation.dispatcher.isEnabled(),t||a}function i(e){delete e.rec_type,delete e.rec_pattern,delete e.event_pid,delete e.event_length}function r(){var t=e.$keyboardNavigation.dispatcher.getActiveNode();return t&&t.eventId?t.eventId:e._select_id}e.config.key_nav=!0,e.$keyboardNavigation._pasteDate=null,e.$keyboardNavigation._pasteSection=null;var n=null,s={};document.body?dhtmlxEvent(document.body,"mousemove",t):dhtmlxEvent(window,"load",function(){ dhtmlxEvent(document.body,"mousemove",t)}),e.attachEvent("onMouseMove",function(t,a){var i=e.getState();if(i.mode&&i.min_date){var r=e.getActionData(a);e.$keyboardNavigation._pasteDate=r.date,e.$keyboardNavigation._pasteSection=r.section}}),e._make_pasted_event=function(t){var a=e.$keyboardNavigation._pasteDate,r=e.$keyboardNavigation._pasteSection,n=t.end_date-t.start_date,s=e._lame_copy({},t);if(i(s),s.start_date=new Date(a),s.end_date=new Date(s.start_date.valueOf()+n),r){var d=e._get_section_property(); e.config.multisection?s[d]=t[d]:s[d]=r}return s},e._do_paste=function(t,a,i){e.addEvent(a),e.callEvent("onEventPasted",[t,a,i])},e._is_key_nav_active=function(){return this._is_initialized()&&!this._is_lightbox_open()&&this.config.key_nav?!0:!1},e._key_nav_copy_paste=function(t){if(!e._is_key_nav_active())return!0;if(t=t||event,37==t.keyCode||39==t.keyCode){t.cancelBubble=!0;var i=e.date.add(e._date,37==t.keyCode?-1:1,e._mode);return e.setCurrentView(i),!0}var s=r();if((t.ctrlKey||t.metaKey)&&67==t.keyCode)return s&&(e._buffer_id=s, n=!0,e.callEvent("onEventCopied",[e.getEvent(s)])),!0;if((t.ctrlKey||t.metaKey)&&88==t.keyCode&&s){n=!1,e._buffer_id=s;var d=e.getEvent(s);e.updateEvent(d.id),e.callEvent("onEventCut",[d])}if((t.ctrlKey||t.metaKey)&&86==t.keyCode&&a(t)){var d=e.getEvent(e._buffer_id);if(d){var o=e._make_pasted_event(d);if(n)o.id=e.uid(),e._do_paste(n,o,d);else{var l=e.callEvent("onBeforeEventChanged",[o,t,!1,d]);l&&(e._do_paste(n,o,d),n=!0)}}return!0}}},e._temp_key_scope(),function(){function t(e){clearTimeout(_), _=setTimeout(e,1)}function a(t){if(e.config.key_nav&&l.isEnabled()){var a=t,i=new e.$keyboardNavigation.Event(a.eventId);if(!i.isValid()){var r=i.start||a.start,n=i.end||a.end,s=i.section||a.section;i=new e.$keyboardNavigation.TimeSlot(r,n,s),i.isValid()||(i=new e.$keyboardNavigation.TimeSlot)}l.setActiveNode(i);var d=l.getActiveNode();d&&d.getNode&&document.activeElement!=d.getNode()&&l.focusNode(l.getActiveNode())}}function i(e,t){for(;e&&e!=t;)e=e.parentNode;return!(e!=t)}function r(e){for(var t=0;t-1&&(r=!0); var s=u.apply(this,arguments);if(e.config.key_nav&&l.isEnabled()){var d=l.getActiveNode();if(d.eventId==i||r){var o=new e.$keyboardNavigation.Event(i);r?(l.disable(),t(function(){l.enable(),a(o)})):a(o)}}return s},e.attachEvent("onEventDeleted",function(t){if(!e.config.key_nav)return!0;if(l.isEnabled()){var a=l.getActiveNode();a.eventId==t&&l.setActiveNode(new e.$keyboardNavigation.TimeSlot)}return!0}),e.attachEvent("onClearAll",function(){return e.config.key_nav?void(l.isEnabled()&&l.getActiveNode()instanceof e.$keyboardNavigation.Event&&l.setActiveNode(new e.$keyboardNavigation.TimeSlot)):!0; }),e.attachEvent("onClick",function(i){if(!e.config.key_nav)return!0;var r=new e.$keyboardNavigation.Event(i);return t(function(){e.getEvent(i)&&(l.enable(),a(r))}),!0}),e.attachEvent("onEmptyClick",function(t,a){if(!e.config.key_nav)return!0;if(l.isEnabled()||l.enable(),l.isEnabled()){var i=e.getActionData(a);if(i.date){var r=e.$keyboardNavigation.TimeSlot;l.setActiveNode(r.prototype.nextSlot(new r(i.date,null,i.section)))}}});var v=[],g=e.renderCalendar;e.renderCalendar=function(){var t=g.apply(this,arguments); t._key_nav_click||(t._key_nav_click=!0,e.event(t,"click",s)),t._key_nav_focus||(t._key_nav_focus=!0,e.event(t,"focus",n));for(var a=!1,i=0;i