summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-04-27 17:38:22 +0100
committerPhil Hughes <me@iamphill.com>2016-05-16 12:22:17 +0100
commitbef5695a81af7a0afbb7ebe30d8ce344afe824f5 (patch)
tree98d7c607338cb59f0617657e28923fb6aa500db0
parent1c9440c2cf171e919f3e7317e9a9827576f9aafd (diff)
downloadgitlab-ce-bef5695a81af7a0afbb7ebe30d8ce344afe824f5.tar.gz
Formats tooltip title & date correctly
Correctly changes the activity when clicking a date - will also revert back to old data when clicking date again
-rw-r--r--app/assets/javascripts/calendar.js.coffee36
1 files changed, 25 insertions, 11 deletions
diff --git a/app/assets/javascripts/calendar.js.coffee b/app/assets/javascripts/calendar.js.coffee
index 9c4d529f7e9..dd6adfe978f 100644
--- a/app/assets/javascripts/calendar.js.coffee
+++ b/app/assets/javascripts/calendar.js.coffee
@@ -1,5 +1,6 @@
class @Calendar
constructor: (timestamps, calendar_activities_path) ->
+ currentSelectedDate = ''
# Get the highest value from the timestampes
highestValue = 0
_.each timestamps, (count) ->
@@ -89,7 +90,14 @@ class @Calendar
.attr 'width', 15
.attr 'height', 15
.attr 'title', (stamp) ->
- "#{stamp.count} contributions<br />#{gl.utils.formatDate stamp.date}"
+ contribText = 'No contributions'
+
+ if stamp.count > 0
+ contribText = "#{stamp.count} contribution#{if stamp.count > 1 then 's' else ''}"
+
+ date = dateFormat(stamp.date, 'mmm d, yyyy')
+
+ "#{contribText}<br />#{date}"
.attr 'class', 'user-contrib-cell js-tooltip'
.attr 'fill', (stamp) ->
if stamp.count isnt 0
@@ -98,16 +106,22 @@ class @Calendar
'#ededed'
.attr 'data-container', 'body'
.on 'click', (stamp) ->
- date = stamp.date
- 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
+ if currentSelectedDate is ''
+ currentSelectedDate = stamp.date
+ formated_date = currentSelectedDate.getFullYear() + "-" + (currentSelectedDate.getMonth()+1) + "-" + currentSelectedDate.getDate()
+
+ $.ajax
+ url: calendar_activities_path
+ data:
+ date: formated_date
+ cache: false
+ dataType: 'html'
+ success: (data) ->
+ $('.user-calendar-activities').html data
+ else
+ currentSelectedDate = ''
+ $('.user-calendar-activities, .content_list').html ''
+ Pager.getOld()
# Month titles
svg.append 'g'