@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 8.96 kB
JavaScript
module.exports=function(n){var a={};function i(e){if(a[e])return a[e].exports;var t=a[e]={exports:{},id:e,loaded:!1};return n[e].call(t.exports,t,t.exports,i),t.loaded=!0,t.exports}return i.m=n,i.c=a,i.p="",i(0)}({0:function(e,t,n){e.exports=n(1432)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1138:function(e,t){e.exports=require("./kendo.tooltip")},1197:function(e,t){e.exports=require("./kendo.multiviewcalendar")},1420:function(e,t){e.exports=require("./kendo.scheduler.view")},1432:function(e,t,n){var a;n(3),n=[n(1420),n(1197),n(1138)],void 0===(t="function"==typeof(a=function(){var e={id:"scheduler.yearview",name:"Scheduler Year View",category:"web",description:"The Scheduler Year View",depends:["scheduler.view","multiviewcalendar","tooltip"],hidden:true},d=window.kendo.jQuery,t=void 0,c=window.kendo,a=c.ui,i=a.SchedulerView,n=d.extend,p=c.template,f=c.date.firstDayOfYear,v=c.date.firstDayOfMonth,h=c.date.lastDayOfMonth,o="navigate",r="keydown",y="activate",m="show",_="hide",l="click",k=".",s=".kendoYearView",u={layout:"k-scheduler-layout k-scheduler-layout-flex k-scheduler-yearview",body:"k-scheduler-body",tooltip:"k-scheduler-tooltip",indicator:"k-day-indicator",event:"k-tooltip-event",hidden:"k-hidden"},D=p("<div class='k-tooltip-title k-text-center'>"+"<div class='k-month'>#:kendo.format('{0:MMM}', date)#</div>"+"<div tabindex='0' class='k-link k-day k-text-primary'>#:kendo.format('{0:dd}', date)#</div>"+"</div>"+"#if(events.length){#"+"<div class='k-tooltip-events-container'>"+"<div class='k-tooltip-events'>"+"#for(var i = 0; i < events.length; i+=1){#"+"#var event = events[i]#"+"<div class='k-tooltip-event k-event' title='#:event.title#'"+"# if (event.resources[0]) { #"+"style='background-color: #: event.resources[0].color #; border-color: #: event.resources[0].color #;'"+"#}#>"+"<div class='k-event-title k-text-ellipsis'>#:event.title#</div>"+"<span class='k-spacer'></span>"+"<span class='k-event-time'>#:kendo.format('{0:t}', event.start)#</span>"+"</div>"+"#}#"+"</div>"+"</div>"+"#} else {#"+"<div class='k-no-data k-text-center'>#:messages.noData#</div>"+"#}#"),g=i.extend({init:function(e,t){var n=this;i.fn.init.call(n,e,t);n._yearRange();n._templates();n._layout();n._initCalendar();n._initTooltip()},options:{title:"Year",name:"year",months:12,startDate:null,messages:{noData:"No events on this date."},selectedDateFormat:"{0:yyyy}",selectedShortDateFormat:"{0:yyyy}",selectedMobileDateFormat:"{0:yyyy}",tooltipTemplate:D},name:"year",events:[o],_yearRange:function(){var e=this,t=e.options,n;e._startDate=t.startDate?v(t.startDate):f(t.date);e._startDate.setFullYear(t.date.getFullYear());n=new Date(e._startDate);n.setMonth(n.getMonth()+t.months);e._endDate=n},_templates:function(){var e=this.options,t=n({},c.Template,e.templateSettings);this.tooltipTemplate=c.template(e.tooltipTemplate,t)},_layout:function(){var e=this,t=u;e.content=d("<div/>").addClass(t.layout);e.element.append(e.content);e.body=d("<div/>").addClass(t.body);e.content.append(e.body)},_initCalendar:function(){var e=this,t=e.options,n=d("<div/>");e.body.append(n);e.calendar=new a.MultiViewCalendar(n,{views:t.months,value:e.startDate(),showViewHeader:true,footer:false});if(!t.selectable)e._disableCalendarSelection();e.calendar.value(null);e.calendar.header.toggleClass(u.hidden);e.calendar.element.on(l+s,"td[role='gridcell']",e._calendarCellClick.bind(e));e.calendar.element.on(r+s,"table.k-content",e._calendarKeydown.bind(e));e.calendar.bind(o,e._calendarNavigate.bind(e));e.calendar.element.find("table").attr("tabindex","-1")},_calendarCellClick:function(e){var t=this,n=t.calendar.selectable.value().first();e.preventDefault();e.stopPropagation();t._displayTooltip(n)},_calendarKeydown:function(e){var t=this,n=c.keys,a=e.keyCode;if(a==n.ENTER||a==n.SPACEBAR){e.preventDefault();t._displayTooltip(t.calendar.selectable.value().first())}},_calendarNavigate:function(e){var t=this,n=e.sender,a=n._firstViewValue<t.startDate(),i=a?t.previousDate():t.nextDate();t.trigger(o,{view:"year",date:i});t._focusCellOnNavigate()},_focusCellOnNavigate:function(){var e=this,t=e.calendar||e.element.find(".k-calendar").getKendoMultiViewCalendar(),n,a;if(!t)return;n=t._firstViewValue<e.startDate();a=n?e.lastDateInRange():e.nextDate();if(e.options.selectable)t.value(a);t._focusCell(t._cellByDate(a),true)},_disableCalendarSelection:function(){var e=this;if(!e.calendar)return;e.calendar.value(null);e.calendar.element.off(r,e.calendar._move);e.calendar.element.find("table").attr("tabindex","-1")},_initTooltip:function(){var e=this,t=e.content,n=e._buildTooltipTemplate.bind(e);e.tooltip=new a.Tooltip(t,{filter:".k-calendar td[role='gridcell']",showOn:l,position:"right",content:n,width:220});e._initTooltipPopup();e.tooltip.bind(m,e._tooltipShow.bind(e));e.tooltip.bind(_,e._tooltipHide.bind(e))},_initTooltipPopup:function(){var e=this,t=e.tooltip;if(!e.tooltip)return;t._initPopup();t.popup.element.addClass(u.tooltip);t.popup.element.on(l+s,".k-tooltip-title > .k-day",e._tooltipTitleClick.bind(e));t.popup.element.on(r+s,e,e._tooltipKeydown.bind(e))},_buildTooltipTemplate:function(){var t=this,n=c.parseDate(t.calendar.current()),e=t.eventsByDate||[];e=e.filter(function(e){return c.toString(new Date(e.value),"d")==c.toString(n,"d")});if(e&&e[0])e[0].items.map(function(e){e.resources=t.eventResources(e)||[]});return t.tooltipTemplate({date:n,events:e[0]?e[0].items:[],messages:t.options.messages})},_inverseTooltipEventsColor:function(){var e=this;d.each(e.tooltip.popup.element.find(k+u.event),function(){e._inverseEventColor(d(this))})},_tooltipShow:function(e){var t=this,n=e.sender;n.refresh();t._inverseTooltipEventsColor();n.popup.element.find(":kendoFocusable").first().trigger("focus")},_tooltipHide:function(){if(!this.calendar)return;this.calendar._focusCell(this.calendar.selectable.value().first(),true)},_tooltipTitleClick:function(){this._navigateToDayView()},_tooltipKeydown:function(e){var t=this,n=t.tooltip.popup.element,a=d(e.target),i=c.keys,o=e.keyCode,r=e.shiftKey;if(a.is(".k-day")&&o==i.ENTER||o==i.SPACEBAR){e.preventDefault();t._navigateToDayView()}if(o==i.TAB){var l=n.find(":kendoFocusable").first();var s=n.find(":kendoFocusable").last();if(r&&a.is(l)){s.trigger("focus");e.preventDefault()}else if(a.is(s)){l.trigger("focus");e.preventDefault()}}},_navigateToDayView:function(){var e=d.grep(this.options.views,function(e){return d.isPlainObject(e)&&e.type=="kendo.ui.DayView"||e==="day"}).length;if(e)this.trigger(o,{view:"day",date:this.calendar.current()})},_displayTooltip:function(e){var t=this;if(!e.length)return;if(!t.options.selectable)e.removeClass("k-state-selected");setTimeout(function(){t.tooltip.show(e)},50)},_renderEventIndicators:function(){var e=this,t=e.calendar,n,a;t.element.find("."+u.indicator).remove();e.eventsByDate.forEach(function(e){n=t._currentView.toDateString(new Date(e.value));a=t.element[0].querySelector("[data-value='"+n+"']");if(e.items.length)d("<span/>").addClass(u.indicator).appendTo(a)})},_groupEventsByDate:function(e){var t=[],n;if(!e.length)return[];n=e.map(function(e){e.formattedDate=e.start.toDateString();return e});t=new c.data.Query(n).sort([{field:"start",dir:"asc"},{field:"end",dir:"desc"}]).group({field:"formattedDate"}).toArray();return t},lastDateInRange:function(){var e=new Date(this.previousDate());e.setMonth(e.getMonth()-1+this.options.months);return h(e)},nextDate:function(){return c.date.nextYear(this._startDate)},previousDate:function(){return c.date.previousYear(this._startDate)},startDate:function(){return this._startDate},endDate:function(){return this._endDate},moveToEvent:function(){return false},constrainSelection:function(){return false},inRange:function(){return true},select:function(e){this.clearSelection();if(e.start>=this.startDate()&&e.start<this.endDate())this.calendar.value(e.start);else{this.calendar.value(this.calendar._firstViewValue);e.start=e.end=this.calendar.value()}this.current(this.calendar.selectable.value()[0])},selectionByElement:function(e){if(!e.length)return;e=d(e);return{index:this.calendar._index,start:c.calendar.toDateObject(e),end:c.calendar.toDateObject(e),isAllDay:false,uid:0}},current:function(e){if(e!==t)this._current=e;else return this._current},move:function(e,t){var n=false,a=this.options.selectable;if(!a||!e)return;if(t===c.keys.DOWN||t===c.keys.UP||t===c.keys.LEFT||t===c.keys.RIGHT){n=true;this.calendar.focus()}if(t===c.keys.ENTER||t===c.keys.SPACEBAR)n=true;if(n)e.start=e.end=this.calendar.value();return n},render:function(e){var t=this;t._cachedEvents=e;t.eventsByDate=t._groupEventsByDate(e)||[];t._renderEventIndicators();t.trigger(y)},destroy:function(){var e=this;if(e.tooltip){e.tooltip.destroy();e.tooltip=null}if(e.calendar){e.calendar.destroy();e.calendar=null}if(e.element){e.content.remove();e.element.off(s)}i.fn.destroy.call(this)}});return n(true,a,{YearView:g}),window.kendo})?a.apply(t,n):a)||(e.exports=t)}});