Commit fa817dffeae76fa101ee8849bbac645307c0c82f

Authored by Drew Blessing
1 parent d476ac7d

Add time ago tooltips to show actual date/time

Clean up admin dashboad tooltips

Clean up admin dashboad tooltips

Clean up admin dashboad tooltips

Add helper method

change to use app helper

Modify tooltips to use new helper

Convert remaining times

Adjust one tooltip
app/helpers/application_helper.rb
... ... @@ -72,7 +72,7 @@ module ApplicationHelper
72 72  
73 73 def last_commit(project)
74 74 if project.repo_exists?
75   - time_ago_in_words(project.repository.commit.committed_date) + " ago"
  75 + time_ago_with_tooltip(project.repository.commit.committed_date) + " ago"
76 76 else
77 77 "Never"
78 78 end
... ... @@ -136,9 +136,9 @@ module ApplicationHelper
136 136 Digest::SHA1.hexdigest string
137 137 end
138 138  
139   - def project_last_activity project
  139 + def project_last_activity(project)
140 140 if project.last_activity_at
141   - time_ago_in_words(project.last_activity_at) + " ago"
  141 + time_ago_with_tooltip(project.last_activity_at, 'bottom', 'last_activity_time_ago') + " ago"
142 142 else
143 143 "Never"
144 144 end
... ... @@ -215,4 +215,14 @@ module ApplicationHelper
215 215 Pygments::Lexer[:js].highlight(string).html_safe
216 216 end
217 217 end
  218 +
  219 + def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago')
  220 + capture_haml do
  221 + haml_tag :time, time_ago_in_words(date),
  222 + class: html_class, datetime: date, title: date.stamp("Aug 21, 2011 9:23pm"),
  223 + data: { toggle: 'tooltip', placement: placement }
  224 +
  225 + haml_tag :script, "$('." + html_class + "').tooltip()"
  226 + end.html_safe
  227 + end
218 228 end
... ...
app/helpers/notes_helper.rb
... ... @@ -31,8 +31,14 @@ module NotesHelper
31 31  
32 32 def note_timestamp(note)
33 33 # Shows the created at time and the updated at time if different
34   - ts = "#{time_ago_in_words(note.created_at)} ago"
35   - ts << content_tag(:small, " (Edited #{time_ago_in_words(note.updated_at)} ago)") if note.updated_at != note.created_at
  34 + ts = "#{time_ago_with_tooltip(note.created_at, 'bottom', 'note_created_ago')} ago"
  35 + if note.updated_at != note.created_at
  36 + ts << capture_haml do
  37 + haml_tag :small do
  38 + haml_concat " (Edited #{time_ago_with_tooltip(note.updated_at, 'bottom', 'note_edited_ago')} ago)"
  39 + end
  40 + end
  41 + end
36 42 ts.html_safe
37 43 end
38 44 end
... ...
app/views/admin/dashboard/index.html.haml
... ... @@ -37,8 +37,7 @@
37 37 %p
38 38 = link_to project.name_with_namespace, [:admin, project]
39 39 %span.light.pull-right
40   - = time_ago_in_words project.created_at
41   - ago
  40 + #{time_ago_with_tooltip(project.created_at)} ago
42 41  
43 42 .span4
44 43 %h4 Latest users
... ... @@ -48,8 +47,7 @@
48 47 = link_to [:admin, user] do
49 48 = user.name
50 49 %span.light.pull-right
51   - = time_ago_in_words user.created_at
52   - ago
  50 + #{time_ago_with_tooltip(user.created_at)} ago
53 51  
54 52 .span4
55 53 %h4 Latest groups
... ... @@ -59,8 +57,7 @@
59 57 = link_to [:admin, group] do
60 58 = group.name
61 59 %span.light.pull-right
62   - = time_ago_in_words group.created_at
63   - ago
  60 + #{time_ago_with_tooltip(group.created_at)} ago
64 61  
65 62 %br
66 63 .row
... ...
app/views/events/_event.html.haml
1 1 - if event.proper?
2 2 .event-item{class: "#{event.body? ? "event-block" : "event-inline" }"}
3 3 %span.cgray.pull-right
4   - #{time_ago_in_words(event.created_at)} ago.
  4 + #{time_ago_with_tooltip(event.created_at)} ago
5 5  
6 6 = cache event do
7 7 = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:''
... ...
app/views/events/_event_last_push.html.haml
... ... @@ -5,9 +5,8 @@
5 5 %strong= truncate(event.ref_name, length: 28)
6 6 at
7 7 %strong= link_to_project event.project
8   - %span
9   - = time_ago_in_words(event.created_at)
10   - ago.
  8 + #{time_ago_with_tooltip(event.created_at)} ago
  9 +
