/** 
 * Kendo UI v2016.3.1118 (http://www.telerik.com/kendo-ui)                                                                                                                                              
 * Copyright 2016 Telerik AD. All rights reserved.                                                                                                                                                      
 *                                                                                                                                                                                                      
 * Kendo UI commercial licenses may be obtained at                                                                                                                                                      
 * http://www.telerik.com/purchase/license-agreement/kendo-ui-complete                                                                                                                                  
 * If you do not own a commercial license, this file shall be governed by the trial license terms.                                                                                                      
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       

*/
!function(e,define){define("kendo.scheduler.agendaview.min",["kendo.scheduler.view.min"],e)}(function(){return function(e){function t(e){var t,s,a=0;for(t=0,s=e.length;t<s;t++)a+=e[t].items.length;return a}function s(e,t){return e.valuePrimitive&&(t=r.getter(e.dataValueField)(t)),t}function a(e){for(var t,s=0,a=e.length,r=[];s<a;s++)t=e[s],t.groups?(t=n(t.groups),r=r.concat(t)):r=r.concat(n(t.items));return r}function n(e){for(var t=[].concat(e),s=t.shift(),a=[],n=[].push;s;)s.groups?n.apply(t,s.groups):s.items?n.apply(t,s.items):n.call(a,s),s=t.shift();return a}var r=window.kendo,i=r.ui,o=".kendoAgendaView",l='<div class="k-task" title="#:title.replace(/"/g,"\'")#" data-#=kendo.ns#uid="#=uid#"># if (resources[0]) {#<span class="k-scheduler-mark" style="background-color:#=resources[0].color#"></span># } ## if (data.isException()) { #<span class="k-icon k-i-exception"></span># } else if (data.isRecurring()) {#<span class="k-icon k-i-refresh"></span># } #{0}#if (showDelete) {#<a href="\\#" class="k-link k-event-delete"><span class="k-icon k-si-close"></span></a>#}#</div>',u=r.Class.extend({init:function(e){this._view=e},_getColumns:function(e,t){return e.concat(t)},_getGroupsInDay:function(){return[]},_getSumOfItemsForDate:function(){return 0},_renderTaskGroupsCells:function(e,t,s,a){var n=this._view;0===s&&0===a&&t.length&&n._renderTaskGroupsCells(e,t)},_renderDateCell:function(e,t,s,a,n,i){var o=this._view;e.push(r.format('<td class="k-scheduler-datecolumn{3}{2}" rowspan="{0}">{1}</td>',s.length,o._dateTemplate({date:a}),n!=i.length-1||t.length?"":" k-last",t.length?"":" k-first"))},_renderDates:function(){},_getParents:function(e){return e.splice(0)},_getGroupsByDate:function(){},_renderTaskGroups:function(e,t,s){var a=this._view;e.append(a._renderTaskGroups(t,s))}}),d=r.Class.extend({init:function(e){this._view=e},_getColumns:function(e,t){var s,a,n=this._view;return n._isMobilePhoneView()?e.concat(t):(s=t.slice(0,1),a=t.slice(1),s.concat(e).concat(a))},_compareDateGroups:function(e,t,s){return e[s].text==t[s].text&&(0===s||this._compareDateGroups(e,t,s-1))},_getGroupsInDay:function(e,t){var s,a,n,r,i,o=[],l=null;for(s=0;s<e.length;s++)for(a=0;a<e[s].items.length;a++){if(n=0,0===o.length)for(n;n<t[s].length;n++)o.push([1]);else for(n;n<t[s].length;n++)if(this._compareDateGroups(t[s],l,n))o[n][o[n].length-1]++;else{for(r=o[n][o[n].length-1]-1,i=0;i<r;i++)o[n].push(0);o[n].push(1)}l=t[s]}return o},_getSumOfItemsForDate:function(e){var t,s=0;for(t=0;t<e.length;t++)s+=e[t].items.length;return s},_renderTaskGroupsCells:function(e,t,s,a,n,i,o,l){var u,d=this._view,c=d._isMobilePhoneView();if(c)0===s&&0===a&&t.length&&d._renderTaskGroupsCells(e,t);else for(0===s&&0===a&&e.push(r.format('<td class="k-scheduler-datecolumn k-first" rowspan="{0}">{1}</td>',i,d._dateTemplate({date:o}))),u=0;u<t[s].length;u++)n[u][l]&&e.push(r.format('<td class="k-scheduler-groupcolumn" rowspan="{0}">{1}</td>',n[u][l],d._groupTemplate({value:t[s][u].text}),t[s][u].className))},_renderDateCell:function(){},_renderDates:function(e){var t,s=this._view,a=s._groupsByDate.sort(function(e,t){return e.array[0].value.getTime()-t.array[0].value.getTime()});for(t=0;t<a.length;t++)e.append(s._renderTaskGroups(a[t].array,a[t].groups))},_getParents:function(e){return e.slice(0)},_getGroupsByDate:function(e,t,s){var a,n,r,i,o=this._view;if(e[t].items)for(a=0;a<e[t].items.length;a++){for(n=e[t].items[a].value,r=!1,i=0;i<o._groupsByDate.length;i++)o._groupsByDate[i].array[0].value.getTime()===n.getTime()&&(r=!0,o._groupsByDate[i].array.push(e[t].items[a]),o._groupsByDate[i].groups.push(s));r||o._groupsByDate.push({array:[e[t].items[a]],groups:[s]})}},_renderTaskGroups:function(){}});r.ui.scheduler.AgendaGroupedView=u,r.ui.scheduler.AgendaGroupedByDateView=d,i.AgendaView=i.SchedulerView.extend({init:function(t,s){i.SchedulerView.fn.init.call(this,t,s),this._groupedView=this._getGroupedView(),s=this.options,s.editable&&(s.editable=e.extend({"delete":!0},s.editable,{create:!1,update:!1})),this.title=s.title,this._eventTemplate=this._eventTmpl(s.eventTemplate,l),this._dateTemplate=r.template(s.eventDateTemplate),this._groupTemplate=r.template(s.eventGroupTemplate),this._timeTemplate=r.template(s.eventTimeTemplate),this.element.on("mouseenter"+o,".k-scheduler-agenda .k-scheduler-content tr","_mouseenter").on("mouseleave"+o,".k-scheduler-agenda .k-scheduler-content tr","_mouseleave").on("click"+o,".k-scheduler-agenda .k-scheduler-content .k-link:has(.k-si-close)","_remove"),this._renderLayout(s.date)},name:"agenda",_getGroupedView:function(){return this._isGroupedByDate()?new r.ui.scheduler.AgendaGroupedByDateView(this):new r.ui.scheduler.AgendaGroupedView(this)},_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(r.attr("uid"))})},nextDate:function(){return r.date.nextDay(this.startDate())},startDate:function(){return this._startDate},endDate:function(){return this._endDate},previousDate:function(){return r.date.previousDay(this.startDate())},_renderLayout:function(e){this._startDate=e,this._endDate=r.date.addDays(e,7),this.createLayout(this._layout()),this.table.addClass("k-scheduler-agenda")},_layout:function(){var e,t,s,a=[{text:this.options.messages.time,className:"k-scheduler-timecolumn"},{text:this.options.messages.event}];if(this._isMobilePhoneView()||a.splice(0,0,{text:this.options.messages.date,className:"k-scheduler-datecolumn"}),e=this.groupedResources,e.length){for(t=[],s=0;s<e.length;s++)t.push({text:"",className:"k-scheduler-groupcolumn"});a=this._groupedView._getColumns(t,a)}return{columns:a}},_tasks:function(e){var t,s,a,n,i,o,l,u=[];for(t=0;t<e.length;t++)if(s=e[t],a=s.start,n=s.isAllDay?r.date.getDate(s.end):s.end,i=Math.ceil((n-r.date.getDate(a))/r.date.MS_PER_DAY),s.isAllDay&&(i+=1),o=s.clone(),o.startDate=r.date.getDate(a),o.startDate>=this.startDate()&&u.push(o),i>1)for(o.end=r.date.nextDay(a),o.head=!0,l=1;l<i;l++)a=o.end,o=s.clone(),o.start=a,o.startDate=r.date.getDate(a),o.end=r.date.nextDay(a),l==i-1?(o.end=new Date(o.start.getFullYear(),o.start.getMonth(),o.start.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),o.tail=!0):(o.isAllDay=!0,o.middle=!0),(r.date.getDate(o.end)<=this.endDate()&&o.start>=this.startDate()||r.date.getDate(o.start).getTime()==this.endDate().getTime())&&u.push(o);return new r.data.Query(u).sort([{field:"start",dir:"asc"},{field:"end",dir:"asc"}]).groupBy({field:"startDate"}).toArray()},_renderTaskGroups:function(e,t){var s,a,n,i,o,l,u,d,c=[],h=this.options.editable,p=h&&h.destroy!==!1&&!this._isMobile(),g=this._isMobilePhoneView(),f=this._groupedView._getSumOfItemsForDate(e),m=this._groupedView._getGroupsInDay(e,t),_=0;for(s=0;s<e.length;s++)for(a=e[s].value,n=e[s].items,i=r.date.isToday(a),o=0;o<n.length;o++)l=n[o],u=[],d=g?[]:u,this._groupedView._renderTaskGroupsCells(d,t,s,o,m,f,a,_),_++,0===o&&(g?(d.push(r.format('<td class="k-scheduler-datecolumn" colspan="2">{0}</td>',this._dateTemplate({date:a}))),c.push('<tr role="row" aria-selected="false"'+(i?' class="k-today">':">")+d.join("")+"</tr>")):this._groupedView._renderDateCell(u,t,n,a,s,e)),l.format=l.head?"{0:t}":l.tail?"{1:t}":"{0:t}-{1:t}",l.resources=this.eventResources(l),u.push(r.format('<td class="k-scheduler-timecolumn"><div>{0}{1}{2}</div></td><td>{3}</td>',l.tail||l.middle?'<span class="k-icon k-i-arrow-w"></span>':"",this._timeTemplate(l.clone({start:l._startTime||l.start,end:l.endTime||l.end})),l.head||l.middle?'<span class="k-icon k-i-arrow-e"></span>':"",this._eventTemplate(l.clone({showDelete:p})))),c.push('<tr role="row" aria-selected="false"'+(i?' class="k-today">':">")+u.join("")+"</tr>");return c.join("")},_renderTaskGroupsCells:function(e,t){for(var s=0;s<t.length;s++)e.push(r.format('<td class="k-scheduler-groupcolumn{2}" rowspan="{0}">{1}</td>',t[s].rowSpan,this._groupTemplate({value:t[s].text}),t[s].className))},render:function(e){var t,s,n=this.content.find("table").empty(),r=[];e.length>0&&(t=this.groupedResources,t.length?(r=this._createGroupConfiguration(e,t,null),this._groupsByDate=[],this._renderGroups(r,n,[]),this._groupedView._renderDates(n)):(r=this._tasks(e),n.append(this._renderTaskGroups(r,[])))),s=this._eventsList=a(r),this._angularItems(n,s),this.refreshLayout(),this.trigger("activate")},_angularItems:function(e,t){this.angular("compile",function(){var s=[],a=t.map(function(t){return s.push({dataItem:t}),e.find(".k-task["+r.attr("uid")+"="+t.uid+"]")});return{elements:a,data:s}})},_renderGroups:function(e,t,s){var a,n,r;for(a=0,n=e.length;a<n;a++)r=this._groupedView._getParents(s),r.push(e[a]),this._groupedView._getGroupsByDate(e,a,r),e[a].groups?this._renderGroups(e[a].groups,t,r):this._groupedView._renderTaskGroups(t,e[a].items,r)},_createGroupConfiguration:function(e,a,n){var o,l,u,d,c,h,p,g=a[0],f=[],m=g.dataSource.view(),_=this._isMobilePhoneView();for(o=0;o<m.length;o++)l=s(g,m[o]),u=new r.data.Query(e).filter({field:g.field,operator:i.SchedulerView.groupEqFilter(l)}).toArray(),u.length&&(d=this._tasks(u),c=n?"":" k-first",o===m.length-1&&(!n||n.className.indexOf("k-last")>-1)&&(c+=" k-last"),h={text:r.getter(g.dataTextField)(m[o]),value:l,rowSpan:0,className:c},a.length>1?(h.groups=this._createGroupConfiguration(u,a.slice(1),h),n&&(n.rowSpan+=h.rowSpan)):(h.items=d,p=t(h.items),_&&(p+=h.items.length),h.rowSpan=p,n&&(n.rowSpan+=p)),f.push(h));return f},selectionByElement:function(t){var s,a,n;if(t=e(t),!t.hasClass("k-scheduler-datecolumn")&&this._eventsList.length)return t.is(".k-task")&&(t=t.closest("td")),this._isMobile()?(n=t.parent(),s=n.parent().children().filter(function(){return e(this).children(":not(.k-scheduler-datecolumn)").length}).index(n)):s=t.parent().index(),a=this._eventsList[s],{index:s,start:a.start,end:a.end,isAllDay:a.isAllDay,uid:a.uid}},select:function(e){this.clearSelection();var t=this.table.find(".k-task").eq(e.index).closest("tr").addClass("k-state-selected").attr("aria-selected",!0)[0];this.current(t)},move:function(e,t){var s,a=!1,n=e.index;return t==r.keys.UP?(n--,a=!0):t==r.keys.DOWN&&(n++,a=!0),a&&(s=this._eventsList[n],s&&(e.start=s.start,e.end=s.end,e.isAllDay=s.isAllDay,e.events=[s.uid],e.index=n)),a},moveToEvent:function(){return!1},constrainSelection:function(e){var t=this._eventsList[0];t&&(e.start=t.start,e.end=t.end,e.isAllDay=t.isAllDay,e.events=[t.uid],e.index=0)},isInRange:function(){return!0},destroy:function(){this.element&&this.element.off(o),i.SchedulerView.fn.destroy.call(this)},options:{title:"Agenda",name:"agenda",editable:!0,selectedDateFormat:"{0:D}-{1:D}",selectedShortDateFormat:"{0:d} - {1:d}",eventTemplate:"#:title#",eventTimeTemplate:"#if(data.isAllDay) {##=this.options.messages.allDay##} else { ##=kendo.format(format, start, end)## } #",eventDateTemplate:'<strong class="k-scheduler-agendaday">#=kendo.toString(date, "dd")#</strong><em class="k-scheduler-agendaweek">#=kendo.toString(date,"dddd")#</em><span class="k-scheduler-agendadate">#=kendo.toString(date, "y")#</span>',eventGroupTemplate:'<strong class="k-scheduler-adgendagroup">#=value#</strong>',messages:{event:"Event",date:"Date",time:"Time",allDay:"all day"}}})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t,s){(s||t)()});
//# sourceMappingURL=kendo.scheduler.agendaview.min.js.map
