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