From 71ae37ab0d414d124f0481ad20479215dbe97d9b Mon Sep 17 00:00:00 2001 From: supermamie Date: Tue, 3 Jul 2018 15:02:17 +0200 Subject: [PATCH] [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"}} --- src/js/yunohost/main.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index 0d87feb2..569ce7f4 100644 --- a/src/js/yunohost/main.js +++ b/src/js/yunohost/main.js @@ -50,6 +50,38 @@ + ''); }); + 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( + '' + + ' ' + + ''); + } + else + { + return new Handlebars.SafeString( + '' + + ' ' + + ''); + } + }); + // Load tooltips on the page; needed if using tooltips Handlebars.registerHelper('load_tooltips', function() { return new Handlebars.SafeString(