kendo.scheduler.monthview.min.js 18.4 KB
/** 
 * Kendo UI v2016.1.112 (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(t,define){define("kendo.scheduler.monthview.min",["kendo.scheduler.view.min"],t)}(function(){return function(t){function e(t,e){return t.slice(e).concat(t.slice(0,e))}function n(t,e){for(var n=e.firstDay,s=new Date(t.getFullYear(),t.getMonth(),0,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds());s.getDay()!=n;)i.date.setTime(s,-1*h);return s}function s(t,e,n){var s,i=e,o=n;return s=t,s>=i&&o>=s}var i=window.kendo,o=i.ui,r=o.SchedulerView,a=".kendoMonthView",l=t.extend,d=i.date.getDate,h=i.date.MS_PER_DAY,u=6,c=7,f=i.template('<span class="k-link k-nav-day">#:kendo.toString(date, "dd")#</span>'),p='<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#=inverseColor ? " k-event-inverse" : ""#"#} else {#class="k-event"#}#><span class="k-event-actions"># if(data.tail || data.middle) {#<span class="k-icon k-i-arrow-w"></span>#}## if(data.isException()) {#<span class="k-icon k-i-exception"></span># } else if(data.isRecurring()) {#<span class="k-icon k-i-refresh"></span>#}#</span>{0}<span class="k-event-actions">#if (showDelete) {#<a href="\\#" class="k-link k-event-delete"><span class="k-icon k-si-close"></span></a>#}## if(data.head || data.middle) {#<span class="k-icon k-i-arrow-e"></span>#}#</span># if(resizable && !data.tail && !data.middle) {#<span class="k-resize-handle k-resize-w"></span>#}## if(resizable && !data.head && !data.middle) {#<span class="k-resize-handle k-resize-e"></span>#}#</div>',v=i.template('<div title="#=title.replace(/"/g,"&\\#34;")#"><div class="k-event-template">#:title#</div></div>'),g=i.template('<div style="width:#=width#px;left:#=left#px;top:#=top#px" class="k-more-events k-button"><span>...</span></div>');o.MonthView=r.extend({init:function(t,e){var n=this;r.fn.init.call(n,t,e),n.title=n.options.title,n._templates(),n._editable(),n._renderLayout(n.options.date),n._groups()},name:"month",_updateDirection:function(t,e,n,s,i){var o,r,a,l,d;n&&(o=e[0].start,r=e[e.length-1].end,a=o.index===r.index,l=o.collectionIndex===r.collectionIndex,d=i?a&&l||l:a&&l,d&&(t.backward=s))},_changeViewPeriod:function(t,e,n){var s=n?7:1;return e&&(s*=-1),t.start=i.date.addDays(t.start,s),t.end=i.date.addDays(t.end,s),(!n||n&&this._isVerticallyGrouped())&&(t.groupIndex=e?this.groups.length-1:0),t.events=[],!0},_continuousSlot:function(t,e,n){var s=t.backward?0:e.length-1,i=this.groups[t.groupIndex];return i.continuousSlot(e[s].start,n)},_changeGroupContinuously:function(t,e,n,s){var i,o,r,a;return n||(i=t.groupIndex,o=this.groups.length-1,r=this._isVerticallyGrouped(),a=this.groups[i],!e&&r?(e=a[s?"lastSlot":"firstSlot"](),i+=s?-1:1):e&&!r&&(i=s?o:0),(0>i||i>o)&&(i=s?o:0,e=null),t.groupIndex=i),e},_normalizeHorizontalSelection:function(t,e,n){var s;return s=n?e[0].start:e[e.length-1].end},_normalizeVerticalSelection:function(t,e){var n;return n=t.backward?e[0].start:e[e.length-1].end},_templates:function(){var t=this.options,e=l({},i.Template,t.templateSettings);this.eventTemplate=this._eventTmpl(t.eventTemplate,p),this.dayTemplate=i.template(t.dayTemplate,e),this.groupHeaderTemplate=i.template(t.groupHeaderTemplate,e)},dateForTitle:function(){return i.format(this.options.selectedDateFormat,this._firstDayOfMonth,this._lastDayOfMonth)},shortDateForTitle:function(){return i.format(this.options.selectedShortDateFormat,this._firstDayOfMonth,this._lastDayOfMonth)},nextDate:function(){return i.date.nextDay(this._lastDayOfMonth)},previousDate:function(){return i.date.previousDay(this._firstDayOfMonth)},startDate:function(){return this._startDate},endDate:function(){return this._endDate},_renderLayout:function(e){var s=this;this._firstDayOfMonth=i.date.firstDayOfMonth(e),this._lastDayOfMonth=i.date.lastDayOfMonth(e),this._startDate=n(e,this.calendarInfo()),this.createLayout(this._layout()),this._content(),this.refreshLayout(),this.content.on("click"+a,".k-nav-day,.k-more-events",function(e){var n=t(e.currentTarget).offset(),i=s._slotByPosition(n.left,n.top);e.preventDefault(),s.trigger("navigate",{view:"day",date:i.startDate()})})},_editable:function(){this.options.editable&&!this._isMobilePhoneView()&&(this._isMobile()?this._touchEditable():this._mouseEditable())},_mouseEditable:function(){var e=this;e.element.on("click"+a,".k-scheduler-monthview .k-event a:has(.k-si-close)",function(n){e.trigger("remove",{uid:t(this).closest(".k-event").attr(i.attr("uid"))}),n.preventDefault()}),e.options.editable.create!==!1&&e.element.on("dblclick"+a,".k-scheduler-monthview .k-scheduler-content td",function(n){var s,i=t(n.currentTarget).offset(),o=e._slotByPosition(i.left,i.top);o&&(s=e._resourceBySlot(o),e.trigger("add",{eventInfo:l({isAllDay:!0,start:o.startDate(),end:o.startDate()},s)})),n.preventDefault()}),e.options.editable.update!==!1&&e.element.on("dblclick"+a,".k-scheduler-monthview .k-event",function(n){e.trigger("edit",{uid:t(this).closest(".k-event").attr(i.attr("uid"))}),n.preventDefault()})},_touchEditable:function(){var e=this,n=0;i.support.mobileOS.android&&(n=5),e.options.editable.create!==!1&&(e._addUserEvents=new i.UserEvents(e.element,{threshold:n,filter:".k-scheduler-monthview .k-scheduler-content td",tap:function(n){var s,i=t(n.target).offset(),o=e._slotByPosition(i.left,i.top);o&&(s=e._resourceBySlot(o),e.trigger("add",{eventInfo:l({isAllDay:!0,start:o.startDate(),end:o.startDate()},s)})),n.preventDefault()}})),e.options.editable.update!==!1&&(e._editUserEvents=new i.UserEvents(e.element,{threshold:n,filter:".k-scheduler-monthview .k-event",tap:function(n){0===t(n.event.target).closest("a:has(.k-si-close)").length&&(e.trigger("edit",{uid:t(n.target).closest(".k-event").attr(i.attr("uid"))}),n.preventDefault())}}))},selectionByElement:function(e){var n=t(e).offset();return this._slotByPosition(n.left,n.top)},_columnCountForLevel:function(t){var e=this.columnLevels[t];return e?e.length:0},_rowCountForLevel:function(t){var e=this.rowLevels[t];return e?e.length:0},_content:function(){var t,e="<tbody>",n=1,s=this.groupedResources;for(s.length&&this._isVerticallyGrouped()&&(n=this._rowCountForLevel(s.length-1)),t=0;n>t;t++)e+=this._createCalendar(t);e+="</tbody>",this.content.find("table").html(e)},_createCalendar:function(t){var e,n,s,o,r=this.startDate(),a=c*u,l=c,d=[r],h="",f=1,p=this._isVerticallyGrouped(),v=this.groupedResources;for(v.length&&(p||(f=this._columnCountForLevel(v.length-1))),this._slotIndices={},e=0,n=a/l;n>e;e++){for(h+="<tr>",d.push(r),s=e*l,o=0;f>o;o++)h+=this._createRow(r,s,l,p?t:o);r=i.date.addDays(r,l),h+="</tr>"}return this._weekStartDates=d,this._endDate=i.date.previousDay(r),h},_createRow:function(t,e,n,s){var o,r=this,a=r._firstDayOfMonth,l=r._lastDayOfMonth,h=r.dayTemplate,u="",c="",f=function(){return r._resourceBySlot({groupIndex:s})};for(o=0;n>o;o++)u="",i.date.isToday(t)&&(u+="k-today"),i.date.isInDateRange(t,a,l)||(u+=" k-other-month"),c+="<td ",""!==u&&(c+='class="'+u+'"'),c+=">",c+=h({date:t,resources:f}),c+="</td>",r._slotIndices[d(t).getTime()]=e+o,t=i.date.nextDay(t);return c},_layout:function(){var n,s,i,o=this.calendarInfo(),r=this._isMobile()?o.days.namesShort:o.days.names,a=e(r,o.firstDay),l=t.map(a,function(t){return{text:t}}),d=this.groupedResources;if(d.length)if(this._isVerticallyGrouped()){for(s=[],i=0;6>i;i++)s.push({text:"<div>&nbsp;</div>",className:"k-hidden k-slot-cell"});n=this._createRowsLayout(d,s,this.groupHeaderTemplate)}else l=this._createColumnsLayout(d,l,this.groupHeaderTemplate);return{columns:l,rows:n}},_createEventElement:function(e){var n,s=this.options,o=s.editable,r=this._isMobile();return e.showDelete=o&&o.destroy!==!1&&!r,e.resizable=o&&o.resize!==!1&&!r,e.ns=i.ns,e.resources=this.eventResources(e),e.inverseColor=e.resources&&e.resources[0]?this._shouldInverseResourceColor(e.resources[0]):!1,n=t(this.eventTemplate(e)),this.angular("compile",function(){return{elements:n,data:[{dataItem:e}]}}),n},_isInDateSlot:function(t){var e=this.groups[0],n=e.firstSlot().start,o=e.lastSlot().end-1,r=i.date.toUtcTime(t.start),a=i.date.toUtcTime(t.end);return(s(r,n,o)||s(a,n,o)||s(n,r,a)||s(o,r,a))&&(!s(a,n,n)||s(a,r,r)||t.isAllDay)},_slotIndex:function(t){return this._slotIndices[d(t).getTime()]},_positionMobileEvent:function(e,n,s){var o,a,l,d,h,u,c,f=e.start;e.start.offsetLeft>e.end.offsetLeft&&(f=e.end),o=e.start.index,a=o,l=3,d=r.collidingEvents(e.events(),o,a),d.push({element:n,start:o,end:a}),h=r.createRows(d),u=e.collection.at(o),c=u.container,c||(c=t(i.format('<div class="k-events-container" style="top:{0};left:{1};width:{2}"/>',f.offsetTop+f.firstChildTop+f.firstChildHeight-3+"px",f.offsetLeft+"px",f.offsetWidth+"px")),u.container=c,this.content[0].appendChild(c[0])),l>=h.length&&(e.addEvent({element:n,start:o,end:a,groupIndex:f.groupIndex}),s._continuousEvents.push({element:n,uid:n.attr(i.attr("uid")),start:e.start,end:e.end}),c[0].appendChild(n[0]))},_positionEvent:function(e,n,s){var o,a,l,d,h,u,c,f,p,v,_,m,y,k,D,w=this.options.eventHeight,b=e.start;for(e.start.offsetLeft>e.end.offsetLeft&&(b=e.end),o=e.start.index,a=e.end.index,l=b.eventCount,d=r.collidingEvents(e.events(),o,a),h=o!==a?5:4,d.push({element:n,start:o,end:a}),u=r.createRows(d),c=0,f=Math.min(u.length,l);f>c;c++)for(p=u[c].events,v=b.offsetTop+b.firstChildHeight+c*w+3*c+"px",_=0,m=p.length;m>_;_++)p[_].element[0].style.top=v;if(u.length>l)for(y=o;a>=y;y++){if(k=e.collection,D=k.at(y),D.more)return;D.more=t(g({ns:i.ns,start:y,end:y,width:D.clientWidth-2,left:D.offsetLeft+2,top:D.offsetTop+D.firstChildHeight+l*w+3*l})),this.content[0].appendChild(D.more[0])}else e.addEvent({element:n,start:o,end:a,groupIndex:b.groupIndex}),n[0].style.width=e.innerWidth()-h+"px",n[0].style.left=b.offsetLeft+2+"px",n[0].style.height=w+"px",s._continuousEvents.push({element:n,uid:n.attr(i.attr("uid")),start:e.start,end:e.end}),n.appendTo(this.content)},_slotByPosition:function(t,e){var n,s,i=this.content.offset();for(t-=i.left,e-=i.top,e+=this.content[0].scrollTop,t+=this.content[0].scrollLeft,t=Math.ceil(t),e=Math.ceil(e),n=0;this.groups.length>n;n++)if(s=this.groups[n].daySlotByPosition(t,e))return s;return null},_createResizeHint:function(t){var e=t.startSlot().offsetLeft,n=t.start.offsetTop,s=t.innerWidth(),i=t.start.clientHeight-2,o=r.fn._createResizeHint.call(this,e,n,s,i);o.appendTo(this.content),this._resizeHint=this._resizeHint.add(o)},_updateResizeHint:function(t,e,n,s){var o,r,a;for(this._removeResizeHint(),o=this.groups[e],r=o.ranges(n,s,!0,t.isAllDay),a=0;r.length>a;a++)this._createResizeHint(r[a]);this._resizeHint.find(".k-label-top,.k-label-bottom").text(""),this._resizeHint.first().addClass("k-first").find(".k-label-top").text(i.toString(i.timezone.toLocalDate(n),"M/dd")),this._resizeHint.last().addClass("k-last").find(".k-label-bottom").text(i.toString(i.timezone.toLocalDate(s),"M/dd"))},_updateMoveHint:function(t,e,n){var s,o,r,a,l,d=i.date.toUtcTime(t.start)+n,h=d+t.duration(),u=this.groups[e],c=u.ranges(d,h,!0,t.isAllDay);for(this._removeMoveHint(),s=0;c.length>s;s++)o=c[s],r=o.startSlot(),a=o.endSlot(),l=this._createEventElement(t.clone({head:o.head,tail:o.tail})),l.css({left:r.offsetLeft+2,top:r.offsetTop+r.firstChildHeight,height:this.options.eventHeight,width:o.innerWidth()-(r.index!==a.index?5:4)}),l.addClass("k-event-drag-hint"),l.appendTo(this.content),this._moveHint=this._moveHint.add(l)},_groups:function(){var t,e,n,s,o,r,a,l,d,h,f,p,v,g,_,m,y,k,D,w=this._groupCount(),b=c,x=u;for(this.groups=[],t=0;w>t;t++)this._addResourceView(t);for(e=this.content[0].getElementsByTagName("tr"),n=this.startDate(),s=0;w>s;s++)for(o=0,r=0,this._isVerticallyGrouped()&&(r=s),a=r*x;(r+1)*x>a;a++)for(l=this.groups[s],d=l.addDaySlotCollection(i.date.addDays(n,o),i.date.addDays(this.startDate(),o+b)),h=e[a],f=h.children,p=0,h.setAttribute("role","row"),this._isVerticallyGrouped()||(p=s),v=p*b;(p+1)*b>v;v++)g=f[v],_=g.clientHeight,m=g.children.length?g.children[0].offsetHeight+3:0,y=i.date.addDays(n,o),k=i.date.MS_PER_DAY,n.getHours()!==y.getHours()&&(k+=(n.getHours()-y.getHours())*i.date.MS_PER_HOUR),y=i.date.toUtcTime(y),k+=y,o++,D=Math.floor((_-m-this.options.moreButtonHeight)/(this.options.eventHeight+3)),g.setAttribute("role","gridcell"),g.setAttribute("aria-selected",!1),d.addDaySlot(g,y,k,D)},render:function(t){this.content.children(".k-event,.k-more-events,.k-events-container").remove(),this._groups(),t=new i.data.Query(t).sort([{field:"start",dir:"asc"},{field:"end",dir:"desc"}]).toArray();var e=this.groupedResources;e.length?this._renderGroups(t,e,0,1):this._renderEvents(t,0),this.refreshLayout(),this.trigger("activate")},_renderEvents:function(t,e){var n,s,i,o,r,a,l,d,h,u,c,f=this._isMobilePhoneView();for(s=0,i=t.length;i>s;s++)if(n=t[s],this._isInDateSlot(n))for(o=this.groups[e],o._continuousEvents||(o._continuousEvents=[]),r=o.slotRanges(n,!0),a=r.length,l=0;a>l;l++)d=r[l],h=n.start,u=n.end,a>1&&(0===l?u=d.end.endDate():l==a-1?h=d.start.startDate():(h=d.start.startDate(),u=d.end.endDate())),c=n.clone({start:h,end:u,head:d.head,tail:d.tail}),f?this._positionMobileEvent(d,this._createEventElement(c),o):this._positionEvent(d,this._createEventElement(c),o)},_renderGroups:function(t,e,n,s){var o,a,l,d,h=e[0];if(h)for(o=h.dataSource.view(),a=0;o.length>a;a++)l=this._resourceValue(h,o[a]),d=new i.data.Query(t).filter({field:h.field,operator:r.groupEqFilter(l)}).toArray(),e.length>1?n=this._renderGroups(d,e.slice(1),n++,s+1):this._renderEvents(d,n++);return n},_groupCount:function(){var t=this.groupedResources;return t.length?this._isVerticallyGrouped()?this._rowCountForLevel(t.length-1):this._columnCountForLevel(t.length)/this._columnOffsetForResource(t.length):1},_columnOffsetForResource:function(t){return this._columnCountForLevel(t)/this._columnCountForLevel(t-1)},destroy:function(){this.table&&this.table.removeClass("k-scheduler-monthview"),this.content&&this.content.off(a),this.element&&this.element.off(a),r.fn.destroy.call(this),this._isMobile()&&!this._isMobilePhoneView()&&this.options.editable&&(this.options.editable.create!==!1&&this._addUserEvents.destroy(),this.options.editable.update!==!1&&this._editUserEvents.destroy())},events:["remove","add","edit","navigate"],options:{title:"Month",name:"month",eventHeight:25,moreButtonHeight:13,editable:!0,selectedDateFormat:"{0:y}",selectedShortDateFormat:"{0:y}",groupHeaderTemplate:"#=text#",dayTemplate:f,eventTemplate:v}})}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(t,e,n){(n||e)()});
//# sourceMappingURL=kendo.scheduler.monthview.min.js.map