/* * 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(t,e){return e()})(["./kendo.scheduler.view.min"],function(){!function(t){function e(t,e){return t.valuePrimitive&&(e=c.getter(t.dataValueField)(e)),e}function n(){return c.culture().calendars.standard}function s(t){for(var e=n(),s=e.firstDay,i=new Date(t.getFullYear(),t.getMonth(),0,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds());i.getDay()!=s;)c.date.setTime(i,-1*x);return i}function i(t,e,n){var s,i=e.getTime(),o=n.getTime();return s=t.getTime(),s>=i&&o>=s}function o(e,n,s){return n&&n.length?(n=n[n.length-1],e=t.map(e,function(t){return t.groupIndex==s&&t.element.attr(c.attr("uid"))}),t.inArray(n,e)):a(e,s)}function a(t,e){for(var n=0,s=t.length;s>n;n++)if(t[n].groupIndex==e)return n-1;return-1}function r(t,e,n,s){return 0===t%I?0===e?(s=c.date.addDays(s,-1),e=n-1):(s=c.date.addDays(s,6),e--):s=c.date.addDays(s,-1),{date:s,groupIndex:e}}function d(t,e,n,s){return 0===t?0===e?(s=c.date.addDays(s,-1),e=n-1):(s=c.date.addDays(s,k*I-1),e--):s=c.date.addDays(s,-1),{date:s,groupIndex:e}}function l(t,e,n,s){return 0===(t+1)%I?e==n-1?(s=c.date.addDays(s,1),e=0):(s=c.date.addDays(s,-6),e++):s=c.date.addDays(s,1),{date:s,groupIndex:e}}function h(t,e,n,s){return t==k*I-1?e==n-1?(e=0,s=c.date.addDays(s,1)):(s=c.date.addDays(s,-(k*I-1)),e++):s=c.date.addDays(s,1),{date:s,groupIndex:e}}function u(t,e,n,s){return k>=t?0===e?(s=c.date.addDays(s,-7),e=n-1):(s=c.date.addDays(s,k*I-k-1),e--):s=c.date.addDays(s,-7),{date:s,groupIndex:e}}function f(t,e,n,s){return t>=k*I-I?e==n-1?(s=c.date.addDays(s,7),e=0):(s=c.date.addDays(s,-(k*I-I)),e++):s=c.date.addDays(s,7),{date:s,groupIndex:e}}var c=window.kendo,p=c.ui,g=c.keys,v=p.SchedulerView,_=".kendoMonthView",m=t.extend,y=t.proxy,D=c.date.getDate,x=c.date.MS_PER_DAY,k=6,I=7,w=c.template('#=kendo.toString(date, "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 && !data.tail && !data.middle) {##}## if(resizable && !data.head && !data.middle) {##}#
',b=c.template('
#:title#
'),S=c.template('
...
');p.MonthView=v.extend({init:function(t,e){var n=this;v.fn.init.call(n,t,e),n.title=n.name=n.options.title,n._templates(),n._editable(),n._renderLayout(n.options.date),n._slots()},select:function(t){var e=this;e.clearSelection(),e._selectEvents(t.events)||e._selectSlots(e._applyOffset(e._slotIndex(t.start),t.groupIndex),e._applyOffset(e._slotIndex(t.end),t.groupIndex),e._row.slots,t.groupIndex||0)},_selectEvents:function(t){var e,n=!1,s=c.attr("uid");return t[0]?(e=this.table.find("["+s+"="+t.join("],["+s+"=")+"]"),e.length>0&&(n=!0,e.addClass("k-state-selected"),this._scrollTo(e.last()[0],this.content[0])),n):n},_selectSlots:function(e,n,s,i){var o=e;for(e>n&&(e=n,n=o),o=e;n>=o;o++)i===s[o].groupIndex&&t(s[o].element).addClass("k-state-selected");s[n]&&this._scrollTo(s[n].element,this.content[0])},clearSelection:function(){this.table.find(".k-state-selected").removeClass("k-state-selected")},move:function(t,e,n){var s=!1,i=t.end,o=!0,a={date:i,groupIndex:t.groupIndex||0},p=!n&&this.groupedResources.length,v=this._isVerticallyGrouped(),_=this._groupCount(),m=this._slotIndex(i);return e==g.LEFT?(p?a=v?d(m,t.groupIndex,_,i):r(m,t.groupIndex,_,i):a.date=c.date.addDays(i,-1),s=!0):e==g.RIGHT?(p?a=v?h(m,t.groupIndex,_,i):l(m,t.groupIndex,_,i):a.date=c.date.addDays(i,1),s=!0):e==g.DOWN?(p&&v?a=f(m,t.groupIndex,_,i):a.date=c.date.addDays(i,7),s=!0):e==g.UP&&(p&&v?a=u(m,t.groupIndex,_,i):a.date=c.date.addDays(i,-7),s=!0),i=a.date,n&&(o=this._isInDateSlot({start:i,end:i})),s&&o&&(n||(t.start=i),t.groupIndex=a.groupIndex,t.end=i,t.events=[]),s},moveToEvent:function(t,e){var n,s=this,i=e?-1:1,a=t.groupIndex||0,r=s._applyOffset(s._slotIndex(t.start),a),d=s._row.events,l=o(d,t.events,a),h=this.groupedResources.length,u=s._row.slots,f=d.length;if(e)if(0>l||h&&0===this._removeOffset(l,a))for(l=h?l+1:0;f>l&&d[l].start-1;l--){if(d[l].groupIndexl;l++){if(d[l].groupIndex>a){n=d[l];break}if(d[l].start>=r&&d[l].element.attr(c.attr("uid"))!=t.events[0]){n=d[l];break}}return n&&(t.events=[n.element.attr(c.attr("uid"))],t.start=u[n.start].start,t.end=u[n.end].end,t.groupIndex=this._groupIndex(n.start)),n},moveSelectionToPeriod:function(t){var e=new Date(t.start),n=this._lastDayOfMonth,s=n.getMonth();e.setFullYear(n.getFullYear(),s),e.getMonth()!=s&&(e=new Date(n)),t.start=t.end=e},_templates:function(){var t=this.options,e=m({},c.Template,t.templateSettings);this.eventTemplate=this._eventTmpl(t.eventTemplate),this.dayTemplate=c.template(t.dayTemplate,e)},dateForTitle:function(){return c.format(this.options.selectedDateFormat,this._firstDayOfMonth,this._lastDayOfMonth)},nextDate:function(){return c.date.nextDay(this._lastDayOfMonth)},previousDate:function(){return c.date.previousDay(this._firstDayOfMonth)},startDate:function(){return this._startDate},endDate:function(){return this._endDate},_renderLayout:function(e){var n=this;this._firstDayOfMonth=c.date.firstDayOfMonth(e),this._lastDayOfMonth=c.date.lastDayOfMonth(e),this._startDate=s(e),this.createLayout(this._layout()),this.table.addClass("k-scheduler-monthview"),this._content(),this.refreshLayout(),this.content.on("click"+_,".k-nav-day,.k-more-events",function(e){var s=t(e.currentTarget).offset(),i=n._slotByPosition(s.left,s.top);e.preventDefault(),n.trigger("navigate",{view:"day",date:i.start})})},_editable:function(){this.options.editable&&(c.support.mobileOS?this._touchEditable():this._mouseEditable())},_mouseEditable:function(){var e=this;e.element.on("click"+_,".k-scheduler-monthview .k-event a:has(.k-si-close)",function(n){e.trigger("remove",{uid:t(this).closest(".k-event").attr(c.attr("uid"))}),n.preventDefault()}),e.options.editable.create!==!1&&e.element.on("dblclick"+_,".k-scheduler-monthview .k-scheduler-content td",function(n){var s=t(n.currentTarget).offset(),i=e._slotByPosition(s.left,s.top),o=e._resourceBySlot(i);e.trigger("add",{eventInfo:m({isAllDay:!0,start:i.start,end:i.end},o)}),n.preventDefault()}),e.options.editable.update!==!1&&e.element.on("dblclick"+_,".k-scheduler-monthview .k-event",function(n){e.trigger("edit",{uid:t(this).closest(".k-event").attr(c.attr("uid"))}),n.preventDefault()})},_touchEditable:function(){var e=this;e._closeUserEvents=new c.UserEvents(e.element,{filter:".k-scheduler-monthview .k-event a:has(.k-si-close)",tap:function(n){e.trigger("remove",{uid:t(n.target).closest(".k-event").attr(c.attr("uid"))}),n.preventDefault()}}),e.options.editable.create!==!1&&(e._addUserEvents=new c.UserEvents(e.element,{filter:".k-scheduler-monthview .k-scheduler-content td",tap:function(n){var s=t(n.target).offset(),i=e._slotByPosition(s.left,s.top),o=e._resourceBySlot(i);e.trigger("add",{eventInfo:m({isAllDay:!0,start:i.start,end:i.end},o)}),n.preventDefault()}})),e.options.editable.update!==!1&&(e._editUserEvents=new c.UserEvents(e.element,{filter:".k-scheduler-monthview .k-event.k-state-selected",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(c.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="",n=1,s=this.groupedResources;for(s.length&&this._isVerticallyGrouped()&&(n=this._rowCountForLevel(s.length-1)),t=0;n>t;t++)e+=this._createCalendar();e+="",this.content.find("table").html(e)},_createCalendar:function(){var t,e,n,s=this.startDate(),i=I*k,o=I,a=[s],r="",d=1,l=this.groupedResources;for(l.length&&(this._isVerticallyGrouped()||(d=this._columnCountForLevel(l.length-1))),this._slotIndices={},t=0;i/o>t;t++){for(r+="",a.push(s),e=t*o,n=0;d>n;n++)r+=this._createRow(s,e,o);s=c.date.addDays(s,o),r+=""}return this._weekStartDates=a,this._endDate=c.date.previousDay(s),r},_createRow:function(t,e,n){var s,i=this._firstDayOfMonth,o=this._lastDayOfMonth,a=this.dayTemplate,r="",d="";for(s=0;n>s;s++)r="",c.date.isToday(t)&&(r+="k-today"),c.date.isInDateRange(t,i,o)||(r+=" k-other-month"),d+="",d+=a({date:t}),d+="",this._slotIndices[D(t).getTime()]=e+s,t=c.date.nextDay(t);return d},_layout:function(){var e,s,i,o=n().days.names,a=t.map(o,function(t){return{text:t}}),r=this.groupedResources;if(r.length)if(this._isVerticallyGrouped()){for(s=[],i=0;6>i;i++)s.push({text:"
 
",className:"k-hidden k-slot-cell"});e=this._createRowsLayout(r,s)}else a=this._createColumnsLayout(r,a);return{columns:a,rows:e}},_eventTmpl:function(t){var e,n=this.options,s=m({},c.Template,n.templateSettings),i=s.paramName,o="",a=typeof t,r={storage:{},count:0};return"function"===a?(r.storage["tmpl"+r.count]=t,o+="#=this.tmpl"+r.count+"("+i+")#",r.count++):"string"===a&&(o+=t),e=c.template(c.format(T,o),s),r.count>0&&(e=y(e,r.storage)),e},_createEventElement:function(e){var n=this.options,s=n.editable;return e.showDelete=s&&s.destroy!==!1,e.resizable=s&&s.resize!==!1,e.ns=c.ns,e.resources=this.eventResources(e),t(this.eventTemplate(e))},_isInDateSlot:function(t){var e=this.startDate(),n=new Date(this.endDate().getTime()+x-1);return i(t.start,e,n)||i(t.end,e,n)||i(e,t.start,t.end)||i(n,t.start,t.end)},_slotIndex:function(t){return this._slotIndices[D(t).getTime()]},_calculateAllDayEventWidth:function(t,e,n){var s,i=0,o=e==n?"clientWidth":"offsetWidth";for(s=e;n>=s;s++)i+=t[s][o];return i},_positionEvent:function(e,n,s,i){var o,a,r,d,l,h,u,f,p,g=this.options.eventHeight,_=e[s],m=_.eventCount,y=v.collidingHorizontallyEvents(this._row.events,s,i),D=s!==i?5:4;for(y.push({element:n,start:s,end:i}),o=v.createRows(y),a=0,r=Math.min(o.length,m);r>a;a++)for(d=o[a].events,l=_.offsetTop+_.firstChildHeight+a*g+3*a+"px",h=0,u=d.length;u>h;h++)d[h].element[0].style.top=l;if(o.length>m)for(f=s;i>=f;f++){if(p=e[f],p.more)return;p.more=t(S({ns:c.ns,start:f,end:f,width:p.clientWidth-2,left:p.offsetLeft+2,top:p.offsetTop+p.firstChildHeight+m*g+3*m})),this.content[0].appendChild(p.more[0])}else this._row.events.push({element:n,start:s,end:i,groupIndex:this._groupIndex(s)}),n[0].style.width=this._calculateAllDayEventWidth(e,s,i)-D+"px",n[0].style.left=_.offsetLeft+2+"px",n[0].style.height=g+"px",this.content[0].appendChild(n[0])},_splitEvents:function(t){var e,n,s,o,a,r,d,l,h=[],u=this._weekStartDates;for(e=0,a=t.length;a>e;e++){for(n=m({},t[e]),r=0,d=u.length;d>r;r++)o=u[r],s=Math.ceil((n.end-n.start)/x),i(o,n.start,n.end)&&s>=1&&(D(n.start).getTime()===D(o).getTime()?s>1&&(n.tail?(n.tail=!1,n.middle=!0):s>7&&(n.head=!0)):(l=m({},n),n.tail?(n.tail=!1,l.middle=!0):l.head=!0,l.start=n.start,l.end=c.date.previousDay(o),h.push(l),n.start=o,n.head=!1,D(n.end).getTime()>D(this.endDate()).getTime()+x-1?n.middle=!0:n.tail=!0,n.end=n.end));n.end>this.endDate()&&(n.head=!0),h.push(n)}return h},_slotByPosition:function(t,e){var n,s,i,o=this.content.offset();for(t-=o.left,e-=o.top,e+=this.content[0].scrollTop,t+=this.content[0].scrollLeft,t=Math.ceil(t),e=Math.ceil(e),n=this._row.slots,s=0;s=i.offsetTop&&e<=i.offsetTop+i.clientHeight&&t>=i.offsetLeft&&tn;n++)s+=o[n].offsetWidth;return s+=o[e].clientWidth},r=a(e.index,n.index),d=e.clientHeight-2,l=v.fn._createResizeHint.call(this,s,i,r,d);l.appendTo(this.content),this._resizeHint=this._resizeHint.add(l)},_updateResizeHint:function(t,e,n){var s,i,o,a=this._row.slots,r={startSlot:e,endSlot:n},d=[r];for(s=e.index;s<=n.index;s++)i=a[s],i.groupIndex==e.groupIndex&&(i.offsetTop>r.endSlot.offsetTop?(r={startSlot:i,endSlot:i},d.push(r)):r.endSlot=i);for(this._removeResizeHint(),o=0;ou.endSlot.offsetTop?(u={startSlot:g,endSlot:g},f.push(u)):u.endSlot=g);for(this._removeMoveHint(),v=0;vt;t++)n=l[t],s=n.clientHeight,i=n.firstChild.offsetHeight+3,o=this._groupIndex(t),a=this._removeOffset(t,o),r=c.date.addDays(this.startDate(),a),d.slots.push({clientWidth:n.clientWidth,clientHeight:s,offsetWidth:n.offsetWidth,offsetTop:n.offsetTop,firstChildHeight:i,offsetLeft:n.offsetLeft,eventCount:Math.floor((s-i)/(h+3)),start:r,end:r,element:n,isAllDay:!0,index:t,groupIndex:o});this._row=d},render:function(t){this.content.children(".k-event,.k-more-events").remove(),this._slots(),t=new c.data.Query(this._splitEvents(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,a;for(s=0,i=t.length;i>s;s++)n=t[s],this._isInDateSlot(n)&&(o=this._slotIndex(n.start),a=this._slotIndex(n.end),0>o&&a>-1&&(o=a),0>o&&(o=0),(0>a||!a)&&o!==a&&(a=this._row.slots.length/this._groupCount()-1),n.startIndex=this._applyOffset(o,e),n.endIndex=this._applyOffset(a,e),0!==c.date.getMilliseconds(n.end)||n.end.getTime()==n.start.getTime()||n.isAllDay||n.head||n.middle||(n.endIndex=Math.max(n.startIndex,n.endIndex-1)),this._positionEvent(this._row.slots,this._createEventElement(n),n.startIndex,n.endIndex))},_renderGroups:function(t,n,s,i){var o,a,r,d,l=n[0];if(l)for(o=l.dataSource.view(),a=0;a1?s=this._renderGroups(d,n.slice(1),s++,i+1):this._renderEvents(d,s++);return s},_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},_removeOffset:function(t,e){var n,s,i,o,a=this.groupedResources,r=0;return a.length&&(this._isVerticallyGrouped()?r=I*k*e:(n=this._columnOffsetForResource(a.length),s=this._groupCount(),i=n*s,o=Math.floor(t/i),r=n*(s-1)*o,r+=n*e)),t-r},_applyOffset:function(t,e){var n,s,i=this.groupedResources,o=0,a=I,r=k;return i.length&&(this._isVerticallyGrouped()?o=a*r*e:(n=Math.floor(t/a),s=this._columnOffsetForResource(i.length),o=s*(this._groupCount()-1)*n,o+=s*e)),t+o},_groupIndex:function(t){var e,n,s,i,o,a=this.groupedResources;return a.length?this._isVerticallyGrouped()?Math.floor(t/(I*k)):(e=this._columnOffsetForResource(a.length),n=this._groupCount(),s=e*n,i=Math.floor(t/s),o=e*n*i,Math.floor((t-o)/e)):0},_columnOffsetForResource:function(t){return this._columnCountForLevel(t)/this._columnCountForLevel(t-1)},_resourceBySlot:function(t){var n,s,i,o,a,r,d,l,h,u,f,p,g,v=this.groupedResources,_={};if(v.length)for(n=t.index,s=this._columnOffsetForResource(v.length),this._isVerticallyGrouped()&&(s=k*I),i=s*this._groupCount(),o=0,a=v.length;a>o;o++)r=v[o],d=r.dataSource.view().length,l=i/d,h=Math.floor(n/i),u=l*d*h,f=Math.floor((n-u)/l),i/=d,p=e(r,r.dataSource.at(f)),r.multiple&&(p=[p]),g=c.setter(r.field),g(_,p);return _},destroy:function(){this.table&&this.table.removeClass("k-scheduler-monthview"),this.content&&this.content.off(_),this.element&&this.element.off(_),v.fn.destroy.call(this),c.support.mobileOS&&(this._closeUserEvents.destroy(),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,editable:!0,selectedDateFormat:"{0:y}",dayTemplate:w,eventTemplate:b}})}(window.kendo.jQuery)});