UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 31.7 kB
module.exports=function(e){function t(s){if(a[s])return a[s].exports;var i=a[s]={exports:{},id:s,loaded:!1};return e[s].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var a={};return t.m=e,t.c=a,t.p="",t(0)}({0:function(e,t,a){e.exports=a(1382)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1377:function(e,t){e.exports=require("./kendo.scheduler.view")},1382:function(e,t,a){var s,i,n;!function(o,define){i=[a(1377)],s=o,n="function"==typeof s?s.apply(t,i):s,!(void 0!==n&&(e.exports=n))}(function(){return function(e,t){function a(e){var t=new Date(1980,1,1,0,0,0);return d(t,T(e)),t}function s(e,t,a){return e>=t&&e<=a}function i(e,t,a,s){return s=s?e<=a:e<a,e>t&&s}function n(e,t,a,s){var i,n=e._continuousEvents,o=n[n.length-1],l=m(t.start.startDate()).getTime();if(s&&o&&m(o.start.startDate()).getTime()==l){for(i=n.length-1;i>-1&&!(n[i].isAllDay||m(n[i].start.startDate()).getTime()<l);i--);n.splice(i+1,0,{element:a,isAllDay:!0,uid:a.attr(r.attr("uid")),start:t.start,end:t.end})}else n.push({element:a,isAllDay:s,uid:a.attr(r.attr("uid")),start:t.start,end:t.end})}function o(e){var t,a,s;if(e.workDays&&e.workDays.length)return e.workDays;for(t=[],a=e.workWeekStart%7,s=Math.abs(e.workWeekEnd%7),t.push(a);s!=a;)a>6?a-=7:a++,t.push(a);return t}var r=window.kendo,l=r.ui,d=r.date.setTime,u=l.SchedulerView,h=r._outerWidth,c=r._outerHeight,p=e.extend,f=e.proxy,m=r.date.getDate,_=r.date.MS_PER_MINUTE,g=r.date.MS_PER_DAY,v="k-current-time",y="k-current-time-arrow",D="k-event-inverse",k=.8666,T=r.date.getMilliseconds,w=".kendoMultiDayView",S=r.template('<div title="(#=kendo.format("{0:t} - {1:t}", start, end)#): #=title.replace(/"/g,"&\\#34;")#"><div class="k-event-template k-event-time">#:kendo.format("{0:t} - {1:t}", start, end)#</div><div class="k-event-template">${title}</div></div>'),C=r.template('<div title="(#=kendo.format("{0:t}", start)#): #=title.replace(/"/g,"&\\#34;")#"><div class="k-event-template">${title}</div></div>'),b=r.template("#var dateString = isMobile ? kendo.toString(date,'ddd')[0] : kendo.toString(date,'ddd M/dd'); #<span class='k-link k-nav-day'>#=dateString#</span>"),x='<div role="gridcell" aria-selected="false" data-#=ns#uid="#=uid#"#if (resources[0]) { #style="background-color:#=resources[0].color#; border-color: #=resources[0].color#"class="k-event"#} else {#class="k-event"#}#><span class="k-event-actions"># if(data.tail || data.middle) {#<span class="k-icon k-i-arrow-60-left"></span>#}## if(data.isException()) {#<span class="k-icon k-i-non-recurrence"></span># } else if(data.isRecurring()) {#<span class="k-icon k-i-reload"></span># } #</span>{0}<span class="k-event-actions">#if (showDelete) {#<a href="\\#" class="k-link k-event-delete" title="${data.messages.destroy}" aria-label="${data.messages.destroy}"><span class="k-icon k-i-close"></span></a>#}## if(data.head || data.middle) {#<span class="k-icon k-i-arrow-60-right"></span>#}#</span>#if(resizable && !singleDay && !data.tail && !data.middle){#<span class="k-resize-handle k-resize-w"></span>#}##if(resizable && !singleDay && !data.head && !data.middle){#<span class="k-resize-handle k-resize-e"></span>#}#</div>',E='<div role="gridcell" aria-selected="false" data-#=ns#uid="#=uid#" #if (resources[0]) { #style="background-color:#=resources[0].color #; border-color: #=resources[0].color#"class="k-event"#} else {#class="k-event"#}#><span class="k-event-actions"># if(data.isException()) {#<span class="k-icon k-i-non-recurrence"></span># } else if(data.isRecurring()) {#<span class="k-icon k-i-reload"></span># } #</span>{0}<span class="k-event-actions">#if (showDelete) {#<a href="\\#" class="k-link k-event-delete" title="${data.messages.destroy}" aria-label="${data.messages.destroy}"><span class="k-icon k-i-close"></span></a>#}#</span><span class="k-event-top-actions"># if(data.tail || data.middle) {#<span class="k-icon k-i-arrow-60-up"></span># } #</span><span class="k-event-bottom-actions"># if(data.head || data.middle) {#<span class="k-icon k-i-arrow-60-down"></span># } #</span># if(resizable && !data.tail && !data.middle) {#<span class="k-resize-handle k-resize-n"></span># } ## if(resizable && !data.head && !data.middle) {#<span class="k-resize-handle k-resize-s"></span># } #</div>',H=u.extend({init:function(e,t){var a=this;u.fn.init.call(a,e,t),a.title=a.options.title||a.options.name,a._workDays=o(a.options),a._templates(),a._editable(),a.calculateDateRange(),a._groups(),a._currentTime(!0)},_currentTimeMarkerUpdater:function(){this._updateCurrentTimeMarker(new Date)},_updateCurrentTimeMarker:function(t){var a,s,i,n,o,l,d,u,p,f,m,_,g,D,T,w,S,C,b,x=this.options,E="<div class='"+v+"'></div>";for(x.currentTimeMarker.useLocalTimezone===!1&&(o=x.dataSource.options.schema.timezone,x.dataSource&&o&&(l=r.timezone.offset(t,o),t=r.timezone.convert(t,t.getTimezoneOffset(),l))),a=this.times.find("."+v),s=this.content.find("."+v),d=x.group&&"horizontal"!=x.group.orientation?this.groups.length:1,u=this.times.find("tr:first th:first"),p=this.times.find("tr:first th:last"),u.length>0&&p.length>0&&(n=this._isRtl?u.position().left+c(u)-c(p):p.position().left),f=0;f<d;f++){if(m=this.groups[f],!m)return;if(_=r.date.toUtcTime(t),g=m.timeSlotRanges(_,_+1),0===g.length)return;D=g[0].collection,T=D.slotByStartDate(t),T&&(w=a[f]?a.eq(f):e(E).prependTo(this.times),S=Math.round(g[0].innerRect(t,new Date(t.getTime()+1),!1).top),C={},this._isRtl?(C.right=n,w.addClass(y+"-left")):(C.left=n,w.addClass(y+"-right")),i||(i=h(w)*k/2),C.top=S-i,w.css(C),b=s[f]?s.eq(f):e(E).prependTo(this.content),b.css({top:S,height:"1px",right:0,left:0}))}},_currentTime:function(e){var a=this,s=a.options.currentTimeMarker;s!==!1&&s.updateInterval!==t&&(a._currentTimeMarkerUpdater(),e&&(a._currentTimeUpdateTimer=setInterval(f(this._currentTimeMarkerUpdater,a),s.updateInterval)))},_updateResizeHint:function(e,t,a,s){var i,n,o,l,d,h,c,p,f,m,_,g,v=e.isMultiDay(),y=this.groups[t],D=y.ranges(a,s,v,e.isAllDay);for(this._removeResizeHint(),d=0;d<D.length;d++)if(h=D[d],c=h.startSlot(),this._isGroupedByDate()&&v)for(p=c.index;p<=h.end.index;p++)f=h.collection._slots[p],i=f.offsetWidth,n=f.clientHeight,o=f.offsetTop,l=u.fn._createResizeHint.call(this,f.offsetLeft,o,i,n),this._resizeHint=this._resizeHint.add(l);else i=c.offsetWidth,n=c.clientHeight,o=c.offsetTop,v?i=h.innerWidth():(m=h.outerRect(a,s,this.options.snap),o=m.top,n=m.bottom-m.top),l=u.fn._createResizeHint.call(this,c.offsetLeft,o,i,n),this._resizeHint=this._resizeHint.add(l);_="t",g=this.content,v&&(_="M/dd",g=this.element.find(".k-scheduler-header-wrap:has(.k-scheduler-header-all-day) > div"),g.length||(g=this.content)),this._resizeHint.appendTo(g),this._resizeHint.find(".k-label-top,.k-label-bottom").text(""),this._resizeHint.first().addClass("k-first").find(".k-label-top").text(r.toString(r.timezone.toLocalDate(a),_)),this._resizeHint.last().addClass("k-last").find(".k-label-bottom").text(r.toString(r.timezone.toLocalDate(s),_))},_updateMoveHint:function(t,a,s){var i,n,o,l,d,u,h,c,p,f,m=t.isMultiDay(),_=this.groups[a],g=r.date.toUtcTime(t.start)+s,v=g+t.duration(),y=_.ranges(g,v,m,t.isAllDay);for(g=r.timezone.toLocalDate(g),v=r.timezone.toLocalDate(v),this._removeMoveHint(t.uid),!m&&(0===T(v)||T(v)<T(this.startTime()))&&y.length>1&&y.pop(),i=e(),n=0;n<y.length;n++)if(o=y[n],l=o.start,u={left:l.offsetLeft+2,top:l.offsetTop},this._isGroupedByDate()&&m)for(h=l.index;h<=o.end.index;h++)c=o.collection._slots[h],u.left=this._isRtl?.1*c.clientWidth+c.offsetLeft+2:c.offsetLeft+2,u.height=c.offsetHeight,u.width=.9*c.clientWidth-2,d=this._createEventElement(t.clone({start:g,end:v}),!m),t.inverseColor&&d.addClass(D),this._appendMoveHint(d,u),i=i.add(d);else this._isRtl&&(u.left=.1*l.clientWidth+l.offsetLeft+2),m?u.width=o.innerWidth()-2:(p=o.outerRect(g,v,this.options.snap),u.top=p.top,u.height=p.bottom-p.top,u.width=.9*l.clientWidth-2),d=this._createEventElement(t.clone({start:g,end:v}),!m),t.inverseColor&&d.addClass(D),this._appendMoveHint(d,u),i=i.add(d);f=this.content,m&&(f=this.element.find(".k-scheduler-header-wrap:has(.k-scheduler-header-all-day) > div"),f.length||(f=this.content)),i.appendTo(f)},_appendMoveHint:function(e,t){e.addClass("k-event-drag-hint"),e.css(t),this._moveHint=this._moveHint.add(e)},_slotByPosition:function(e,t){var a,s,i,n;for(this._isVerticallyGrouped()?(s=this.content.offset(),t+=this.content[0].scrollTop,e+=this.content[0].scrollLeft):s=this.element.find(".k-scheduler-header-wrap:has(.k-scheduler-header-all-day)").find(">div").offset(),s&&(e-=s.left,t-=s.top),e=Math.ceil(e),t=Math.ceil(t),n=0;n<this.groups.length;n++)if(i=this.groups[n],a=i.daySlotByPosition(e,t,this._isGroupedByDate()))return a;for(s&&(e+=s.left,t+=s.top),s=this.content.offset(),e-=s.left,t-=s.top,this._isVerticallyGrouped()||(t+=this.content[0].scrollTop,e+=this.content[0].scrollLeft),e=Math.ceil(e),t=Math.ceil(t),n=0;n<this.groups.length;n++)if(i=this.groups[n],a=i.timeSlotByPosition(e,t))return a;return null},_groupCount:function(){var e=this.groupedResources,t=this._isGroupedByDate();return e.length?"vertical"===this._groupOrientation()?t?this._columnCountForLevel(e.length-1):this._rowCountForLevel(e.length-1):t?this._columnCountForLevel(e.length)/this._columnCountForLevel(0):this._columnCountForLevel(e.length)/this._columnOffsetForResource(e.length):1},_columnCountInResourceView:function(){var e=this.groupedResources,t=this._isGroupedByDate();return!e.length||this._isVerticallyGrouped()?t?this._rowCountForLevel(0):this._columnCountForLevel(0):t?this._columnCountForLevel(0):this._columnOffsetForResource(e.length)},_timeSlotGroups:function(e,t){var a,s,i,n,o,r,l,d,u,h,c=this._timeSlotInterval(),p=e,f=this._isGroupedByDate(),m=this.content.find("tr:not(.k-scheduler-header-all-day)");for(m.attr("role","row"),o=m.length,this._isVerticallyGrouped()&&(f&&(p=t),o=Math.floor(o/p)),r=0;r<p;r++)for(l=0,d=0,this._isVerticallyGrouped()?l=r:d=r,i=l*o;i<(l+1)*o;){if(u=m[i].children,i%o===0&&(s=T(new Date((+this.startTime())))),h=0,f)if(this._isVerticallyGrouped())for(n=0;n<e;n++)a=this.groups[n],this._addTimeSlotGroup(a,u,n,s,c,r);else for(a=this.groups[r],n=d;n<e*t;n+=e)this._addTimeSlotGroup(a,u,n,s,c,h),h++;else for(a=this.groups[r],n=d*t;n<(d+1)*t;n++)this._addTimeSlotGroup(a,u,n,s,c,h),h++;s+=c,i++}},_addTimeSlotGroup:function(e,t,a,s,i,n){var o,r,l,d=t[a],u=e.getTimeSlotCollection(n),h=this._dates[n];h&&d&&(o=Date.UTC(h.getFullYear(),h.getMonth(),h.getDate()),r=o+s,l=r+i,d.setAttribute("role","gridcell"),d.setAttribute("aria-selected",!1),u.addTimeSlot(d,r,l))},_addDaySlotGroup:function(e,t,a,s,i){var n,o=t[a],l=this._dates[i];l&&(n=Date.UTC(l.getFullYear(),l.getMonth(),l.getDate()),o.setAttribute("role","gridcell"),o.setAttribute("aria-selected",!1),e.addDaySlot(o,n,n+r.date.MS_PER_DAY))},_daySlotGroups:function(e,t){var a,s,i,n,o,r,l,d,u,h=e,c=this._isGroupedByDate();for(this._isVerticallyGrouped()?(c&&(h=t),a=this.element.find(".k-scheduler-header-all-day")):a=this.element.find(".k-scheduler-header-all-day tr"),a.attr("role","row"),i=0;i<h;i++)if(n=0,this._isVerticallyGrouped()&&(n=i),l=a[n].children,d=0,this._isVerticallyGrouped()||(d=i),u=0,c)if(this._isVerticallyGrouped())for(s=0;s<e;s++)o=this.groups[s],r=o.getDaySlotCollection(0),this._addDaySlotGroup(r,l,s,t,i);else for(o=this.groups[i],r=o.getDaySlotCollection(0),s=d;s<e*t;s+=e)this._addDaySlotGroup(r,l,s,t,u),u++;else for(o=this.groups[i],r=o.getDaySlotCollection(0),s=d*t;s<(d+1)*t;s++)this._addDaySlotGroup(r,l,s,t,u),u++},_groups:function(){var e,t,a,s=this._groupCount(),i=this._columnCountInResourceView();for(this.groups=[],e=0;e<s;e++){for(t=this._addResourceView(e),a=0;a<i;a++)this._dates[a]&&t.addTimeSlotCollection(this._dates[a],r.date.addDays(this._dates[a],1));this.options.allDaySlot&&t.addDaySlotCollection(this._dates[0],r.date.addDays(this._dates[this._dates.length-1],1))}this._timeSlotGroups(s,i),this.options.allDaySlot&&this._daySlotGroups(s,i)},options:{name:"MultiDayView",selectedDateFormat:"{0:D}",selectedShortDateFormat:"{0:d}",selectedMobileDateFormat:"{0:MMM} {0:dd} - {1:dd}",allDaySlot:!0,showWorkHours:!1,title:"",startTime:r.date.today(),endTime:r.date.today(),minorTickCount:2,majorTick:60,majorTimeHeaderTemplate:"<span>#=kendo.toString(date, 't')#</span>",minorTimeHeaderTemplate:"&\\#8203;",groupHeaderTemplate:"#=text#",slotTemplate:"&nbsp;",allDaySlotTemplate:"&nbsp;",eventTemplate:S,allDayEventTemplate:C,dateHeaderTemplate:b,editable:!0,workDayStart:new Date(1980,1,1,8,0,0),workDayEnd:new Date(1980,1,1,17,0,0),workWeekStart:1,workWeekEnd:5,footer:{command:"workDay"},messages:{allDay:"all day",showFullDay:"Show full day",showWorkDay:"Show business hours"},currentTimeMarker:{updateInterval:1e4,useLocalTimezone:!0}},events:["remove","add","edit"],_templates:function(){var e=this.options,t=p({},r.Template,e.templateSettings);this.eventTemplate=this._eventTmpl(e.eventTemplate,E),this.allDayEventTemplate=this._eventTmpl(e.allDayEventTemplate,x),this.majorTimeHeaderTemplate=r.template(e.majorTimeHeaderTemplate,t),this.minorTimeHeaderTemplate=r.template(e.minorTimeHeaderTemplate,t),this.dateHeaderTemplate=r.template(e.dateHeaderTemplate,t),this.slotTemplate=r.template(e.slotTemplate,t),this.allDaySlotTemplate=r.template(e.allDaySlotTemplate,t),this.groupHeaderTemplate=r.template(e.groupHeaderTemplate,t)},_editable:function(){this.options.editable&&(this._isMobile()?this._touchEditable():this._mouseEditable())},_mouseEditable:function(){var t=this;t.element.on("click"+w,".k-event a:has(.k-i-close)",function(a){t.trigger("remove",{uid:e(this).closest(".k-event").attr(r.attr("uid"))}),a.preventDefault()}),t.options.editable.create!==!1&&t.element.on("dblclick"+w,".k-scheduler-content > table td",function(a){var s,i;e(this).parent().hasClass("k-scheduler-header-all-day")||(s=t._slotByPosition(a.pageX,a.pageY),s&&(i=t._resourceBySlot(s),t.trigger("add",{eventInfo:p({start:s.startDate(),end:s.endDate()},i)})),a.preventDefault())}).on("dblclick"+w,".k-scheduler-header-all-day td",function(e){var a,s=t._slotByPosition(e.pageX,e.pageY);s&&(a=t._resourceBySlot(s),t.trigger("add",{eventInfo:p({},{isAllDay:!0,start:r.date.getDate(s.startDate()),end:r.date.getDate(s.startDate())},a)})),e.preventDefault()}),t.options.editable.update!==!1&&t.element.on("dblclick"+w,".k-event",function(a){t.trigger("edit",{uid:e(this).closest(".k-event").attr(r.attr("uid"))}),a.preventDefault()})},_touchEditable:function(){var a=this,s=0;r.support.mobileOS.android&&(s=5),a.options.editable.create!==!1&&(a._addUserEvents=new r.UserEvents(a.element,{threshold:s,filter:".k-scheduler-content td",useClickAsTap:!r.support.browser.edge,tap:function(s){var i,n,o,r;a._scrolling||e(s.target).parent().hasClass("k-scheduler-header-all-day")||(i=s.x.location!==t?s.x.location:s.x,n=s.y.location!==t?s.y.location:s.y,o=a._slotByPosition(i,n),o&&(r=a._resourceBySlot(o),a.trigger("add",{eventInfo:p({start:o.startDate(),end:o.endDate()},r)})),s.preventDefault())}}),a._allDayUserEvents=new r.UserEvents(a.element,{threshold:s,useClickAsTap:!r.support.browser.edge,filter:".k-scheduler-header-all-day td",tap:function(e){var s,i,n,o;a._scrolling||(s=e.x.location!==t?e.x.location:e.x,i=e.y.location!==t?e.y.location:e.y,n=a._slotByPosition(s,i),n&&(o=a._resourceBySlot(n),a.trigger("add",{eventInfo:p({},{isAllDay:!0,start:r.date.getDate(n.startDate()),end:r.date.getDate(n.startDate())},o)})),e.preventDefault())}})),a.options.editable.update!==!1&&(a._editUserEvents=new r.UserEvents(a.element,{threshold:s,useClickAsTap:!r.support.browser.edge,filter:".k-event",tap:function(t){var s,i;a._scrolling||(s=e(t.target).closest(".k-event"),i=e(t.touch.initialTouch),i.hasClass("k-i-close")?a.trigger("remove",{uid:s.attr(r.attr("uid"))}):s.hasClass("k-event-active")||a.trigger("edit",{uid:s.attr(r.attr("uid"))}),t.preventDefault())}}))},_layout:function(e){var t,a,s,i=[],n=[],o=this.options,l=this,d=l._isGroupedByDate();for(t=0;t<e.length;t++)a={},a.text=l.dateHeaderTemplate({date:e[t],isMobile:l._isMobile()}),r.date.isToday(e[t])&&(a.className="k-today"),i.push(a);return s=this.groupedResources,o.allDaySlot&&n.push({text:o.messages.allDay,allDay:!0,cellContent:function(t){var a=t;return t=s.length&&"vertical"!==l._groupOrientation()?t%e.length:t,l.allDaySlotTemplate({date:e[t],resources:function(){return l._resourceBySlot({groupIndex:a})}})}}),this._forTimeRange(this.startTime(),this.endTime(),function(e,t,a,s){var i=t?l.majorTimeHeaderTemplate:l.minorTimeHeaderTemplate,o={text:i({date:e}),className:s?"k-slot-cell":""};n.push(o)}),s.length&&("vertical"===this._groupOrientation()?d?(n=this._createDateLayout(i,n),i=this._createColumnsLayout(s,null,this.groupHeaderTemplate)):n=this._createRowsLayout(s,n,this.groupHeaderTemplate):i=d?this._createColumnsLayout(s,i,this.groupHeaderTemplate,i):this._createColumnsLayout(s,i,this.groupHeaderTemplate)),{columns:i,rows:n}},_footer:function(){var t,a,s,i=this.options;i.footer!==!1&&(t='<div class="k-scheduler-footer k-toolbar">',a=i.footer.command,this._isMobile()&&(t+='<span class="k-state-default k-scheduler-today"><a href="#" class="k-link">',t+=i.messages.today+"</a></span>"),a&&"workDay"===a&&(this._isMobile()?(t+='<span class="k-state-default k-scheduler-fullday"><a href="#" class="k-link">',t+=(i.showWorkHours?i.messages.showFullDay:i.messages.showWorkDay)+"</a></span>"):(t+='<button type="button" class="k-button k-scheduler-fullday">',t+='<span class="k-icon k-i-clock"></span>',t+='<span class="k-button-text">',t+=i.showWorkHours?i.messages.showFullDay:i.messages.showWorkDay,t+="</span>",t+="</button>")),t+="</div>",this.footer=e(t).appendTo(this.element),s=this,this.footer.on("click"+w,".k-scheduler-fullday",function(e){e.preventDefault(),s.trigger("navigate",{view:s.name||i.name,date:i.date,isWorkDay:!i.showWorkHours})}),this.footer.on("click"+w,".k-scheduler-today",function(e){var t,a,n,o,l;e.preventDefault(),t=s.options.timezone,a="today",n=new Date,t?(l=r.timezone.offset(n,t),o=r.timezone.convert(n,n.getTimezoneOffset(),l)):o=n,s.trigger("navigate",{view:s.name||i.name,action:a,date:o})}))},_forTimeRange:function(e,t,s,i){var n,o,r,l,u,h,c,p,f,m,v,y,D,k,w,S;for(e=a(e),t=a(t),n=this,o=T(e),r=T(t),l=n.options.minorTickCount,u=n.options.majorTick*_,h=u/l||1,c=new Date((+e)),p=c.getDate(),m=0,y="",v=g/h,o!=r&&(o>r&&(r+=g),v=(r-o)/h),v=Math.round(v);m<v;m++)D=m%(u/h),k=0===D,w=D<l-1,S=D===l-1,y+=s(c,k,w,S),d(c,h,!1);return r&&(f=T(c),p<c.getDate()&&(f+=g),f>r&&(c=new Date((+t)))),i&&(y+=i(c)),y},_content:function(e){var t=this,a="";a+="<tbody>",a+=t._renderRows(e,t.rowLevels,t.columnLevels),a+="</tbody>",this.content.find("table").append(a)},_virtualContent:function(e,t){var a=this,s="",i=a._dates;s+=a._renderRows(i,e,t),a.content.find("table tbody").append(s)},_renderRows:function(e,t,a){var s,i,n,o=this,r="vertical"===o._groupOrientation(),l=o._isGroupedByDate(),d=0,u=e.length,h=o.options,c=o.startTime(),p=this.endTime(),f=1,m=1,_=this.groupedResources,g="";for(_.length&&(s=o._recalculateLevels(t,a),m=s.rowCount,f=s.groupsCount),i=function(t,a,s){var i,h,c,p="",m=0;if(p="<tr"+(s?' class="k-middle-row"':"")+">",l)for(i=0,h=u;i<h;i++){for(m=0;m<f;m++)c=i,r&&(c=d),p=o._addCellsToContent(p,e,t,c,m,n);if(r)break}else for(;m<f;m++)for(i=0,h=u;i<h;i++)p=o._addCellsToContent(p,e,t,i,m,n);return p+="</tr>"},n=0;n<m;n++)g+=h.allDaySlot&&r?this._allDayVerticalGroupRow(e,n,f,d):"",g+=this._forTimeRange(c,p,i),r&&d++;return g},_recalculateLevels:function(e,t){var a=this,s=a._isGroupedByDate(),i="vertical"===a._groupOrientation(),n=1,o=1;return i?(o=a._rowCountForLevel(e.length-2,e),s&&(n=a._columnCountForLevel(t.length-1))):n=s?a._columnCountForLevel(t.length-1)/this._columnCountForLevel(0):a._columnCountForLevel(t.length-2),{rowCount:o,groupsCount:n}},_allDayVerticalGroupRow:function(e,t,a,s){var i,n=this,o='<tr class="k-scheduler-header-all-day">',r=n._isGroupedByDate(),l=r?0:t,d=n.allDaySlotTemplate,u=function(){return n._resourceBySlot({groupIndex:l})};if(r)for(;l<a;l++)o+="<td>"+d({date:e[s],resources:u})+"</td>";else for(i=0;i<e.length;i++)o+="<td>"+d({date:e[i],resources:u})+"</td>";return o+"</tr>"},_addCellsToContent:function(e,t,a,s,i,n){var o,l=this,d="",u=this.slotTemplate,h="vertical"===this._groupOrientation(),c=function(e){return function(){return l._resourceBySlot({groupIndex:e})}};return r.date.isToday(t[s])&&(d+="k-today"),(r.date.getMilliseconds(a)<r.date.getMilliseconds(this.options.workDayStart)||r.date.getMilliseconds(a)>=r.date.getMilliseconds(this.options.workDayEnd)||!this._isWorkDay(t[s]))&&(d+=" k-nonwork-hour"),e+="<td"+(""!==d?' class="'+d+'"':"")+">",o=r.date.getDate(t[s]),r.date.setTime(o,r.date.getMilliseconds(a)),e+=u({date:o,resources:c(h&&!l._isGroupedByDate()?n:i)}),e+="</td>"},_isWorkDay:function(e){var t,a=e.getDay(),s=this._workDays;for(t=0;t<s.length;t++)if(s[t]===a)return!0;return!1},_render:function(t){var a,s=this;t=t||[],this._dates=t,this._startDate=t[0],this._endDate=t[t.length-1||0],this.createLayout(this._layout(t)),this._content(t),this._footer(),this.refreshLayout(),this._isVirtualized()&&this._tryRenderContent(),a=this.element.find(".k-scheduler-header-all-day td"),a.length&&(this._allDayHeaderHeight=a.first()[0].clientHeight),s.element.on("click"+w,".k-nav-day",function(t){var a,i=e(t.currentTarget).closest("th"),n=i.offset(),o=0,r=c(i);s._isGroupedByDate()&&(s._isVerticallyGrouped()?(o=h(s.times),r=0):r=c(s.datesHeader)),a=s._slotByPosition(n.left+o,n.top+r),s.trigger("navigate",{view:"day",date:a.startDate()})})},startTime:function(){var e=this.options;return e.showWorkHours?e.workDayStart:e.startTime},endTime:function(){var e=this.options;return e.showWorkHours?e.workDayEnd:e.endTime},startDate:function(){return this._startDate},endDate:function(){return this._endDate},_end:function(e){var t=T(this.endTime())||g;return e&&(t=0),new Date(this._endDate.getTime()+t)},nextDate:function(){return r.date.nextDay(this.endDate())},previousDate:function(){return r.date.previousDay(this.startDate())},calculateDateRange:function(){this._render([this.options.date])},destroy:function(){var e=this;e._currentTimeUpdateTimer&&clearInterval(e._currentTimeUpdateTimer),e.datesHeader&&e.datesHeader.off(w),e.element&&e.element.off(w),e.footer&&e.footer.remove(),u.fn.destroy.call(this),this._isMobile()&&e.options.editable&&(e.options.editable.create!==!1&&(e._addUserEvents.destroy(),e._allDayUserEvents.destroy()),e.options.editable.update!==!1&&e._editUserEvents.destroy())},inRange:function(e){var t,a,s,i,n=u.fn.inRange.call(this,e);return e.isAllDay?n:(t=T(this.startTime()),a=T(this.endTime())||r.date.MS_PER_DAY,s=T(e.start),i=T(e.end)||r.date.MS_PER_DAY,n&&t<=s&&i<=a)},selectionByElement:function(e){var t=e.offset(),a=Math.round(e.innerHeight())-5;return this._slotByPosition(t.left,t.top+a)},_timeSlotInterval:function(){var e=this.options;return e.majorTick/e.minorTickCount*_},_timeSlotIndex:function(e){var t=this.options,a=T(e),s=T(this.startTime()),i=t.majorTick/t.minorTickCount*_;return(a-s)/i},_slotIndex:function(e,t){return t?this._dateSlotIndex(e):this._timeSlotIndex(e)},_dateSlotIndex:function(e,t){var a,i,n,o,l=this._dates||[],d=1;for(a=0,i=l.length;a<i;a++)if(n=r.date.getDate(l[a]),o=new Date(r.date.getDate(l[a]).getTime()+g-(t?0:1)),s(e,n,o))return a*d;return-1},_positionAllDayEvent:function(t,a){var s,i,n,o,r,l,d,h=a.innerWidth(),c=a.start.index,p=a.end.index,f=u.collidingEvents(a.events(),c,p),m=this._headerColumnCount||0,_=2,g=c!==p?3:2,v=this._allDayHeaderHeight,y=a.startSlot();for(t.css({left:y.offsetLeft+_,width:h-g}),a.addEvent({slotIndex:c,start:c,end:p,element:t}),f.push({slotIndex:c,start:c,end:p,element:t}),s=u.createRows(f),s.length&&s.length>m&&(this._headerColumnCount=s.length),i=a.start.offsetTop,n=0,o=s.length;n<o;n++)for(r=s[n].events,l=0,d=r.length;l<d;l++)e(r[l].element).css({top:i+n*v,height:v-2})},_arrangeColumns:function(e,t,a,s){var i,n,o,r,l,d,h,c,p,f,m,_,g=s.start;for(e={element:e,slotIndex:g.index,start:t,end:t+a},n=g.clientWidth,o=.1*n,l=s.events(),d=u.collidingEvents(l,e.start,e.end),s.addEvent(e),d.push(e),i=u.createColumns(d),h=(n-o)/i.length,c=0,p=i.length;c<p;c++)for(r=i[c].events,f=0,m=r.length;f<m;f++)_=h-2,r[f].element[0].style.width=(_>0?_:h)+"px",r[f].element[0].style.left=(this._isRtl?o:0)+g.offsetLeft+c*h+2+"px"},_positionEvent:function(e,t,a){var s=e._startTime||e.start,i=e._endTime||e.end,n=r.getComputedStyles(a.start.element,["border-top-width","border-bottom-width"]),o=a.innerRect(s,i,!1),l=o.bottom-o.top-parseFloat(n["border-top-width"])-parseFloat(n["border-bottom-width"]);l<0&&(l=0),t.css({top:o.top,height:l}),this._arrangeColumns(t,o.top,t[0].clientHeight,a)},_createEventElement:function(t,a,i,n){var o,l,d,u,h,c,f=a?this.eventTemplate:this.allDayEventTemplate,_=this.options,v=_.editable,y=this._isMobile(),D=v&&v.destroy!==!1&&!y,k=v&&v.resize!==!1,w=m(this.startDate()),S=m(this.endDate()),C=T(this.startTime()),b=T(this.endTime()),x=t._time("start"),E=t._time("end");return C>=b&&(b=T(new Date(this.endTime().getTime()+g-1))),a||t.isAllDay||(S=new Date(S.getTime()+g)),l=t.start,d=t.end,t.isAllDay&&(d=m(t.end)),!s(m(l),w,S)&&!s(d,w,S)||a&&x<C&&E>b?o=!0:m(l)<w||a&&x<C?n=!0:(d>S&&!a||a&&E>b)&&(i=!0),u=this.eventResources(t),t._startTime&&x!==r.date.getMilliseconds(t.start)&&(l=new Date(x),l=r.timezone.apply(l,"Etc/UTC")),t._endTime&&E!==r.date.getMilliseconds(t.end)&&(d=new Date(E),d=r.timezone.apply(d,"Etc/UTC")),h=p({},{ns:r.ns,resizable:k,showDelete:D,middle:o,head:i,tail:n,singleDay:1==this._dates.length,resources:u,inverseColor:!1,messages:_.messages},t,{start:l,end:d}),c=e(f(h)),this.angular("compile",function(){return{elements:c,data:[{dataItem:h}]}}),c},_isInTimeSlot:function(e){var t,a=this.startTime(),s=this.endTime(),n=e._startTime||e.start,o=e._endTime||e.end;return T(s)===T(r.date.getDate(s))&&(s=r.date.getDate(s),d(s,g-1)),e._date("end")>e._date("start")&&(o=+e._date("end")+(g-1)),o=e._endTime?o-e._date("end"):T(new Date(o)),n=e._startTime?n-e._date("start"):T(new Date(n)),s=T(s),a=T(a),a===n&&n===o||(t=n!==s,i(n,a,s,t)||i(o,a,s,t)||i(a,n,o)||i(s,n,o))},_isInDateSlot:function(e){var t=this.groups[0],a=t.firstSlot().start,i=t.lastSlot().end-1,n=r.date.toUtcTime(e.start),o=r.date.toUtcTime(e.end);return(s(n,a,i)||s(o,a,i)||s(a,n,o)||s(i,n,o))&&(!s(o,a,a)||s(o,n,n)||e.isAllDay)},_updateAllDayHeaderHeight:function(e){var t,a;if(this._height!==e&&(this._height=e,t=this.element.find(".k-scheduler-header-all-day td"),t.length))for(t.parent().add(this.element.find(".k-scheduler-times-all-day").parent()).height(e),a=0;a<this.groups.length;a++)this.groups[a].refresh()},_renderEvents:function(e,t){var a,s,i,o,l,d,u,h,c,p,f,m,_,v,y,D,k,T,w,S,C,b=this.datesHeader.find(".k-scheduler-header-wrap > div"),x=this._isGroupedByDate();for(s=0,i=e.length;s<i;s++)if(a=e[s],this._isInDateSlot(a))if(o=a.isAllDay||a.duration()>=g,l=o&&!this._isVerticallyGrouped()?b:this.content,o){if(this.options.allDaySlot){if(f=this.groups[t],!f)continue;if(f._continuousEvents||(f._continuousEvents=[]),u=f.slotRanges(a),u.length)if(h=u[0],D=h.start.index,k=h.end.index,x&&D!==k)for(c=h.start.start,p=h.end.end,T=c,w=c,S=h.start.index;S<=h.end.index;S++)d=this._createEventElement(a,!o,S!==k,S!==D),C=f.daySlotRanges(T,w,!0)[0],T=w+=r.date.MS_PER_DAY,this._positionAllDayEvent(d,C),n(f,C,d,!0),d.appendTo(l),this._inverseEventColor(d);else d=this._createEventElement(a,!o),this._positionAllDayEvent(d,u[0]),n(f,u[0],d,!0),d.appendTo(l),this._inverseEventColor(d)}}else if(this._isInTimeSlot(a)){if(f=this.groups[t],!f)continue;for(f._continuousEvents||(f._continuousEvents=[]),u=f.slotRanges(a),m=u.length,_=0;_<m;_++)h=u[_],c=a.start,p=a.end,m>1&&(0===_?p=h.end.endDate():_==m-1?c=h.start.startDate():(c=h.start.startDate(),p=h.end.endDate())),v=a.clone({start:c,end:p,_startTime:a._startTime,_endTime:a.endTime}),this._isInTimeSlot(v)&&(y=h.head,d=this._createEventElement(a,!o,y,h.tail),d.appendTo(l),this._inverseEventColor(d),this._positionEvent(v,d,h),n(f,h,d,!1))}},render:function(t){var a,i,n,o;for(this._headerColumnCount=0,this._cachedEvents=t,this._groups(),this.element.find(".k-event").remove(),t=new r.data.Query(t).sort([{field:"start",dir:"asc"},{field:"end",dir:"desc"}]).toArray(),a=[],this._eventsByResource(t,this.groupedResources,a),i=e.map(this._dates,function(t){return Math.max.apply(null,e.map(a,function(a){return e.grep(a,function(e){return e.isMultiDay()&&s(t,m(e.start),m(e.end))}).length}))}),n=Math.max.apply(null,i),this._updateAllDayHeaderHeight((n+1)*this._allDayHeaderHeight),o=0;o<a.length;o++)this._renderEvents(a[o],o);this.refreshLayout(),this._currentTime(!1),this.trigger("activate")},_eventsByResource:function(e,t,a){var s,i,n,o,l=t[0];if(l)for(s=l.dataSource.view(),i=0;i<s.length;i++)n=this._resourceValue(l,s[i]),o=new r.data.Query(e).filter({field:l.field,operator:u.groupEqFilter(n)}).toArray(),t.length>1?this._eventsByResource(o,t.slice(1),a):a.push(o);else a.push(e)},_columnOffsetForResource:function(e){return this._columnCountForLevel(e)/this._columnCountForLevel(e-1)},_columnCountForLevel:function(e){var t=this.columnLevels[e];return t?t.length:0},_rowCountForLevel:function(e,t){t=t||this.rowLevels;var a=t[e];return a?a.length:0},clearSelection:function(){this.content.add(this.datesHeader).find(".k-state-selected").removeAttr("id").attr("aria-selected",!1).removeClass("k-state-selected")},_updateDirection:function(e,t,a,s,i){var n=e.isAllDay,o=t[0].start,r=t[t.length-1].end;a&&(i?n||o.index!==r.index||o.collectionIndex!==r.collectionIndex||(e.backward=s):(n&&o.index===r.index||!n&&o.collectionIndex===r.collectionIndex)&&(e.backward=s))},_changeViewPeriod:function(e,t,a){var s,i,n,o,r,l,u,h,c,p,f,m,_;if(!a)return s=t?this.previousDate():this.nextDate(),i=e.start,n=e.end,o=this._isGroupedByDate()&&this._isVerticallyGrouped(),r=this.groups[e.groupIndex],l=t?r._timeSlotCollections:r._getCollections(r.daySlotCollectionCount()),u=l[l.length-1]._slots,h=t||r.daySlotCollectionCount()?u.length-1:0,p=new Date(s),f=new Date(s),!this._isInRange(p,f)&&(e.start=p,e.end=f,o?(m=new Date(u[h].startDate()),_=new Date(u[h].endDate()),c=T(_)?T(_):g,d(e.start,T(m)),d(e.end,c),r.daySlotCollectionCount()&&(e.isAllDay=!e.isAllDay)):(c=e.isAllDay||!T(n)?g:T(n),d(e.start,T(i)),d(e.end,c)),this._isVerticallyGrouped()||(e.groupIndex=t?this.groups.length-1:0),e.events=[],!0)}});p(!0,l,{MultiDayView:H,DayView:H.extend({options:{name:"DayView",title:"Day",selectedMobileDateFormat:"{0:MMM d}"},name:"day"}),WeekView:H.extend({options:{name:"WeekView",title:"Week",selectedDateFormat:"{0:D} - {1:D}",selectedShortDateFormat:"{0:d} - {1:d}"},name:"week",calculateDateRange:function(){var e,t,a=this.options.date,s=r.date.dayOfWeek(a,this.calendarInfo().firstDay,-1),i=[];for(e=0,t=7;e<t;e++)i.push(s),s=r.date.nextDay(s);this._render(i)}}),WorkWeekView:H.extend({options:{name:"WorkWeekView",title:"Work Week",selectedDateFormat:"{0:D} - {1:D}",selectedShortDateFormat:"{0:d} - {1:d}"},name:"workWeek",nextDate:function(){var e=r.date.dayOfWeek(r.date.nextDay(this.startDate()),this.calendarInfo().firstDay,1);return r.date.addDays(e,this._workDays[0])},previousDate:function(){var e=r.date.dayOfWeek(this.startDate(),this.calendarInfo().firstDay,-1),t=this._workDays;return r.date.addDays(e,t[t.length-1]-7)},calculateDateRange:function(){var e=this.options,t=e.date,a=r.date.dayOfWeek,s=a(t,this.calendarInfo().firstDay,-1),i=a(s,e.workWeekStart,1),n=a(i,e.workWeekEnd,1),o=[],l=e.workDays&&e.workDays.length?e.workDays.map(function(e){return a(s,e,1).getTime()}):null;for(l&&(i=s,n=a(i,this.calendarInfo().firstDay+6,1));i<=n;)l&&l.indexOf(i.getTime())>-1?o.push(i):l||o.push(i),i=r.date.nextDay(i);this._render(o)}})})}(window.kendo.jQuery),window.kendo},a(3))}});