11 10 .pull-right
12 11 = link_to new_mr_path_from_push_event(event), title: "New Merge Request", class: "btn btn-create btn-small" do
13 12 Create Merge Request
... ...
app/views/profiles/keys/_key.html.haml
... ... @@ -4,8 +4,6 @@
4 4 %span
5 5 (#{key.fingerprint})
6 6 %span.cgray
7   - added
8   - = time_ago_in_words(key.created_at)
9   - ago
  7 + added #{time_ago_with_tooltip(key.created_at)} ago
10 8  
11 9 = link_to 'Remove', profile_key_path(key), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-small btn-remove delete-key pull-right"
... ...
app/views/projects/branches/_branch.html.haml
... ... @@ -27,6 +27,4 @@
27 27 = image_tag avatar_icon(commit.author_email), class: "avatar s16", alt: ''
28 28 %span.light
29 29 = gfm escape_once(truncate(commit.title, length: 40))
30   - %span
31   - = time_ago_in_words(commit.committed_date)
32   - ago
  30 + #{time_ago_with_tooltip(commit.committed_date)} ago
... ...
app/views/projects/commit/_commit_box.html.haml
... ... @@ -23,16 +23,14 @@
23 23 %span.light Authored by
24 24 %strong
25 25 = commit_author_link(@commit, avatar: true, size: 24)
26   - %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")}
27   - #{time_ago_in_words(@commit.authored_date)} ago
  26 + #{time_ago_with_tooltip(@commit.authored_date)} ago
28 27  
29 28 - if @commit.different_committer?
30 29 .commit-info-row
31 30 %span.light Committed by
32 31 %strong
33 32 = commit_committer_link(@commit, avatar: true, size: 24)
34   - %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")}
35   - #{time_ago_in_words(@commit.committed_date)} ago
  33 + #{time_ago_with_tooltip(@commit.committed_date)} ago
36 34  
37 35 .commit-info-row
38 36 %span.cgray= pluralize(@commit.parents.count, "parent")
... ...
app/views/projects/commits/_commit.html.haml
... ... @@ -13,7 +13,4 @@
13 13  
14 14 .commit-row-info
15 15 = commit_author_link(commit, avatar: true, size: 16)
16   - %time.committed_ago{ datetime: commit.committed_date, title: commit.committed_date.stamp("Aug 21, 2011 9:23pm") }
17   - = time_ago_in_words(commit.committed_date)
18   - ago
19   - &nbsp;
  16 + #{time_ago_with_tooltip(commit.committed_date)} ago &nbsp;
... ...
app/views/projects/commits/_inline_commit.html.haml
... ... @@ -3,7 +3,4 @@
3 3 = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"
4 4 &nbsp;
5 5 = link_to_gfm truncate(commit.title, length: 40), project_commit_path(project, commit.id), class: "commit-row-message"
6   - %time.committed_ago{ datetime: commit.committed_date, title: commit.committed_date.stamp("Aug 21, 2011 9:23pm") }
7   - = time_ago_in_words(commit.committed_date)
8   - ago
9   - &nbsp;
  6 + #{time_ago_with_tooltip(commit.committed_date)} ago &nbsp;
... ...
app/views/projects/deploy_keys/_deploy_key.html.haml
... ... @@ -21,5 +21,4 @@
21 21 - deploy_key.projects.map(&:name_with_namespace).each do |project_name|
22 22 %span.label= project_name
23 23 %small.pull-right
24   - Created #{time_ago_in_words(deploy_key.created_at)} ago
25   -
  24 + Created #{time_ago_with_tooltip(deploy_key.created_at)} ago
... ...
app/views/projects/issues/_issue.html.haml
... ... @@ -26,7 +26,7 @@
26 26 %i.icon-time
27 27 = issue.milestone.title
28 28 .pull-right
29   - %small updated #{time_ago_in_words(issue.updated_at)} ago
  29 + %small updated #{time_ago_with_tooltip(issue.updated_at, 'bottom', 'issue_update_ago')} ago
30 30  
31 31 .issue-labels
32 32 - issue.labels.each do |label|
... ...
app/views/projects/merge_requests/_merge_request.html.haml
... ... @@ -34,4 +34,4 @@
34 34  
35 35  
36 36 .pull-right
37   - %small updated #{time_ago_in_words(merge_request.updated_at)} ago
  37 + %small updated #{time_ago_with_tooltip(merge_request.updated_at, 'bottom', 'merge_request_updated_ago')} ago
... ...
app/views/projects/merge_requests/show/_mr_box.html.haml
... ... @@ -34,13 +34,13 @@
34 34 %span
35 35 %i.icon-remove
36 36 Closed by #{link_to_member(@project, @merge_request.closed_event.author)}
37   - %span #{time_ago_in_words(@merge_request.closed_event.created_at)} ago.
  37 + #{time_ago_with_tooltip(@merge_request.closed_event.created_at)} ago.
38 38 - if @merge_request.merged?
39 39 .ui-box-bottom.alert-success
40 40 %span
41 41 %i.icon-ok
42 42 Merged by #{link_to_member(@project, @merge_request.merge_event.author)}
43   - #{time_ago_in_words(@merge_request.merge_event.created_at)} ago.
  43 + #{time_ago_with_tooltip(@merge_request.merge_event.created_at)} ago.
44 44 - if !@closes_issues.empty? && @merge_request.opened?
45 45 .ui-box-bottom.alert-info
46 46 %span
... ...
app/views/projects/notes/_discussion.html.haml
... ... @@ -32,8 +32,7 @@
32 32 last updated by
33 33 = link_to_member(@project, last_note.author, avatar: false)
34 34 %span.discussion-last-update
35   - = time_ago_in_words(last_note.updated_at)
36   - ago
  35 + #{time_ago_with_tooltip(last_note.updated_at, 'bottom', 'discussion_updated_ago')} ago
37 36 .discussion-body
38 37 - if note.for_diff_line?
39 38 - if note.active?
... ...
app/views/projects/protected_branches/index.html.haml
... ... @@ -46,8 +46,6 @@
46 46 = commit.short_id
47 47 %span.light
48 48 = gfm escape_once(truncate(commit.title, length: 40))
49   - %span
50   - = time_ago_in_words(commit.committed_date)
51   - ago
  49 + #{time_ago_with_tooltip(commit.committed_date)} ago
52 50 - else
53 51 (branch was removed from repository)
... ...
app/views/projects/refs/logs_tree.js.haml
... ... @@ -5,5 +5,5 @@
5 5  
6 6 :plain
7 7 var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}");
8   - row.find("td.tree_time_ago").html('#{escape_javascript time_ago_in_words(commit.committed_date)} ago');
  8 + row.find("td.tree_time_ago").html('#{escape_javascript time_ago_with_tooltip(commit.committed_date)} ago');
