UNPKG

@progress/kendo-ui

Version:

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

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