Commit 9a7e2399dd766bae96ed15b6e6d4c69374d310fe
1 parent
e2dbe0fa
Exists in
spb-stable
and in
3 other branches
Use jquery timeago plugin
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
6 additions
and
5 deletions
Show diff stats
app/assets/javascripts/main.js.coffee
| @@ -81,6 +81,7 @@ $ -> | @@ -81,6 +81,7 @@ $ -> | ||
| 81 | $(@).parents('form').submit() | 81 | $(@).parents('form').submit() |
| 82 | 82 | ||
| 83 | $("abbr.timeago").timeago() | 83 | $("abbr.timeago").timeago() |
| 84 | + $('.js-timeago').timeago() | ||
| 84 | 85 | ||
| 85 | # Flash | 86 | # Flash |
| 86 | if (flash = $(".flash-container")).length > 0 | 87 | if (flash = $(".flash-container")).length > 0 |
app/helpers/application_helper.rb
| @@ -72,7 +72,7 @@ module ApplicationHelper | @@ -72,7 +72,7 @@ module ApplicationHelper | ||
| 72 | 72 | ||
| 73 | def last_commit(project) | 73 | def last_commit(project) |
| 74 | if project.repo_exists? | 74 | if project.repo_exists? |
| 75 | - time_ago_with_tooltip(project.repository.commit.committed_date) + " ago" | 75 | + time_ago_with_tooltip(project.repository.commit.committed_date) |
| 76 | else | 76 | else |
| 77 | "Never" | 77 | "Never" |
| 78 | end | 78 | end |
| @@ -210,11 +210,11 @@ module ApplicationHelper | @@ -210,11 +210,11 @@ module ApplicationHelper | ||
| 210 | 210 | ||
| 211 | def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago') | 211 | def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago') |
| 212 | capture_haml do | 212 | capture_haml do |
| 213 | - haml_tag :time, time_ago_in_words(date), | ||
| 214 | - class: html_class, datetime: date, title: date.stamp("Aug 21, 2011 9:23pm"), | 213 | + haml_tag :time, date.to_s, |
| 214 | + class: html_class, datetime: date.getutc.iso8601, title: date.stamp("Aug 21, 2011 9:23pm"), | ||
| 215 | data: { toggle: 'tooltip', placement: placement } | 215 | data: { toggle: 'tooltip', placement: placement } |
| 216 | 216 | ||
| 217 | - haml_tag :script, "$('." + html_class + "').tooltip()" | 217 | + haml_tag :script, "$('." + html_class + "').timeago().tooltip()" |
| 218 | end.html_safe | 218 | end.html_safe |
| 219 | end | 219 | end |
| 220 | end | 220 | end |
app/views/events/_event.html.haml
| 1 | - if event.proper? | 1 | - if event.proper? |
| 2 | .event-item{class: "#{event.body? ? "event-block" : "event-inline" }"} | 2 | .event-item{class: "#{event.body? ? "event-block" : "event-inline" }"} |
| 3 | %span.cgray.pull-right | 3 | %span.cgray.pull-right |
| 4 | - #{time_ago_with_tooltip(event.created_at)} ago | 4 | + #{time_ago_with_tooltip(event.created_at)} |
| 5 | 5 | ||
| 6 | = cache event do | 6 | = cache event do |
| 7 | = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:'' | 7 | = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:'' |