UNPKG

@progress/kendo-ui

Version:

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

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