UNPKG

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