Skip to content

Commit

Permalink
Make time tooltips interactive (go-gitea#23526)
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind authored and GiteaBot committed Mar 16, 2023
1 parent b7c2f48 commit ed0d397
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/timeutil/since.go
Expand Up @@ -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)))
}
Expand All @@ -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)))
}
1 change: 1 addition & 0 deletions web_src/js/modules/tippy.js
Expand Up @@ -33,6 +33,7 @@ export function initTooltip(el, props = {}) {
content,
delay: 100,
role: 'tooltip',
...(el.getAttribute('data-tooltip-interactive') === 'true' ? {interactive: true} : {}),
...props,
});
}
Expand Down

0 comments on commit ed0d397

Please sign in to comment.