UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 8.55 kB
module.exports=function(e){function t(a){if(n[a])return n[a].exports;var i=n[a]={exports:{},id:a,loaded:!1};return e[a].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}({0:function(e,t,n){e.exports=n(1408)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1123:function(e,t){e.exports=require("./kendo.tooltip")},1188:function(e,t){e.exports=require("./kendo.multiviewcalendar")},1397:function(e,t){e.exports=require("./kendo.scheduler.view")},1408:function(e,t,n){var a,i,o;!function(r,define){i=[n(1397),n(1188),n(1123)],a=r,o="function"==typeof a?a.apply(t,i):a,!(void 0!==o&&(e.exports=o))}(function(){return function(e,t){var n=window.kendo,a=n.ui,i=a.SchedulerView,o=e.extend,r=e.proxy,l=n.template,s=n.date.firstDayOfYear,d=n.date.firstDayOfMonth,c=n.date.lastDayOfMonth,u="navigate",p="keydown",v="activate",f="show",h="hide",y="click",_=".",m=".kendoYearView",k={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=l("<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:[u],_yearRange:function(){var e,t=this,n=t.options;t._startDate=n.startDate?d(n.startDate):s(n.date),t._startDate.setFullYear(n.date.getFullYear()),e=new Date(t._startDate),e.setMonth(e.getMonth()+n.months),t._endDate=e},_templates:function(){var e=this.options,t=o({},n.Template,e.templateSettings);this.tooltipTemplate=n.template(e.tooltipTemplate,t)},_layout:function(){var t=this,n=k;t.content=e("<div/>").addClass(n.layout),t.element.append(t.content),t.body=e("<div/>").addClass(n.body),t.content.append(t.body)},_initCalendar:function(){var t=this,n=t.options,i=e("<div/>");t.body.append(i),t.calendar=new a.MultiViewCalendar(i,{views:n.months,value:t.startDate(),showViewHeader:!0,footer:!1}),n.selectable||t._disableCalendarSelection(),t.calendar.value(null),t.calendar.header.toggleClass(k.hidden),t.calendar.element.on(y+m,"td[role='gridcell']",r(t._calendarCellClick,t)),t.calendar.element.on(p+m,"table.k-content",r(t._calendarKeydown,t)),t.calendar.bind(u,r(t._calendarNavigate,t))},_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,a=n.keys,i=e.keyCode;i!=a.ENTER&&i!=a.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(u,{view:"year",date:i}),t._focusCellOnNavigate()},_focusCellOnNavigate:function(){var e,t,n=this,a=n.calendar||n.element.find(".k-calendar").getKendoMultiViewCalendar();a&&(e=a._firstViewValue<n.startDate(),t=e?n.lastDateInRange():n.nextDate(),n.options.selectable&&a.value(t),a._focusCell(a._cellByDate(t),!0))},_disableCalendarSelection:function(){var e=this;e.calendar&&(e.calendar.value(null),e.calendar.element.off(p,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:y,position:"right",content:n,width:220}),e._initTooltipPopup(),e.tooltip.bind(f,r(e._tooltipShow,e)),e.tooltip.bind(h,r(e._tooltipHide,e))},_initTooltipPopup:function(){var e=this,t=e.tooltip;e.tooltip&&(t._initPopup(),t.popup.element.addClass(k.tooltip),t.popup.element.on(y+m,".k-tooltip-title > .k-day",r(e._tooltipTitleClick,e)),t.popup.element.on(p+m,e,r(e._tooltipKeydown,e)))},_buildTooltipTemplate:function(){var e=this,t=n.parseDate(e.calendar.current()),a=e.eventsByDate||[];return a=a.filter(function(e){return n.toString(new Date(e.value),"d")==n.toString(t,"d")}),a&&a[0]&&a[0].items.map(function(t){t.resources=e.eventResources(t)||[]}),e.tooltipTemplate({date:t,events:a[0]?a[0].items:[],messages:e.options.messages})},_inverseTooltipEventsColor:function(){var t=this;e.each(t.tooltip.popup.element.find(_+k.event),function(){t._inverseEventColor(e(this))})},_tooltipShow:function(e){var t=this,n=e.sender;n.refresh(),t._inverseTooltipEventsColor(),n.popup.element.find(":kendoFocusable").first().trigger("focus")},_tooltipHide:function(){this.calendar&&this.calendar._focusCell(this.calendar.selectable.value().first(),!0)},_tooltipTitleClick:function(){this._navigateToDayView()},_tooltipKeydown:function(t){var a,i,o=this,r=o.tooltip.popup.element,l=e(t.target),s=n.keys,d=t.keyCode,c=t.shiftKey;(l.is(".k-day")&&d==s.ENTER||d==s.SPACEBAR)&&(t.preventDefault(),o._navigateToDayView()),d==s.TAB&&(a=r.find(":kendoFocusable").first(),i=r.find(":kendoFocusable").last(),c&&l.is(a)?(i.trigger("focus"),t.preventDefault()):l.is(i)&&(a.trigger("focus"),t.preventDefault()))},_navigateToDayView:function(){var t=e.grep(this.options.views,function(t){return e.isPlainObject(t)&&"kendo.ui.DayView"==t.type||"day"===t}).length;t&&this.trigger(u,{view:"day",date:this.calendar.current()})},_displayTooltip:function(e){var t=this;e.length&&(t.options.selectable||e.removeClass("k-state-selected"),setTimeout(function(){t.tooltip.show(e)},50))},_renderEventIndicators:function(){var t,n,a=this,i=a.calendar;i.element.find("."+k.indicator).remove(),a.eventsByDate.forEach(function(a){t=i._currentView.toDateString(new Date(a.value)),n=i.element[0].querySelector("[data-value='"+t+"']"),a.items.length&&e("<span/>").addClass(k.indicator).appendTo(n)})},_groupEventsByDate:function(e){var t,a=[];return e.length?(t=e.map(function(e){return e.formattedDate=e.start.toDateString(),e}),a=new n.data.Query(t).sort([{field:"start",dir:"asc"},{field:"end",dir:"desc"}]).group({field:"formattedDate"}).toArray()):[]},lastDateInRange:function(){var e=new Date(this.previousDate());return e.setMonth(e.getMonth()-1+this.options.months),c(e)},nextDate:function(){return n.date.nextYear(this._startDate)},previousDate:function(){return n.date.previousYear(this._startDate)},startDate:function(){return this._startDate},endDate:function(){return this._endDate},moveToEvent:function(){return!1},constrainSelection:function(){return!1},inRange:function(){return!0},select:function(e){this.clearSelection(),e.start>=this.startDate()&&e.start<this.endDate()?this.calendar.value(e.start):(this.calendar.value(this.calendar._firstViewValue),e.start=e.end=this.calendar.value()),this.current(this.calendar.selectable.value()[0])},selectionByElement:function(t){if(t.length)return t=e(t),{index:this.calendar._index,start:n.calendar.toDateObject(t),end:n.calendar.toDateObject(t),isAllDay:!1,uid:0}},current:function(e){return e===t?this._current:(this._current=e,t)},move:function(e,t){var a=!1,i=this.options.selectable;if(i&&e)return t!==n.keys.DOWN&&t!==n.keys.UP&&t!==n.keys.LEFT&&t!==n.keys.RIGHT||(a=!0,this.calendar.focus()),t!==n.keys.ENTER&&t!==n.keys.SPACEBAR||(a=!0),a&&(e.start=e.end=this.calendar.value()),a},render:function(e){var t=this;t._cachedEvents=e,t.eventsByDate=t._groupEventsByDate(e)||[],t._renderEventIndicators(),t.trigger(v)},destroy:function(){var e=this;e.tooltip&&(e.tooltip.destroy(),e.tooltip=null),e.calendar&&(e.calendar.destroy(),e.calendar=null),e.element&&(e.content.remove(),e.element.off(m)),i.fn.destroy.call(this)}});o(!0,a,{YearView:g})}(window.kendo.jQuery),window.kendo},n(3))}});