BlueGit

timfa bluegit

Files

bluegit / internal / runnercfg / tip.go

tip.go

tip.go 946 B Download Raw
1package runnercfg
2
3import (
4 "html/template"
5 "strings"
6
7 "gitlab.com/Timfa/bluegit/internal/i18n"
8)
9
10// Tip maakt een info-icoon (i) met uitleg uit de catalogus. Het is een
11// span (geen button), zodat het label van het omringende veld blijft
12// wijzen naar het invoerveld; tip.js maakt hem bedienbaar met tik/Enter.
13// De uitleg verschijnt bij hover, toetsenbordfocus en als het veld in
14// hetzelfde .tiphost-element focus heeft.
15func Tip(lang i18n.Lang, key string) template.HTML {
16 id := "tip-" + strings.NewReplacer(".", "-", "_", "-").Replace(key)
17 text := template.HTMLEscapeString(i18n.T(lang, key))
18 info := template.HTMLEscapeString(i18n.T(lang, "tip.info"))
19 return template.HTML(`<span class="tip"><span class="tip-i" role="button" tabindex="0" aria-expanded="false" aria-label="` + info + `" aria-describedby="` + id + `">i</span><span class="tip-b" role="tooltip" id="` + id + `" title="` + text + `">` + text + `</span></span>`)
20}