From 9a7e2399dd766bae96ed15b6e6d4c69374d310fe Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 30 Dec 2013 14:38:42 +0200 Subject: [PATCH] Use jquery timeago plugin Signed-off-by: Dmitriy Zaporozhets --- app/assets/javascripts/main.js.coffee | 1 + app/helpers/application_helper.rb | 8 ++++---- app/views/events/_event.html.haml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 10c40dff5fd..5add7541a73 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -81,6 +81,7 @@ $ -> $(@).parents('form').submit() $("abbr.timeago").timeago() + $('.js-timeago').timeago() # Flash if (flash = $(".flash-container")).length > 0 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7ca52598cfb..cd3afd5cc32 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -72,7 +72,7 @@ module ApplicationHelper def last_commit(project) if project.repo_exists? - time_ago_with_tooltip(project.repository.commit.committed_date) + " ago" + time_ago_with_tooltip(project.repository.commit.committed_date) else "Never" end @@ -210,11 +210,11 @@ module ApplicationHelper def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago') capture_haml do - haml_tag :time, time_ago_in_words(date), - class: html_class, datetime: date, title: date.stamp("Aug 21, 2011 9:23pm"), + haml_tag :time, date.to_s, + class: html_class, datetime: date.getutc.iso8601, title: date.stamp("Aug 21, 2011 9:23pm"), data: { toggle: 'tooltip', placement: placement } - haml_tag :script, "$('." + html_class + "').tooltip()" + haml_tag :script, "$('." + html_class + "').timeago().tooltip()" end.html_safe end end diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index daed9116789..8cf26671e3b 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -1,7 +1,7 @@ - if event.proper? .event-item{class: "#{event.body? ? "event-block" : "event-inline" }"} %span.cgray.pull-right - #{time_ago_with_tooltip(event.created_at)} ago + #{time_ago_with_tooltip(event.created_at)} = cache event do = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:''