Brad
Brad is a very simple Gem for Rails that uses Bootstrap3 Popovers to add contextual help to any document element.
It can also generate an help button if needed.
The default help button code uses fontawesome, but you can change it as you like.
The contents of the popover are taken from the language files (I18n).
Usage:
with the help icon:
help_me_brad(key)
where key is the key to the translation, as in t(key)
Example
help_me_brad('brad.help_key_foo')
without the help icon:
help_me_brad(key, help_button:false)
this line renders the hidden popover contents div
then, in the triggering element
data: brad_data_options(key, derp: 'herp')
the brad_data_options(key, opts = {})
helper method generates all the data options needed to transform any element into a trigger for Brad popovers
Example
text_field_tag 'this_field_requires_some_explanations', data: brad_data_options('foo.help_key_bar')
Language file structure
foo:
help_key_bar:
title_html: The title key must be title_html
text_html: The text key must be text_html and, as the title, it can contain <em>html!</em>
Options
You can use all the Bootstrap popover options, plus the button_html
option, to customize the html button code
the default button HTML is
<i class="fa fa-question-circle fa-lg text-info"></i>
and the default popover template is
<div class="brad popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>
Example
help_me_brad('foo.help_key_bar', trigger: "click", placement: "bottom", animation: "false")