@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines • 35.5 kB
JavaScript
/* @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.SchedulerTimelineview={}),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.timelineview`,name:`Scheduler Timeline View`,category:`web`,description:`The Scheduler Timeline View`,depends:[`scheduler.view`,`icons`],hidden:!0};(function(e,t){var n=window.kendo,r=n.ui,i=n.date.setTime,a=r.SchedulerView,o=n._outerWidth,s=n._outerHeight,c=e.extend,l=n.htmlEncode,u=n.date.getDate,d=n.date.getMilliseconds,f=n.date.MS_PER_DAY,p=n.date.MS_PER_MINUTE,m=`k-current-time`,h=`k-current-time-arrow`,g=`k-scheduler-header-wrap`,_=`k-event-inverse`,v=.8666,y=`.`,b=`.kendoTimelineView`,x=n.template(({title:e,start:t,end:r})=>`<div><div class="k-event-template k-event-time">${l(n.format(`{0:t} - {1:t}`,t,r))}</div><div class="k-event-template">${e}</div></div>`),S=n.template(({date:e})=>`<span class='k-link k-nav-day'>${n.format(`{0:m}`,e)}</span>`),C=e=>`<div role="button" aria-label="${l(e.ariaLabel)}" data-${e.ns}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">`:`class="k-event">`}<span class="k-event-actions">${e.tail?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?n.ui.icon(`caret-alt-right`):``}</span>${e.resizable&&!e.tail?`<span class="k-resize-handle k-resize-w"></span>`:``}${e.resizable&&!e.head?`<span class="k-resize-handle k-resize-e"></span>`:``}</div>`;function w(e){var t=new Date(1980,1,1,0,0,0);return i(t,d(e)),t}function T(){return e(`<div class='k-event'></div>`).appendTo(document.body)}function E(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}function D(e){var t=0;if(e.columns){for(var n=0;n<e.columns.length;n++)t+=D(e.columns[n]);return e.colspan=t,t}else return e.colspan=1,1}var O=n.Class.extend({init:function(e){this._view=e},_getTimeSlotByPosition:function(e,t,n){return this._view.groups[n].timeSlotByPosition(e,t)},_hideHeaders:function(){var e=this._view;e.timesHeader.find(`table tr`).last().hide(),e.datesHeader.find(`table tr`).last().hide()},_setColspan:function(e){D(e)},_createRowsLayout:function(e,t,n){return this._view._createRowsLayout(e,t,n)},_createVerticalColumnsLayout:function(e,t,n,r){return r},_createColumnsLayout:function(e,t,n){return this._view._createColumnsLayout(e,t,n)},_getRowCount:function(){return this._view._groupCount()},_getGroupsCount:function(){return 1},_addContent:function(e,t,r,i,a,o,s,c){for(var l=this._view,u=``,d=l.options,f=function(e){return function(){return l._resourceBySlot({groupIndex:e})}},p=function(t){var r=``,i=``,a;return n.date.isToday(e[g])&&(i+=`k-today`),(n.date.getMilliseconds(t)<n.date.getMilliseconds(d.workDayStart)||n.date.getMilliseconds(t)>=n.date.getMilliseconds(d.workDayEnd)||!l._isWorkDay(e[g]))&&(i+=` k-nonwork-hour`),r+=`<td`+(i===``?``:` class="`+i+`"`)+`>`,a=n.date.getDate(e[g]),n.date.setTime(a,n.date.getMilliseconds(t)),r+=s({date:a,resources:f(c?m:h)}),r+=`</td>`,r},m=0;m<i;m++){u+=`<tr>`;for(var h=0;h<r;h++)for(var g=0,_=t;g<_;g++)u+=l._forTimeRange(a,o,p);u+=`</tr>`}return u},_addTimeSlotsCollections:function(e,t,n,r,i){var a=this._view,o=n.length;i&&(o=Math.floor(o/e));for(var s=0;s<e;s++){var c=0,l=a.groups[s],u;i&&(c=s);var f=c*o,p=0;i||(p=s);for(var m=n[f].children,h=m.length/(i?1:e),g=h/t,_=0;_<t;_++){var v=_*g+h*p;u=d(new Date(+a.startTime()));for(var y=0;y<g;y++)a._addTimeSlotToCollection(l,m,y,v,_,u,r),u+=r}}},_getVerticalGroupCount:function(e){return e},_getVerticalRowCount:function(e,t,n){return this._view._isVerticallyGrouped()?e[t].maxRowCount:n},_renderEvent:function(e,t,n,r,i,a){var o=this._view,s=o._createEventElement(n.occurrence,t,i.head||n.head,i.tail||n.tail);s.appendTo(a).css({top:0,height:o.options.eventHeight});var c={start:n.occurrence._startTime||n.occurrence.start,end:n.occurrence._endTime||n.occurrence.end,element:s,uid:t.uid,slotRange:i,rowIndex:0,offsetTop:0};e.events[t.uid]=c,o._inverseEventColor(s),o.addContinuousEvent(r,i,s,t.isAllDay),o._arrangeRows(c,i,e)},_verticalCountForLevel:function(e){return this._view._rowCountForLevel(e)},_horizontalCountForLevel:function(e){return this._view._columnCountForLevel(e)},_updateCurrentVerticalTimeMarker:function(t,n){var r=this._view,i=`<div class='`+m+`'></div>`,a=r.datesHeader.find(y+g),s=Math.round(t[0].innerRect(n,new Date(n.getTime()+1),!1).left),c=e(i).prependTo(a).addClass(h+`-down`);c.css({left:r._adjustLeftPosition(s-o(c)*v/2),top:a.find(`tr`).last().prev().position().top}),e(i).prependTo(r.content).css({left:r._adjustLeftPosition(s),width:`1px`,height:r.content[0].scrollHeight-1,top:0})},_changeGroup:function(){return t},_prevGroupSlot:function(e,t,n){return this._view._isVerticallyGrouped()?e:t._collection(0,n).last()},_nextGroupSlot:function(e,t,n){return this._view._isVerticallyGrouped()?e:t._collection(0,n).first()},_verticalSlots:function(e,t){return this._view._changeGroup(e,t)},_verticalMethod:function(e){return e?`leftSlot`:`rightSlot`},_normalizeVerticalSelection:function(){return t},_horizontalSlots:function(e,t,n,r,i,a,o){var s=this._view,c={};return c.startSlot=t[n](r),c.endSlot=t[n](i),!a&&s._isHorizontallyGrouped()&&(!c.startSlot||!c.endSlot)&&(c.startSlot=c.endSlot=s._changeGroup(e,o)),c},_changeVerticalViewPeriod:function(){return!1},_changeHorizontalViewPeriod:function(e,t,n,r){var i=this._view;return!!((!e.startSlot||!e.endSlot)&&!t&&i._changeViewPeriod(n,r,!1))},_updateDirection:function(e,t,n,r){this._view._updateDirection(e,t,n,r,!0)},_createMoveHint:function(e,t){var n=this._view,r=e.start,i=n._createEventElement(t.occurrence,t.occurrence,!1,!1);i.addClass(`k-event-drag-hint`);var a=e.innerRect(t.occurrence.start,t.occurrence.end,n.options.snap),o=a.right-a.left;o<0&&(o=0);var s={left:n._adjustLeftPosition(a.left),top:r.offsetTop,height:r.offsetHeight,width:o};i.css(s),t.occurrence.inverseColor&&i.addClass(_),n._appendMoveHint(i)},_adjustLeftPosition:function(e){var t=this._view;return t._isRtl&&(e-=t.content[0].scrollWidth-t.content[0].clientWidth),e}}),k=n.Class.extend({init:function(e){this._view=e},_getTimeSlotByPosition:function(e,t,n){return this._view.groups[n].timeSlotByPosition(e,t,!0)},_hideHeaders:function(){var e=this._view;e._isVerticallyGrouped()?e.times.find(`.k-last`).hide():(e.timesHeader.find(`table tr`).eq(2).hide(),e.datesHeader.find(`table tr`).eq(2).hide())},_setColspan:function(){},_createRowsLayout:function(e,t,n,r){return this._view._createDateLayout(r,null,!0)},_createVerticalColumnsLayout:function(e,t,n){return this._view._createColumnsLayout(e,null,n)},_createColumnsLayout:function(e,t,n,r){return this._view._createColumnsLayout(e,t,n,r,!0)},_getRowCount:function(e){return this._view._rowCountForLevel(e)},_getGroupsCount:function(){return this._view._groupCount()},_addContent:function(e,t,r,a,o,s,c,l){for(var u=this._view,d=``,f=u.options,m=function(e){return function(){return u._resourceBySlot({groupIndex:e})}},h=function(t,r,i,a,o,s){var l=``,d=``,p,h=u._isVerticallyGrouped()?y:x;return n.date.isToday(e[x])&&(d+=`k-today`),(n.date.getMilliseconds(t)<n.date.getMilliseconds(f.workDayStart)||n.date.getMilliseconds(t)>=n.date.getMilliseconds(f.workDayEnd)||!u._isWorkDay(e[h]))&&(d+=` k-nonwork-hour`),l+=`<td`+(d===``?``:` class="`+d+`"`)+`>`,p=n.date.getDate(e[x]),n.date.setTime(p,n.date.getMilliseconds(t)),l+=c({date:p,resources:m(s)}),l+=`</td>`,l},g=new Date(o),_=u.options.minorTickCount,v=u.options.majorTick*p/_||1,y,b=0;b<a;b++){d+=`<tr>`,b%(a/u._dates.length)===0&&(y=b/(a/u._dates.length),g=new Date(u._dates[y]),n.date.setTime(g,n.date.getMilliseconds(o)));for(var x=0,S=t;x<S;x++)if(d+=u._forTimeRange(g,s,h,l,r),l){i(g,v,!1);break}d+=`</tr>`}return d},_addTimeSlotsCollections:function(e,t,n,r,i){var a=this._view,o=n.length;i&&(o/=t);for(var s=0;s<t;s++){var c=0,l;i&&(c=s);var u=c*o,f=0,p=n[u].children,m=i?o:p.length/(t*e),h=p.length/t,g;l=d(new Date(+a.startTime()));for(var _=0;_<m;_++){i?(g=0,p=n[_+m*s].children):(g=s*h+e*_,f++);for(var v=0;v<e;v++){var y=a.groups[v];a._addTimeSlotToCollection(y,p,v,g,s,l,r)}l+=r}}},_getVerticalGroupCount:function(){return this._view.content.find(`tr`).length},_getVerticalRowCount:function(e,t,n){return n},_renderEvent:function(e,t,n,r,i,a,o,s){for(var c=this._view,l,u=[],d=i.start.index;d<=i.end.index;d++){l=c._createEventElement(n.occurrence,t,d!==s,d!==o),l.appendTo(a).css({top:0,height:c.options.eventHeight});var f=r._timeSlotCollections[0]._slots[d],p=r.timeSlotRanges(f.start,f.end,!1)[0],m={start:d===o?n.occurrence._startTime||n.occurrence.start:f.start,end:d===s?n.occurrence._endTime||n.occurrence.end:f.end,element:l,uid:t.uid,slotRange:p,rowIndex:0,offsetTop:0};e.events[t.uid]=m,u.push(m),c.addContinuousEvent(r,p,l,t.isAllDay),c._arrangeRows(m,p,e)}e.events[t.uid]=u},_verticalCountForLevel:function(e){return this._view._columnCountForLevel(e)},_horizontalCountForLevel:function(e,t){var n=this._view;return n._columnCountForLevel(t)/n._columnCountForLevel(2)},_updateCurrentVerticalTimeMarker:function(t,n){var r=this._view,i=r.times.find(`tr`).first().find(`th`).first(),a=r.times.find(`tr`).first().find(`th`).last(),c=`<div class='`+m+`'></div>`,l=e(c).prependTo(r.times),u=Math.round(t[0].innerRect(n,new Date(n.getTime()+1),!1).top),d={};this._isRtl?(d.right=i.position().left+s(i)-s(a),l.addClass(h+`-left`)):(d.left=a.position().left,l.addClass(h+`-right`)),d.top=u-o(l)*v/2,l.css(d),e(c).prependTo(r.content).css({top:u,height:`1px`,right:`1px`,width:r.content[0].scrollWidth,left:0})},_changeGroup:function(e,t,n){var r=this._view;n||(e.groupIndex=t?r.groups.length-1:0)},_prevGroupSlot:function(e){return e},_nextGroupSlot:function(e){return e},_changeDate:function(e,t,n){var r=this._view.groups[e.groupIndex],i,a;if(t){if(i=r._getCollections(!1),a=n.index-1,a>=0)return i[0]._slots[a]}else if(i=r._getCollections(!1),a=n.index+1,i[0]&&i[0]._slots[a])return i[0]._slots[a]},_verticalSlots:function(e,t,n){return this._changeDate(e,t,n)},_verticalMethod:function(e,t){return t?e?`upSlot`:`downSlot`:e?`leftSlot`:`rightSlot`},_normalizeVerticalSelection:function(e,n,r,i){var a=this._view;return i?t:a._normalizeVerticalSelection(e,n,r)},_horizontalSlots:function(e,t,n,r,i,a,o){var s=this._view,c=s._changeGroup(e,o),l={};return c?l.startSlot=l.endSlot=c:s._isVerticallyGrouped()||(l.startSlot=t[n](r),l.endSlot=t[n](i)),l},_changeVerticalViewPeriod:function(e,t,n,r){var i=this._view;return!!((!e.startSlot||!e.endSlot)&&!t&&i._changeViewPeriod(n,r,i._isVerticallyGrouped()))},_changeHorizontalViewPeriod:function(e,t,n,r){var i=this._view;return i._isVerticallyGrouped()?!1:!!((!e.startSlot||!e.endSlot)&&!t&&i._changeViewPeriod(n,r,!1))},_updateDirection:function(e,t,n,r){var i=this._view;i._updateDirection(e,t,n,r,!i._isVerticallyGrouped())},_createMoveHint:function(e,t){for(var n=this._view,r=e.start,i=e.end,a=r.index;a<=i.index;a++){var o=e.collection._slots[a],s=n._createEventElement(t.occurrence,t.occurrence,!1,!1);s.addClass(`k-event-drag-hint`);var c={left:o.offsetLeft+2,top:o.offsetTop,height:n.options.eventHeight,width:o.offsetWidth};s.css(c),t.occurrence.inverseColor&&s.addClass(_),n._appendMoveHint(s)}},_adjustLeftPosition:function(e){var t=this._view;return t._isRtl&&!t._isVerticallyGrouped()&&(e-=t.content[0].scrollWidth-t.content[0].offsetWidth),e}});n.ui.scheduler.TimelineGroupedView=O,n.ui.scheduler.TimelineGroupedByDateView=k;var A=a.extend({init:function(e,t){var n=this,r=T();a.fn.init.call(n,e,t),n._zeroWidthEventOffset=r.outerWidth(),r.remove(),n._groupedView=n._getGroupedView(),n.title=n.options.title||n.options.name,n._workDays=E(n.options),n._templates(),n._editable(),n.calculateDateRange(),n._groups(),n._currentTime(!0)},name:`timeline`,_isVirtualized:function(){return!1},_getGroupedView:function(){return this._isGroupedByDate()?new n.ui.scheduler.TimelineGroupedByDateView(this):new n.ui.scheduler.TimelineGroupedView(this)},_getNextEventIndexBySlot:function(e,t,r){if(this._isVerticallyGrouped())return n.ui.SchedulerView.fn._getNextEventIndexBySlot.call(this,e,t,r);for(var i=0,a=0;a<t.length;a++){if(e.startDate()>t[a].start.startDate()){i++;continue}if(e.startDate().getTime()===t[a].start.startDate().getTime()&&r>t[a].start.groupIndex){i++;continue}break}return i},_getSelectedSlot:function(e,t,r,i,a,o){return this._isVerticallyGrouped()?n.ui.SchedulerView.fn._getSelectedSlot.call(this,e,t,r,i,a,o):e},_getSortedEvents:function(t){return this._isVerticallyGrouped()?n.ui.SchedulerView.fn._getSortedEvents.call(this,t):t.sort(function(t,n){var r=t.start.startDate().getTime()-n.start.startDate().getTime();return r===0&&(t.start.isDaySlot&&!n.start.isDaySlot&&(r=-1),!t.start.isDaySlot&&n.start.isDaySlot&&(r=1)),r===0&&(r=t.start.groupIndex-n.start.groupIndex),r===0&&(r=e(t.element).index()-e(n.element).index()),r})},_currentTimeMarkerUpdater:function(){this._updateCurrentTimeMarker(new Date)},_scrollTo:function(e,t){a.fn._scrollTo.call(this,e,t);var n=e.offsetLeft,r=e.offsetWidth,i=t.scrollLeft,o=t.clientWidth,s=n+r,c=0;c=i>n?n:s>i+o?r<=o?s-o:n:i,t.scrollLeft=c},_updateCurrentTimeMarker:function(t){var r=this.options;if(this.datesHeader.find(y+m).remove(),this.times.find(y+m).remove(),this.content.find(y+m).remove(),this._isInDateSlot({start:t,end:t})){if(r.currentTimeMarker.useLocalTimezone===!1){var i=r.dataSource.options.schema.timezone;if(r.dataSource&&i){var a=n.timezone.offset(t,i);t=n.timezone.convert(t,t.getTimezoneOffset(),a)}}for(var s=!r.group||r.group.orientation==`vertical`?1:this.groups.length,c=0;c<s;c++){var l=this.groups[c];if(!l)return;var u=n.date.toUtcTime(t),d=l.timeSlotRanges(u,u+1);if(d.length===0)return;if(d[0].collection.slotByStartDate(t))if(this._isVerticallyGrouped())this._groupedView._updateCurrentVerticalTimeMarker(d,t);else{var f=`<div class='`+m+`'></div>`,p=this.datesHeader.find(y+g),_=Math.round(d[0].innerRect(t,new Date(t.getTime()+1),!1).left),b=e(f).prependTo(p).addClass(h+`-down`);b.css({left:this._adjustLeftPosition(_-o(b)*v/2),top:p.find(`tr`).last().prev().position().top}),e(f).prependTo(this.content).css({left:this._adjustLeftPosition(_),width:`1px`,height:this.content[0].scrollHeight-1,top:0})}}}},_adjustLeftPosition:function(e){return this._groupedView._adjustLeftPosition(e)},_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)))},_editable:function(){this.options.editable&&(this._isMobile()?this._touchEditable():this._mouseEditable())},_mouseEditable:function(){var t=this;t.element.on(`click`+b,`.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`+b,`.k-scheduler-content > table td`,function(e){var n=t._slotByPosition(e.pageX,e.pageY);if(n){var r=t._resourceBySlot(n);t.trigger(`add`,{eventInfo:c({start:n.startDate(),end:n.endDate()},r)})}e.preventDefault()}),t.options.editable.update!==!1&&t.element.on(`dblclick`+b,`.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,useClickAsTap:!n.support.browser.edge,filter:`.k-scheduler-content td`,tap:function(e){if(!r._scrolling){var n=e.x.location===t?e.x:e.x.location,i=e.y.location===t?e.y:e.y.location,a=r._slotByPosition(n,i);if(a){var o=r._resourceBySlot(a);r.trigger(`add`,{eventInfo:c({start:a.startDate(),end:a.endDate()},o)})}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()}}}))},_slotByPosition:function(e,t){var r,i=this.content,a=i.offset(),o;if(e-=a.left,t-=a.top,this._isRtl){var s=n.support.browser;s.mozilla||s.webkit&&s.version>=85?(e+=i[0].scrollWidth-i[0].offsetWidth,e+=i[0].scrollLeft):s.msie?(e-=n.scrollLeft(i),e+=i[0].scrollWidth-i[0].offsetWidth):s.webkit&&(e+=i[0].scrollLeft)}else e+=i[0].scrollLeft;for(t+=i[0].scrollTop,e=Math.ceil(e),t=Math.ceil(t),o=0;o<this.groups.length;o++)if(r=this._groupedView._getTimeSlotByPosition(e,t,o),r)return r;return null},options:{name:`TimelineView`,title:`Timeline`,selectedDateFormat:`{0:D}`,selectedShortDateFormat:`{0:d}`,selectedMobileDateFormat:`{0:MMM dd}`,date:n.date.today(),startTime:n.date.today(),endTime:n.date.today(),showWorkHours:!1,minorTickCount:2,editable:!0,workDayStart:new Date(1980,1,1,8,0,0),workDayEnd:new Date(1980,1,1,17,0,0),workWeekStart:1,workWeekEnd:5,majorTick:60,eventHeight:25,eventMinWidth:0,columnWidth:100,groupHeaderTemplate:({text:e})=>e,majorTimeHeaderTemplate:({date:e})=>n.toString(e,`t`),slotTemplate:()=>` `,eventTemplate:x,dateHeaderTemplate:S,footer:{command:`workDay`},currentTimeMarker:{updateInterval:1e4,useLocalTimezone:!0},ongoingEvents:{cssClass:null,enabled:!0,updateInterval:6e4},messages:{defaultRowText:`All events`,showFullDay:`Show full day`,showWorkDay:`Show business hours`}},events:[`remove`,`add`,`edit`],_templates:function(){var e=this.options,t=c({},n.Template,e.templateSettings);this.eventTemplate=n.template(C),this.majorTimeHeaderTemplate=n.template(e.majorTimeHeaderTemplate,t),this.dateHeaderTemplate=n.template(e.dateHeaderTemplate,t),this.slotTemplate=n.template(e.slotTemplate,t),this.groupHeaderTemplate=n.template(e.groupHeaderTemplate,t)},_render:function(t){var n=this;t||=[],n._dates=t,n._startDate=t[0],n._endDate=t[t.length-1||0],n._calculateSlotRanges(),n.createLayout(n._layout(t)),n._content(t),n._footer(),n._setContentWidth(),n.refreshLayout(),n.datesHeader.on(`click`+b,`.k-nav-day`,function(t){var r=e(t.currentTarget).closest(`th`),i=n._slotByPosition(r.offset().left,n.content.offset().top);n.trigger(`navigate`,{view:`timeline`,date:i.startDate()})}),n._groupedView._hideHeaders()},_setContentWidth:function(){var e=this.content.width(),t=this.content.find(`table`),n=t.find(`tr`).first().children().length,r=100,i=n*this.options.columnWidth;e<i&&(r=Math.ceil(i/e*100)),t.add(this.datesHeader.find(`table`)).css(`width`,r+`%`)},_calculateSlotRanges:function(){var e=this._dates,t=this.startTime(),r=this.endTime();r=d(r),t=d(t),r===t?r+=f-1:r<t&&(r+=f);for(var a=[],o=0;o<e.length;o++){var s=u(e[o]);i(s,t);var c=u(e[o]);i(c,r),a.push({start:n.date.toUtcTime(s),end:n.date.toUtcTime(c)})}this._slotRanges=a},_forTimeRange:function(e,t,n,r,a){e=w(e),t=w(t);var o=this,s=d(e),c=d(t),l=o.options.minorTickCount,u=o.options.majorTick*p,m=u/l||1,h=new Date(+e),g=0,_,v=``;for(_=f/m,s!=c&&(s>c&&(c+=f),_=(c-s)/m),_=r?1:Math.round(_),a&&(_*=a);g<_;g++){var y=g%(u/m),b=y===0,x=y<l-1,S=y===l-1,C=l;if(_%l!==0){var T=_-(g+1)<l;b&&T&&(C=_%l)}v+=n(h,b,x,S,C,g%a),r||(a?g%a===a-1&&i(h,m,!1):i(h,m,!1))}return v},_layout:function(e){for(var t=[],n=[],r=this,i=[{text:r.options.messages.defaultRowText}],a=r._groupedView,o=[],s=0;s<r.options.minorTickCount;s++)o.push({text:`​`,minorTicks:!0});this._forTimeRange(r.startTime(),r.endTime(),function(e,n,i,s,c){var l=r.majorTimeHeaderTemplate;if(n){var u={text:l({date:e}),className:s?`k-slot-cell`:``,columns:o.slice(0,c)};a._setColspan(u),t.push(u)}});for(var c=0;c<e.length;c++)n.push({text:r.dateHeaderTemplate({date:e[c]}),className:`k-slot-cell`,columns:t.slice(0)});var l=this.groupedResources;return l.length&&(this._groupOrientation()===`vertical`?(i=a._createRowsLayout(l,null,this.groupHeaderTemplate,n),n=a._createVerticalColumnsLayout(l,null,this.groupHeaderTemplate,n)):n=a._createColumnsLayout(l,n,this.groupHeaderTemplate,n)),{columns:n,rows:i}},_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},toggleFullDay:function(){var e=this.options;this.trigger(`navigate`,{view:this.name||e.name,date:e.date,isWorkDay:!e.showWorkHours})},_columnCountForLevel:function(e){var t=this.columnLevels[e];return t?t.length:0},_rowCountForLevel:function(e){var t=this.rowLevels[e];return t?t.length:0},_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},_content:function(e){var t=this,n=t.startTime(),r=this.endTime(),i=1,a=1,o=e.length,s=``,c=this.groupedResources,l=this.slotTemplate,u=!1;c.length&&(u=t._groupOrientation()===`vertical`,u?(a=t._groupedView._getRowCount(this.rowLevels.length-1),i=t._groupedView._getGroupsCount()):i=t._groupCount()),s+=`<tbody>`,s+=t._groupedView._addContent(e,o,i,a,n,r,l,u),s+=`</tbody>`,this.content.find(`table`).append(s)},_groups:function(){var e=this._groupCount(),t=this._dates,r=t.length;this.groups=[];for(var a=0;a<e;a++){var o=this._addResourceView(a),s=t[0],c=t[t.length-1||0],l=d(this.startTime()),f=d(this.endTime());l!==0&&f<=l&&(s=u(s),i(s,l),c=u(c),i(c,f)),o.addTimeSlotCollection(s,n.date.addDays(c,1))}this._timeSlotGroups(e,r)},_isHorizontallyGrouped:function(){return this.groupedResources.length&&this._groupOrientation()===`horizontal`},_timeSlotGroups:function(e,t){var n=this._timeSlotInterval(),r=this._isVerticallyGrouped(),i=this.content.find(`tr`);this._groupedView._addTimeSlotsCollections(e,t,i,n,r)},_addTimeSlotToCollection:function(e,t,n,r,i,a,o){var s=t[n+r],c=e.getTimeSlotCollection(0),l=this._dates[i],u=Date.UTC(l.getFullYear(),l.getMonth(),l.getDate())+a,d=u+o;c.addTimeSlot(s,u,d,!0)},startDate:function(){return this._startDate},endDate:function(){return this._endDate},visibleEndDate:function(){var e=d(this.startTime()),t=d(this.endTime()),r=this.endDate();return e!==0&&t<=e&&(r=n.date.addDays(r,1)),r},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},_timeSlotInterval:function(){var e=this.options;return e.majorTick/e.minorTickCount*p},nextDate:function(){return n.date.nextDay(this.endDate())},previousDate:function(){return n.date.previousDay(this.startDate())},calculateDateRange:function(){this._render([this.options.date])},render:function(e){this._headerColumnCount=0,this._groups(),this.element.find(`.k-event`).remove(),e=new n.data.Query(e).sort([{field:`start`,dir:`asc`},{field:`end`,dir:`desc`}]).toArray();var t=[];this._eventsByResource(e,this.groupedResources,t);for(var r=[],i=0,a=0;a<t.length;a++){var o={groupIndex:a,maxRowCount:0,events:{}};r.push(o),this._renderEvents(t[a],a,o),i<o.maxRowCount&&(i=o.maxRowCount)}this._setRowsHeight(r,t.length,i),this._positionEvents(r,t.length),this._currentTime(!1),this._ongoingEvents(e),this.trigger(`activate`)},_positionEvents:function(e,t){for(var n=0;n<t;n++){var r=e[n].events;for(var i in r){var a=r[i];if(Array.isArray(a))for(var o=0;o<a.length;o++)this._positionEvent(a[o]);else this._positionEvent(a)}}},_setRowsHeight:function(t,n,r){var i=this.options.eventHeight,a=this._getBottomRowOffset(),o=this._groupedView,s=o._getVerticalGroupCount(n);n=this._isVerticallyGrouped()?s:1;for(var c=0;c<n;c++){var l=o._getVerticalRowCount(t,c,r);l||=1;var u=(i+2)*l+a,d=e(this.times.find(`tr`)[c]),f=e(this.content.find(`tr`)[c]);d.height(u),f.height(u)}this._setContentWidth(),this.refreshLayout(),this._refreshSlots()},_getBottomRowOffset:function(){var e=this.options.eventHeight*.5,t=this._isMobile(),n,r;return t?(n=30,r=60):(n=15,r=30),e>r?e=r:e<n&&(e=n),e},_positionEvent:function(e){var t=this.options.eventHeight,n=2,r=e.slotRange.innerRect(e.start,e.end,!1),i=this._adjustLeftPosition(r.left),a=r.right-r.left;if(a<0&&(a=0),a<this.options.eventMinWidth){var o=e.slotRange.collection,s=o._slots[o._slots.length-1],c=s.offsetLeft+s.offsetWidth;a=this.options.eventMinWidth,c<i+a&&(a=c-r.left)}e.element.css({top:e.slotRange.start.offsetTop+e.rowIndex*(t+n)+`px`,left:i,width:a})},_refreshSlots:function(){for(var e=0;e<this.groups.length;e++)this.groups[e].refresh()},_eventsByResource:function(e,r,i,o){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===o});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:a.groupEqFilter(u)}).toArray();r.length>1?this._eventsByResource(d,r.slice(1),i,u):i.push(d)}}else i.push(e)},_isInDateSlot:function(e){var t=e.start,r=e.end,i=u(this._startDate);return t<n.date.addDays(u(this.visibleEndDate()),1)&&i<=r},_isInTimeSlot:function(e){var t=e._startTime||n.date.toUtcTime(e.start),r=e._endTime||n.date.toUtcTime(e.end),i=this._slotRanges;t===r&&(r+=1);for(var a=0;a<i.length;a++)if(t<i[a].end&&i[a].start<r)return!0;return!1},_adjustEvent:function(e){var t=e.start,r=e.end,a=e._time(`start`),o=e._time(`end`),s=d(this.startTime()),c=d(this.endTime()),l=null,p=null,m,h=!1,g=!1;return e.isAllDay&&(t=u(t),a=0,r=u(r),o=f,p=n.date.addDays(r,1)),c===0&&(c=f),c<=s?(a<s&&a>=c&&(l=u(t),i(l,s),g=!0),o>c&&o<=s&&(p=u(r),i(p,c),h=!0)):(s>a?(l=u(t),i(l,s),g=!0):c<=a&&(l=u(t),l=n.date.addDays(l,1),i(l,s),g=!0),c<o?(p=u(r),i(p,c),h=!0):s>o&&(p=u(r),p=n.date.addDays(p,-1),i(p,c),h=!0)),m=e.clone({start:l||t,end:p||r,_startTime:l?n.date.toUtcTime(l):e._startTime,_endTime:p?n.date.toUtcTime(p):e._endTime,isAllDay:!1}),{occurrence:m,head:h,tail:g}},_renderEvents:function(e,t,n){var r,i,a;for(i=0,a=e.length;i<a;i++)if(r=e[i],this._isInDateSlot(r)){var o=r.isAllDay||r.duration()>=f,s=this.content;if(o||this._isInTimeSlot(r)){var c=this._adjustEvent(r),l=this.groups[t];if(l._continuousEvents||=[],this._isInTimeSlot(c.occurrence)){var u=l.slotRanges(c.occurrence,!1)[0],d=u.start.index,p=u.end.index;this._groupedView._renderEvent(n,r,c,l,u,s,d,p)}}}},addContinuousEvent:function(e,t,r,i){e._continuousEvents.push({element:r,isAllDay:i,uid:r.attr(n.attr(`uid`)),start:t.start,end:t.end})},_createEventElement:function(t,r,i,a){var o=this.eventTemplate,s=this.options.editable,l=this._isMobile(),u=s&&s.destroy!==!1&&!l,d=s&&s.resize!==!1,f=r._time(`start`),p=r._time(`end`),m=r.start,h=r.end,g=this.eventResources(r);r._startTime&&f!==n.date.getMilliseconds(r.start)&&(m=new Date(f),m=n.timezone.apply(m,`Etc/UTC`)),r._endTime&&p!==n.date.getMilliseconds(r.end)&&(h=new Date(p),h=n.timezone.apply(h,`Etc/UTC`));var _=e(o(c({},{ns:n.ns,resizable:d,showDelete:u,head:i,tail:a,singleDay:this._dates.length==1,resources:g,inverseColor:!1,messages:this.options.messages,ariaLabel:this._formatEventAriaLabel(r.title,m,h,r.isAllDay),template:this.options.eventTemplate},r,{start:m,end:h})));return n.applyStylesFromKendoAttributes(_,[`background-color`,`border-color`]),_},_arrangeRows:function(e,t,n){var r=this,i=t.start.index,o=t.end.index,s=e.slotRange.innerRect(e.start,e.end,!1),c=s.right+this.options.eventMinWidth,l=a.collidingEvents(t.events(),s.left,c);t.addEvent({slotIndex:i,slotIndexEnd:o,start:s.left,end:c,zeroWidthEventOffset:r._zeroWidthEventOffset,rectLeft:s.left,rectRight:c,element:e.element,uid:e.uid}),l.push({slotIndex:i,slotIndexEnd:o,start:s.left,end:c,zeroWidthEventOffset:r._zeroWidthEventOffset,uid:e.uid});var u=a.createRows(l);n.maxRowCount<u.length&&(n.maxRowCount=u.length);for(var d=0,f=u.length;d<f;d++)for(var p=u[d].events,m=0,h=p.length;m<h;m++)n.events[p[m].uid].rowIndex=d},_groupCount:function(){var e=this.groupedResources,t=this._groupedView;return e.length?this._groupOrientation()===`vertical`?t._verticalCountForLevel(e.length-1):t._horizontalCountForLevel(e.length-1,this.columnLevels.length-1):1},_updateEventForSelection:function(e){return this._adjustEvent(e.clone()).occurrence},_eventOptionsForMove:function(e){return e.isAllDay?{isAllDay:!1}:{}},_updateEventForResize:function(e){e.isAllDay&&e.set(`isAllDay`,!1)},_updateMoveHint:function(e,t,n){var r=this.groups[t],i=e.clone({start:e.start,end:e.end}),a=i.duration();if(i.start=new Date(i.start.getTime()+n),i.end=new Date(+i.start+a),this._removeMoveHint(e.uid),this._isInDateSlot(i)&&(i.isAllDay||i.duration()>=f||this._isInTimeSlot(i)))for(var o=this._adjustEvent(i),s=r.slotRanges(o.occurrence,!1),c=0;c<s.length;c++)this._groupedView._createMoveHint(s[c],o)},_appendMoveHint:function(e){e.appendTo(this.content),this._moveHint=this._moveHint.add(e)},_updateResizeHint:function(e,t,r,i){var o=this.groups[t].ranges(r,i,!1,!1);this._removeResizeHint();for(var s=0;s<o.length;s++){var c=o[s],l=c.startSlot(),u=c.innerRect(r,i,!1);u.top=l.offsetTop;var d=u.right-u.left;if(d<0){for(var f=0;f<c.events().length;f++)if(c.events()[f].uid===e.uid){d=c.events()[f].rectRight-u.left;break}}var p=c.endSlot().offsetTop+l.offsetHeight-u.top,m=this._adjustLeftPosition(u.left),h=a.fn._createResizeHint.call(this,m,u.top,d,p);this._resizeHint=this._resizeHint.add(h)}var g=`t`,_=this.content;this._resizeHint.appendTo(_),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),g)),this._resizeHint.last().addClass(`k-last`).find(`.k-label-bottom`).text(n.toString(n.timezone.toLocalDate(i),g))},selectionByElement:function(e){var t=e.offset();return this._slotByPosition(t.left,t.top)},_updateDirection:function(e,t,n,r,i){var a=t[0].start,o=t[t.length-1].end;n&&!i&&a.index===o.index&&a.collectionIndex===o.collectionIndex&&(e.backward=r)},_changeGroup:function(e,t){var n=this[t?`prevGroupSlot`:`nextGroupSlot`](e.start,e.groupIndex,!1);return n&&(e.groupIndex+=t?-1:1),this._groupedView._changeGroup(e,t,n),n},prevGroupSlot:function(e,t,n){var r=this.groups[t],i=r.ranges(e,e,n,!1)[0].start;if(!(t<=0))return this._groupedView._prevGroupSlot(i,r,n)},nextGroupSlot:function(e,t,n){var r=this.groups[t],i=r.ranges(e,e,n,!1)[0].start;if(!(t>=this.groups.length-1))return this._groupedView._nextGroupSlot(i,r,n)},_verticalSlots:function(e,t,n,r){var i=this._groupedView,a=i._verticalMethod(r,n),o=t[0].start,s=t[t.length-1].end,c=this.groups[e.groupIndex],l=i._normalizeVerticalSelection(e,t,r,n);return l&&(o=s=l),o=c[a](o),s=c[a](s),!n&&this._isVerticallyGrouped()&&(!o||!s)&&(o=s=i._verticalSlots(e,r,l)),{startSlot:o,endSlot:s}},_horizontalSlots:function(e,t,n,r){var i=r?`upSlot`:`downSlot`,a=t[0].start,o=t[t.length-1].end,s=this.groups[e.groupIndex],c={};return n?(c.startSlot=s[i](a),c.endSlot=s[i](o),!n&&this._isHorizontallyGrouped()&&(!a||!o)&&(c.startSlot=c.endSlot=this._changeGroup(e,r))):c=this._groupedView._horizontalSlots(e,s,i,a,o,n,r),c},_changeViewPeriod:function(e,t){var n=t?this.previousDate():this.nextDate(),r=e.start,a=e.end,o=new Date(n),s=new Date(n);if(this._isInRange(o,s))return!1;e.start=o,e.end=s,this._isHorizontallyGrouped()&&(e.groupIndex=t?this.groups.length-1:0);var c=a-r;return t?(a=d(this.endTime()),a=a===0?f:a,i(e.start,a-c),i(e.end,a)):(r=d(this.startTime()),i(e.start,r),i(e.end,r+c)),e.events=[],!0},move:function(e,t,r){var i=!1,a=this.groups[e.groupIndex],o=n.keys,s=this._groupedView,c=a.ranges(e.start,e.end,!1,!1),l,u,d,f;if(t===o.DOWN||t===o.UP){if(i=!0,d=t===o.UP,s._updateDirection(e,c,r,d),f=this._verticalSlots(e,c,r,d),s._changeVerticalViewPeriod(f,r,e,d))return i}else if((t===o.LEFT||t===o.RIGHT)&&(i=!0,d=t===o.LEFT,this._updateDirection(e,c,r,d,!1),f=this._horizontalSlots(e,c,r,d),s._changeHorizontalViewPeriod(f,r,e,d)))return i;if(i){if(l=f.startSlot,u=f.endSlot,r){var p=e.backward;p&&l?e.start=l.startDate():!p&&u&&(e.end=u.endDate())}else l&&u&&(e.start=l.startDate(),e.end=u.endDate());e.events=[]}return i},destroy:function(){var e=this;e.element&&e.element.off(b),e._currentTimeUpdateTimer&&clearInterval(e._currentTimeUpdateTimer),a.fn.destroy.call(this),this._isMobile()&&e.options.editable&&(e.options.editable.create!==!1&&e._addUserEvents.destroy(),e.options.editable.update!==!1&&e._editUserEvents.destroy())},_resourceBySlot:function(e){var t=this.groupedResources,n={},r=this.options.group;if(t.length&&r.orientation===`horizontal`&&r.date){var i=e.groupIndex,o=this.columnLevels,s=o[o.length-1],c=t[t.length-1],l=s[i],u,d,f,p;for(this._setResourceValue(l,c,n),f=o.length-2;f>=3;f--)for(s=o[f],c=t[f-3],u=0,p=0;p<s.length;p++)if(l=s[p],d=l.columns.length,d>i-u){this._setResourceValue(l,c,n);break}else u+=d;return n}else return a.fn._resourceBySlot.call(this,e)}});c(!0,r,{TimelineView:A,TimelineWeekView:A.extend({options:{name:`TimelineWeekView`,title:`Timeline Week`,selectedDateFormat:`{0:D} - {1:D}`,selectedShortDateFormat:`{0:d} - {1:d}`,selectedMobileDateFormat:`{0:MMM dd} - {1:dd}`,majorTick:120},name:`timelineWeek`,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)}}),TimelineWorkWeekView:A.extend({options:{name:`TimelineWorkWeekView`,title:`Timeline Work Week`,selectedDateFormat:`{0:D} - {1:D}`,selectedShortDateFormat:`{0:d} - {1:d}`,selectedMobileDateFormat:`{0:MMM dd} - {1:dd}`,majorTick:120},name:`timelineWorkWeek`,nextDate:function(){var e=n.date.dayOfWeek(n.date.nextDay(this.endDate()),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)}}),TimelineMonthView:A.extend({options:{name:`TimelineMonthView`,title:`Timeline Month`,selectedDateFormat:`{0:D} - {1:D}`,selectedShortDateFormat:`{0:d} - {1:d}`,workDayStart:new Date(1980,1,1,0,0,0),workDayEnd:new Date(1980,1,1,23,59,59),footer:!1,majorTick:1440,minorTickCount:1},name:`timelineMonth`,calculateDateRange:function(){var e=this.options.date,t=n.date.firstDayOfMonth(e),r=n.date.lastDayOfMonth(e),i,a,o=[];for(i=0,a=r.getDate();i<a;i++)o.push(t),t=n.date.nextDay(t);this._render(o)}})})})(window.kendo.jQuery);var i=kendo;e.__meta__=r,e.default=i});
//# sourceMappingURL=kendo.scheduler.timelineview.min.js.map