BigW Consortium Gitlab

calendar.js.coffee 1001 Bytes
Newer Older
1
class @Calendar
2 3 4 5 6
  options =
    month: "short"
    day: "numeric"
    year: "numeric"

7
  constructor: (timestamps, starting_year, starting_month, calendar_activities_path) ->
8 9
    cal = new CalHeatMap()
    cal.init
10
      itemName: ["contribution"]
11 12 13 14 15 16 17 18 19 20 21 22
      data: timestamps
      start: new Date(starting_year, starting_month)
      domainLabelFormat: "%b"
      id: "cal-heatmap"
      domain: "month"
      subDomain: "day"
      range: 12
      tooltip: true
      label:
        position: "top"
      legend: [
        0
23 24
        10
        20
25
        30
26 27
      ]
      legendCellPadding: 3
28
      cellSize: $('.user-calendar').width() / 73
29
      onClick: (date, count) ->
30 31 32 33 34 35 36 37 38 39
        formated_date = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate()
        $.ajax
          url: calendar_activities_path
          data:
            date: formated_date
          cache: false
          dataType: "html"
          success: (data) ->
            $(".user-calendar-activities").html data