/* * Kendo UI Beta v2013.2.716 (http://kendoui.com) * Copyright 2013 Telerik AD. All rights reserved. * * Kendo UI Beta license terms available at * http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx */ ("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.scheduler.view.min"],function(){!function(e){function t(e){var t,a,s=0;for(t=0,a=e.length;a>t;t++)s+=e[t].items.length;return s}function a(e,t){return e.valuePrimitive&&(t=r.getter(e.dataValueField)(t)),t}function s(e){for(var t,a=0,s=e.length,r=[];s>a;a++)t=e[a],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),a=t.shift(),s=[],n=[].push;a;)a.groups?n.apply(t,a.groups):a.items?n.apply(t,a.items):n.call(s,a),a=t.shift();return s}var r=window.kendo,i=r.ui,o=".kendoAgendaView",l=e.extend;i.AgendaView=i.SchedulerView.extend({init:function(e,t){i.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=r.template(t.eventTemplate),this._dateTemplate=r.template(t.eventDateTemplate),this._groupTemplate=r.template(t.eventGroupTemplate),this._timeTemplate=r.template(t.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(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(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,a=[{text:this.options.messages.date,className:"k-scheduler-datecolumn"},{text:this.options.messages.time,className:"k-scheduler-timecolumn"},{text:this.options.messages.event}],s=this.groupedResources;if(s.length){for(e=[],t=0;t1)for(o.end=r.date.nextDay(s),o.head=!0,d=1;i>d;d++)s=o.end,o=l({},a),o.start=s,o.startDate=r.date.getDate(s),o.end=r.date.nextDay(s),d==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),o.end.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 a,s,n,i,o,d,u,c,h=[];for(a=0;a{1}',t[c].rowSpan,this._groupTemplate({value:t[c].text}),t[c].className));0===o&&u.push(r.format('{1}',n.length,this._dateTemplate({date:s}),a!=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),u.push(r.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))),h.push("':">")+u.join("")+"")}return h.join("")},render:function(e){var t,a=this.content.find("table").empty(),n=[];e.length>0&&(t=this.groupedResources,t.length?(n=this._createGroupConfiguration(e,t,null),this._renderGroups(n,a,[])):(n=this._tasks(e),a.append(this._renderTaskGroups(n,[])))),this._eventsList=s(n),this.refreshLayout(),this.trigger("activate")},_renderGroups:function(e,t,a){var s,n,r;for(s=0,n=e.length;n>s;s++)r=a.splice(0),r.push(e[s]),e[s].groups?this._renderGroups(e[s].groups,t,r):t.append(this._renderTaskGroups(e[s].items,r))},_createGroupConfiguration:function(e,s,n){var o,l,d,u,c,h,p,m=s[0],g=[],f=m.dataSource.view();for(o=0;o-1)&&(c+=" k-last"),h={text:r.getter(m.dataTextField)(f[o]),value:l,rowSpan:0,className:c},s.length>1?(h.groups=this._createGroupConfiguration(d,s.slice(1),h),n&&(n.rowSpan+=h.rowSpan)):(h.items=u,p=t(h.items),h.rowSpan=p,n&&(n.rowSpan+=p)),g.push(h));return g},selectionByElement:function(t){var a,s;return t=e(t),t.hasClass("k-scheduler-datecolumn")?void 0:(a=t.parent().index(),s=this._eventsList[a],s.index=a,s)},select:function(e){this.clearSelection();var t=this.table.find(".k-task").eq(e.index).closest("tr").addClass("k-state-selected")[0];t&&this._scrollTo(t,this.content[0])},move:function(e,t){var a,s=!1,n=e.index;return t==r.keys.UP?(n--,s=!0):t==r.keys.DOWN&&(n++,s=!0),s&&(a=this._eventsList[n],a&&(e.start=a.start,e.end=a.end,e.isAllDay=a.isAllDay,e.events=[a.uid],e.index=n)),s},moveSelectionToPeriod: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",selectedDateFormat:"{0:D}-{1:D}",eventTemplate:'
# if (resources[0]) {## } ## if (data.id && data.recurrenceId) { ## } else if (data.recurrenceRule || data.recurrenceId) {## } ##:title#
',eventTimeTemplate:"#if(data.isAllDay) {#all day#} else { ##=kendo.format(format, start, end)## } #",eventDateTemplate:'#=kendo.toString(date, "dd")##=kendo.toString(date,"dddd")##=kendo.toString(date, "y")#',eventGroupTemplate:'#=value#',messages:{event:"Event",date:"Date",time:"Time"}}})}(window.kendo.jQuery)});