@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
2 lines • 32.3 kB
JavaScript
module.exports=function(e){function t(i){if(a[i])return a[i].exports;var s=a[i]={exports:{},id:i,loaded:!1};return e[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var a={};return t.m=e,t.c=a,t.p="",t(0)}({0:function(e,t,a){e.exports=a(1403)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1397:function(e,t){e.exports=require("./kendo.scheduler.view")},1403:function(e,t,a){var i,s,n;!function(o,define){s=[a(1397)],i=o,n="function"==typeof i?i.apply(t,s):i,!(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 i(e,t,a){return e>=t&&e<=a}function s(e,t,a,i){return i=i?e<=a:e<a,e>t&&i}function n(e,t,a,i){var s,n=e._continuousEvents,o=n[n.length-1],l=m(t.start.startDate()).getTime();if(i&&o&&m(o.start.startDate()).getTime()==l){for(s=n.length-1;s>-1&&!(n[s].isAllDay||m(n[s].start.startDate()).getTime()<l);s--);n.splice(s+1,0,{element:a,isAllDay:!0,uid:a.attr(r.attr("uid")),start:t.start,end:t.end})}else n.push({element:a,isAllDay:i,uid:a.attr(r.attr("uid")),start:t.start,end:t.end})}function o(e){var t,a,i;if(e.workDays&&e.workDays.length)return e.workDays;for(t=[],a=e.workWeekStart%7,i=Math.abs(e.workWeekEnd%7),t.push(a);i!=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,g=r.date.MS_PER_MINUTE,_=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,i,s,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),i=this.content.find("."+v),d=x.group&&"horizontal"!=x.group.orientation?this.groups.length:1,u=this.times.find("tr").first().find("th").first(),p=this.times.find("tr").first().find("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(g=r.date.toUtcTime(t),_=m.timeSlotRanges(g,g+1),0===_.length)return;D=_[0].collection,T=D.slotByStartDate(t),T&&(w=a[f]?a.eq(f):e(E).prependTo(this.times),S=Math.round(_[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")),s||(s=h(w)*k/2),C.top=S-s,w.css(C),b=i[f]?i.eq(f):e(E).prependTo(this.content),b.css({top:S,height:"1px",right:0,left:0}))}},_currentTime:function(e){var a=this,i=a.options.currentTimeMarker;i!==!1&&i.updateInterval!==t&&(a._currentTimeMarkerUpdater(),e&&(a._currentTimeUpdateTimer=setInterval(f(this._currentTimeMarkerUpdater,a),i.updateInterval)))},_updateResizeHint:function(e,t,a,i){var s,n,o,l,d,h,c,p,f,m,g,_,v,y,D;for(s=this.options.enforceAllDaySlot?e.isMultiDay():e.isAllDay,n=this.groups[t],o=n.ranges(a,i,s,e.isAllDay),this._removeResizeHint(),p=0;p<o.length;p++)if(f=o[p],m=f.startSlot(),this._isGroupedByDate()&&s)for(g=m.index;g<=f.end.index;g++)_=f.collection._slots[g],l=_.offsetWidth,d=_.clientHeight,h=_.offsetTop,c=u.fn._createResizeHint.call(this,_.offsetLeft,h,l,d),this._resizeHint=this._resizeHint.add(c);else l=m.offsetWidth,d=m.clientHeight,h=m.offsetTop,s?l=f.innerWidth():(v=f.outerRect(a,i,this.options.snap),h=v.top,d=v.bottom-v.top),c=u.fn._createResizeHint.call(this,m.offsetLeft,h,l,d),this._resizeHint=this._resizeHint.add(c);y="t",D=this.content,s&&(y="M/dd",D=this.element.find(".k-scheduler-header-wrap:has(.k-scheduler-header-all-day) > div"),D.length||(D=this.content)),this._resizeHint.appendTo(D),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),y)),this._resizeHint.last().addClass("k-last").find(".k-label-bottom").text(r.toString(r.timezone.toLocalDate(i),y))},_updateMoveHint:function(t,a,i){var s,n,o,l,d,u,h,c,p,f,m,g,_,v,y;for(s=this.options.enforceAllDaySlot?t.isMultiDay():t.isAllDay,n=this.groups[a],o=r.date.toUtcTime(t.start)+i,l=o+t.duration(),d=n.ranges(o,l,s,t.isAllDay),o=r.timezone.toLocalDate(o),l=r.timezone.toLocalDate(l),this._removeMoveHint(t.uid),!s&&T(l)<T(this.startTime())&&l<this._end().getTime()&&0!==T(l)&&d.length>1&&d.pop(),u=e(),h=0;h<d.length;h++)if(c=d[h],p=c.start,m={left:p.offsetLeft+2,top:p.offsetTop},this._isGroupedByDate()&&s)for(g=p.index;g<=c.end.index;g++)_=c.collection._slots[g],m.left=this._isRtl?.1*_.clientWidth+_.offsetLeft+2:_.offsetLeft+2,m.height=_.offsetHeight,m.width=.9*_.clientWidth-2,f=this._createEventElement(t.clone({start:o,end:l}),!s),t.inverseColor&&f.addClass(D),this._appendMoveHint(f,m),u=u.add(f);else this._isRtl&&(m.left=.1*p.clientWidth+p.offsetLeft+2),s?m.width=c.innerWidth()-2:(v=c.outerRect(o,l,this.options.snap),m.top=v.top,m.height=v.bottom-v.top,m.width=.9*p.clientWidth-2),f=this._createEventElement(t.clone({start:o,end:l}),!s),t.inverseColor&&f.addClass(D),this._appendMoveHint(f,m),u=u.add(f);y=this.content,s&&(y=this.element.find(".k-scheduler-header-wrap:has(.k-scheduler-header-all-day) > div"),y.length||(y=this.content)),u.appendTo(y)},_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,i,s,n;for(this._isVerticallyGrouped()?(i=this.content.offset(),t+=this.content[0].scrollTop,e+=this.content[0].scrollLeft):i=this.element.find(".k-scheduler-header-wrap:has(.k-scheduler-header-all-day)").find(">div").offset(),i&&(e-=i.left,t-=i.top),e=Math.ceil(e),t=Math.ceil(t),n=0;n<this.groups.length;n++)if(s=this.groups[n],a=s.daySlotByPosition(e,t,this._isGroupedByDate()))return a;for(i&&(e+=i.left,t+=i.top),i=this.content.offset(),e-=i.left,t-=i.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(s=this.groups[n],a=s.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,i,s,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,s=l*o;s<(l+1)*o;){if(u=m[s].children,s%o===0&&(i=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,i,c,r);else for(a=this.groups[r],n=d;n<e*t;n+=e)this._addTimeSlotGroup(a,u,n,i,c,h),h++;else for(a=this.groups[r],n=d*t;n<(d+1)*t;n++)this._addTimeSlotGroup(a,u,n,i,c,h),h++;i+=c,s++}},_addTimeSlotGroup:function(e,t,a,i,s,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+i,l=r+s,d.setAttribute("role","gridcell"),d.setAttribute("aria-selected",!1),u.addTimeSlot(d,r,l))},_addDaySlotGroup:function(e,t,a,i,s){var n,o=t[a],l=this._dates[s];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,i,s,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"),s=0;s<h;s++)if(n=0,this._isVerticallyGrouped()&&(n=s),l=a[n].children,d=0,this._isVerticallyGrouped()||(d=s),u=0,c)if(this._isVerticallyGrouped())for(i=0;i<e;i++)o=this.groups[i],r=o.getDaySlotCollection(0),this._addDaySlotGroup(r,l,i,t,s);else for(o=this.groups[s],r=o.getDaySlotCollection(0),i=d;i<e*t;i+=e)this._addDaySlotGroup(r,l,i,t,u),u++;else for(o=this.groups[s],r=o.getDaySlotCollection(0),i=d*t;i<(d+1)*t;i++)this._addDaySlotGroup(r,l,i,t,u),u++},_groups:function(){var e,t,a,i=this._groupCount(),s=this._columnCountInResourceView();for(this.groups=[],e=0;e<i;e++){for(t=this._addResourceView(e),a=0;a<s;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(i,s),this.options.allDaySlot&&this._daySlotGroups(i,s)},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:" ",allDaySlotTemplate:" ",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},enforceAllDaySlot:!1},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 i,s;e(this).parent().hasClass("k-scheduler-header-all-day")||(i=t._slotByPosition(a.pageX,a.pageY),i&&(s=t._resourceBySlot(i),t.trigger("add",{eventInfo:p({start:i.startDate(),end:i.endDate()},s)})),a.preventDefault())}).on("dblclick"+w,".k-scheduler-header-all-day td",function(e){var a,i=t._slotByPosition(e.pageX,e.pageY);i&&(a=t._resourceBySlot(i),t.trigger("add",{eventInfo:p({},{isAllDay:!0,start:r.date.getDate(i.startDate()),end:r.date.getDate(i.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,i=0;r.support.mobileOS.android&&(i=5),a.options.editable.create!==!1&&(a._addUserEvents=new r.UserEvents(a.element,{threshold:i,filter:".k-scheduler-content td",useClickAsTap:!r.support.browser.edge,tap:function(i){var s,n,o,r;a._scrolling||e(i.target).parent().hasClass("k-scheduler-header-all-day")||(s=i.x.location!==t?i.x.location:i.x,n=i.y.location!==t?i.y.location:i.y,o=a._slotByPosition(s,n),o&&(r=a._resourceBySlot(o),a.trigger("add",{eventInfo:p({start:o.startDate(),end:o.endDate()},r)})),i.preventDefault())}}),a._allDayUserEvents=new r.UserEvents(a.element,{threshold:i,useClickAsTap:!r.support.browser.edge,filter:".k-scheduler-header-all-day td",tap:function(e){var i,s,n,o;a._scrolling||(i=e.x.location!==t?e.x.location:e.x,s=e.y.location!==t?e.y.location:e.y,n=a._slotByPosition(i,s),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:i,useClickAsTap:!r.support.browser.edge,filter:".k-event",tap:function(t){var i,s;a._scrolling||(i=e(t.target).closest(".k-event"),s=e(t.touch.initialTouch),s.hasClass("k-i-close")?a.trigger("remove",{uid:i.attr(r.attr("uid"))}):i.hasClass("k-event-active")||a.trigger("edit",{uid:i.attr(r.attr("uid"))}),t.preventDefault())}}))},_layout:function(e){var t,a,i,s=[],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"),s.push(a);return i=this.groupedResources,o.allDaySlot&&n.push({text:o.messages.allDay,allDay:!0,cellContent:function(t){var a=t;return t=i.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,i){var s=t?l.majorTimeHeaderTemplate:l.minorTimeHeaderTemplate,o={text:s({date:e}),className:i?"k-slot-cell":""};n.push(o)}),i.length&&("vertical"===this._groupOrientation()?d?(n=this._createDateLayout(s,n),s=this._createColumnsLayout(i,null,this.groupHeaderTemplate)):n=this._createRowsLayout(i,n,this.groupHeaderTemplate):s=d?this._createColumnsLayout(i,s,this.groupHeaderTemplate,s):this._createColumnsLayout(i,s,this.groupHeaderTemplate)),{columns:s,rows:n}},_footer:function(){var t,a,i,s=this.options;s.footer!==!1&&(t='<div class="k-scheduler-footer k-toolbar">',a=s.footer.command,this._isMobile()&&(t+='<span class="k-state-default k-scheduler-today"><a href="#" class="k-link">',t+=s.messages.today+"</a></span>"),a&&"workDay"===a&&(this._isMobile()?(t+='<span class="k-state-default k-scheduler-fullday"><a href="#" class="k-link">',t+=(s.showWorkHours?s.messages.showFullDay:s.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+=s.showWorkHours?s.messages.showFullDay:s.messages.showWorkDay,t+="</span>",t+="</button>")),t+="</div>",this.footer=e(t).appendTo(this.element),i=this,this.footer.on("click"+w,".k-scheduler-fullday",function(e){e.preventDefault(),i.trigger("navigate",{view:i.name||s.name,date:s.date,isWorkDay:!s.showWorkHours})}),this.footer.on("click"+w,".k-scheduler-today",function(e){var t,a,n,o,l;e.preventDefault(),t=i.options.timezone,a="today",n=new Date,t?(l=r.timezone.offset(n,t),o=r.timezone.convert(n,n.getTimezoneOffset(),l)):o=n,i.trigger("navigate",{view:i.name||s.name,action:a,date:o})}))},_forTimeRange:function(e,t,i,s){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*g,h=u/l||1,c=new Date((+e)),p=c.getDate(),m=0,y="",v=_/h,o!=r&&(o>r&&(r+=_),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+=i(c,k,w,S),d(c,h,!1);return r&&(f=T(c),p<c.getDate()&&(f+=_),f>r&&(c=new Date((+t)))),s&&(y+=s(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,i="",s=a._dates;i+=a._renderRows(s,e,t),a.content.find("table tbody").append(i)},_renderRows:function(e,t,a){var i,s,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,g=this.groupedResources,_="";for(g.length&&(i=o._recalculateLevels(t,a),m=i.rowCount,f=i.groupsCount),s=function(t,a,i){var s,h,c,p="",m=0;if(p="<tr"+(i?' class="k-middle-row"':"")+">",l)for(s=0,h=u;s<h;s++){for(m=0;m<f;m++)c=s,r&&(c=d),p=o._addCellsToContent(p,e,t,c,m,n);if(r)break}else for(;m<f;m++)for(s=0,h=u;s<h;s++)p=o._addCellsToContent(p,e,t,s,m,n);return p+="</tr>"},n=0;n<m;n++)_+=h.allDaySlot&&r?this._allDayVerticalGroupRow(e,n,f,d):"",_+=this._forTimeRange(c,p,s),r&&d++;return _},_recalculateLevels:function(e,t){var a=this,i=a._isGroupedByDate(),s="vertical"===a._groupOrientation(),n=1,o=1;return s?(o=a._rowCountForLevel(e.length-2,e),i&&(n=a._columnCountForLevel(t.length-1))):n=i?a._columnCountForLevel(t.length-1)/this._columnCountForLevel(0):a._columnCountForLevel(t.length-2),{rowCount:o,groupsCount:n}},_allDayVerticalGroupRow:function(e,t,a,i){var s,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[i],resources:u})+"</td>";else for(s=0;s<e.length;s++)o+="<td>"+d({date:e[s],resources:u})+"</td>";return o+"</tr>"},_addCellsToContent:function(e,t,a,i,s,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[i])&&(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[i]))&&(d+=" k-nonwork-hour"),e+="<td"+(""!==d?' class="'+d+'"':"")+">",o=r.date.getDate(t[i]),r.date.setTime(o,r.date.getMilliseconds(a)),e+=u({date:o,resources:c(h&&!l._isGroupedByDate()?n:s)}),e+="</td>"},_isWorkDay:function(e){var t,a=e.getDay(),i=this._workDays;for(t=0;t<i.length;t++)if(i[t]===a)return!0;return!1},_render:function(t){var a,i=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),i.element.on("click"+w,".k-nav-day",function(t){var a,s=e(t.currentTarget).closest("th"),n=s.offset(),o=0,r=c(s);i._isGroupedByDate()&&(i._isVerticallyGrouped()?(o=h(i.times),r=0):r=c(i.datesHeader)),a=i._slotByPosition(n.left+o,n.top+r),i.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())||_;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,i,s,n=u.fn.inRange.call(this,e);return e.isAllDay?n:(t=T(this.startTime()),a=T(this.endTime())||r.date.MS_PER_DAY,i=T(e.start),s=T(e.end)||r.date.MS_PER_DAY,n&&t<=i&&s<=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*g},_timeSlotIndex:function(e){var t=this.options,a=T(e),i=T(this.startTime()),s=t.majorTick/t.minorTickCount*g;return(a-i)/s},_slotIndex:function(e,t){return t?this._dateSlotIndex(e):this._timeSlotIndex(e)},_dateSlotIndex:function(e,t){var a,s,n,o,l=this._dates||[],d=1;for(a=0,s=l.length;a<s;a++)if(n=r.date.getDate(l[a]),o=new Date(r.date.getDate(l[a]).getTime()+_-(t?0:1)),i(e,n,o))return a*d;return-1},_positionAllDayEvent:function(t,a){var i,s,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,g=2,_=c!==p?3:2,v=this._allDayHeaderHeight,y=a.startSlot();for(t.css({left:y.offsetLeft+g,width:h-_}),a.addEvent({slotIndex:c,start:c,end:p,element:t}),f.push({slotIndex:c,start:c,end:p,element:t}),i=u.createRows(f),i.length&&i.length>m&&(this._headerColumnCount=i.length),s=a.start.offsetTop,n=0,o=i.length;n<o;n++)for(r=i[n].events,l=0,d=r.length;l<d;l++)e(r[l].element).css({top:s+n*v,height:v-2})},_arrangeColumns:function(e,t,a,i){var s,n,o,r,l,d,h,c,p,f,m,g,_=i.start;for(e={element:e,slotIndex:_.index,start:t,end:t+a},n=_.clientWidth,o=.1*n,l=i.events(),d=u.collidingEvents(l,e.start,e.end),i.addEvent(e),d.push(e),s=u.createColumns(d),h=(n-o)/s.length,c=0,p=s.length;c<p;c++)for(r=s[c].events,f=0,m=r.length;f<m;f++)g=h-2,r[f].element[0].style.width=(g>0?g:h)+"px",r[f].element[0].style.left=(this._isRtl?o:0)+_.offsetLeft+c*h+2+"px"},_positionEvent:function(e,t,a){var i=e._startTime||e.start,s=e._endTime||e.end,n=r.getComputedStyles(a.start.element,["border-top-width","border-bottom-width"]),o=a.innerRect(i,s,!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,s,n){var o,l,d,u,h,c,f=a?this.eventTemplate:this.allDayEventTemplate,g=this.options,v=g.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()+_-1))),a||t.isAllDay||(S=new Date(S.getTime()+_)),l=t.start,d=t.end,t.isAllDay&&(d=m(t.end)),!i(m(l),w,S)&&!i(d,w,S)||a&&t.start.getTime()!==t.end.getTime()&&(x<C||x>=b)&&(E>b||E<=C)?o=!0:m(l)<w||a&&0!==x&&t.start.getTime()!==t.end.getTime()&&(x<C||x>=b)?n=!0:(d>S&&!a||a&&0!==E&&t.start.getTime()!==t.end.getTime()&&(E>b||E<=C))&&(s=!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:s,tail:n,singleDay:1==this._dates.length,resources:u,inverseColor:!1,messages:g.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(),i=this.endTime(),n=e._startTime||e.start,o=e._endTime||e.end;return T(i)===T(r.date.getDate(i))&&(i=r.date.getDate(i),d(i,_-1)),e._date("end")>e._date("start")&&(o=+e._date("end")+(_-1)),o=e._endTime?o-e._date("end"):T(new Date(o)),n=e._startTime?n-e._date("start"):T(new Date(n)),i=T(i),a=T(a),a===n&&n===o||(t=n!==i,s(n,a,i,t)||s(o,a,i,t)||s(a,n,o)||s(i,n,o)||e.end.getDate()>e.start.getDate()&&o>a)},_isInDateSlot:function(e){var t=this.groups[0],a=t.firstSlot().start,s=t.lastSlot().end-1,n=r.date.toUtcTime(e.start),o=r.date.toUtcTime(e.end);return(i(n,a,s)||i(o,a,s)||i(a,n,o)||i(s,n,o))&&(!i(o,a,a)||i(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,i,s,o,l,d,u,h,c,p,f,m,g,v,y,D,k,T,w,S,C,b=this.datesHeader.find(".k-scheduler-header-wrap > div"),x=this._isGroupedByDate();for(i=0,s=e.length;i<s;i++)if(a=e[i],this._isInDateSlot(a))if(o=this.options.enforceAllDaySlot?a.isAllDay||a.duration()>=_:a.isAllDay,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,g=0;g<m;g++)h=u[g],c=a.start,p=a.end,m>1&&(0===g?p=h.end.endDate():g==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,s,n,o,l=this;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),s=e.map(this._dates,function(t){return Math.max.apply(null,e.map(a,function(a){return e.grep(a,function(e){return l.options.enforceAllDaySlot?e.isMultiDay()&&i(t,m(e.start),m(e.end)):e.isAllDay&&i(t,m(e.start),m(e.end))}).length}))}),n=Math.max.apply(null,s),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,a,i,s){var n,o,l,d,h=a[0];if(h)for(n=h.dataSource.view(),n=n.filter(function(e){var a=r.getter(h.dataParentValueField)(e);return null===a||a===t||a===s}),o=0;o<n.length;o++)l=this._resourceValue(h,n[o]),d=new r.data.Query(e).filter({field:h.field,operator:u.groupEqFilter(l)}).toArray(),a.length>1?this._eventsByResource(d,a.slice(1),i,l):i.push(d);else i.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,i,s){var n=e.isAllDay,o=t[0].start,r=t[t.length-1].end;a&&(s?n||o.index!==r.index||o.collectionIndex!==r.collectionIndex||(e.backward=i):(n&&o.index===r.index||!n&&o.collectionIndex===r.collectionIndex)&&(e.backward=i))},_changeViewPeriod:function(e,t,a){var i,s,n,o,r,l,u,h,c,p,f,m,g;if(!a)return i=t?this.previousDate():this.nextDate(),s=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(i),f=new Date(i),!this._isInRange(p,f)&&(e.start=p,e.end=f,o?(m=new Date(u[h].startDate()),g=new Date(u[h].endDate()),c=T(g)?T(g):_,d(e.start,T(m)),d(e.end,c),r.daySlotCollectionCount()&&(e.isAllDay=!e.isAllDay)):(c=e.isAllDay||!T(n)?_:T(n),d(e.start,T(s)),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,i=r.date.dayOfWeek(a,this.calendarInfo().firstDay,-1),s=[];for(e=0,t=7;e<t;e++)s.push(i),i=r.date.nextDay(i);this._render(s)}}),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,i=a(t,this.calendarInfo().firstDay,-1),s=a(i,e.workWeekStart,1),n=a(s,e.workWeekEnd,1),o=[],l=e.workDays&&e.workDays.length?e.workDays.map(function(e){
return a(i,e,1).getTime()}):null;for(l&&(s=i,n=a(s,this.calendarInfo().firstDay+6,1));s<=n;)l&&l.indexOf(s.getTime())>-1?o.push(s):l||o.push(s),s=r.date.nextDay(s);this._render(o)}})})}(window.kendo.jQuery),window.kendo},a(3))}});