[enh] add a template to display a clickable help

The template name is helpTooltip and can be called with 2 arguments : help text and optional url.
Here are a few examples :
{{helpTooltip (t 'user_fullname_help') (t 'user_fullname_help_url')}}
{{helpTooltip (t 'user_fullname_help')}}
{{helpTooltip "This is some help" "https://some.help.url/this_is_the_help"}}
{{helpTooltip "Some help, without link"}}
This commit is contained in:
supermamie 2018-07-03 15:02:17 +02:00
parent df67dd6a44
commit 71ae37ab0d

View file

@ -50,6 +50,38 @@
+ '</span>');
});
Handlebars.registerHelper('helpTooltip', function(text, url) {
var help = null;
var helpUrl = null;
if (text && text.string && text.string.trim() != "")
{
help = text.string;
}
if (url && url.string && url.string.trim() != "")
{
helpUrl = url.string;
}
if (help == null && helpUrl == null)
{
return "";
}
if (helpUrl == null)
{
return new Handlebars.SafeString(
'<span data-toggle="tooltip" title="' + help + '" data-html="true" data-placement="right">'
+ ' <i class="fa-question-circle"></i>'
+ '</span>');
}
else
{
return new Handlebars.SafeString(
'<span data-toggle="tooltip" title="' + help + '" data-html="true" data-placement="right">'
+ ' <a href="' + helpUrl + '" class="fa-question-circle"></a>'
+ '</span>');
}
});
// Load tooltips on the page; needed if using tooltips
Handlebars.registerHelper('load_tooltips', function() {
return new Handlebars.SafeString(