Module: BootstrapHelper
- Included in:
- ComboboxInput
- Defined in:
- app/helpers/bootstrap_helper.rb
Instance Method Summary collapse
-
#boot_alert(*args, &block) ⇒ Object
Messages ========.
-
#boot_icon(type) ⇒ Object
Icons =====.
-
#boot_label(content, type = nil) ⇒ Object
Labels ======.
- #boot_nav_filter(name, entries, type = :link) ⇒ Object
-
#boot_nav_header(title, refresh_action = false) ⇒ Object
Navigation ==========.
- #boot_nav_li_checkbox(filter_name, param_value, title = nil, param_name = filter_name, current_value = , classes = [], &content) ⇒ Object
- #boot_nav_li_link(filter_name, param_value, title = nil, param_name = filter_name, current_value = , classes = [], &content) ⇒ Object
- #boot_no_entry_alert ⇒ Object
- #boot_page_title(action_or_title = nil, model = nil) ⇒ Object
-
#modal_header(title) ⇒ Object
Modal =====.
Instance Method Details
#boot_alert(*args, &block) ⇒ Object
Messages
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/bootstrap_helper.rb', line 46 def boot_alert(*args, &block) if block_given? type = args[0] content = capture(&block) else content = args[0] type = args[1] end type ||= 'info' content_tag(:div, :class => "alert alert-block alert-#{type} fade in") do link_to('×'.html_safe, '#', :class => 'close', 'data-dismiss' => 'alert') + content end end |
#boot_icon(type) ⇒ Object
Icons
22 23 24 |
# File 'app/helpers/bootstrap_helper.rb', line 22 def boot_icon(type) content_tag(:i, '', :class => "icon-#{type}") end |
#boot_label(content, type = nil) ⇒ Object
Labels
28 29 30 31 32 33 |
# File 'app/helpers/bootstrap_helper.rb', line 28 def boot_label(content, type = nil) return "" unless content.present? classes = ['label', "label-#{type}"].compact.join(' ') content_tag(:span, content, :class => classes) end |
#boot_nav_filter(name, entries, type = :link) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'app/helpers/bootstrap_helper.rb', line 121 def boot_nav_filter(name, entries, type = :link) refresh_action = (type == :checkbox) content_tag(:ul, :class => ['nav', 'nav-list']) do content = [] content << boot_nav_header(name, refresh_action) entries.each do |entry| if entry.is_a? Hash title = entry[:title] value = entry[:value] else title = value = entry end case type when :link content << boot_nav_li_link(name, value, title) when :checkbox content << boot_nav_li_checkbox(name, value, title) end end content.join("\n").html_safe end end |
#boot_nav_header(title, refresh_action = false) ⇒ Object
Navigation
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/helpers/bootstrap_helper.rb', line 67 def boot_nav_header(title, refresh_action = false) if title.is_a? Symbol title = t("#{title}.title") end content_tag(:li, :class => 'nav-header') do content = [title] if refresh_action content << content_tag(:button, :type => "submit", :style => 'border: none; background-color: transparent; float: right') do content_tag(:i, "", :class => 'icon-refresh') end end content.join("\n").html_safe end end |
#boot_nav_li_checkbox(filter_name, param_value, title = nil, param_name = filter_name, current_value = , classes = [], &content) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'app/helpers/bootstrap_helper.rb', line 99 def boot_nav_li_checkbox(filter_name, param_value, title = nil, param_name = filter_name, current_value = params[param_name], classes = [], &content) active = current_value.include? param_value.to_s classes << "active" if active title ||= param_value title = t("#{filter_name.to_s}.#{title}", :default => title) if block_given? content_tag(:li, :class => classes, &content) else content_tag(:li, :class => classes) do content_tag 'label', :class => 'checkbox' do content = [] content << content_tag('input', '', :type => 'checkbox', :checked => active, :name => "#{param_name}[]", :value => param_value) content << title content.join("\n").html_safe end end end end |
#boot_nav_li_link(filter_name, param_value, title = nil, param_name = filter_name, current_value = , classes = [], &content) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/helpers/bootstrap_helper.rb', line 84 def boot_nav_li_link(filter_name, param_value, title = nil, param_name = filter_name, current_value = params[param_name], classes = [], &content) classes << "active" if current_value.to_s == param_value.to_s title ||= param_value title = t("#{filter_name.to_s}.#{title}", :default => title) if block_given? content_tag(:li, :class => classes, &content) else content_tag(:li, :class => classes) do url = url_for(params.merge({param_name => param_value})) link_to title, url end end end |
#boot_no_entry_alert ⇒ Object
61 62 63 |
# File 'app/helpers/bootstrap_helper.rb', line 61 def boot_no_entry_alert boot_alert t('alerts.empty') end |
#boot_page_title(action_or_title = nil, model = nil) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/bootstrap_helper.rb', line 2 def boot_page_title(action_or_title = nil, model = nil) if action_or_title.is_a? String title = action_or_title else action = action_or_title || action_name if action.to_s == 'show' && defined?(resource) && resource.present? title = resource.to_s else title = t_title(action, model) end end content_for :page_title, title content_tag(:div, :class => 'page-header') do content_tag(:h1, title) end end |
#modal_header(title) ⇒ Object
Modal
37 38 39 40 41 42 |
# File 'app/helpers/bootstrap_helper.rb', line 37 def modal_header(title) content_tag(:div, :class => 'modal-header') do content_tag(:button, '×'.html_safe, :type => 'button', :class => 'close', 'data-dismiss' => 'modal') + content_tag(:h3, title) end end |