").append(this.times.add(this.content).wrap("").parent())},_scroller:function(){var t,n=this;this.content.bind("scroll"+y,function(){n.datesHeader.find(">.k-scheduler-header-wrap").scrollLeft(this.scrollLeft),n.times.scrollTop(this.scrollTop)}),t=_.touchScroller(this.content,{avoidScrolling:function(t){return e(t.event.target).closest(".k-event.k-state-selected").length>0}}),t&&t.movable&&(this._touchScroller=t,this.content=t.scrollElement,t.movable.bind("change",function(e){n.datesHeader.find(">.k-scheduler-header-wrap").scrollLeft(-e.sender.x),n.times.scrollTop(-e.sender.y)}))},_resourcesForGroups:function(){var e,t,n,i,r=[],o=this.options.group,a=this.options.resources;if(o=o&&o.resources?o.resources:[],a&&o.length)for(e=0,t=a.length;t>e;e++)for(n=0,i=o.length;i>n;n++)a[e].name===o[n]&&r.push(a[e]);this.groupedResources=r},_isGroupedByDate:function(){var t=this.options.group;return t=t&&t.resources?t.resources:[],e.inArray("date",t)>-1},_createColumnsLayout:function(e,t){if(this._isGroupedByDate()){for(var n=0,i=t.length;i>n;n++)t[n].columns=g("columns",e);return t}return g("columns",e,t)},_groupOrientation:function(){var e=this.options.group;return e&&e.resources?e.orientation:"horizontal"},_isVerticallyGrouped:function(){return this.groupedResources.length&&"vertical"===this._groupOrientation()},_createRowsLayout:function(e,t){return g("rows",e,t)},selectionByElement:function(){return null},clearSelection:function(){this.content.find(".k-state-selected").removeClass("k-state-selected")},select:function(){},destroy:function(){var e=this;b.fn.destroy.call(this),e.table&&(_.destroy(e.table),e.table.remove())}}),e.extend(w.SchedulerView,{createColumns:p,createRows:f,rangeIndex:c,collidingEvents:d,collidingHorizontallyEvents:l,groupEqFilter:m})}(window.kendo.jQuery),function(e){function t(e){var t=new Date(1980,1,1,0,0,0);return f(t,b(e)),t}function n(e,t,n){var i,r=t.getTime(),o=n.getTime();return i=e.getTime(),i>=r&&o>=i}function i(e,t,n){return e>t&&n>e}function r(e,t,n){var i,r,o;for(i=0;i=o.offsetLeft&&t=o.offsetTop&&nr;r++)i=t[r],n(e[i.start])&&a.push(i);return a}function a(e){e.className=e.className.replace(A,"")+" k-state-selected"}function s(e,t){return e.valuePrimitive&&(t=d.getter(e.dataValueField)(t)),t}function l(t,n,i){return n&&n.length?(n=n[n.length-1],t=e.map(t,function(e){return e.element.data("uid")}),e.inArray(n,t)+(i?-1:1)):i&&n?n.length-1:0}var d=window.kendo,c=d.ui,u=d.keys,p=d.date.addDays,f=d.date.setTime,h=c.SchedulerView,g=e.extend,m=e.proxy,v=d.date.getDate,_=d.date.MS_PER_MINUTE,w=d.date.MS_PER_DAY,b=d.date.getMilliseconds,y=".kendoMultiDayView",k=d.template('- #=kendo.format("{0:t} - {1:t}", start, end)#
- ${title}
'),x=d.template(''),C=d.template("#=kendo.toString(date, 'ddd M/dd')#"),T='# if(data.tail || data.middle) {##}## if(data.id && data.recurrenceId) {## } else if(data.recurrenceRule || data.recurrenceId) {## } #{0} #if (showDelete) {##}## if(data.head || data.middle) {##}##if(resizable && !singleDay && !data.tail && !data.middle){# #}##if(resizable && !singleDay && !data.head && !data.middle){# #}# ',S='# if(data.id && data.recurrenceId) {## } else if(data.recurrenceRule || data.recurrenceId) {## } #{0} #if (showDelete) {##}## if(data.tail || data.middle) {## } ## if(data.head || data.middle) {## } ## if(resizable && !data.tail && !data.middle) {# # } ## if(resizable && !data.head && !data.middle) {# # } # ',D=h.extend({init:function(e,t){var n=this;h.fn.init.call(n,e,t),n.title=n.options.title||n.options.name,n._templates(),n._editable(),n.calculateDateRange(),n._slots()},_toDaySlot:function(e){if(!e.isAllDay)return e;var t=0;return this._isVerticallyGrouped()&&(t+=e.groupIndex*this._rowCountInGroup()),this._columns[e.columnIndex].slots[t]},_toAllDaySlot:function(e){return e.isAllDay?e:this._rows[e.groupIndex].slots[e.columnIndex]},_updateResizeHint:function(e,t,n){var i,r,o,a,s,l,c,u,p,f,g,m="south"==e||"north"==e,v=this.content,_=function(e,t,n,i){var r,o=0;for(r=t;n>r;r++)o+=e[r][i];return o+=e[n][i]};if(this._removeResizeHint(),m){for(t=this._toDaySlot(t),n=this._toDaySlot(n),r=[],o=t.columnIndex;o<=n.columnIndex;o++)a=this._columns[o].slots,s=0,l=a.length-1,this._isVerticallyGrouped()&&(s=t.groupIndex*this._rowCountInGroup(),l=(t.groupIndex+1)*this._rowCountInGroup()-1),c=a[s],u=a[l],c.startn.start&&(u=n),r.push({startSlot:c,endSlot:u});for(p=0;pw,I=i.groupIndex*this._columnCountInGroup();if(A?(i=this._toAllDaySlot(i),r=this._rows[i.index].slots):(i=this._toDaySlot(i),r=this._columns[i.columnIndex].slots),o=i.start.getTime()-n.start.getTime(),a=t.end.getTime()-t.start.getTime(),s=new Date(t.start.getTime()),d.date.setTime(s,o),l=new Date(s.getTime()),f(l,a),A?(c=this._dateSlotIndex(s)+I,u=this._dateSlotIndex(l)+I):(c=Math.floor(this._timeSlotIndex(s)),u=Math.ceil(this._timeSlotIndex(l)),this._isVerticallyGrouped()&&(c+=i.groupIndex*this._rowCountInGroup(),u+=i.groupIndex*this._rowCountInGroup())),0>c&&(c=0),0>u&&(u=r.length-1),A&&this._isGroupedByDate()&&(c=u=i.columnIndex),t.isAllDay||(u=Math.max(c,u-1)),p=r[c],this._removeMoveHint(),A)this._moveHint=this._createEventElement(e.extend({},t,{start:s,end:l}),!1),this._moveHint.addClass("k-event-drag-hint"),this._moveHint.css({left:p.offsetLeft+2,top:p.offsetTop,width:this._calculateAllDayEventWidth(r,c,u)-4});else{for(h=Math.max(0,this._dateSlotIndex(l)),(0===b(l)||b(l)g.start&&(x=g),m.push({startSlot:k,endSlot:x});for(C=0;C1&&(n=r(this._rows,e,t)))return n;for(o=0;o=i.offsetLeft&&e=n.offsetTop&&t<=n.offsetTop+n.clientHeight)return n},_slots:function(){var e,t,n,i,r,o,a,s,l,d,c,u,p,f,h,g,m=this.content[0].getElementsByTagName("tr"),v=m[0].children.length,_=[];for(e=0;v>e;e++)_.push({slots:[],events:[]});for(a=0,s="vertical"===this._groupOrientation(),l=".k-scheduler-header-all-day tr",this._isVerticallyGrouped()&&(l=".k-scheduler-header-all-day"),d=this.element.find(l),c=this._isVerticallyGrouped()?d.length:0,u=0;u-1)a++;else for(t=p.children,n=0;n1?i.offsetTop:i.parentNode.parentNode.parentNode.offsetTop,offsetLeft:i.offsetLeft,clientHeight:i.clientHeight,offsetHeight:i.offsetHeight,offsetWidth:i.offsetWidth,clientWidth:i.clientWidth,element:i,isAllDay:!0,start:r.start,end:r.end,index:u,columnIndex:n},o.groupIndex=s?u:this._groupHorizontalIndex(n),h.slots.push(o);f.push(h)}else f.push(h);this._rows=f},options:{name:"MultiDayView",selectedDateFormat:"{0:D}",allDaySlot:!0,title:"",startTime:d.date.today(),endTime:d.date.today(),minorTickCount:2,majorTick:60,majorTimeHeaderTemplate:"#=kendo.toString(date, 't')#",minorTimeHeaderTemplate:" ",eventTemplate:k,allDayEventTemplate:x,dateHeaderTemplate:C,editable:!0,messages:{allDay:"all day"}},events:["remove","add","edit"],_templates:function(){var e=this.options,t=g({},d.Template,e.templateSettings);this.eventTemplate=this._eventTmpl(e.eventTemplate,S),this.allDayEventTemplate=this._eventTmpl(e.allDayEventTemplate,T),this.majorTimeHeaderTemplate=d.template(e.majorTimeHeaderTemplate,t),this.minorTimeHeaderTemplate=d.template(e.minorTimeHeaderTemplate,t),this.dateHeaderTemplate=d.template(e.dateHeaderTemplate,t)},_editable:function(){this.options.editable&&(d.support.mobileOS?this._touchEditable():this._mouseEditable())},_mouseEditable:function(){var t=this;t.element.on("click"+y,".k-event a:has(.k-si-close)",function(n){t.trigger("remove",{uid:e(this).closest(".k-event").attr(d.attr("uid"))}),n.preventDefault()}),t.options.editable.create!==!1&&t.element.on("dblclick"+y,".k-scheduler-content td",function(n){var i,r;e(this).parent().hasClass("k-scheduler-header-all-day")||(i=t._slotByPosition(n.pageX,n.pageY),r=t._resourceBySlot(i),t.trigger("add",{eventInfo:g({start:i.start,end:i.end},r)}),n.preventDefault())}).on("dblclick"+y,".k-scheduler-header-all-day td",function(e){var n=t._slotByPosition(e.pageX,e.pageY),i=t._resourceBySlot(n);t.trigger("add",{eventInfo:g({},{isAllDay:!0,start:d.date.getDate(n.start),end:d.date.getDate(n.end)},i)}),e.preventDefault()}),t.options.editable.update!==!1&&t.element.on("dblclick"+y,".k-event",function(n){t.trigger("edit",{uid:e(this).closest(".k-event").attr(d.attr("uid"))}),n.preventDefault()})},_touchEditable:function(){var t=this;t._closeUserEvents=new d.UserEvents(t.element,{filter:".k-event a:has(.k-si-close)",tap:function(n){t.trigger("remove",{uid:e(n.target).closest(".k-event").attr(d.attr("uid"))}),n.preventDefault()}}),t.options.editable.create!==!1&&(t._addUserEvents=new d.UserEvents(t.element,{filter:".k-scheduler-content td",tap:function(n){var i,r;e(n.target).parent().hasClass("k-scheduler-header-all-day")||(i=t._slotByPosition(n.x.location,n.y.location),r=t._resourceBySlot(i),t.trigger("add",{eventInfo:g({start:i.start,end:i.end},r)}),n.preventDefault())}}),t._allDayUserEvents=new d.UserEvents(t.element,{filter:".k-scheduler-header-all-day td",tap:function(e){var n=t._slotByPosition(e.x.location,e.y.location),i=t._resourceBySlot(n);t.trigger("add",{eventInfo:g({},{isAllDay:!0,start:d.date.getDate(n.start),end:d.date.getDate(n.end)},i)}),e.preventDefault()}})),t.options.editable.update!==!1&&(t._editUserEvents=new d.UserEvents(t.element,{filter:".k-event.k-state-selected",tap:function(n){0===e(n.event.target).closest("a:has(.k-si-close)").length&&(t.trigger("edit",{uid:e(n.target).closest(".k-event").attr(d.attr("uid"))}),n.preventDefault())}}))},_layout:function(e){var t,n,i,r=[],o=[],a=this.options,s=this;for(t=0;t",this.footer=e(t).appendTo(this.element)},_forTimeRange:function(e,n,i,r){var o,a,s,l,d,c,u,p,h,g,m,v,y,k,x,C;for(e=t(e),n=t(n),s=this,l=b(e),d=b(n),c=s.options.minorTickCount,u=s.options.majorTick*_,p=u/c||1,h=new Date(+e),g=h.getDate(),m=0,v="",a=w/p,l!=d&&(l>d&&(d+=w),a=(d-l)/p),a=Math.round(a);a>m;m++)y=m%(u/p),k=0===y,x=c-1>y,C=y===c-1,v+=i(h,k,x,C),f(h,p,!1);return d&&(o=b(h),gd&&(h=new Date(+n))),r&&(v+=r(h)),v},_content:function(e){var t,n,i=this,r=i.options,o=r.startTime,a=r.endTime,s=1,l=1,c=e.length,u="",p=this.groupedResources,f="";for(p.length&&("vertical"===i._groupOrientation()?(l=this._rowCountForLevel(this.rowLevels.length-2),r.allDaySlot&&(f='")):(s=this._columnCountForLevel(this.columnLevels.length-2),this._isGroupedByDate()&&(s=this._columnCountForLevel(p.length),c=1))),u+="",t=function(t,n){var i,r,o,a="";for(a="",o=0;s>o;o++)for(i=0,r=c;r>i;i++)a+="",a+=" | ";return a+=" "},n=0;l>n;n++)u+=f,u+=this._forTimeRange(o,a,t);u+="",this.content.find("table").append(u)},_render:function(t){var n,i=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(),n=this.element.find(".k-scheduler-header-all-day td"),n.length&&(this._allDayHeaderHeight=n.first()[0].clientHeight),i.datesHeader.on("click"+y,".k-nav-day",function(t){var n=e(t.currentTarget).closest("th");i.trigger("navigate",{view:"day",date:i._slotIndexDate(n.index())})})},startDate:function(){return this._startDate},endDate:function(){return this._endDate},_end:function(e){var t=b(this.options.endTime)||w;return e&&(t=0),new Date(this._endDate.getTime()+t)},nextDate:function(){return d.date.nextDay(this.endDate())},previousDate:function(){return d.date.previousDay(this.startDate())},calculateDateRange:function(){this._render([this.options.date])},destroy:function(){var e=this;e.datesHeader&&e.datesHeader.off(y),e.element&&e.element.off(y),h.fn.destroy.call(this),e.footer&&e.footer.remove(),d.support.mobileOS&&(e._closeUserEvents.destroy(),e.options.editable.create!==!1&&(e._addUserEvents.destroy(),e._allDayUserEvents.destroy()),e.options.editable.update!==!1&&e._editUserEvents.destroy())
},selectionByElement:function(e){var t=e.offset();return this._slotByPosition(t.left,t.top)},_slotIndexTime:function(e){return e=this._adjustSlotIndex(e),b(this.options.startTime)+this._timeSlotInterval()*e},_timeSlotInterval:function(){var e=this.options;return e.majorTick/e.minorTickCount*_},_rangeByIndex:function(e,t,n){var i=d.date.getDate(this._slotIndexDate(t)),r=d.date.getDate(i);return f(i,this._slotIndexTime(e)),n=this._adjustSlotIndex(n),this._adjustSlotIndex(e)>=n?(f(r,b(this.options.endTime)),d.date.getDate(r).getTime()===r.getTime()&&(r=d.date.nextDay(r))):f(r,this._slotIndexTime(e+1)),{start:i,end:r}},_slotIndexDate:function(e){var t,n,i,r,o,a=this._dates||[],s=b(new Date(+this.options.startTime)),l=b(new Date(+this.options.endTime));for(s>=l&&(l+=w),r=this.groupedResources,o="vertical"===this._groupOrientation(),r.length&&!o&&(e=this._adjustColumnIndex(e)),t=0,n=a.length;n>t;t++)if(i=new Date(+a[t]),f(i,s),e===t)return i;return null},_adjustSlotIndex:function(e){if(this._isVerticallyGrouped()){var t=this._rowCountInGroup();return e-t*Math.floor(e/t)}return e},_groupHorizontalIndex:function(e){return this.groupedResources.length?Math.floor(e/this._columnCountInGroup()):0},_groupVerticalIndex:function(e){return this.groupedResources.length?Math.floor(e/this._rowCountInGroup()):0},_adjustColumnIndex:function(e){var t=this._columnCountInGroup();return this._isGroupedByDate()?Math.floor(e/t):e-t*Math.floor(e/t)},_columnCountInGroup:function(){var e=this.groupedResources;return e.length?this._isGroupedByDate()?this._columnCountForLevel(e.length)/this._columnCountForLevel(0):this._columnOffsetForResource(e.length):0},_rowCountInGroup:function(){var e,t=this.groupedResources;return t.length?(e=this.options.allDaySlot?this._rowCountForLevel(t.length-1):0,(this._rowCountForLevel(t.length)-e)/this._rowCountForLevel(t.length-1)):0},_timeSlotIndex:function(e){var t=this.options,n=b(e),i=b(t.startTime),r=t.majorTick/t.minorTickCount*_;return(n-i)/r},_dateSlotIndex:function(e,t){var i,r,o,a,s=this._dates||[],l=1;for(this._isGroupedByDate()&&(l=this._columnCountInGroup()),i=0,r=s.length;r>i;i++)if(o=d.date.getDate(s[i]),a=new Date(d.date.getDate(s[i]).getTime()+w-(t?0:1)),n(e,o,a))return i*l;return-1},_calculateAllDayEventWidth:function(e,t,n){var i,r,o=0,a=t!==n?"offsetWidth":"clientWidth";for(i=0,r=e.length;r>i;i++)i>=t&&n>=i&&(o+=e[i][a]);return o},_calculateEventHeight:function(e,t,n){var i,r,o=0;for(t===n&&(n+=1),i=0,r=e.length;r>i;i++)i>=t&&n>i&&(o+=e[i].offsetHeight);return o},_positionAllDayEvent:function(t,n,i,r){var o,a,s,l,d,c,u,p=t.slots[i],f=this._calculateAllDayEventWidth(t.slots,i,r),g=h.collidingHorizontallyEvents(t.events,i,r),m=this._headerColumnCount||0,v=2,_=i!==r?5:4,w=this._allDayHeaderHeight;for(n.css({left:p.offsetLeft+v,width:f-_}),t.events.push({start:i,end:r,element:n}),g.push({start:i,end:r,element:n}),o=h.createRows(g),o.length&&o.length>m&&(this._updateAllDayHeaderHeight(w*o.length+w),this._headerColumnCount=o.length),a=p.offsetTop,s=0,l=o.length;l>s;s++)for(d=o[s].events,c=0,u=d.length;u>c;c++)e(d[c].element).css({top:a+s*w})},_arrangeColumns:function(t,n,i){var r,o,a,s,l,d,c,u=i.clientWidth,p=.1*u,f=i.events,g=h.collidingEvents(f,t.start,t.end);for(i.events.push(t),g.push(t),r=h.createColumns(g),a=(u-p)/r.length,s=0,l=r.length;l>s;s++)for(o=r[s].events,d=0,c=o.length;c>d;d++)e(o[d].element).css({width:a-4,left:i.offsetLeft+s*a+2})},_positionEvent:function(e,t,n,i){var r,o=this._columns[n],a=this._isVerticallyGrouped()?this._rowCountInGroup():o.slots.length,s=Math.floor(this._timeSlotIndex(e.startTime||e.start))+i,l=Math.ceil(this._timeSlotIndex(e.endTime||e.end)),d=4;(s>0||0>s)&&0>=l&&(l=a),0>s&&(s=0),l>a&&(l=a),l+=i,r=o.slots[Math.floor(s)],t.css({height:this._calculateEventHeight(o.slots,s,l)-d,top:r.offsetTop}),this._arrangeColumns({element:t,start:s,end:l},n,o)},_eventTmpl:function(e,t){var n,i=this.options,r=g({},d.Template,i.templateSettings),o=r.paramName,a="",s=typeof e,l={storage:{},count:0};return"function"===s?(l.storage["tmpl"+l.count]=e,a+="#=this.tmpl"+l.count+"("+o+")#",l.count++):"string"===s&&(a+=e),n=d.template(d.format(t,a),r),l.count>0&&(n=m(n,l.storage)),n},_createEventElement:function(t,i,r,o){var a,s,l=i?this.eventTemplate:this.allDayEventTemplate,c=this.options,u=c.editable,p=u&&u.destroy!==!1,f=u&&u.resize!==!1,h=v(this.startDate()),m=v(this.endDate()),_=b(c.startTime),y=b(c.endTime),k=b(t.startTime||t.start),x=b(t.endTime||t.end);return _>=y&&(y=b(new Date(c.endTime.getTime()+w-1))),i||t.isAllDay||(m=new Date(m.getTime()+w)),s=t.end,t.isAllDay&&(s=v(t.end)),!n(v(t.start),h,m)&&!n(s,h,m)||i&&_>k&&x>y?a=!0:v(t.start)k?o=!0:(s>m&&!i||i&&x>y)&&(r=!0),e(l(g({},{ns:d.ns,resizable:f,showDelete:p,middle:a,head:r,tail:o,singleDay:1==this._dates.length||this._isGroupedByDate(),resources:this.eventResources(t)},t,{start:t.startTime||t.start,end:t.endTime||t.end})))},_isInTimeSlot:function(e){var t=this.options.startTime,n=this.options.endTime,r=e.startTime||e.start,o=e.endTime||e.end;return b(n)===b(d.date.getDate(n))&&(n=d.date.getDate(n),f(n,w-1)),b(o)===b(d.date.getDate(o))&&o.getTime()>r.getTime()&&(o=d.date.getDate(o),f(o,w-1)),o=b(o),r=b(r),n=b(n),t=b(t),t===r&&r===o?!0:i(r,t,n)||i(o,t,n)||i(t,r,o)||i(n,r,o)},_isInDateSlot:function(e){var t=this.startDate(),i=new Date(this.endDate().getTime()+w-1);return n(e.start,t,i)||n(e.end,t,i)||n(t,e.start,e.end)||n(i,e.start,e.end)},_updateAllDayHeaderHeight:function(e){var t,n,i,r,o,a=this.element.find(".k-scheduler-header-all-day td");if(a.length){for(t=e-a[0].clientHeight,a.parent().add(this.element.find(".k-scheduler-times-all-day").parent()).height(e),n=0,o=0;or;r++)if(i=e[r],this._isInDateSlot(i))if(a=this._dateSlotIndex(i.start),s=this._dateSlotIndex(i.end,!i.isAllDay),l=i.isAllDay||i.end.getTime()-i.start.getTime()>=w,c=l?y:this.content,l)this.options.allDaySlot&&(0>a&&(a=0),0>s&&(s=(this.groupedResources.length&&!C?this._columnCountInGroup():this._rows[0].slots.length)-1),u=this._createEventElement(i,!l),this._positionAllDayEvent(this._rows[n],u,a+x,s+x),u.appendTo(c));else if(this._isInTimeSlot(i))for(-1===a&&s>-1&&(a=s),p=a;s>=p;p++)f=i.start,h=i.end,m=!1,v=!1,p>a&&(f=d.date.getDate(h),d.date.setTime(f,b(this.options.startTime)),f>h&&(f=d.date.addDays(f,-1)),v=!0),s>p&&(h=d.date.getDate(f),d.date.setTime(h,b(this.options.endTime)),f>h&&(h=d.date.addDays(h,1)),m=!0),_=g({},i,{start:f,end:h}),this._isInTimeSlot(_)&&(u=this._createEventElement(i,!l,m,v),this._positionEvent(_,u,p+x,k),u.appendTo(c))},render:function(e){var t,n;this._headerColumnCount=0,this._slots(),this.element.find(".k-event").remove(),this._updateAllDayHeaderHeight(this._allDayHeaderHeight),e=new d.data.Query(e).sort([{field:"start",dir:"asc"},{field:"end",dir:"desc"}]).toArray(),t=this.groupedResources,t.length?(n=1,this._isGroupedByDate()&&(this._isVerticallyGrouped()||(this.columnLevels.push(Array(this._columnCountForLevel(this.columnLevels.length-1))),n=2)),this._renderGroups(e,t,0,n)):this._renderEvents(e,0,0),this.refreshLayout(),this.trigger("activate")},_resourceBySlot:function(e){var t,n,i,r,o,a,l,c,u,p,f=this.groupedResources,h={},g=this._isVerticallyGrouped();if(f.length)for(t=g?e.index:e.columnIndex,e.isAllDay&&g&&(t*=this._rowCountInGroup()),n=0,this._isGroupedByDate()&&(n=1,t-=Math.floor(t/this._columnCountInGroup())*this._columnCountInGroup()),i=0,r=f.length;r>i;i++)o=f[i],g?(l=this.options.allDaySlot?this._rowCountForLevel(f.length-1):0,a=(this._rowCountForLevel(f.length)-l)/this._rowCountForLevel(i)):a=this._columnCountForLevel(f.length)/this._columnCountForLevel(i+n),c=Math.floor(t/a),t-=c*a,u=s(o,o.dataSource.at(c)),o.multiple&&(u=[u]),p=d.setter(o.field),p(h,u);return h},_renderGroups:function(e,t,n,i){var r,o,a,l,c,u,p=t[0],f="vertical"===this._groupOrientation();if(f?(o=1===t.length&&this.options.allDaySlot?this._rowCountForLevel(i-1):0,r=(this._rowCountForLevel(i)-o)/this._rowCountForLevel(i-1)):r=this._columnOffsetForResource(i),p)for(a=p.dataSource.view(),l=0;l1?this._renderGroups(u,t.slice(1),r*l,i+1):this._renderEvents(this._splitAllDayEvents(u),r*(l+n),f?l+n:0)},_splitAllDayEvents:function(e){var t,n,i,r,o,a,s,l;if(this._isGroupedByDate()){for(t=[],n=0;n1)for(s.end=d.date.getDate(r),s.isAllDay=!0,l=1;a>l;l++)r=d.date.getDate(d.date.nextDay(s.end)),s=g({},i),s.start=r,s.isAllDay=!0,s.end=d.date.getDate(r),t.push(s);return t}return 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){var t=this.rowLevels[e];return t?t.length:0},_selectionOffset:function(){return this._dates.length},normalizeSelection:function(e){var t,n=this._columns,i=this._dateSlotIndex(e.start),r=this._timeSlotIndex(e.start);(0>i||i>=n.length)&&(i=0),t=this._columns[i].slots,0>r?r=0:r>t.length-1&&(r=t.length-1),t=this._columns[i].slots[r],e.start=new Date(t.start),e.end=new Date(t.end)},isInRange:function(e){return this._slotByDate(e)},moveSelectionToPeriod:function(e){var t=this._selectionOffset(),n=e.start,i=e.end;this._dateSlotIndex(n)<0||this._dateSlotIndex(i)<0?(n>=this.endDate()&&(t=-t),e.start=p(n,t),e.end=p(i,t),e.events=[]):this.normalizeSelection(e)},clearSelection:function(){this.content.add(this.datesHeader).find(".k-state-selected").removeClass("k-state-selected")},select:function(e){if(e){if(this.clearSelection(),e.events[0]&&this._selectEvents(e))return;this._selectCells(e)}},_selectEvents:function(e){for(var t,n=this.content.add(this.datesHeader.children()),i=e.events,r=i.length,o=0;r>o;o++)if(t=n.children("[data-uid="+i[o]+"]").addClass("k-state-selected"),t=t[t.length-1],!t)return this.clearSelection(),undefined;return t?(this._scrollTo(t,this.content[0]),!0):undefined},_selectCells:function(e){var t,n,i,r,o,s,l,d,c,u,p,f,h,g,m,v,_,y,k=e.start,x=e.end,C=k>x;if(C&&(k=new Date(x),x=new Date(e.start)),o=this,s=this.groupedResources,l=o._columns,d=Math.floor(o._timeSlotIndex(k)),c=Math.ceil(o._timeSlotIndex(x)),u=o._dateSlotIndex(k),p=o._dateSlotIndex(x),f=b(this.options.endTime),h=b(x),g=this._isVerticallyGrouped(),m=0,v=0,0>u&&(u=0),0>p&&(p=f===b(x)?this._columnCountInGroup()||this._columns.length:u),0>d&&(d=0),(0>c||u===p&&d>c)&&(c=d),_=Math.abs(b(this.options.endTime)-b(this.options.startTime)||w),C&&Math.abs(x-k)>_&&(c+=1),g?(v=this._rowCountInGroup()||0,v=e.groupIndex*v,d+=v,c+=v):(m=this._columnOffsetForResource(s.length),m=e.groupIndex*m||0,u+=m,p+=m),e.isAllDay)for(y=g?e.groupIndex:0,t=o._rows[y].slots;p>=u;u++)t[u].groupIndex===e.groupIndex&&(r=t[u].element,a(r));else for(0===h&&h===f&&u!==p&&(p-=1,c=this._rowCountInGroup()+this._rowCountInGroup()*e.groupIndex||l[p].slots.length),n=c;p>=u;u++){for(u===p?n=c:p>u&&(n=this._rowCountInGroup()+this._rowCountInGroup()*e.groupIndex||l[p].slots.length),t=l[u].slots,d!==n&&(n-=1);n>=d;d++)r=t[d].element,a(r),i||(i=r);d=0+v}r=C?i:r,r&&o._scrollTo(r,o.content[0])},move:function(e,t,n){var i,r,o=this.groupedResources,a=this._timeSlotInterval(),s=new Date(e.start),l=new Date(e.end),d=Math.abs(s-l)>a,c=this._columnCountInGroup(),h=e.isAllDay,g=!1;if(t===u.DOWN){if(g=!0,h){if(n)return e.events=[],g;e.isAllDay=!1,i=this._firstSlot(s),s=i.start,l=i.end}else n||(d?l>s?s=new Date(l):l=new Date(s+a):f(s,a)),f(l,a),s.getTime()===l.getTime()&&(n?(f(s,-a),f(l,a)):f(l,a));this._slotByDate(new Date(l-a))&&this._slotByDate(s)||(r=e.groupIndex+1l&&(s=new Date(l)),l=new Date(s)),f(s,-a)),f(l,-a),s.getTime()===l.getTime()&&(n?(f(s,a),f(l,-a)):f(l,a)),n&&!this._slotByDate(s>l?l:s))return e.events=[],g;n||(this._isVerticallyGrouped()&&e.isAllDay&&e.groupIndex-1>-1?(e.groupIndex-=1,e.isAllDay=!1,i=this._lastSlot(e.start),s=i.start,l=i.end):!this._slotByDate(s)&&this.options.allDaySlot&&(e.isAllDay=!0,i=this._firstSlot(e.start),l=s=i.start))}else t===u.RIGHT?(g=!0,n||(s=p(s,1)),l=p(l,1),n&&!d&&(l.setHours(s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()),f(l,a)),s>this._end(h)&&o.length&&!this._isVerticallyGrouped()&&(e.groupIndex+=1,this._columnCountForLevel(o.length)>e.groupIndex*c?(s=p(s,-c),l=p(l,-c)):e.groupIndex=0)):t===u.LEFT&&(g=!0,n||(s=p(s,-1)),l=p(l,-1),n&&!d&&l.setHours(s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()),s-1?(s=p(s,c),l=p(l,c)):e.groupIndex=this._columnCountForLevel(o.length)/c-1));return g&&(e.events=[],e.start=s,e.end=l),g},_firstSlot:function(e){return this._columns[this._dateSlotIndex(e)].slots[0]},_lastSlot:function(e){var t=this._columns[this._dateSlotIndex(e)].slots;return t[t.length-1]},_slotByDate:function(e){var t,n=this._columns[this._dateSlotIndex(e)];return n&&(t=n.slots[this._timeSlotIndex(e)],t&&t.start.getTime()===e.getTime())?t:null},_slotByAllDay:function(e){var t=this._rows[0].slots[this._dateSlotIndex(e)];return t||null},_getAllDayEvents:function(e,t){var n,i,r,o,a=this._rows[0],s=a.events;for(r=l(s,t),o=s.length;o>r;r++)if(i=s[r],i.start===e){n=i;break}return n},moveToEvent:function(e,t){var n,i,r,a,s,c,u=e.events.length,p=this._columns.length,f=function(t){return t.start=e.start},m=function(t){return t.start>=e.start};if(c=e.isAllDay?this._slotByAllDay(e.start):this._slotByDate(e.start),n=c.columnIndex,t)for(;n>=0;n--){if(i=this._columns[n],r=o(i.slots,i.events,f),r[0]&&(s=-1,u?(s=l(r,e.events,t),u=0):s=r.length-1,a=r[s]))return e.start=i.slots[a.start].start,e.end=i.slots[a.end-1].end,e.events=[a.element.data("uid")],!0;if(r=o(this._rows[0].slots,this._rows[0].events,h),r[0]&&(s=-1,u?(s=l(r,e.events,t),u=0):s=r.length-1,a=r[s]))return e.start=this._rows[0].slots[a.start].start,e.end=this._rows[0].slots[a.end].end,e.events=[a.element.data("uid")],e.isAllDay=!0,!0}else for(;p>n;n++)if(i=this._columns[n],r=o(i.slots,i.events,g),r[0]){if(s=u?l(r,e.events):0,a=r[s])return e.start=i.slots[a.start].start,e.end=i.slots[a.end-1].end,e.events=[a.element.data("uid")],!0}else if(r=o(this._rows[0].slots,this._rows[0].events,m),r[0]&&(s=u?l(r,e.events):0,a=r[s]))return e.start=this._rows[0].slots[a.start].start,e.end=this._rows[0].slots[a.end].end,e.events=[a.element.data("uid")],e.isAllDay=!0,!0}}),A=/\s*k-state-selected/;g(!0,c,{MultiDayView:D,DayView:D.extend({options:{title:"Day"},name:"day"}),WeekView:D.extend({options:{title:"Week",selectedDateFormat:"{0:D} - {1:D}"},name:"week",calculateDateRange:function(){var e,t,n=this.options.date,i=d.date.dayOfWeek(n,0,-1),r=[];for(e=0,t=7;t>e;e++)r.push(i),i=d.date.nextDay(i);this._render(r)}})})}(window.kendo.jQuery),function(e){function t(e){var t,n,i=0;for(t=0,n=e.length;n>t;t++)i+=e[t].items.length;return i}function n(e,t){return e.valuePrimitive&&(t=o.getter(e.dataValueField)(t)),t}function i(e){for(var t,n=0,i=e.length,o=[];i>n;n++)t=e[n],t.groups?(t=r(t.groups),o=o.concat(t)):o=o.concat(r(t.items));return o}function r(e){for(var t=[].concat(e),n=t.shift(),i=[],r=[].push;n;)n.groups?r.apply(t,n.groups):n.items?r.apply(t,n.items):r.call(i,n),n=t.shift();return i}var o=window.kendo,a=o.ui,s=".kendoAgendaView",l=e.extend;a.AgendaView=a.SchedulerView.extend({init:function(e,t){a.SchedulerView.fn.init.call(this,e,t),t=this.options,t.editable&&(t.editable=l({"delete":!0},t.editable,{create:!1,update:!1})),this.title=t.title,this.name=t.name,this._eventTemplate=o.template(t.eventTemplate),this._dateTemplate=o.template(t.eventDateTemplate),this._groupTemplate=o.template(t.eventGroupTemplate),this._timeTemplate=o.template(t.eventTimeTemplate),this.element.on("mouseenter"+s,".k-scheduler-agenda .k-scheduler-content tr","_mouseenter").on("mouseleave"+s,".k-scheduler-agenda .k-scheduler-content tr","_mouseleave").on("click"+s,".k-scheduler-agenda .k-scheduler-content .k-link:has(.k-si-close)","_remove"),this._renderLayout(t.date)},_mouseenter:function(t){e(t.currentTarget).addClass("k-state-hover")},_mouseleave:function(t){e(t.currentTarget).removeClass("k-state-hover")},_remove:function(t){t.preventDefault(),this.trigger("remove",{uid:e(t.currentTarget).closest(".k-task").attr(o.attr("uid"))})},nextDate:function(){return o.date.nextDay(this.startDate())},startDate:function(){return this._startDate},endDate:function(){return this._endDate},previousDate:function(){return o.date.previousDay(this.startDate())},_renderLayout:function(e){this._startDate=e,this._endDate=o.date.addDays(e,7),this.createLayout(this._layout()),this.table.addClass("k-scheduler-agenda")},_layout:function(){var e,t,n=[{text:this.options.messages.date,className:"k-scheduler-datecolumn"},{text:this.options.messages.time,className:"k-scheduler-timecolumn"},{text:this.options.messages.event}],i=this.groupedResources;if(i.length){for(e=[],t=0;t1)for(s.end=o.date.nextDay(i),s.head=!0,d=1;a>d;d++)i=s.end,s=l({},n),s.start=i,s.startDate=o.date.getDate(i),s.end=o.date.nextDay(i),d==a-1?(s.end=new Date(s.start.getFullYear(),s.start.getMonth(),s.start.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()),s.tail=!0):(s.isAllDay=!0,s.middle=!0),s.end.getTime()<=this.endDate().getTime()&&c.push(s);return new o.data.Query(c).sort([{field:"start",dir:"asc"},{field:"end",dir:"asc"}]).groupBy({field:"startDate"}).toArray()},_renderTaskGroups:function(e,t){var n,i,r,a,s,d,c,u,p=[];for(n=0;n{1} | ',t[u].rowSpan,this._groupTemplate({value:t[u].text}),t[u].className));0===s&&c.push(o.format('{1} | ',r.length,this._dateTemplate({date:i}),n!=e.length-1||t.length?"":" k-last")),d.format=d.head?"{0:t}":d.tail?"{1:t}":"{0:t}-{1:t}",d.resources=this.eventResources(d),c.push(o.format('{0}{1}{2} | {3} | ',d.tail||d.middle?'':"",this._timeTemplate(l({},d,{start:d.startTime||d.start,end:d.endTime||d.end})),d.head||d.middle?'':"",this._eventTemplate(d))),p.push("