Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useless JS operation for relative time tooltips #20756

Merged
merged 3 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func testViewRepo(t *testing.T) {
}
})

f.commitTime, _ = s.Find("span.time-since").Attr("title")
f.commitTime, _ = s.Find("span.time-since").Attr("data-content")
items = append(items, f)
})

Expand Down
4 changes: 2 additions & 2 deletions modules/timeutil/since.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func TimeSince(then time.Time, lang translation.Locale) template.HTML {
}

func htmlTimeSince(then, now time.Time, lang translation.Locale) template.HTML {
return template.HTML(fmt.Sprintf(`<span class="time-since" title="%s">%s</span>`,
return template.HTML(fmt.Sprintf(`<span class="time-since tooltip" data-content="%s">%s</span>`,
then.In(setting.DefaultUILocation).Format(GetTimeFormat(lang.Language())),
timeSince(then, now, lang)))
}
Expand All @@ -245,7 +245,7 @@ func TimeSinceUnix(then TimeStamp, lang translation.Locale) template.HTML {
}

func htmlTimeSinceUnix(then, now TimeStamp, lang translation.Locale) template.HTML {
return template.HTML(fmt.Sprintf(`<span class="time-since" title="%s">%s</span>`,
return template.HTML(fmt.Sprintf(`<span class="time-since tooltip" data-content="%s">%s</span>`,
then.FormatInLocation(GetTimeFormat(lang.Language()), setting.DefaultUILocation),
timeSinceUnix(int64(then), int64(now), lang)))
}
2 changes: 1 addition & 1 deletion modules/timeutil/since_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestHtmlTimeSince(t *testing.T) {
// test that `diff` yields a result containing `expected`
test := func(expected string, diff time.Duration) {
actual := htmlTimeSince(BaseDate, BaseDate.Add(diff), translation.NewLocale("en-US"))
assert.Contains(t, actual, `title="Sat Jan 1 00:00:00 UTC 2000"`)
assert.Contains(t, actual, `data-content="Sat Jan 1 00:00:00 UTC 2000"`)
assert.Contains(t, actual, expected)
}
test("1 second", time.Second)
Expand Down
8 changes: 0 additions & 8 deletions web_src/js/features/common-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ export function initGlobalTooltips() {
}

export function initGlobalCommon() {
// Show exact time
$('.time-since').each(function () {
$(this)
.addClass('tooltip')
.attr('data-content', $(this).attr('title'))
.attr('title', '');
});

// Undo Safari emoji glitch fix at high enough zoom levels
if (navigator.userAgent.match('Safari')) {
$(window).resize(() => {
Expand Down