summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJacob Schatz <jschatz1@gmail.com>2016-04-12 19:28:55 +0000
committerJacob Schatz <jschatz1@gmail.com>2016-04-12 19:28:55 +0000
commit20418dc7dae516943253fd4a603e2b96ed25559e (patch)
treeff03d09fe7abd31baa46bada81658dffe3d8c26f /app
parent66e6052b93cf588bb04633fde9fb99097e2cf60d (diff)
parent44727525952f22c2234d2991e20f4f4f8bac3221 (diff)
downloadgitlab-ce-20418dc7dae516943253fd4a603e2b96ed25559e.tar.gz
Merge branch 'issue_14206' into 'master'
Fix datetimes on tooltips Closes #14206 Updates tooltip datetimes on `.timeago()` instances. **Inline notes** ![Screen_Shot_2016-04-07_at_1.25.12_PM](/uploads/2f55390a7e91dabf75e71fe3bda91849/Screen_Shot_2016-04-07_at_1.25.12_PM.png) **Existing and new notes** ![Screen_Shot_2016-04-07_at_1.24.49_PM](/uploads/202bb7476738eb048f2d94abb68174e7/Screen_Shot_2016-04-07_at_1.24.49_PM.png) **Issuable dates** ![Screen_Shot_2016-04-07_at_1.24.32_PM](/uploads/80fd5cc3c06fade0b1c615bc7b7611a8/Screen_Shot_2016-04-07_at_1.24.32_PM.png) **Build dates** ![Screen_Shot_2016-04-07_at_1.25.02_PM](/uploads/832f43284005ea610a3ad54a49b97104/Screen_Shot_2016-04-07_at_1.25.02_PM.png) See merge request !3497
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/application.js.coffee3
-rw-r--r--app/assets/javascripts/lib/datetime_utility.js.coffee17
-rw-r--r--app/assets/javascripts/merge_request_tabs.js.coffee6
-rw-r--r--app/assets/javascripts/notes.js.coffee14
-rw-r--r--app/helpers/application_helper.rb2
5 files changed, 35 insertions, 7 deletions
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee
index f01c67e9474..b05138ac1ac 100644
--- a/app/assets/javascripts/application.js.coffee
+++ b/app/assets/javascripts/application.js.coffee
@@ -41,6 +41,7 @@
#= require shortcuts_issuable
#= require shortcuts_network
#= require jquery.nicescroll
+#= require date.format
#= require_tree .
#= require fuzzaldrin-plus
#= require cropper
@@ -163,7 +164,7 @@ $ ->
$('.trigger-submit').on 'change', ->
$(@).parents('form').submit()
- $('abbr.timeago, .js-timeago').timeago()
+ gl.utils.localTimeAgo($('abbr.timeago, .js-timeago'), false)
# Flash
if (flash = $(".flash-container")).length > 0
diff --git a/app/assets/javascripts/lib/datetime_utility.js.coffee b/app/assets/javascripts/lib/datetime_utility.js.coffee
new file mode 100644
index 00000000000..ad1d1c70481
--- /dev/null
+++ b/app/assets/javascripts/lib/datetime_utility.js.coffee
@@ -0,0 +1,17 @@
+((w) ->
+
+ w.gl ?= {}
+ w.gl.utils ?= {}
+
+ w.gl.utils.formatDate = (datetime) ->
+ dateFormat(datetime, 'mmm d, yyyy h:MMtt Z')
+
+ w.gl.utils.localTimeAgo = ($timeagoEls, setTimeago = true) ->
+ $timeagoEls.each( ->
+ $el = $(@)
+ $el.attr('title', gl.utils.formatDate($el.attr('datetime')))
+ )
+
+ $timeagoEls.timeago() if setTimeago
+
+) window
diff --git a/app/assets/javascripts/merge_request_tabs.js.coffee b/app/assets/javascripts/merge_request_tabs.js.coffee
index 9946249adbf..ef0b534a709 100644
--- a/app/assets/javascripts/merge_request_tabs.js.coffee
+++ b/app/assets/javascripts/merge_request_tabs.js.coffee
@@ -142,7 +142,7 @@ class @MergeRequestTabs
url: "#{source}.json"
success: (data) =>
document.querySelector("div#commits").innerHTML = data.html
- $('.js-timeago').timeago()
+ gl.utils.localTimeAgo($('.js-timeago', 'div#commits'))
@commitsLoaded = true
@scrollToElement("#commits")
@@ -153,7 +153,7 @@ class @MergeRequestTabs
url: "#{source}.json" + @_location.search
success: (data) =>
document.querySelector("div#diffs").innerHTML = data.html
- $('.js-timeago').timeago()
+ gl.utils.localTimeAgo($('.js-timeago', 'div#diffs'))
$('div#diffs .js-syntax-highlight').syntaxHighlight()
@expandViewContainer() if @diffViewType() is 'parallel'
@diffsLoaded = true
@@ -166,7 +166,7 @@ class @MergeRequestTabs
url: "#{source}.json"
success: (data) =>
document.querySelector("div#builds").innerHTML = data.html
- $('.js-timeago').timeago()
+ gl.utils.localTimeAgo($('.js-timeago', 'div#builds'))
@buildsLoaded = true
@scrollToElement("#builds")
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index 86e3b860fcb..a67890200dd 100644
--- a/app/assets/javascripts/notes.js.coffee
+++ b/app/assets/javascripts/notes.js.coffee
@@ -163,9 +163,15 @@ class @Notes
else if @isNewNote(note)
@note_ids.push(note.id)
- $('ul.main-notes-list')
+ $notesList = $('ul.main-notes-list')
+
+ $notesList
.append(note.html)
.syntaxHighlight()
+
+ # Update datetime format on the recent note
+ gl.utils.localTimeAgo($notesList.find("#note_#{note.id} .js-timeago"), false)
+
@initTaskList()
@updateNotesCount(1)
@@ -217,6 +223,8 @@ class @Notes
# append new note to all matching discussions
discussionContainer.append note_html
+ gl.utils.localTimeAgo($('.js-timeago', note_html), false)
+
@updateNotesCount(1)
###
@@ -345,7 +353,9 @@ class @Notes
updateNote: (_xhr, note, _status) =>
# Convert returned HTML to a jQuery object so we can modify it further
$html = $(note.html)
- $('.js-timeago', $html).timeago()
+
+ gl.utils.localTimeAgo($('.js-timeago', $html))
+
$html.syntaxHighlight()
$html.find('.js-task-list-container').taskList('enable')
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e6ceb213532..16e5b8ac223 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -184,7 +184,7 @@ module ApplicationHelper
element = content_tag :time, time.to_s,
class: "#{html_class} js-timeago #{"js-timeago-pending" unless skip_js}",
datetime: time.to_time.getutc.iso8601,
- title: time.in_time_zone.to_s(:medium),
+ title: time.to_time.in_time_zone.to_s(:medium),
data: { toggle: 'tooltip', placement: placement, container: 'body' }
unless skip_js