diff options
| author | Hannes Rosenögger <123haynes@gmail.com> | 2015-01-28 22:18:22 +0100 |
|---|---|---|
| committer | Hannes Rosenögger <123haynes@gmail.com> | 2015-01-29 01:25:26 +0100 |
| commit | 792ced2f4190226c3335967a8e5a30d3b72bd4ae (patch) | |
| tree | 0411a2c41710a7f0d2c06fa141b8875c77873968 /app/assets/javascripts/calendar.js.coffee | |
| parent | 8eb365c0a04b912d2e10eb16adeeb4216563be2c (diff) | |
| download | gitlab-ce-792ced2f4190226c3335967a8e5a30d3b72bd4ae.tar.gz | |
Add a commit calendar to the user profile
Diffstat (limited to 'app/assets/javascripts/calendar.js.coffee')
| -rw-r--r-- | app/assets/javascripts/calendar.js.coffee | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/app/assets/javascripts/calendar.js.coffee b/app/assets/javascripts/calendar.js.coffee new file mode 100644 index 00000000000..e3bb420a278 --- /dev/null +++ b/app/assets/javascripts/calendar.js.coffee @@ -0,0 +1,71 @@ +class @calendar + options = + month: "short" + day: "numeric" + year: "numeric" + + constructor: (timestamps,starting_year,starting_month,activities_path) -> + cal = new CalHeatMap() + cal.init + itemName: ["commit"] + data: timestamps + start: new Date(starting_year, starting_month) + domainLabelFormat: "%b" + id: "cal-heatmap" + domain: "month" + subDomain: "day" + range: 12 + tooltip: true + domainDynamicDimension: false + colLimit: 4 + label: + position: "top" + domainMargin: 1 + legend: [ + 0 + 1 + 4 + 7 + ] + legendCellPadding: 3 + onClick: (date, count) -> + $.ajax + url: activities_path + data: + date: date + + dataType: "json" + success: (data) -> + $("#loading_commits").fadeIn() + calendar.calendarOnClick data, date, count + setTimeout (-> + $("#calendar_onclick_placeholder").fadeIn 500 + return + ), 400 + setTimeout (-> + $("#loading_commits").hide() + return + ), 400 + return + return + return + + @calendarOnClick: (data, date, nb)-> + $("#calendar_onclick_placeholder").hide() + $("#calendar_onclick_placeholder").html -> + "<span class='calendar_onclick_second'><b>" + + ((if nb is null then "no" else nb)) + + "</b><span class='calendar_commit_date'> commit" + + ((if (nb isnt 1) then "s" else "")) + " " + + date.toLocaleDateString("en-US", options) + + "</span><hr class='calendar_onclick_hr'></span>" + $.each data, (key, data) -> + $.each data, (index, data) -> + $("#calendar_onclick_placeholder").append -> + "Pushed <b>" + ((if data is null then "no" else data)) + " commit" + + ((if (data isnt 1) then "s" else "")) + + "</b> to <a href='/" + index + "'>" + + index + "</a><hr class='calendar_onclick_hr'>" + return + return + return |