9 9 row.find("td.tree_commit").html('#{escape_javascript render("projects/tree/tree_commit_column", commit: commit)}');
... ...
app/views/projects/snippets/_snippet.html.haml
... ... @@ -18,4 +18,5 @@
18 18 by
19 19 = image_tag avatar_icon(snippet.author_email), class: "avatar avatar-inline s16"
20 20 = snippet.author_name
21   - %span.light #{time_ago_in_words(snippet.created_at)} ago
  21 + %span.light
  22 + #{time_ago_with_tooltip(snippet.created_at)} ago
... ...
app/views/projects/tags/index.html.haml
... ... @@ -24,8 +24,7 @@
24 24 .pull-right
25 25 %small.cdark
26 26 %i.icon-calendar
27   - = time_ago_in_words(commit.committed_date)
28   - ago
  27 + #{time_ago_with_tooltip(commit.committed_date)} ago
29 28 %p.prepend-left-20
30 29 = link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace"
31 30 &ndash;
... ...
app/views/projects/wikis/history.html.haml
... ... @@ -23,8 +23,7 @@
23 23 %td
24 24 = commit.title
25 25 %td
26   - = time_ago_in_words(version.date)
27   - ago
  26 + #{time_ago_with_tooltip(version.date)} ago
28 27 %td
29 28 %strong
30 29 = @wiki.page.wiki.page(@wiki.page.name, commit.id).try(:format)
... ...
app/views/projects/wikis/pages.html.haml
... ... @@ -8,4 +8,4 @@
8 8 = link_to wiki_page.title.titleize, project_wiki_path(@project, wiki_page)
9 9 %small (#{wiki_page.format})
10 10 .pull-right
11   - %small Last edited #{time_ago_in_words(wiki_page.commit.created_at)} ago
  11 + %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} ago
... ...
app/views/projects/wikis/show.html.haml
... ... @@ -12,4 +12,4 @@
12 12 = preserve do
13 13 = render_wiki_content(@wiki)
14 14  
15   -%p.time Last edited by #{commit_author_link(@wiki.commit, avatar: true, size: 16)} #{time_ago_in_words @wiki.commit.created_at} ago
  15 +%p.span Last edited by #{commit_author_link(@wiki.commit, avatar: true, size: 16)} #{time_ago_with_tooltip(@wiki.commit.created_at)} ago
... ...
app/views/snippets/_snippet.html.haml
... ... @@ -20,4 +20,4 @@
20 20 = link_to user_snippets_path(snippet.author) do
21 21 = image_tag avatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: ''
22 22 = snippet.author_name
23   - %span.light #{time_ago_in_words(snippet.created_at)} ago
  23 + %span.light #{time_ago_with_tooltip(snippet.created_at)} ago
... ...