Skip to content

Commit 23a6fa9

Browse files
GiteaBotsilverwind
andauthored
Make time tooltips interactive (#23526) (#23527)
Backport #23526 by @silverwind Fixes https://codeberg.org/forgejo/forgejo/issues/511 <img width="379" alt="Screenshot 2023-03-16 at 20 23 10" src="https://user-images.githubusercontent.com/115237/225731294-4c6e4f44-bdcc-4c8c-86e2-49f7c03b377d.png"> Co-authored-by: silverwind <me@silverwind.io>
1 parent b7c2f48 commit 23a6fa9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: modules/timeutil/since.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func TimeSince(then time.Time, lang translation.Locale) template.HTML {
233233
}
234234

235235
func htmlTimeSince(then, now time.Time, lang translation.Locale) template.HTML {
236-
return template.HTML(fmt.Sprintf(`<span class="time-since tooltip" data-content="%s">%s</span>`,
236+
return template.HTML(fmt.Sprintf(`<span class="time-since tooltip" data-content="%s" data-tooltip-interactive="true">%s</span>`,
237237
then.In(setting.DefaultUILocation).Format(GetTimeFormat(lang.Language())),
238238
timeSince(then, now, lang)))
239239
}
@@ -244,7 +244,7 @@ func TimeSinceUnix(then TimeStamp, lang translation.Locale) template.HTML {
244244
}
245245

246246
func htmlTimeSinceUnix(then, now TimeStamp, lang translation.Locale) template.HTML {
247-
return template.HTML(fmt.Sprintf(`<span class="time-since tooltip" data-content="%s">%s</span>`,
247+
return template.HTML(fmt.Sprintf(`<span class="time-since tooltip" data-content="%s" data-tooltip-interactive="true">%s</span>`,
248248
then.FormatInLocation(GetTimeFormat(lang.Language()), setting.DefaultUILocation),
249249
timeSinceUnix(int64(then), int64(now), lang)))
250250
}

Diff for: web_src/js/modules/tippy.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function initTooltip(el, props = {}) {
3333
content,
3434
delay: 100,
3535
role: 'tooltip',
36+
...(el.getAttribute('data-tooltip-interactive') === 'true' ? {interactive: true} : {}),
3637
...props,
3738
});
3839
}

0 commit comments

Comments
 (0)