Method: ApplicationHelper#legend_tag
- Defined in:
- lib/mir_utility.rb
#legend_tag(text, args = {}) ⇒ Object
DRY way to return a legend tag that renders correctly in all browsers
Sample usage:
<%= legend_tag "Report Criteria" -%>
Sample usage with help text:
<%= legend_tag "Report Criteria", :help => "Some descriptive copy here." -%>
<span id="hide_or_show_backlinks" class="show_link" style="background-color: #999999;
border: 1px solid #999999;" onclick="javascript:hide_or_show('backlinks');"></span>Backlinks (<%=
@google_results.size -%>)
<%- end -%>
Recommended CSS to support display of help icon and text:
.help_icon {
display: block;
float: left;
margin-top: -16px;
margin-left: 290px;
border-left: 1px solid #444444;
padding: 3px 6px;
cursor: pointer;
}
div.popup_help {
color: #666666;
width: 98%;
background: #ffffff;
padding: 1em;
border: 1px solid #999999;
margin: 1em 0em;
}
341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/mir_utility.rb', line 341 def legend_tag(text, args={}) args[:id] ||= text.downcase.gsub(/ /,'_') if args[:help] _html = %{<div id="#{args[:id]}" class="faux_legend">#{text}<span class="help_icon" onclick="$('#{args[:id]}_help').toggle();">?</span></div>\r} _html << %{<div id="#{args[:id]}_help" class="popup_help" style="display: none;">#{args[:help]}<br /></div>\r} else _html = %{<div id="#{args[:id]}" class="faux_legend">#{text}</div>\r} end _html.gsub!(/ id=""/,'') _html.gsub!(/ class=""/,'') _html end |