@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines (2 loc) • 31.6 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("kendo.scheduler.view.js"),require("kendo.icons.js")):"function"==typeof define&&define.amd?define(["exports","kendo.scheduler.view","kendo.icons"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.SchedulerDayview={}))}(this,(function(e){!function(e,t){var a=window.kendo,i=a.ui,r=a.htmlEncode,n=a.date.setTime,s=i.SchedulerView,o=a._outerWidth,l=a._outerHeight,d=e.extend,h=a.date.getDate,u=a.date.MS_PER_MINUTE,c=a.date.MS_PER_DAY,p="k-current-time",f="k-current-time-arrow",m="k-event-inverse",v=a.date.getMilliseconds,_=".kendoMultiDayView",g=a.template((({start:e,end:t,title:i})=>`<div title="(${a.format("{0:t} - {1:t}",e,t)}): ${i.replace(/"/g,""")}"><div class="k-event-template k-event-time">${r(a.format("{0:t} - {1:t}",e,t))}</div><div class="k-event-template">${i}</div></div>`)),y=a.template((({start:e,title:t})=>`<div title="(${a.format("{0:t}",e)}): ${t.replace(/"/g,""")}"><div class="k-event-template">${t}</div></div>`)),D=a.template((({isMobile:e,date:t})=>`<span class='k-link k-nav-day'>${e?a.toString(t,"ddd")[0]:a.toString(t,"ddd M/dd")}</span>`)),k=e=>`<div role="button" aria-label="${r(e.ariaLabel)}" ${a.attr("uid")}="${e.uid}"`+(e.resources[0]?`${a.attr("style-background-color")}="${e.resources[0].color}" ${a.attr("style-border-color")}="${e.resources[0].color}"`:"")+' class="k-event"><span class="k-event-actions">'+(e.tail||e.middle?a.ui.icon("caret-alt-left"):"")+(e.isException()?a.ui.icon("arrows-no-repeat"):e.isRecurring()?a.ui.icon("arrow-rotate-cw"):"")+"</span>"+a.template(e.template)(e)+'<span class="k-event-actions">'+(e.showDelete?`<a href="#" class="k-link k-event-delete" title="${e.messages.destroy}" aria-label="${e.messages.destroy}">${a.ui.icon("x")}</a>`:"")+(e.head||e.middle?a.ui.icon("caret-alt-right"):"")+"</span>"+(!e.resizable||e.singleDay||e.tail||e.middle?"":'<span class="k-resize-handle k-resize-w"></span>')+(!e.resizable||e.singleDay||e.head||e.middle?"":'<span class="k-resize-handle k-resize-e"></span>')+"</div>",T=e=>`<div role="button" aria-label="${r(e.ariaLabel)}" ${a.attr("uid")}="${e.uid}"`+(e.resources[0]?`${a.attr("style-background-color")}="${e.resources[0].color}" ${a.attr("style-border-color")}="${e.resources[0].color}"`:"")+' class="k-event"><span class="k-event-actions">'+(e.isException()?a.ui.icon("arrows-no-repeat"):e.isRecurring()?a.ui.icon("arrow-rotate-cw"):"")+"</span>"+a.template(e.template)(e)+'<span class="k-event-actions">'+(e.showDelete?`<a href="#" class="k-link k-event-delete" title="${e.messages.destroy}" aria-label="${e.messages.destroy}">${a.ui.icon("x")}</a>`:"")+"</span>"+(e.tail||e.middle?'<span class="k-event-top-actions">'+a.ui.icon("caret-alt-up")+"</span>":"")+(e.head||e.middle?'<span class="k-event-bottom-actions">'+a.ui.icon("caret-alt-down")+"</span>":"")+(!e.resizable||e.tail||e.middle?"":'<span class="k-resize-handle k-resize-n"></span>')+(!e.resizable||e.head||e.middle?"":'<span class="k-resize-handle k-resize-s"></span>')+"</div>";function w(e){var t=new Date(1980,1,1,0,0,0);return n(t,v(e)),t}function S(e,t,a){return e>=t&&e<=a}function b(e,t,a,i){return i=i?e<=a:e<a,e>t&&i}function C(e,t,i,r){var n=e._continuousEvents,s=n[n.length-1],o=h(t.start.startDate()).getTime();if(r&&s&&h(s.start.startDate()).getTime()==o){for(var l=n.length-1;l>-1&&!(n[l].isAllDay||h(n[l].start.startDate()).getTime()<o);l--);n.splice(l+1,0,{element:i,isAllDay:!0,uid:i.attr(a.attr("uid")),start:t.start,end:t.end})}else n.push({element:i,isAllDay:r,uid:i.attr(a.attr("uid")),start:t.start,end:t.end})}var x=s.extend({init:function(e,t){var a=this;s.fn.init.call(a,e,t),a.title=a.options.title||a.options.name,a._workDays=function(e){if(e.workDays&&e.workDays.length)return e.workDays;var t=[],a=e.workWeekStart%7,i=Math.abs(e.workWeekEnd%7);for(t.push(a);i!=a;)a>6?a-=7:a++,t.push(a);return t}(a.options),a._templates(),a._editable(),a.calculateDateRange(),a._groups(),a._currentTime(!0)},_currentTimeMarkerUpdater:function(){this._updateCurrentTimeMarker(new Date)},_updateCurrentTimeMarker:function(t){var i,r,n,s,d=this.options,h="<div class='"+p+"'></div>";if(!1===d.currentTimeMarker.useLocalTimezone){var u=d.dataSource.options.schema.timezone;if(d.dataSource&&u){var c=a.timezone.offset(t,u);t=a.timezone.convert(t,t.getTimezoneOffset(),c)}}i=this.times.find("."+p),r=this.content.find("."+p);var m=d.group&&"horizontal"!=d.group.orientation?this.groups.length:1,v=this.times.find("tr").first().find("th").first(),_=this.times.find("tr").first().find("th").last();v.length>0&&_.length>0&&(s=this._isRtl?v.position().left+l(v)-l(_):_.position().left);for(var g=0;g<m;g++){var y=this.groups[g];if(!y)return;var D=a.date.toUtcTime(t),k=y.timeSlotRanges(D,D+1);if(0===k.length)return;if(k[0].collection.slotByStartDate(t)){var T=i[g]?i.eq(g):e(h).prependTo(this.times),w=Math.round(k[0].innerRect(t,new Date(t.getTime()+1),!1).top),S={};this._isRtl?(S.right=s,T.addClass(f+"-left")):(S.left=s,T.addClass(f+"-right")),n||(n=.8666*o(T)/2),S.top=w-n,T.css(S),(r[g]?r.eq(g):e(h).prependTo(this.content)).css({top:w,height:"1px",right:0,left:0})}}},_currentTime:function(e){var a=this,i=a.options.currentTimeMarker;!1!==i&&i.updateInterval!==t&&(a._currentTimeMarkerUpdater(),e&&(a._currentTimeUpdateTimer=setInterval(this._currentTimeMarkerUpdater.bind(a),i.updateInterval)))},_updateResizeHint:function(e,t,i,r){var n;n=this.options.enforceAllDaySlot?e.isMultiDay():e.isAllDay;var o,l,d,h,u=this.groups[t].ranges(i,r,n,e.isAllDay);this._removeResizeHint();for(var c=0;c<u.length;c++){var p=u[c],f=p.startSlot();if(this._isGroupedByDate()&&n)for(var m=f.index;m<=p.end.index;m++){var v=p.collection._slots[m];o=v.offsetWidth,l=v.clientHeight,d=v.offsetTop,h=s.fn._createResizeHint.call(this,v.offsetLeft,d,o,l),this._resizeHint=this._resizeHint.add(h)}else{if(o=f.offsetWidth,l=f.clientHeight,d=f.offsetTop,n)o=p.innerWidth();else{var _=p.outerRect(i,r,this.options.snap);d=_.top,l=_.bottom-_.top}h=s.fn._createResizeHint.call(this,f.offsetLeft,d,o,l),this._resizeHint=this._resizeHint.add(h)}}var g="t",y=this.content;n&&(g="M/dd",(y=this.element.find(".k-scheduler-header-wrap:has(.k-scheduler-header-all-day) > div")).length||(y=this.content)),this._resizeHint.appendTo(y),this._resizeHint.find(".k-label-top,.k-label-bottom").text(""),this._resizeHint.first().addClass("k-first").find(".k-label-top").text(a.toString(a.timezone.toLocalDate(i),g)),this._resizeHint.last().addClass("k-last").find(".k-label-bottom").text(a.toString(a.timezone.toLocalDate(r),g))},_updateMoveHint:function(t,i,r){var n;n=this.options.enforceAllDaySlot?t.isMultiDay():t.isAllDay;var s=this.groups[i],o=a.date.toUtcTime(t.start)+r,l=o+t.duration(),d=s.ranges(o,l,n,t.isAllDay);o=a.timezone.toLocalDate(o),l=a.timezone.toLocalDate(l),this._removeMoveHint(t.uid),!n&&v(l)<v(this.startTime())&&l<this._end().getTime()&&0!==v(l)&&d.length>1&&d.pop();for(var h=e(),u=0;u<d.length;u++){var c,p=d[u],f=p.start,_={left:f.offsetLeft+2,top:f.offsetTop};if(this._isGroupedByDate()&&n)for(var g=f.index;g<=p.end.index;g++){var y=p.collection._slots[g];_.left=this._isRtl?.1*y.clientWidth+y.offsetLeft+2:y.offsetLeft+2,_.height=y.offsetHeight,_.width=.9*y.clientWidth-2,c=this._createEventElement(t.clone({start:o,end:l}),!n),t.inverseColor&&c.addClass(m),this._appendMoveHint(c,_),h=h.add(c)}else{if(this._isRtl&&(_.left=.1*f.clientWidth+f.offsetLeft+2),n)_.width=p.innerWidth()-2;else{var D=p.outerRect(o,l,this.options.snap);_.top=D.top,_.height=D.bottom-D.top,_.width=.9*f.clientWidth-2}c=this._createEventElement(t.clone({start:o,end:l}),!n),t.inverseColor&&c.addClass(m),this._appendMoveHint(c,_),h=h.add(c)}}var k=this.content;n&&((k=this.element.find(".k-scheduler-header-wrap:has(.k-scheduler-header-all-day) > div")).length||(k=this.content)),h.appendTo(k)},_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,r;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),r=0;r<this.groups.length;r++)if(a=this.groups[r].daySlotByPosition(e,t,this._isGroupedByDate()))return a;for(i&&(e+=i.left,t+=i.top),e-=(i=this.content.offset()).left,t-=i.top,this._isVerticallyGrouped()||(t+=this.content[0].scrollTop,e+=this.content[0].scrollLeft),e=Math.ceil(e),t=Math.ceil(t),r=0;r<this.groups.length;r++)if(a=this.groups[r].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,r,n,s=this._timeSlotInterval(),o=e,l=this._isGroupedByDate(),d=this.content.find("tr:not(.k-scheduler-header-all-day)"),h=d.length;this._isVerticallyGrouped()&&(l&&(o=t),h=Math.floor(h/o));for(var u=0;u<o;u++){var c=0,p=0;for(this._isVerticallyGrouped()?c=u:p=u,r=c*h;r<(c+1)*h;){var f=d[r].children;r%h==0&&(i=v(new Date(+this.startTime())));var m=0;if(l)if(this._isVerticallyGrouped())for(n=0;n<e;n++)a=this.groups[n],this._addTimeSlotGroup(a,f,n,i,s,u);else for(a=this.groups[u],n=p;n<e*t;n+=e)this._addTimeSlotGroup(a,f,n,i,s,m),m++;else for(a=this.groups[u],n=p*t;n<(p+1)*t;n++)this._addTimeSlotGroup(a,f,n,i,s,m),m++;i+=s,r++}}},_addTimeSlotGroup:function(e,t,a,i,r,n){var s=t[a],o=e.getTimeSlotCollection(n),l=this._dates[n];if(l&&s){var d=Date.UTC(l.getFullYear(),l.getMonth(),l.getDate())+i,h=d+r;o.addTimeSlot(s,d,h)}},_addDaySlotGroup:function(e,t,i,r,n){var s=t[i],o=this._dates[n];if(o){var l=Date.UTC(o.getFullYear(),o.getMonth(),o.getDate());e.addDaySlot(s,l,l+a.date.MS_PER_DAY)}},_daySlotGroups:function(e,t){var a,i,r=e,n=this._isGroupedByDate();this._isVerticallyGrouped()?(n&&(r=t),a=this.element.find(".k-scheduler-header-all-day")):a=this.element.find(".k-scheduler-header-all-day tr");for(var s=0;s<r;s++){var o,l=0;this._isVerticallyGrouped()&&(l=s);var d=a[l].children,h=0;this._isVerticallyGrouped()||(h=s);var u=0;if(n)if(this._isVerticallyGrouped())for(i=0;i<e;i++)o=this.groups[i].getDaySlotCollection(0),this._addDaySlotGroup(o,d,i,t,s);else for(o=this.groups[s].getDaySlotCollection(0),i=h;i<e*t;i+=e)this._addDaySlotGroup(o,d,i,t,u),u++;else for(o=this.groups[s].getDaySlotCollection(0),i=h*t;i<(h+1)*t;i++)this._addDaySlotGroup(o,d,i,t,u),u++}},_groups:function(){var e=this._groupCount(),t=this._columnCountInResourceView();this.groups=[];for(var i=0;i<e;i++){for(var r=this._addResourceView(i),n=0;n<t;n++)this._dates[n]&&r.addTimeSlotCollection(this._dates[n],a.date.addDays(this._dates[n],1));this.options.allDaySlot&&r.addDaySlotCollection(this._dates[0],a.date.addDays(this._dates[this._dates.length-1],1))}this._timeSlotGroups(e,t),this.options.allDaySlot&&this._daySlotGroups(e,t)},options:{name:"MultiDayView",selectedDateFormat:"{0:D}",selectedShortDateFormat:"{0:d}",selectedMobileDateFormat:"{0:MMM} {0:dd} - {1:dd}",allDaySlot:!0,showWorkHours:!1,title:"",startTime:a.date.today(),endTime:a.date.today(),minorTickCount:2,majorTick:60,majorTimeHeaderTemplate:({date:e})=>`<span>${a.toString(e,"t")}</span>`,minorTimeHeaderTemplate:()=>"​",groupHeaderTemplate:({text:e})=>e,slotTemplate:()=>" ",allDaySlotTemplate:()=>" ",eventTemplate:g,allDayEventTemplate:y,dateHeaderTemplate:D,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},ongoingEvents:{cssClass:null,enabled:!0,updateInterval:6e4},enforceAllDaySlot:!1},events:["remove","add","edit"],_templates:function(){var e=this.options,t=d({},a.Template,e.templateSettings);this.allDayEventTemplate=a.template(k),this.eventTemplate=a.template(T),this.majorTimeHeaderTemplate=a.template(e.majorTimeHeaderTemplate,t),this.minorTimeHeaderTemplate=a.template(e.minorTimeHeaderTemplate,t),this.dateHeaderTemplate=a.template(e.dateHeaderTemplate,t),this.slotTemplate=a.template(e.slotTemplate,t),this.allDaySlotTemplate=a.template(e.allDaySlotTemplate,t),this.groupHeaderTemplate=a.template(e.groupHeaderTemplate,t)},_editable:function(){this.options.editable&&(this._isMobile()?this._touchEditable():this._mouseEditable())},_mouseEditable:function(){var t=this;t.element.on("click"+_,".k-event a:has(.k-i-x),.k-event a:has(.k-svg-i-x)",(function(i){t.trigger("remove",{uid:e(this).closest(".k-event").attr(a.attr("uid"))}),i.preventDefault()})),!1!==t.options.editable.create&&t.element.on("dblclick"+_,".k-scheduler-content > table td",(function(a){if(!e(this).parent().hasClass("k-scheduler-header-all-day")){var i=t._slotByPosition(a.pageX,a.pageY);if(i){var r=t._resourceBySlot(i);t.trigger("add",{eventInfo:d({start:i.startDate(),end:i.endDate()},r)})}a.preventDefault()}})).on("dblclick"+_,".k-scheduler-header-all-day td",(function(e){var i=t._slotByPosition(e.pageX,e.pageY);if(i){var r=t._resourceBySlot(i);t.trigger("add",{eventInfo:d({},{isAllDay:!0,start:a.date.getDate(i.startDate()),end:a.date.getDate(i.startDate())},r)})}e.preventDefault()})),!1!==t.options.editable.update&&t.element.on("dblclick"+_,".k-event",(function(i){t.trigger("edit",{uid:e(this).closest(".k-event").attr(a.attr("uid"))}),i.preventDefault()}))},_touchEditable:function(){var i=this,r=0;a.support.mobileOS.android&&(r=5),!1!==i.options.editable.create&&(i._addUserEvents=new a.UserEvents(i.element,{threshold:r,filter:".k-scheduler-content td",useClickAsTap:!a.support.browser.edge,tap:function(a){if(!i._scrolling&&!e(a.target).parent().hasClass("k-scheduler-header-all-day")){var r=a.x.location!==t?a.x.location:a.x,n=a.y.location!==t?a.y.location:a.y,s=i._slotByPosition(r,n);if(s){var o=i._resourceBySlot(s);i.trigger("add",{eventInfo:d({start:s.startDate(),end:s.endDate()},o)})}a.preventDefault()}}}),i._allDayUserEvents=new a.UserEvents(i.element,{threshold:r,useClickAsTap:!a.support.browser.edge,filter:".k-scheduler-header-all-day td",tap:function(e){if(!i._scrolling){var r=e.x.location!==t?e.x.location:e.x,n=e.y.location!==t?e.y.location:e.y,s=i._slotByPosition(r,n);if(s){var o=i._resourceBySlot(s);i.trigger("add",{eventInfo:d({},{isAllDay:!0,start:a.date.getDate(s.startDate()),end:a.date.getDate(s.startDate())},o)})}e.preventDefault()}}})),!1!==i.options.editable.update&&(i._editUserEvents=new a.UserEvents(i.element,{threshold:r,useClickAsTap:!a.support.browser.edge,filter:".k-event",tap:function(t){if(!i._scrolling){var r=e(t.target).closest(".k-event");e(t.touch.initialTouch).is(".k-i-x,.k-svg-i-x")?i.trigger("remove",{uid:r.attr(a.attr("uid"))}):r.hasClass("k-event-active")||i.trigger("edit",{uid:r.attr(a.attr("uid"))}),t.preventDefault()}}}))},_layout:function(e){for(var t=[],i=[],r=this.options,n=this,s=n._isGroupedByDate(),o=0;o<e.length;o++){var l={};l.text=n.dateHeaderTemplate({date:e[o],isMobile:n._isMobile()}),a.date.isToday(e[o])&&(l.className="k-today"),t.push(l)}var d=this.groupedResources;return r.allDaySlot&&i.push({text:r.messages.allDay,allDay:!0,cellContent:function(t){var a=t;return t=d.length&&"vertical"!==n._groupOrientation()?t%e.length:t,n.allDaySlotTemplate({date:e[t],resources:function(){return n._resourceBySlot({groupIndex:a})}})}}),this._forTimeRange(this.startTime(),this.endTime(),(function(e,t,a,r){var s={text:(t?n.majorTimeHeaderTemplate:n.minorTimeHeaderTemplate)({date:e}),className:r?"k-slot-cell":""};i.push(s)})),d.length&&("vertical"===this._groupOrientation()?s?(i=this._createDateLayout(t,i),t=this._createColumnsLayout(d,null,this.groupHeaderTemplate)):i=this._createRowsLayout(d,i,this.groupHeaderTemplate):t=s?this._createColumnsLayout(d,t,this.groupHeaderTemplate,t):this._createColumnsLayout(d,t,this.groupHeaderTemplate)),{columns:t,rows:i}},toggleFullDay:function(){var e=this.options;this.trigger("navigate",{view:this.name||e.name,date:e.date,isWorkDay:!e.showWorkHours})},_footerItems:function(){var e=this,t=[],a=this.options.footer.command;return e._isMobile()&&t.push(e._defaultTools.todayMobile),a&&"workDay"===a&&(e._isMobile()?t.push(e._defaultTools.fulldayMobile):t.push(e._defaultTools.fulldayDesktop)),t},_forTimeRange:function(e,t,a,i){e=w(e),t=w(t);var r,s,o=v(e),l=v(t),d=this.options.minorTickCount,h=this.options.majorTick*u,p=h/d||1,f=new Date(+e),m=f.getDate(),_=0,g="";for(s=c/p,o!=l&&(o>l&&(l+=c),s=(l-o)/p),s=Math.round(s);_<s;_++){var y=_%(h/p);g+=a(f,0===y,y<d-1,y===d-1),n(f,p,!1)}return l&&(r=v(f),m<f.getDate()&&(r+=c),r>l&&(f=new Date(+t))),i&&(g+=i(f)),g},_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="",r=a._dates;i+=a._renderRows(r,e,t),a.content.find("table tbody").append(i)},_renderRows:function(e,t,a){var i=this,r="vertical"===i._groupOrientation(),n=i._isGroupedByDate(),s=0,o=e.length,l=i.options,d=i.startTime(),h=this.endTime(),u=1,c=1,p="";if(this.groupedResources.length){var f=i._recalculateLevels(t,a);c=f.rowCount,u=f.groupsCount}for(var m=function(t,a,l){var d,h,c="",p=0;if(c="<tr"+(l?' class="k-middle-row"':"")+">",n)for(d=0,h=o;d<h;d++){for(p=0;p<u;p++){var f=d;r&&(f=s),c=i._addCellsToContent(c,e,t,f,p,v)}if(r)break}else for(;p<u;p++)for(d=0,h=o;d<h;d++)c=i._addCellsToContent(c,e,t,d,p,v);return c+="</tr>"},v=0;v<c;v++)p+=l.allDaySlot&&r?this._allDayVerticalGroupRow(e,v,u,s):"",p+=this._forTimeRange(d,h,m),r&&s++;return p},_recalculateLevels:function(e,t){var a=this,i=a._isGroupedByDate(),r=1,n=1;return"vertical"===a._groupOrientation()?(n=a._rowCountForLevel(e.length-2,e),i&&(r=a._columnCountForLevel(t.length-1))):r=i?a._columnCountForLevel(t.length-1)/this._columnCountForLevel(0):a._columnCountForLevel(t.length-2),{rowCount:n,groupsCount:r}},_allDayVerticalGroupRow:function(e,t,a,i){var r=this,n='<tr class="k-scheduler-header-all-day">',s=r._isGroupedByDate(),o=s?0:t,l=r.allDaySlotTemplate,d=function(){return r._resourceBySlot({groupIndex:o})};if(s)for(;o<a;o++)n+="<td>"+l({date:e[i],resources:d})+"</td>";else for(var h=0;h<e.length;h++)n+="<td>"+l({date:e[h],resources:d})+"</td>";return n+"</tr>"},_addCellsToContent:function(e,t,i,r,n,s){var o,l,d=this,h="",u=this.slotTemplate,c="vertical"===this._groupOrientation();return a.date.isToday(t[r])&&(h+="k-today"),(a.date.getMilliseconds(i)<a.date.getMilliseconds(this.options.workDayStart)||a.date.getMilliseconds(i)>=a.date.getMilliseconds(this.options.workDayEnd)||!this._isWorkDay(t[r]))&&(h+=" k-nonwork-hour"),e+="<td"+(""!==h?' class="'+h+'"':"")+">",o=a.date.getDate(t[r]),a.date.setTime(o,a.date.getMilliseconds(i)),e+=u({date:o,resources:(l=c&&!d._isGroupedByDate()?s:n,function(){return d._resourceBySlot({groupIndex:l})})}),e+="</td>"},_isWorkDay:function(e){for(var t=e.getDay(),a=this._workDays,i=0;i<a.length;i++)if(a[i]===t)return!0;return!1},_render:function(t){var a=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();var i=this.element.find(".k-scheduler-header-all-day td");i.length&&(this._allDayHeaderHeight=i.first()[0].clientHeight),a.element.on("click"+_,".k-nav-day",(function(t){var i=e(t.currentTarget).closest("th"),r=i.offset(),n=0,s=l(i);a._isGroupedByDate()&&(a._isVerticallyGrouped()?(n=o(a.times),s=0):s=l(a.datesHeader));var d=a._slotByPosition(r.left+n,r.top+s);a.trigger("navigate",{view:"day",date:d.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=v(this.endTime())||c;return e&&(t=0),new Date(this._endDate.getTime()+t)},nextDate:function(){return a.date.nextDay(this.endDate())},previousDate:function(){return a.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(_),e.element&&e.element.off(_),s.fn.destroy.call(this),this._isMobile()&&e.options.editable&&(!1!==e.options.editable.create&&(e._addUserEvents.destroy(),e._allDayUserEvents.destroy()),!1!==e.options.editable.update&&e._editUserEvents.destroy())},inRange:function(e){var t=s.fn.inRange.call(this,e);if(e.isAllDay)return t;var i=v(this.startTime()),r=v(this.endTime())||a.date.MS_PER_DAY,n=v(e.start),o=v(e.end)||a.date.MS_PER_DAY;return t&&i<=n&&o<=r},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*u},_timeSlotIndex:function(e){var t=this.options;return(v(e)-v(this.startTime()))/(t.majorTick/t.minorTickCount*u)},_slotIndex:function(e,t){return t?this._dateSlotIndex(e):this._timeSlotIndex(e)},_dateSlotIndex:function(e,t){var i,r,n=this._dates||[];for(i=0,r=n.length;i<r;i++)if(S(e,a.date.getDate(n[i]),new Date(a.date.getDate(n[i]).getTime()+c-(t?0:1))))return 1*i;return-1},_positionAllDayEvent:function(t,a){var i=a.innerWidth(),r=a.start.index,n=a.end.index,o=s.collidingEvents(a.events(),r,n),l=this._headerColumnCount||0,d=r!==n?3:2,h=this._allDayHeaderHeight,u=a.startSlot();t.css({left:u.offsetLeft+2,width:i-d}),a.addEvent({slotIndex:r,start:r,end:n,element:t}),o.push({slotIndex:r,start:r,end:n,element:t});var c=s.createRows(o);c.length&&c.length>l&&(this._headerColumnCount=c.length);for(var p=a.start.offsetTop,f=0,m=c.length;f<m;f++)for(var v=c[f].events,_=0,g=v.length;_<g;_++)e(v[_].element).css({top:p+f*h,height:h-2})},_arrangeColumns:function(e,t,a,i){var r=i.start;e={element:e,slotIndex:r.index,start:t,end:t+a};var n,o,l=r.clientWidth,d=.1*l,h=i.events(),u=s.collidingEvents(h,e.start,e.end),c=this.table.find(".k-scheduler-content .k-scheduler-table")[0],p=this.table.find(".k-scheduler-content")[0];i.addEvent(e),u.push(e);for(var f=(l-d)/(n=s.createColumns(u)).length,m=0,v=n.length;m<v;m++)for(var _=0,g=(o=n[m].events).length;_<g;_++){var y=f-2;o[_].element[0].style.width=(y>0?y:f)+"px",this._isRtl&&p.clientWidth<p.scrollWidth?o[_].element[0].style.left=d+r.offsetLeft+m*f-(c.clientWidth-p.clientWidth)+"px":o[_].element[0].style.left=(this._isRtl?d:0)+r.offsetLeft+m*f+2+"px"}},_positionEvent:function(e,t,i){var r=e._startTime||e.start,n=e._endTime||e.end,s=a.getComputedStyles(i.start.element,["border-top-width","border-bottom-width"]),o=i.innerRect(r,n,!1),l=o.bottom-o.top-parseFloat(s["border-top-width"])-parseFloat(s["border-bottom-width"]);l<0&&(l=0),t.css({top:o.top,height:l}),this._arrangeColumns(t,o.top,t[0].clientHeight,i)},_createEventElement:function(t,i,r,n){var s,o=i?this.eventTemplate:this.allDayEventTemplate,l=this.options,u=l.editable,p=this._isMobile(),f=u&&!1!==u.destroy&&!p,m=u&&!1!==u.resize,_=h(this.startDate()),g=h(this.endDate()),y=v(this.startTime()),D=v(this.endTime()),k=t._time("start"),T=t._time("end"),w=i?l.eventTemplate:l.allDayEventTemplate;y>=D&&(D=v(new Date(this.endTime().getTime()+c-1))),i||t.isAllDay||(g=new Date(g.getTime()+c));var b=t.start,C=t.end;t.isAllDay&&(C=h(t.end)),!S(h(b),_,g)&&!S(C,_,g)||i&&t.start.getTime()!==t.end.getTime()&&(k<y||k>=D)&&(T>D||T<=y)?s=!0:h(b)<_||i&&0!==k&&t.start.getTime()!==t.end.getTime()&&(k<y||k>=D)?n=!0:(C>g&&!i||i&&0!==T&&t.start.getTime()!==t.end.getTime()&&(T>D||T<=y))&&(r=!0);var x=this.eventResources(t);t._startTime&&k!==a.date.getMilliseconds(t.start)&&(b=new Date(k),b=a.timezone.apply(b,"Etc/UTC")),t._endTime&&T!==a.date.getMilliseconds(t.end)&&(C=new Date(T),C=a.timezone.apply(C,"Etc/UTC"));var E=d({},{ns:a.ns,resizable:m,showDelete:f,middle:s,head:r,tail:n,singleDay:1==this._dates.length,resources:x,inverseColor:!1,messages:l.messages,ariaLabel:this._formatEventAriaLabel(t.title,b,C,t.isAllDay),template:w},t,{start:b,end:C}),M=e(o(E));return a.applyStylesFromKendoAttributes(M,["background-color","border-color"]),M},_isInTimeSlot:function(e){var t=this.startTime(),i=this.endTime(),r=e._startTime||e.start,s=e._endTime||e.end;if(v(i)===v(a.date.getDate(i))&&(i=a.date.getDate(i),n(i,c-1)),e._date("end")>e._date("start")&&(s=+e._date("end")+(c-1)),s=e._endTime?s-e._date("end"):v(new Date(s)),r=e._startTime?r-e._date("start"):v(new Date(r)),i=v(i),(t=v(t))===r&&r===s)return!0;var o=r!==i;return b(r,t,i,o)||b(s,t,i,o)||b(t,r,s)||b(i,r,s)||e.end.getDate()>e.start.getDate()&&s>t},_isInDateSlot:function(e){var t=this.groups[0],i=t.firstSlot().start,r=t.lastSlot().end-1,n=a.date.toUtcTime(e.start),s=a.date.toUtcTime(e.end);return(S(n,i,r)||S(s,i,r)||S(i,n,s)||S(r,n,s))&&(!S(s,i,i)||S(s,n,n)||e.isAllDay)},_updateAllDayHeaderHeight:function(e){if(this._height!==e){this._height=e;var t=this.element.find(".k-scheduler-header-all-day td");if(t.length){t.parent().add(this.element.find(".k-scheduler-times-all-day").parent()).height(e);for(var a=0;a<this.groups.length;a++)this.groups[a].refresh()}}},_renderEvents:function(e,t){var i,r,n,s=this.datesHeader.find(".k-scheduler-header-wrap > div"),o=this._isGroupedByDate();for(r=0,n=e.length;r<n;r++){var l,d,h,u,p,f,m,v;if(i=e[r],this._isInDateSlot(i))if(d=(l=this.options.enforceAllDaySlot?i.isAllDay||i.duration()>=c:i.isAllDay)&&!this._isVerticallyGrouped()?s:this.content,l){if(this.options.allDaySlot){if(!(v=this.groups[t]))continue;if(v._continuousEvents||(v._continuousEvents=[]),(u=v.slotRanges(i)).length){var _=(p=u[0]).start.index,g=p.end.index;if(o&&_!==g){f=p.start.start,m=p.end.end;for(var y=f,D=f,k=p.start.index;k<=p.end.index;k++){h=this._createEventElement(i,!l,k!==g,k!==_);var T=v.daySlotRanges(y,D,!0)[0];y=D+=a.date.MS_PER_DAY,this._positionAllDayEvent(h,T),C(v,T,h,!0),h.appendTo(d),this._inverseEventColor(h)}}else h=this._createEventElement(i,!l),this._positionAllDayEvent(h,u[0]),C(v,u[0],h,!0),h.appendTo(d),this._inverseEventColor(h)}}}else if(this._isInTimeSlot(i)){if(!(v=this.groups[t]))continue;v._continuousEvents||(v._continuousEvents=[]);for(var w=(u=v.slotRanges(i)).length,S=0;S<w;S++){p=u[S],f=i.start,m=i.end,w>1&&(0===S?m=p.end.endDate():S==w-1?f=p.start.startDate():(f=p.start.startDate(),m=p.end.endDate()));var b=i.clone({start:f,end:m,_startTime:i._startTime,_endTime:i.endTime});if(this._isInTimeSlot(b)){var x=p.head;(h=this._createEventElement(i,!l,x,p.tail)).appendTo(d),this._inverseEventColor(h),this._positionEvent(b,h,p),C(v,p,h,!1)}}}}},_eventsPerDate:function(t,a){let i=this;return e.map(t,(function(t){return e.grep(t,(function(e){return i.options.enforceAllDaySlot?e.isMultiDay()&&S(a,h(e.start),h(e.end)):e.isAllDay&&S(a,h(e.start),h(e.end))})).length}))},render:function(t){var i=this;this._headerColumnCount=0,this._cachedEvents=t,this._groups(),this.element.find(".k-event").remove(),t=new a.data.Query(t).sort([{field:"start",dir:"asc"},{field:"end",dir:"desc"}]).toArray();var r=[];this._eventsByResource(t,this.groupedResources,r);var n=e.map(this._dates,(function(e){return Math.max.apply(null,i._eventsPerDate(r,e))})),s=Math.max.apply(null,n);this._updateAllDayHeaderHeight((s+1)*this._allDayHeaderHeight);for(var o=0;o<r.length;o++)this._renderEvents(r[o],o);this.refreshLayout(),this._currentTime(!1),this._ongoingEvents(t),this.trigger("activate")},_eventsByResource:function(e,i,r,n){var o=i[0];if(o){var l=o.dataSource.view();l=l.filter((function(e){var i=a.getter(o.dataParentValueField)(e);return null===i||i===t||i===n}));for(var d=0;d<l.length;d++){var h=this._resourceValue(o,l[d]),u=new a.data.Query(e).filter({field:o.field,operator:s.groupEqFilter(h)}).toArray();i.length>1?this._eventsByResource(u,i.slice(1),r,h):r.push(u)}}else r.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){var a=(t=t||this.rowLevels)[e];return a?a.length:0},clearSelection:function(){this.content.add(this.datesHeader).find(".k-selected").removeAttr("id").removeClass("k-selected")},_updateDirection:function(e,t,a,i,r){var n=e.isAllDay,s=t[0].start,o=t[t.length-1].end;a&&(r?n||s.index!==o.index||s.collectionIndex!==o.collectionIndex||(e.backward=i):(n&&s.index===o.index||!n&&s.collectionIndex===o.collectionIndex)&&(e.backward=i))},_changeViewPeriod:function(e,t,a){if(!a){var i,r,s,o=t?this.previousDate():this.nextDate(),l=e.start,d=e.end,h=this._isGroupedByDate()&&this._isVerticallyGrouped(),u=this.groups[e.groupIndex],p=t?u._timeSlotCollections:u._getCollections(u.daySlotCollectionCount()),f=p[p.length-1]._slots,m=t||u.daySlotCollectionCount()?f.length-1:0;if(r=new Date(o),s=new Date(o),this._isInRange(r,s))return!1;if(e.start=r,e.end=s,h){var _=new Date(f[m].startDate()),g=new Date(f[m].endDate());i=v(g)?v(g):c,n(e.start,v(_)),n(e.end,i),u.daySlotCollectionCount()&&(e.isAllDay=!e.isAllDay)}else i=e.isAllDay||!v(d)?c:v(d),n(e.start,v(l)),n(e.end,i);return this._isVerticallyGrouped()||(e.groupIndex=t?this.groups.length-1:0),e.events=[],!0}}});d(!0,i,{MultiDayView:x,DayView:x.extend({options:{name:"DayView",title:"Day",selectedMobileDateFormat:"{0:MMM d}"},name:"day"}),WeekView:x.extend({options:{name:"WeekView",title:"Week",selectedDateFormat:"{0:D} - {1:D}",selectedShortDateFormat:"{0:d} - {1:d}"},name:"week",calculateDateRange:function(){var e,t=this.options.date,i=a.date.dayOfWeek(t,this.calendarInfo().firstDay,-1),r=[];for(e=0,7;e<7;e++)r.push(i),i=a.date.nextDay(i);this._render(r)}}),WorkWeekView:x.extend({options:{name:"WorkWeekView",title:"Work Week",selectedDateFormat:"{0:D} - {1:D}",selectedShortDateFormat:"{0:d} - {1:d}"},name:"workWeek",nextDate:function(){var e=a.date.dayOfWeek(a.date.nextDay(this.startDate()),this.calendarInfo().firstDay,1);return a.date.addDays(e,this._workDays[0])},previousDate:function(){var e=a.date.dayOfWeek(this.startDate(),this.calendarInfo().firstDay,-1),t=this._workDays;return a.date.addDays(e,t[t.length-1]-7)},calculateDateRange:function(){var e=this.options,t=e.date,i=a.date.dayOfWeek,r=i(t,this.calendarInfo().firstDay,-1),n=i(r,e.workWeekStart,1),s=i(n,e.workWeekEnd,1),o=[],l=e.workDays&&e.workDays.length?e.workDays.map((function(e){return i(r,e,1).getTime()})):null;for(l&&(s=i(n=r,this.calendarInfo().firstDay+6,1));n<=s;)l&&l.indexOf(n.getTime())>-1?o.push(n):l||o.push(n),n=a.date.nextDay(n);this._render(o)}})})}(window.kendo.jQuery);var t=kendo;e.__meta__={id:"scheduler.dayview",name:"Scheduler Day View",category:"web",description:"The Scheduler Day View",depends:["scheduler.view","icons"],hidden:!0},e.default=t,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=kendo.scheduler.dayview.min.js.map