summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2016-04-07 12:02:43 -0500
committerAlfredo Sumaran <alfredo@gitlab.com>2016-04-07 12:02:43 -0500
commit3440c0e61f570e9f42a81fb125a021b138b5bebc (patch)
tree7e07d05798a7831cce6f93ac6dd9232ec0d597b9
parentb19ccdeed45605a7bb79509092b297087d6c6e8c (diff)
downloadgitlab-ce-3440c0e61f570e9f42a81fb125a021b138b5bebc.tar.gz
Update datetime in .timeago elements
This should be done before .timeago() is called on the element
-rw-r--r--app/assets/javascripts/application.js.coffee5
-rw-r--r--app/assets/javascripts/merge_request_tabs.js.coffee12
-rw-r--r--app/assets/javascripts/notes.js.coffee17
3 files changed, 28 insertions, 6 deletions
diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee
index f01c67e9474..922a28b4ef5 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,9 @@ $ ->
$('.trigger-submit').on 'change', ->
$(@).parents('form').submit()
- $('abbr.timeago, .js-timeago').timeago()
+ $timeago = $('abbr.timeago, .js-timeago')
+ gl.utils.updateFormatDate($timeago)
+ $timeago.timeago()
# Flash
if (flash = $(".flash-container")).length > 0
diff --git a/app/assets/javascripts/merge_request_tabs.js.coffee b/app/assets/javascripts/merge_request_tabs.js.coffee
index 839e6ec2c08..fdf084a8a82 100644
--- a/app/assets/javascripts/merge_request_tabs.js.coffee
+++ b/app/assets/javascripts/merge_request_tabs.js.coffee
@@ -141,7 +141,9 @@ class @MergeRequestTabs
url: "#{source}.json"
success: (data) =>
document.querySelector("div#commits").innerHTML = data.html
- $('.js-timeago').timeago()
+ $timeago = $('.js-timeago', 'div#commits')
+ gl.utils.updateFormatDate($timeago)
+ $timeago.timeago()
@commitsLoaded = true
@scrollToElement("#commits")
@@ -152,7 +154,9 @@ class @MergeRequestTabs
url: "#{source}.json" + @_location.search
success: (data) =>
document.querySelector("div#diffs").innerHTML = data.html
- $('.js-timeago').timeago()
+ $timeago = $('.js-timeago', 'div#diffs')
+ gl.utils.updateFormatDate($timeago)
+ $timeago.timeago()
$('div#diffs .js-syntax-highlight').syntaxHighlight()
@expandViewContainer() if @diffViewType() is 'parallel'
@diffsLoaded = true
@@ -165,7 +169,9 @@ class @MergeRequestTabs
url: "#{source}.json"
success: (data) =>
document.querySelector("div#builds").innerHTML = data.html
- $('.js-timeago').timeago()
+ $timeago = $('.js-timeago', 'div#builds')
+ gl.utils.updateFormatDate($timeago)
+ $timeago.timeago()
@buildsLoaded = true
@scrollToElement("#builds")
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee
index 86e3b860fcb..02e52040e3c 100644
--- a/app/assets/javascripts/notes.js.coffee
+++ b/app/assets/javascripts/notes.js.coffee
@@ -163,9 +163,16 @@ 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
+ $timeago = $notesList.find("#note_#{note.id} .js-timeago")
+ gl.utils.updateFormatDate($timeago)
+
@initTaskList()
@updateNotesCount(1)
@@ -217,6 +224,8 @@ class @Notes
# append new note to all matching discussions
discussionContainer.append note_html
+ gl.utils.updateFormatDate($('.js-timeago', note_html))
+
@updateNotesCount(1)
###
@@ -345,7 +354,11 @@ 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()
+
+ $timeago = $('.js-timeago', $html)
+ gl.utils.updateFormatDate($timeago)
+ $timeago.timeago()
+
$html.syntaxHighlight()
$html.find('.js-task-list-container').taskList('enable')