Module: Kadmin::BootstrapHelper
- Defined in:
- app/helpers/kadmin/bootstrap_helper.rb
Overview
Collection of Bootstrap helpers
Instance Method Summary collapse
-
#create_custom_label(label, label_for = '', required = false, display_help = true, title = '', message = '', label_class = 'control-label') ⇒ Object
Custom label generator using bootstrap i.e.
-
#dropdown(prompt, links = []) ⇒ Object
Generates a navigation drop down for bootstrap.
- #glyphicon(icon) ⇒ Object
- #glyphicon_if_else(condition, icon_true, icon_false) ⇒ Object
- #thumbnail_link(url_options, max_height) ⇒ Object
Instance Method Details
#create_custom_label(label, label_for = '', required = false, display_help = true, title = '', message = '', label_class = 'control-label') ⇒ Object
Custom label generator using bootstrap i.e. * for mendatory feilds, help icon and popover for help
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/helpers/kadmin/bootstrap_helper.rb', line 54 def create_custom_label(label, label_for = '', required = false, display_help = true, title = '', = '', label_class = 'control-label') label = t(label) label = label.html_safe require_html = required ? '<span class="required-field"><span>' : '' icon_html = "<i class='fa fa-question-circle' style='color:green'></i>" = '' if display_help = t() = .gsub('"', '\"') = .gsub("'", "\'") = .html_safe title = t(title) title = title.html_safe = "<span data-toggle='popover' title='#{title}' data-placement='top' data-trigger='hover' data-content='#{}'>#{icon_html}</span>" end return "<label for='#{label_for}' class='#{label_class}'' >#{require_html}#{label} #{}</label>".html_safe end |
#dropdown(prompt, links = []) ⇒ Object
Generates a navigation drop down for bootstrap
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/kadmin/bootstrap_helper.rb', line 34 def dropdown(prompt, links = []) = content_tag(:span, '', class: 'caret').prepend(prompt) = (, type: 'button', data: { toggle: 'dropdown' }, class: 'btn btn-sm') list = content_tag(:ul, '', class: 'dropdown-menu') do links.reduce(ActiveSupport::SafeBuffer.new) do |buffer, link| buffer + content_tag(:li, link) end end return content_tag(:div, + list, class: 'dropdown', style: 'display: inline-block;') end |
#glyphicon(icon) ⇒ Object
8 9 10 |
# File 'app/helpers/kadmin/bootstrap_helper.rb', line 8 def glyphicon(icon) return "<i class='fa fa-#{icon}' aria-hidden='true'></i>".html_safe end |
#glyphicon_if_else(condition, icon_true, icon_false) ⇒ Object
15 16 17 |
# File 'app/helpers/kadmin/bootstrap_helper.rb', line 15 def glyphicon_if_else(condition, icon_true, icon_false) return condition ? glyphicon(icon_true) : glyphicon(icon_false) end |
#thumbnail_link(url_options, max_height) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/kadmin/bootstrap_helper.rb', line 21 def thumbnail_link(, max_height) return link_to( image_tag(), , class: 'thumbnail', style: "max-height: #{max_height}px", target: 'new' ) end |