Type.registerNamespace("Telerik.Web.UI.Scheduler.Rendering");
(function(h,b){var e=b.Scheduler,k=e.Rendering,l=e.DateTime,i=Telerik.Web.StringBuilder,m=60000,c=m*60,d=c*24,f=7,j=4,g="yyyy-MM-dd";
k.WeekViewRenderer=function(n){this._model=n;
this._owner=n._owner;
this._resizableAllDays=false;
this._shouldAddAllDayWraps=true;
this._ownerElement=this._owner.get_element();
this._owner.add_propertyChanged(Function.createDelegate(this,this._onSchedulerPropertyChanged));
};
k.WeekViewRenderer.prototype={renderAppointment:function(n){var o=this._getAppointmentParts(n);
var p=this;
n._parts=o;
h.each(o,function(){p._model.addToBlocks(this);
if(this.isAllDay){p._addAllDayAppointmentPart(this,n);
}else{p._addAppointmentPart(this,n);
}});
this._recalcAppointmentsStyles();
},refreshView:function(){this._activateView();
this._updateHeaders();
this._updateColumnHeaders();
this._updateViewTabs();
this._updateFooter();
this._updateShowFullTimeStatus();
},refreshIndicatorState:function(){if(this._model._settings&&this._model._settings.hiddenAptsIndicator===false){return;
}if(!this._owner.get_showFullTime()){this._updateIndicators();
}else{this._clearIndicators();
}},_updateIndicators:function(){var v=[],t=[];
var n=this._model._getFirstDayStart();
var p=e.DateTime.add(e.DateTime.getDate(n),this._model.get_effectiveDayEndTime());
for(var o=0,r=this._model.get_numberOfDays();
o<r;
o++){var s=this._owner.get_appointments().getAppointmentsInRange(e.DateTime.getDate(n),n);
var u=s.find(function(w){return w.get_end()<=n;
})!=null;
var q=this._owner.get_appointments().getAppointmentsStartingInRange(p,(new Date(p)).setHours(24)).get_count()>0;
v[o]=u+0;
t[o]=q+0;
n=e.DateTime.add(n,d);
p=e.DateTime.add(p,d);
}this._owner._updateHiddenAppointmentsIndicator(v,"top");
this._owner._updateHiddenAppointmentsIndicator(t,"bottom");
},_clearIndicators:function(){this._owner._removeIndicatorsTable("rsTopIndicator");
this._owner._removeIndicatorsTable("rsBottomIndicator");
},_updateShowFullTimeStatus:function(){var o=h("div.rsTopWrap table.rsContentTable",this._ownerElement)[0];
var q=o.rows.length;
var p=this._model.get_effectiveDayEndTime()-this._model.get_effectiveDayStartTime();
var n=this._owner.get_minutesPerRow()*m;
var r=p/n;
if(q!=r){if(this._owner.get_showFullTime()){this.showFullTime();
}else{this.showBusinessTime();
}}},_updateFooter:function(){h("div.rsFooter",this._ownerElement).css("display","");
},_updateViewTabs:function(){if(h(".rsHeader ul .rsFirst",this._ownerElement).length==0){return;
}var q=h(".rsHeader ul li.rsSelected",this._ownerElement);
if(q.length==0){return;
}var n=h(this._getViewTabElement());
if(n.is(".rsSelected")){return;
}q.removeClass("rsSelected");
n.addClass("rsSelected");
var t=h("em",q);
var o=h("a",n);
var s=o.find("span");
var p=t[0].className;
t[0].className=o[0].className;
o[0].className=p;
var r=t.text();
t.text(s.text());
s.text(r);
q.append(o.clone());
n.append(t);
o.remove();
},_getViewTabElement:function(){return h(".rsHeader ul .rsHeaderWeek",this._ownerElement).parent()[0];
},_activateView:function(){var q=this._getContentElement();
if(h(q).parent().is(".rsTopWrap")){return;
}var n=h(this._ownerElement);
var r=n.find("div.rsHiddenViews");
var p=h("div.rsTopWrap",n);
var s=h("div.rsContent",p);
var o=h("div.rsHeader",p);
if(o.length>0){o.after(q);
}else{p.prepend(q);
}r.append(s);
},showBusinessTime:function(){var o=h("div.rsTopWrap table.rsContentTable",this._ownerElement);
var n=h("div.rsTopWrap table.rsVerticalHeaderTable",this._ownerElement);
this._removePrependedRows(o,n);
this._removeAppendedRows(o,n);
var p=this._owner.get_localization().Show24Hours;
h("div.rsFooter a.rsFullTime",this._ownerElement).text(p);
},_removeAppendedRows:function(o,n){var q=(d-this._model.get_dayEndTime())/(this._owner.get_minutesPerRow()*m);
var p=h(o[0].rows);
var r=p.length-q-1;
p.filter(":gt("+(r)+")").remove();
n.find("tr:gt("+(r)+")").remove();
},_removePrependedRows:function(o,n){var p=this._model.get_dayStartTime()/(this._owner.get_minutesPerRow()*m);
var q=h(o[0].rows);
q.filter(":lt("+(p)+")").remove();
n.find("tr:lt("+(p)+")").remove();
},showFullTime:function(){var o=h("div.rsTopWrap table.rsContentTable",this._ownerElement);
var n=h("div.rsTopWrap table.rsVerticalHeaderTable",this._ownerElement);
var q=this._owner.get_rowHeight();
var r=o[0].rows[0].cells.length;
this._addRows(o,n,q,r,true);
this._addRows(o,n,q,r);
this._refreshRowHeaders();
var p=this._owner.get_localization().ShowBusinessHours;
h("div.rsFooter a.rsFullTime",this._ownerElement).text(p);
if($telerik.isSafari){o.appendTo(o.parent());
n.appendTo(n.parent());
}},_refreshRowHeaders:function(){var n=h("div.rsTopWrap table.rsVerticalHeaderTable",this._ownerElement);
var o=this._owner.get_timeLabelRowSpan();
var p=this;
n.find("tr").each(function(r){var q=h(this);
if(r%o==0){q.find("div").html(p._getRowHeaderText(r));
}else{q.find("div").html("");
}if(r%o==o-1){q.addClass("rsAlt");
}else{q.removeClass("rsAlt");
}});
},_getRowHeaderText:function(p){var o=new Date(0);
o.setHours(0);
o.setMinutes(0);
var q=this._owner.get_minutesPerRow()*m;
var r=l.add(o,q*p);
var n=this._owner.get_hoursPanelTimeFormat().replace("tt","'<span class=\"rsAmPm\">'tt'</span>'");
return this._getFormattedDateText(r,n);
},_onSchedulerPropertyChanged:function(n,o){if(o.get_propertyName()=="timeLabelRowSpan"){this._refreshRowHeaders();
}},_getDayOfWeek:function(o){var n=this._owner.get_firstDayOfWeek()+o;
if(n>6){n-=7;
}return n;
},_getCellClass:function(o){var n=this._getDayOfWeek(o);
if(n==b.DayOfWeek.Saturday){return"rsSatCol";
}if(n==b.DayOfWeek.Sunday){return"rsSunCol";
}return"";
},_addRows:function(n,p,z,y,w){var q=0;
if(w){q=this._getNumberOfRowsToPrepend();
}else{q=this._getNumberOfRowsToAppend();
}for(var u=0;
u<q;
u++){var s=[];
s[s.length]='<tr style="height:';
s[s.length]=z;
s[s.length]='"></tr>';
var o=h(s.join(""));
var x=o.clone();
var r=[];
r[r.length]="<th><div>";
r[r.length]="</div></th>";
if(w){x.prependTo(p);
}else{x.appendTo(p);
}x.append(r.join(""));
if((w&&u%2==0)||(!w&&u%2!=0)){o.addClass("rsAlt");
}for(var v=0;
v<y;
v++){var t=[];
t[t.length]='<td class="';
t[t.length]=this._getCellClass(v);
t[t.length]='">&nbsp;</td>';
o.append(h(t.join("")));
}if(w){n.prepend(o);
}else{n.append(o);
}}},_getNumberOfRowsToAppend:function(){return(d-this._model.get_dayEndTime())/(this._owner.get_minutesPerRow()*m);
},_getNumberOfRowsToPrepend:function(){return this._model.get_dayStartTime()/(this._owner.get_minutesPerRow()*m);
},_getContentElement:function(){return h(".rsContent.rsWeekView",this._ownerElement)[0];
},_getFormatString:function(){var n=this._getHeaderDateFormat();
return"{0:"+n+"} - {1:"+n+"}";
},_getHeaderDateFormat:function(){return this._model.get_headerDateFormat();
},_getHeaderDateText:function(){var p=this._getHeaderDateFormat();
var r=this._model.get_visibleRangeStart();
var o=this._getFormattedDateText(r,p);
var n=e.DateTime.add(this._model.get_visibleRangeEnd(),-d);
var q=this._getFormattedDateText(n,p);
return String.format("{0} - {1}",o,q);
},_updateHeaders:function(){var n=this._getHeaderDateText();
h("div.rsTopWrap div.rsHeader h2",this._ownerElement).text(n);
},_updateColumnHeaders:function(){var p=this._model.get_columnHeaderDateFormat();
var n=this._model.get_visibleRangeStart();
var o=h("div.rsTopWrap table.rsHorizontalHeaderTable",this._ownerElement);
if(o.length>0){h.each(o[0].rows[0].cells,function(){h(this).html("<a class='rsDateHeader' href='#"+n.format(g)+"'>"+n.localeFormat(p)+"</a>");
n=e.DateTime.add(n,d);
});
}},_recalcAppointmentsStyles:function(){var n=this;
this._model._blockCollection.forEach(function(o){h(o.element).css({width:n._getWidthPercent(o)+"%",left:n._getLeftPercent(o)+"%"});
});
},_getVisibleDuration:function(r,q){var n=new l(r.get_startTime()).get_date().add(this._model.get_effectiveDayStartTime()).toDate();
var o=new l(r.get_startTime()).get_date().add(this._model.get_effectiveDayEndTime()).toDate();
var p=Math.max(q.get_start(),n);
var s=Math.min(q.get_end(),o);
return Math.min(s-p,q.get_duration());
},_getAppointmentElementHeight:function(o){var p=Math.ceil(o/(this._owner.get_minutesPerRow()*m));
var n=p*parseInt(this._owner.get_rowHeight());
n-=j;
return n;
},_addAppointmentPart:function(s,u){var q=s.start;
var n=s.end;
var w=this._model._getTimeSlotForAppointmentPart(s);
var r=h(w.get_domElement());
if(r.children().length==0){r.html("<div class='rsWrap'></div>");
}var o=n-q;
var v=this._buildAptStyles(u);
v.rsApt.push("width: ",this._getWidthPercent(s),"%;");
v.rsApt.push("left: ",this._getLeftPercent(s),"%;");
var t=this._getAppointmentElementHeight(o)+"px";
var p=h(this.getAppointmentHtml(u,true,t,v))[0];
s.element=p;
Array.add(u._domElements,p);
if(u.get_start()<q){this._addArrow(p,"Top");
}if(u.get_end()>n){this._removeResizeGrip(u);
this._addArrow(p,"Bottom");
}r.children(":first").append(p);
},_mapAppointmentStyles:function(n,o,p){h.each(p,function(q,s){var r=n[s];
if(r){o.push(q,": ",r,";");
}});
},_buildAptStyles:function(r){var v=this._owner.get_appointmentStyleMode();
var n=this._appointmentHasCustomColor(r);
var s=this._appointmentHasBorder(r);
var o={rsApt:[],rsAptContent:[],rsAptOut:[],rsAptIn:[],rsAptMid:[]};
var q=this._getEffectiveBackColor(r);
var p=this._getEffectiveBorderColor(r);
var t=q?["background-color:",q,";"].join(""):"";
var u=p?["border-color:",p,";"].join(""):"";
if(v==b.AppointmentStyleMode.Default||(v==b.AppointmentStyleMode.Auto&&!n)){if(u||t){o.rsAptMid.push(t,u);
o.rsAptIn.push(t,u);
o.rsAptContent.push(t,u);
}}else{o.rsApt.push(t);
}if(s&&(v==b.AppointmentStyleMode.Simple||v==b.AppointmentStyleMode.Auto)){this._mapAppointmentStyles(r,o.rsApt,{"border-top-width":"_borderWidth","border-bottom-width":"_borderWidth","border-top-style":"_borderStyle","border-bottom-style":"_borderStyle"});
o.rsApt.push("border-top-color:",p,";");
o.rsApt.push("border-bottom-color:",p,";");
this._mapAppointmentStyles(r,o.rsAptOut,{"border-left-width":"_borderWidth","border-right-width":"_borderWidth","border-left-style":"_borderStyle","border-right-style":"_borderStyle"});
o.rsAptOut.push("border-left-color:",p,";");
o.rsAptOut.push("border-right-color:",p,";");
}return o;
},_appointmentHasBorder:function(n){return this._getEffectiveBorderColor(n)||n.get_borderWidth();
},_appointmentHasBackground:function(n){return this._getEffectiveBackColor(n);
},_getEffectiveBackColor:function(o){if(o.get_backColor()){return o.get_backColor();
}var n="";
o.get_resources().forEach(function(p){var q=o.get_owner();
if(q){n=n||q.get_resourceStyles().getMatchingBackColor(p);
}});
return n;
},_getEffectiveBorderColor:function(o){if(o.get_borderColor()){return o.get_borderColor();
}var n="";
o.get_resources().forEach(function(p){var q=o.get_owner();
if(q){n=n||q.get_resourceStyles().getMatchingBorderColor(p);
}});
return n;
},_appointmentHasCustomColor:function(n){return this._appointmentHasBackground(n)||this._appointmentHasBorder(n);
},_getLeftPercent:function(n){var o=n.column;
if(!o){return 0;
}return o.get_left();
},_getWidthPercent:function(n){var o=n.column;
if(!o){return 100;
}return o.get_width();
},_addAllDayAppointmentPart:function(r,s){var q=r.start;
var n=r.end;
var t=this._model._getAllDayTimeSlotForAppointmentPart(r);
var p=this._getTargetWrapper(t,r.rowIndex);
if(!p){return;
}var o=this._createAllDayAppointmentElement(n-q,s)[0];
r.element=o;
if(!s._domElement){s._domElement=o;
}Array.add(s._domElements,o);
if(s.get_start()<this._model.get_visibleRangeStart()){this._addArrow(o,"Left");
}if(this._model.get_visibleRangeEnd()<s.get_end()){this._removeResizeGrip(s);
this._addArrow(o,"Right");
}p.append(o);
if(this._shouldAddAllDayWraps){h(t.get_domElement()).append(h(this.getWrapperHtml()));
}},_createAllDayAppointmentElement:function(q,n){var p=(Math.ceil((q/d))*100);
var o=(parseInt(this._owner._rowHeight)-j)+"px";
var r=this._buildAptStyles(n);
r.rsApt.push("width: ",p,"%;");
return h(this.getAppointmentHtml(n,this._resizableAllDays,o,r));
},_getAppointmentParts:function(n){var r=[];
var u=this._model;
var y=u._owner.get_showAllDayRow();
var v=e.DateTime.getDate(u.get_visibleRangeStart());
for(var t=0,x=u.get_numberOfDays();
t<x;
t++){var z=e.DateTime.add(v,d*t);
var w=e.DateTime.add(z,d);
if(y&&n._rangeIsInsideAppointment(z,w)){Array.add(r,{isAllDay:true,start:z,end:w,appointment:n});
}else{var s=e.DateTime.add(z,u.get_effectiveDayStartTime());
var p=e.DateTime.add(z,u.get_effectiveDayEndTime());
if(n._isInRange(s,p)){var q=new Date(Math.max(s,n.get_start()));
var o=new Date(Math.min(p,n.get_end()));
Array.add(r,{isAllDay:false,start:q,end:o,appointment:n});
}}}return this._mergeAllDayParts(r);
},_mergeAllDayParts:function(o){var n=[];
h.each(o,function(q){if(q==0){Array.add(n,this);
return;
}var p=n[n.length-1];
if(this.isAllDay&&p.isAllDay){p.end=this.end;
}else{Array.add(n,this);
}});
return n;
},_removeResizeGrip:function(n){h(n.get_element()).find("div.rsAptResize").remove();
},_getRowIndex:function(n){return n._getRowIndex();
},_addAllDayWraps:function(q,o){var n=o.children().length;
var p=(q+1)-n;
for(var r=0;
r<p;
r++){o.append(this.getWrapperHtml());
}},_getTargetWrapper:function(o,q){var n=h(o.get_domElement());
if(this._shouldAddAllDayWraps){this._addAllDayWraps(q,n);
}var p=n.children().eq(q);
if(p.length==0){return;
}p[0].style.zIndex=n[0].parentNode.cells.length-n[0].cellIndex;
return p;
},_addArrow:function(p,n){var o=h(p).find("div.rsAptIn");
o.append(String.format('<a style="z-index: 80;" href="#" class="rsArrow{0}">{1}</a>',n,n.toLowerCase()));
o.addClass(String.format("rsWArrow{0}",n));
},removeAppointment:function(p){if(!p._parts){return;
}var o=this;
var n=null;
if(p._originalParent){n=p._originalParent.parentNode;
}h.each(p._parts,function(){if(this.isAllDay&&o._shouldAddAllDayWraps){o._removeAllDayWrappers(this,n);
}if(this.element){var q=this.element.parentNode;
if(q){q.removeChild(this.element);
}}o._model.removeFromBlock(this);
});
},_removeAllDayWrappers:function(q,n){var s=n||q.element.parentNode.parentNode;
if(!s){return;
}var r=h(s);
var v=r.parent().children().index(r);
var p=q.end-q.start;
var w=Math.ceil(p/d);
var u=r.parent().children().slice(v,v+w);
var t=q.rowIndex;
var o=u.children("div:nth-child("+(t+1)+")");
o.not(":only-child").remove();
},getWrapperHtml:function(){var n=[];
n[n.length]="<div class='rsWrap' style='height:";
n[n.length]=this._owner._rowHeight;
n[n.length]="'></div>";
return n.join("");
},getAppointmentHtml:function(s,n,p,q){var r=new i().append("<div class='").append(this._getClassName(s)).append("' id='").append(this._getUniqueID());
var o=s.get_toolTip();
if(o){r.append("' title='").append(o);
}q.rsApt.push("height: ",p,";");
q.rsAptOut.push("height: ",p,";");
r.append("' style='",q.rsApt.join(""),"'>").append("<div class='rsAptOut' style='",q.rsAptOut.join(""),"'>").append("<div class='rsAptMid' style='",q.rsAptMid.join(""),"'>").append("<div class='rsAptIn' style='",q.rsAptIn.join(""),"'>").append("<div class='rsAptContent' style='",q.rsAptContent.join(""),"'>").append(this._getRecurrenceIconHtml(s)).append(s.get_subject()).append("<a href='#' class='rsAptDelete' style='visibility: hidden;'>delete</a></div></div>").append(n?"<div class='rsAptResize'></div>":"").append("</div></div></div>");
return r.toString();
},_getClassName:function(o){var p=[];
var q=this;
p.push("rsApt");
var s=o.get_cssClass();
if(s){p.push(s);
}o.get_resources().forEach(function(u){q._addUniqueClassName(p,u.get_cssClass());
var v=o.get_owner();
if(v){h.each(v.get_resourceStyles().getMatchingClasses(u),function(){q._addUniqueClassName(p,this);
});
var t=v.get_resources().getResourceByTypeAndKey(u.get_type(),u.get_key());
if(t){q._addUniqueClassName(p,t.get_cssClass());
}}});
var r=this._owner.get_appointmentStyleMode();
var n=this._appointmentHasCustomColor(o);
if(r==b.AppointmentStyleMode.Simple||(r==b.AppointmentStyleMode.Auto&&n)){p.push("rsAptSimple");
}if(r==b.AppointmentStyleMode.Default&&this._appointmentHasBackground(o)){p.push("rsAptColor");
}return p.join(" ");
},_addUniqueClassName:function(n,o){if(o&&Array.indexOf(n,o)==-1){n.push(o);
}},_getRecurrenceIconHtml:function(o){var n=o.get_recurrenceState();
if(n!=b.RecurrenceState.NotRecurring){if(n==b.RecurrenceState.Exception){return'<div class="rsAptRecurrenceException"></div>';
}else{return'<div class="rsAptRecurrence"></div>';
}}return"";
},_getUniqueID:function(){return Math.abs((new Date()).getTime()^Math.floor(Math.random()*100000000)).toString();
},_getFormattedDateText:function(r,o){var n=r.getDate();
var q=r.getMonth()+1;
var p=r.getFullYear();
if(Sys.CultureInfo.CurrentCulture&&Sys.CultureInfo.CurrentCulture.name=="en-US"){switch(o){case"dd":if(n<10){return"0"+n;
}else{return n;
}break;
case"d":return String.format("{0}/{1}/{2}",q,n,p);
break;
}}return r.localeFormat(o);
}};
k.WeekViewRenderer.registerClass("Telerik.Web.UI.Scheduler.Rendering.WeekViewRenderer");
k.DayViewRenderer=function(n){k.DayViewRenderer.initializeBase(this,[n]);
};
k.DayViewRenderer.prototype={_getHeaderDateText:function(){var n=this._model.get_visibleRangeStart();
return n.localeFormat(this._getHeaderDateFormat());
},_getContentElement:function(){return h(".rsContent.rsDayView",this._ownerElement)[0];
},_getViewTabElement:function(){return h(".rsHeader ul .rsHeaderDay",this._ownerElement).parent()[0];
},_updateColumnHeaders:function(){}};
k.DayViewRenderer.registerClass("Telerik.Web.UI.Scheduler.Rendering.DayViewRenderer",k.WeekViewRenderer);
k.TimelineViewRenderer=function(n){k.TimelineViewRenderer.initializeBase(this,[n]);
this._resizableAllDays=true;
};
k.TimelineViewRenderer.prototype={_updateFooter:function(){h("div.rsFooter",this._ownerElement).css("display","none");
},_updateShowFullTimeStatus:function(){},_recalcAppointmentsStyles:function(){},_updateIndicators:function(){},_clearIndicators:function(){},_getAppointmentParts:function(o){var n=[];
var p=this._model;
for(var s=0,r=p._getNumberOfSlots();
s<r;
s++){var q=e.DateTime.add(p.get_visibleRangeStart(),p._getSlotDuration()*s);
var t=e.DateTime.add(q,p._getSlotDuration());
if(o._isInRange(q,t)){Array.add(n,{isAllDay:true,start:q,end:t,appointment:o});
}}return this._mergeAllDayParts(n);
},_createAllDayAppointmentElement:function(q,n){var p=(Math.ceil((q/this._model._getSlotDuration()))*100)+"%";
var o=(parseInt(this._owner._rowHeight)-j)+"px";
var r=this._buildAptStyles(n);
r.rsApt.push("width: ",p,";");
return h(this.getAppointmentHtml(n,this._resizableAllDays,o,r));
},_updateColumnHeaders:function(){this._updateDateColumnHeaders(h("div.rsTopWrap table.rsHorizontalHeaderTable th",this._ownerElement));
},_updateDateColumnHeaders:function(q){var o=this._model._getSlotDuration();
var n=this._model.get_visibleRangeStart();
var r=this._model._getTimeLabelSpan();
var p=this;
q.each(function(){var s=p._getColumnHeaderText(n);
h(this).text(s);
n=new l(n).add(o*r).toDate();
});
},_getColumnHeaderText:function(n){return this._getFormattedDateText(n,this._model.get_columnHeaderDateFormat());
},_getContentElement:function(){return h(".rsContent.rsTimelineView",this._ownerElement)[0];
},_getViewTabElement:function(){return h(".rsHeader ul .rsHeaderTimeline",this._ownerElement).parent()[0];
},_getHeaderDateText:function(){var p=this._getHeaderDateFormat();
var r=this._model.get_visibleRangeStart();
var o=this._getFormattedDateText(r,p);
var n=e.DateTime.add(this._model.get_visibleRangeEnd(),-this._model._getSlotDuration());
var q=this._getFormattedDateText(n,p);
return String.format("{0} - {1}",o,q);
}};
k.TimelineViewRenderer.registerClass("Telerik.Web.UI.Scheduler.Rendering.TimelineViewRenderer",k.WeekViewRenderer);
k.MonthViewRenderer=function(n){k.MonthViewRenderer.initializeBase(this,[n]);
this._weekLength=this._model.get_weekLength();
this._shouldAddAllDayWraps=false;
this._contentElement=h(".rsContent.rsMonthView",this._ownerElement)[0];
this._contentTables=h("table tr td.rsContentWrapper table.rsContentTable",this._contentElement);
};
k.MonthViewRenderer.prototype={_updateIndicators:function(){},_clearIndicators:function(){},refreshView:function(){var q=e.DateTime.subtract(this._model.get_visibleRangeEnd(),this._model.get_visibleRangeStart());
var p=Math.ceil(q/d);
var o=Math.ceil(p/f);
var n=h("table.rsContentTable:first tr",this._getContentElement()).length;
if(n<o){this._addContentRows(o-n);
}else{if(n>o){this._removeContentRows(n-o);
}}h("div.rsShowMore",this._contentElement).removeClass("rsShowMore").html("");
k.MonthViewRenderer.callBaseMethod(this,"refreshView");
},_recalcAppointmentsStyles:function(){},_updateShowFullTimeStatus:function(){},_updateFooter:function(){h("div.rsFooter",this._ownerElement).css("display","none");
},_getTargetWrapper:function(n,o){return k.MonthViewRenderer.callBaseMethod(this,"_getTargetWrapper",[n,o+1]);
},_updateColumnHeaders:function(){var q=this;
var p=this._model.get_dayHeaderDateFormat();
var n=this._model.get_firstDayHeaderDateFormat();
var o=q._owner.get_selectedDate().getMonth();
var r=q._model.get_visibleRangeStart();
h.each(this._contentTables,function(){var t=h("td div.rsDateWrap div.rsDateBox a",this);
var v=r;
var s=0;
var u=new Date(v.getTime());
t.each(function(){var x=l.subtract(v,r)==0&&v.getMonth()==o;
var w;
if(v.getDate()==1||x){w=v.localeFormat(n);
}else{w=q._getFormattedDateText(v,p);
}this.href="#"+v.format(g);
this.innerHTML=w;
var z=o!=v.getMonth();
var y=this.parentNode.parentNode.parentNode;
h(y).toggleClass("rsOtherMonth",z);
if(s==q._weekLength-1){u=l.add(u,7*d);
v=new Date(u.getTime());
s=0;
}else{v=l.add(v,d);
s++;
}q._clearExtraWraps(y);
});
});
},_getAppointmentParts:function(o){var p=[];
var u=this._model;
var y=this._weekLength;
var z=l.subtract(u.get_visibleRangeEnd(),u.get_visibleRangeStart())/d;
var x=u.get_visibleAppointmentsPerDay();
for(var C=0,n=z/y;
C<n;
C++){var v=[];
var A=l.add(u.get_visibleRangeStart(),f*C*d);
var r=e.DateHelper.getStartOfWeek(A,this._owner.get_firstDayOfWeek(),y);
for(var t=0;
t<y;
t++){var B=l.add(r,t*d);
var w=l.add(B,d);
if(o._isInRange(B,w)){var s=this._getSlotForDay(o,B);
var q=this._getAppointmentsInDay(B,w);
if(q<=x){this._ensureWraps(s,q+1);
Array.add(v,{isAllDay:true,start:B,end:w,appointment:o});
}else{this._renderShowMore(s);
}}}v=this._mergeAllDayParts(v);
Array.addRange(p,v);
}return p;
},_getAppointmentsInDay:function(n,o){return this._owner.get_appointments().getAppointmentsInRange(n,o).findAll(function(p){return(p.get_visible());
}).get_count();
},_getSlotForDay:function(p,n){var o=p.clone();
o.set_start(n);
return this._model.getTimeSlotForAppointment(o);
},_renderShowMore:function(n){var p=h(".rsLastWrap",n.get_domElement());
var o=this._owner.get_localization().ShowMore;
if(h(".rsApt",p).length==0){p.addClass("rsShowMore").text(o);
}else{var q=h("<div class='rsLastWrap rsWrap rsShowMore'>"+o+"</div>");
p.removeClass("rsLastWrap").after(q);
}},_ensureWraps:function(q,r){var s=q.get_domElement();
var p=h("div.rsWrap",s).length;
var t=r-p;
if(t<=0){return;
}for(var n=0;
n<t;
n++){var o=h("<div class='rsWrap'></div>");
h("div.rsLastWrap",s).removeClass("rsLastWrap").after(o);
o.addClass("rsLastWrap");
}},_clearExtraWraps:function(q){var n=4;
var p=h("div.rsWrap",q).length-n;
if(p>0){for(var o=0;
o<p;
o++){h("div.rsWrap:nth(1)",q).remove();
}}},removeAppointment:function(n){var o=this._model;
h("div.rsShowMore",this._contentElement).each(function(){var p=o.getTimeSlotFromDomElement(this);
if(p&&n._isInRange(p.get_startTime(),p.get_endTime())){h(this).removeClass("rsShowMore");
this.innerHTML="";
}});
k.MonthViewRenderer.callBaseMethod(this,"removeAppointment",[n]);
},_addContentRows:function(o){for(var n=0;
n<o;
n++){h(".rsContentTable",this._getContentElement()).append(this._getMonthRowHtml());
}},_removeContentRows:function(o){for(var n=0;
n<o;
n++){h(".rsContentTable tr:last-child",this._getContentElement()).remove();
}},_getMonthRowHtml:function(){var p=[];
p[p.length]="<tr class='rsRow'>";
for(var n=0;
n<this._weekLength;
n++){p[p.length]="<td>";
for(var o=0;
o<4;
o++){p[p.length]="<div class='rsWrap";
if(o==0){p[p.length]=" rsDateWrap";
}if(o==3){p[p.length]=" rsLastWrap";
}p[p.length]="'>";
if(o==0){p[p.length]="<div class='rsDateBox'><a class='rsDateHeader' href='#'></a></div>";
}p[p.length]="</div>";
}p[p.length]="</td>";
}p[p.length]="</tr>";
return p.join("");
},_getContentElement:function(){return this._contentElement;
},_getRowIndex:function(n){return n._getRowIndex()+1;
},_getHeaderDateText:function(){var o=this._getHeaderDateFormat();
var n=this._owner.get_selectedDate();
return n.localeFormat(o);
},_getFormatString:function(){var n=this._getHeaderDateFormat();
return"{0:"+n+"}";
},_getViewTabElement:function(){return h(".rsHeader ul .rsHeaderMonth",this._ownerElement).parent()[0];
}};
k.MonthViewRenderer.registerClass("Telerik.Web.UI.Scheduler.Rendering.MonthViewRenderer",k.WeekViewRenderer);
k.ResourceGroupedWeekViewRenderer=function(n){k.ResourceGroupedWeekViewRenderer.initializeBase(this,[n]);
};
k.ResourceGroupedWeekViewRenderer.prototype={_updateIndicators:function(){},_clearIndicators:function(){},_getAppointmentParts:function(n){return a.call(this,n);
},_recalcAppointmentsStyles:function(){var n=this;
h.each(this._model._weekModels,function(){this._blockCollection.forEach(function(o){h(o.element).css({width:n._getWidthPercent(o)+"%",left:n._getLeftPercent(o)+"%"});
});
});
},_updateShowFullTimeStatus:function(){if(!this._model._isVertical){k.ResourceGroupedWeekViewRenderer.callBaseMethod(this,"_updateShowFullTimeStatus",[]);
}},_updateColumnHeaders:function(){if(this._model._isVertical){k.ResourceGroupedWeekViewRenderer.callBaseMethod(this,"_updateColumnHeaders",[]);
return;
}var t=this._model.get_columnHeaderDateFormat();
var n=h("div.rsTopWrap table.rsHorizontalHeaderTable",this._ownerElement);
var q=this._model.get_numberOfDays();
var u=this._model.get_visibleRangeStart();
var p=u;
if(n.length>0){var s=n[0].rows;
var r=s[s.length-1];
var o=0;
h.each(r.cells,function(){var v=new i().append("<a class='rsDateHeader' href='#").append(p.format(g)).append("'>").append(p.localeFormat(t)).append("</a>");
this.innerHTML=v.toString();
p=e.DateTime.add(p,d);
if(o++==q-1){p=u;
o=0;
}});
}}};
k.ResourceGroupedWeekViewRenderer.registerClass("Telerik.Web.UI.Scheduler.Rendering.ResourceGroupedWeekViewRenderer",k.WeekViewRenderer);
k.ResourceGroupedDayViewRenderer=function(n){k.ResourceGroupedDayViewRenderer.initializeBase(this,[n]);
};
k.ResourceGroupedDayViewRenderer.prototype={_updateIndicators:function(){},_clearIndicators:function(){},_getAppointmentParts:function(n){return a.call(this,n);
},_recalcAppointmentsStyles:function(){var n=this;
h.each(this._model._weekModels,function(){this._blockCollection.forEach(function(o){h(o.element).css({width:n._getWidthPercent(o)+"%",left:n._getLeftPercent(o)+"%"});
});
});
},_updateShowFullTimeStatus:function(){if(!this._model._isVertical){k.ResourceGroupedDayViewRenderer.callBaseMethod(this,"_updateShowFullTimeStatus",[]);
}}};
k.ResourceGroupedDayViewRenderer.registerClass("Telerik.Web.UI.Scheduler.Rendering.ResourceGroupedDayViewRenderer",k.DayViewRenderer);
k.ResourceGroupedTimelineViewRenderer=function(n){k.ResourceGroupedTimelineViewRenderer.initializeBase(this,[n]);
};
k.ResourceGroupedTimelineViewRenderer.prototype={_updateIndicators:function(){},_clearIndicators:function(){},renderAppointment:function(n){k.ResourceGroupedTimelineViewRenderer.callBaseMethod(this,"renderAppointment",[n]);
if(this._model._isVertical){var o=h(n.get_element()).parents("tr:first")[0].rowIndex;
this._updateRowHeaderHeight(o);
}},_getAppointmentParts:function(n){return a.call(this,n);
},removeAppointment:function(n){if(!n._parts){return;
}var p=h(n.get_element()).parents("tr:first")[0];
k.ResourceGroupedTimelineViewRenderer.callBaseMethod(this,"removeAppointment",[n]);
if(!p){return;
}var o=p.rowIndex;
if(this._model._isVertical){this._updateRowHeaderHeight(o);
}},refreshView:function(){k.ResourceGroupedTimelineViewRenderer.callBaseMethod(this,"refreshView",[]);
if(this._model._isVertical){for(var n=0;
n<this._model._timelineModels.length;
n++){this._updateRowHeaderHeight(n);
}}},_updateRowHeaderHeight:function(r){var q=h("div.rsTopWrap table.rsVerticalHeaderTable",this._ownerElement);
if(q.length==0){return;
}var s=h("div.rsTopWrap table.rsAllDayTable",this._ownerElement)[0].rows[r];
var p=0;
h.each(s.cells,function(){p=Math.max(h("div.rsWrap",this).length,p);
});
var o=parseInt(this._owner.get_rowHeight());
var n=(o*p)+"px";
h(q[0].rows[r].cells[0]).css("height",n);
},_updateColumnHeaders:function(){if(this._model._isVertical){k.ResourceGroupedTimelineViewRenderer.callBaseMethod(this,"_updateColumnHeaders");
return;
}var q=this._model._getNumberOfSlots();
var p=h("div.rsTopWrap table.rsHorizontalHeaderTable tr:eq(1) th",this._ownerElement);
for(var n=0,o=p.length;
n<o;
n+=q){this._updateDateColumnHeaders(p.slice(n,n+q));
}}};
k.ResourceGroupedTimelineViewRenderer.registerClass("Telerik.Web.UI.Scheduler.Rendering.ResourceGroupedTimelineViewRenderer",k.TimelineViewRenderer);
k.ResourceGroupedMonthViewRenderer=function(n){k.ResourceGroupedMonthViewRenderer.initializeBase(this,[n]);
};
k.ResourceGroupedMonthViewRenderer.prototype={_getAppointmentParts:function(n){return a.call(this,n);
}};
k.ResourceGroupedMonthViewRenderer.registerClass("Telerik.Web.UI.Scheduler.Rendering.ResourceGroupedMonthViewRenderer",k.MonthViewRenderer);
k.DateGroupedWeekViewRenderer=k.WeekViewRenderer;
k.DateGroupedMonthViewRenderer=k.MonthViewRenderer;
k.DateGroupedTimelineViewRenderer=k.TimelineViewRenderer;
function a(q){var n=[];
var p=this._model;
var o=this;
q.get_resources().forEach(function(s){var r=p._resources.getResourceByTypeAndKey(s.get_type(),s.get_key());
if(r){var t=p._resources.indexOf(r);
var u=Object.getType(o).callBaseMethod(o,"_getAppointmentParts",[q]);
h.each(u,function(){this.modelIndex=t;
});
Array.addRange(n,u);
}});
return n;
}})($telerik.$,Telerik.Web.UI);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();