/* * jquery-calendar-heatmap - v1.3.0 * A simple Calendar Heatmap for jQuery. * https://github.com/SeBassTian23/CalendarHeatmap * * Made by Sebastian Kuhlgert * Under MIT License */ !function(b){"use strict";var n="CalendarHeatmap",a={title:null,months:12,weekStartDay:1,lastMonth:(new Date).getMonth()+1,lastYear:(new Date).getFullYear(),coloring:null,labels:{days:!1,months:!0,custom:{weekDayLabels:null,monthLabels:null}},tiles:{shape:"square"},legend:{show:!0,align:"right",minLabel:"Less",maxLabel:"More",divider:" to "},tooltips:{show:!1,options:{}}};function i(t,e,s){this.element=t,this.data=e,this.settings=b.extend(!0,{},a,s),this._defaults=a,this._name=n,this.init()}b.extend(i.prototype,{init:function(){this.calendarHeatmap()},_parse:function(t){var e=[];if(!Array.isArray(t)||"object"!=typeof t)return console.log("Invalid data source"),null;if(Array.isArray(t)&&0=t[s][0]&&e<=t[s][1])return parseInt(s);return 0},_matchDate:function(t,e){return t.find(function(t){return t.date===e})||null},_matchDateIdx:function(t,e){return t.findIndex(function(t){return t.date===e})},_futureDate:function(t){var e=this._dateFormat().split("-"),t=t.split("-");return parseInt(e[0])'),b(".ch-week-labels",this.element).append('
'),b(".ch-week-label-col",this.element).append('
'),this.settings.labels.months&&b(".ch-week-labels",this.element).append('
 
');for(var t=this.settings.weekStartDay,e=0;e<7;e++){var s,a=e+t<7?e+t:e+t-7,n=this._dateWords.ddd[a];(e-1)%2?(s=this.settings.labels.custom.weekDayLabels,Array.isArray(s)?n=s[a]||"":"string"==typeof s?n=this._dateWords[s][a]||"":"function"==typeof s&&(n=s(a))):n=" ",b("
",{class:"ch-day-label",html:n}).appendTo(b(".ch-day-labels",this.element))}}},calendarHeatmap:function(){var t=this._parse(this.data);if(Array.isArray(t)){this.data=t;var e=this._calculateBins(t),s=e.events,a=e.bins,t=this.settings.lastMonth,e=this.settings.lastYear,n=this.settings.months,i=this.settings.weekStartDay||1;b(this.element).empty(),this.settings.title&&b("

",{class:"ch-title",html:this.settings.title}).appendTo(b(this.element)),b(this.element).addClass("ch").append('
'),this._addWeekColumn(),this.settings.tiles.shape&&"square"!==this.settings.tiles.shape&&b(this.element).addClass(" ch-"+this.settings.tiles.shape);for(var l=t,r=e,h=[],d=0;d

'),b(".ch-month:last",this.element).append('
'),this.settings.labels.months&&b(".ch-month:last",this.element).append('
'+o+"
");var p=new Date(r,l+1,0).getDate();b(".ch-month:last .ch-weeks",this.element).append('
');for(var u=0,g=0;g",{class:"ch-day lvl-"+v.level+m,title:f,"data-toggle":"tooltip"}).appendTo(b(".ch-month:last .ch-weeks .ch-week:last",this.element))):b("
",{class:"ch-day"+y}).appendTo(b(".ch-month:last .ch-weeks .ch-week:last",this.element));y=new Date(r,l,g+2).getDay();u++,(y=0===y?7:y)===i&&g'+g+"
"),u=0)}for(;u<7;u++)b(".ch-month:last .ch-weeks .ch-week:last",this.element).append('
')}if(this.settings.legend.show)for(b("
",{class:"ch-legend"}).appendTo(this.element).append(""+(this.settings.legend.minLabel||"")+"").append('
    ').append(""+(this.settings.legend.maxLabel||"")+""),"left"===this.settings.legend.align&&b(".ch-legend",this.element).addClass("ch-legend-left"),"center"===this.settings.legend.align&&b(".ch-legend",this.element).addClass("ch-legend-center"),d=0;d",{class:"ch-lvl lvl-"+d,title:a[d],"data-toggle":"tooltip"}).appendTo(b(".ch-lvls",this.element)),this.settings.coloring&&b(".ch-lvls li:last",this.element).addClass(this.settings.coloring+"-"+d);this.settings.tooltips.show&&"function"==typeof b.fn.tooltip&&b('[data-toggle="tooltip"]',this.element).tooltip(this.settings.tooltips.options)}},updateDates:function(t){this.data=t,this.calendarHeatmap()},appendDates:function(t){var e=this._parse(t);if(Array.isArray(e)&&Array.isArray(this.data))for(var s in e){var a=this._matchDateIdx(this.data,e[s].date);-1