UNPKG

kendo-multi-calendar

Version:
1 lines 2.96 kB
var kendoExt,__extends=this&&this.__extends||function(){var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),__assign=this&&this.__assign||Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t};!function(t){var e=function(o){function s(t,e){var i=o.call(this,t,e)||this;return i.selectToday=function(){var t=new Date,e=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=i.options.cleanSelectedItemsOnTodayClick?[e]:i._values.concat([e]);i.values(n)},i._values=e&&e.values||[],i.navigate(),i}return __extends(s,o),s.isSameDate=function(t,e){return t&&e&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()},s.prototype.values=function(n){if(void 0!==n&&this.canSelectItems(n.length)){var t=this._values.filter(function(e){return n.every(function(t){return!s.isSameDate(e,t)})}),i=null;this._values=n.filter(function(t,e){for(i=e-1;0<=i;i-=1)if(s.isSameDate(t,n[i]))return!1;return!0}),this.updateSelection(this._values,t)}return this._values},s.prototype.value=function(i){var t=(this._values||[]).reduce(function(t,e,n){return s.isSameDate(e,i)?n:t},-1),e=-1===t,n=e&&this._values&&this.canSelectItems(this._values.length+1);if(e&&!n||o.prototype.value.call(this,i),i){var a=[];n?this._values.push(i):e||(a=this._values.splice(t,1)),this.updateSelection(this._values,a)}return o.prototype.value.call(this)},s.prototype.navigate=function(t,e){o.prototype.navigate.call(this,t,e),this.updateSelection(this._values)},s.prototype.navigateDown=function(t){if(t){var e=this._index;if(e===s._views[this.options.depth])return this.value(t),void this.trigger("change");this.navigate(t,e-1)}},s.prototype._todayClick=function(t){this.selectToday(),o.prototype._todayClick.call(this,t)},s.prototype.canSelectItems=function(t){var e=this.options.maxSelectedItems;return!e||t<=e},s.prototype.cellByDate=function(t){return this._table.find("td").filter(function(){return $(this.firstChild).attr(kendo.attr("value"))===t})},s.prototype.updateSelection=function(t,e){var n=this;if(void 0===e&&(e=[]),this._index===s._views[this.options.depth]){var i="k-state-selected",a=this._value;a&&this.cellByDate(this.view().toDateString(a)).removeClass(i),t.forEach(function(t){n.cellByDate(n.view().toDateString(t)).addClass(i)}),e.forEach(function(t){n.cellByDate(n.view().toDateString(t)).removeClass(i)})}},s._views={month:0,year:1,decade:2,century:3},s}(kendo.ui.Calendar);(t.MultiCalendar=e).fn=e.prototype,e.fn.options=__assign({},kendo.ui.Calendar.fn.options,{name:"MultiCalendar",values:[],maxSelectedItems:null,cleanSelectedItemsOnTodayClick:!0}),kendo.ui.plugin(e)}(kendoExt||(kendoExt={}));