aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-03-16 17:23:11 -0400
committerGitHub <noreply@github.com>2023-03-16 16:23:11 -0500
commit23a6fa9421cfcf67754ff962782dcf99e6491bb9 (patch)
tree61055d6d08effa6d92cef7b619247401c84b7453
parentb7c2f48ebfd7ab2c834f08aaa24626d1109dd542 (diff)
downloadgitea-23a6fa9421cfcf67754ff962782dcf99e6491bb9.tar.gz
gitea-23a6fa9421cfcf67754ff962782dcf99e6491bb9.zip
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>
-rw-r--r--modules/timeutil/since.go4
-rw-r--r--web_src/js/modules/tippy.js1
2 files changed, 3 insertions, 2 deletions
diff --git a/modules/timeutil/since.go b/modules/timeutil/since.go
index 295ba7c10e..53c22258c4 100644
--- a/modules/timeutil/since.go
+++ b/modules/timeutil/since.go
@@ -233,7 +233,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 tooltip" data-content="%s">%s</span>`,
+ return template.HTML(fmt.Sprintf(`<span class="time-since tooltip" data-content="%s" data-tooltip-interactive="true">%s</span>`,
then.In(setting.DefaultUILocation).Format(GetTimeFormat(lang.Language())),
timeSince(then, now, lang)))
}
@@ -244,7 +244,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 tooltip" data-content="%s">%s</span>`,
+ return template.HTML(fmt.Sprintf(`<span class="time-since tooltip" data-content="%s" data-tooltip-interactive="true">%s</span>`,
then.FormatInLocation(GetTimeFormat(lang.Language()), setting.DefaultUILocation),
timeSinceUnix(int64(then), int64(now), lang)))
}
diff --git a/web_src/js/modules/tippy.js b/web_src/js/modules/tippy.js
index ce8f0369f1..720f8ba53b 100644
--- a/web_src/js/modules/tippy.js
+++ b/web_src/js/modules/tippy.js
@@ -33,6 +33,7 @@ export function initTooltip(el, props = {}) {
content,
delay: 100,
role: 'tooltip',
+ ...(el.getAttribute('data-tooltip-interactive') === 'true' ? {interactive: true} : {}),
...props,
});
}