UNPKG

@progress/kendo-ui

Version:

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

3 lines 8.48 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("kendo.scheduler.view.min.js"),require("kendo.multiviewcalendar.min.js"),require("kendo.popover.min.js")):typeof define==`function`&&define.amd?define([`exports`,`kendo.scheduler.view.min`,`kendo.multiviewcalendar.min`,`kendo.popover.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.SchedulerYearview={}),e.kendo._globals.SchedulerView,e.kendo._globals.Multiviewcalendar,e.kendo._globals.Popover))})(this,function(e,t,n,r){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let i={id:`scheduler.yearview`,name:`Scheduler Year View`,category:`web`,description:`The Scheduler Year View`,depends:[`scheduler.view`,`multiviewcalendar`,`popover`],hidden:!0};(function(e,t){var n=window.kendo,r=n.ui,i=n.htmlEncode,a=r.SchedulerView,o=e.extend,s=n.template,c=n.date.firstDayOfYear,l=n.date.firstDayOfMonth,u=n.date.lastDayOfMonth,d=`day`,f=`navigate`,p=`keydown`,m=`activate`,h=`click`,g=`focus`,_=`.`,v=`.kendoYearView`,y={layout:`k-scheduler-layout k-scheduler-layout-flex k-scheduler-yearview`,body:`k-scheduler-body`,popover:`k-scheduler-popover`,indicator:`k-day-indicator`,event:`k-popover-event`,hidden:`k-hidden`,calendarView:`k-calendar-view`,scheduler:`k-scheduler`},b=s(({date:e,events:t,messages:r})=>`<div class='k-popover-header'><div class='k-month'>${i(n.format(`{0:MMM}`,e))}</div><div tabindex='0' class='k-link k-day'>${i(n.format(`{0:dd}`,e))}</div></div><div class='k-popover-body'>`+(t.length?`<div class='k-popover-events' role='list' aria-label='Events'>`+t.map(e=>`<div class="k-popover-event k-event" role="listitem" title="${i(e.title)}" ${e.resources[0]?`${n.attr(`style-background-color`)}="${i(e.resources[0].color)}" ${n.attr(`style-border-color`)}="${i(e.resources[0].color)}"`:``}><div class='k-event-title'>${i(e.title)}</div><span class='k-event-time'>${i(n.format(`{0:t}`,e.start))}</span></div>`).join(``)+`</div>`:`<span class='k-no-data'>${i(r.noData)}</span>`)+`</div>`);o(!0,r,{YearView:a.extend({init:function(e,t){var n=this;a.fn.init.call(n,e,t),n._yearRange(),n._templates(),n._layout(),n._initCalendar(),n._initPopover(),a.fn.endInit.call(n)},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:b},name:`year`,events:[f],_yearRange:function(){var e=this,t=e.options,n;e._startDate=t.startDate?l(t.startDate):c(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=o({},n.Template,e.templateSettings);this.popoverTemplate=n.template(e.tooltipTemplate,t)},_layout:function(){var t=this,n=y;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/>`),a,o;t.body.append(i),t.calendar=a=new r.MultiViewCalendar(i,{views:n.months,value:t.startDate(),showViewHeader:!0,footer:!1}),o=a.element,n.selectable||t._disableCalendarSelection(),a.value(null),a.header.toggleClass(y.hidden),o.on(h+v,`td[role='gridcell']`,t._calendarCellClick.bind(t)),o.on(p+v,_+y.calendarView,t._calendarKeydown.bind(t)),a.bind(f,t._calendarNavigate.bind(t))},_calendarCellClick:function(e){var t=this,n=t.calendar.selectable.value().first();e.preventDefault(),e.stopPropagation(),t._displayPopover(n)},_calendarKeydown:function(e){var t=this,r=n.keys,i=e.keyCode;(i==r.ENTER||i==r.SPACEBAR)&&(e.preventDefault(),t._displayPopover(t.calendar.selectable.value().first()))},_calendarNavigate:function(e){var t=this,n=e.sender._firstViewValue<t.startDate()?t.previousDate():t.nextDate();t.trigger(f,{view:`year`,date:n}),t._focusCellOnNavigate()},_focusCellOnNavigate:function(){var e=this,t=e.calendar||e.element.find(`.k-calendar`).getKendoMultiViewCalendar(),n,r;t&&(n=t._firstViewValue<e.startDate(),r=n?e.lastDateInRange():e.nextDate(),t._focusCell(t._cellByDate(r),!0))},_disableCalendarSelection:function(){var e=this;e.calendar&&(e.calendar.value(null),e.calendar.element.off(p,e.calendar._move))},_initPopover:function(){var e=this,t=e.content,n=e._buildPopoverTemplate.bind(e);e.popover=t.kendoPopover({filter:`.k-calendar td[role='gridcell']`,showOn:h,toggleOnClick:!1,position:`right`,callout:!0,template:n,width:220,show:e._popoverShow.bind(e),hide:e._popoverHide.bind(e)}).data(`kendoPopover`),e.popover.element.removeAttr(`data-role`),e._initPopoverPopup()},_initPopoverPopup:function(){var e=this,t=e.popover;e.popover&&(t._initPopup(),t.wrapper.addClass(y.popover).attr(`role`,`dialog`),t.wrapper.on(h+v,`.k-popover-header > .k-day`,e._popoverTitleClick.bind(e)),t.wrapper.on(p+v,`.k-day`,e._popoverKeydown.bind(e)))},_buildPopoverTemplate:function(){var e=this,t=n.parseDate(e.calendar.current()),r=e.eventsByDate||[];return r=r.filter(function(e){return n.toString(new Date(e.value),`d`)==n.toString(t,`d`)}),r&&r[0]&&r[0].items.map(function(t){t.resources=e.eventResources(t)||[]}),e.popoverTemplate({date:t,events:r[0]?r[0].items:[],messages:e.options.messages})},_inversePopoverEventsColor:function(){var t=this;e.each(t.popover.popup.element.find(_+y.event),function(){t._inverseEventColor(e(this))})},_popoverShow:function(e){var t=this,r=e.sender,i=r.popup.wrapper;i.css(`visibility`,`hidden`),r.wrapper.addClass(y.popover).attr(`role`,`dialog`),r.popup.position(),r._offset(r.options.position,r.options.offset,28),r._positionCallout(),i.css(`visibility`,``),n.applyStylesFromKendoAttributes(r.popup.element,[`background-color`,`border-color`]),t._inversePopoverEventsColor(),r.wrapper.find(`.k-day`).trigger(g)},_popoverHide:function(){var e=this.calendar;e&&e.focus()},_popoverTitleClick:function(){this._navigateToDayView()},_popoverKeydown:function(t){var r=this,i=e(t.target),a=n.keys,o=t.keyCode;i.is(`.k-day`)&&(o==a.ENTER||o==a.SPACEBAR)&&(t.preventDefault(),r._navigateToDayView())},_navigateToDayView:function(){e.grep(this.options.views,function(t){return e.isPlainObject(t)&&t.type==`kendo.ui.DayView`||t===d}).length&&this.trigger(f,{view:d,date:this.calendar.current()})},_displayPopover:function(e){var t=this;e.length&&(t.options.selectable||e.removeClass(`k-selected`),setTimeout(function(){t.popover.show(e)},50))},_renderEventIndicators:function(){var t=this,n=t.calendar,r,i;n.element.find(`.`+y.indicator).remove(),t.eventsByDate.forEach(function(t){r=n._currentView.toDateString(new Date(t.value)),i=n.element[0].querySelector(`[data-value='`+r+`']`),t.items.length&&e(`<span/>`).addClass(y.indicator).appendTo(i)})},_groupEventsByDate:function(e){var t=[],r;return e.length?(r=e.map(function(e){return e.formattedDate=e.start.toDateString(),e}),t=new n.data.Query(r).sort([{field:`start`,dir:`asc`},{field:`end`,dir:`desc`}]).group({field:`formattedDate`}).toArray(),t):[]},_resourceBySlot:function(){return{}},lastDateInRange:function(){var e=new Date(this.previousDate());return e.setMonth(e.getMonth()-1+this.options.months),u(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){if(e!==t)this._current=e;else return this._current},render:function(e){var t=this;t._cachedEvents=e,t.eventsByDate=t._groupEventsByDate(e)||[],t._renderEventIndicators(),t.trigger(m)},destroy:function(){var e=this;e.popover&&=(e.popover.destroy(),null),e.calendar&&=(e.calendar.destroy(),null),e.element&&(e.content.remove(),e.element.off(v)),a.fn.destroy.call(this)}})})})(window.kendo.jQuery);var a=kendo;e.__meta__=i,e.default=a}); //# sourceMappingURL=kendo.scheduler.yearview.min.js.map