UNPKG

@progress/kendo-ui

Version:

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

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