Module: OrangewebBootStrapHelper::ViewHelper
- Defined in:
- lib/orangeweb_bootstrap_helper/view_helper.rb
Overview
Extends Application Helpers
Instance Method Summary collapse
- #active_inactive_label(val) ⇒ Object
- #alert_block(title, alert_context = :alert, &block) ⇒ Object
- #alert_inline(title, alert_context = :alert, &block) ⇒ Object
- #badge_default(value) ⇒ Object
- #badge_important(value) ⇒ Object
- #badge_info(value) ⇒ Object
- #badge_inverse(value) ⇒ Object
- #badge_success(value) ⇒ Object
- #badge_warning(value) ⇒ Object
- #bootstrap_badge(value, type) ⇒ Object
- #bootstrap_label(value, type) ⇒ Object
- #button_to_cancel(title, link, opts = {}) ⇒ Object
- #button_to_crud(title, link, ico, color, opts = {}) ⇒ Object
-
#button_to_delete(title, link, opts = {}) ⇒ Object
Cria um botao para novos registros.
- #button_to_edit(title, link, opts = {}) ⇒ Object
- #button_to_new(title, link, opts = {}) ⇒ Object
- #fieldset(title, &block) ⇒ Object
- #form_actions(form, back_url, submit_title = "Gravar", cancel_title = "Cancelar") ⇒ Object
- #form_actions_block(&block) ⇒ Object
- #icon(ico, color = :black) ⇒ Object
- #label_default(value) ⇒ Object
- #label_important(value) ⇒ Object
- #label_info(value) ⇒ Object
- #label_inverse(value) ⇒ Object
- #label_success(value) ⇒ Object
- #label_warning(value) ⇒ Object
- #link_to_back(title, link, opts = {}) ⇒ Object
- #link_to_blank(title, link, opts = {}) ⇒ Object
- #link_to_cancel(title, link, opts = {}) ⇒ Object
- #link_to_crud(title, link, ico, opts = {}) ⇒ Object
- #link_to_delete(title, link, opts = {}) ⇒ Object
- #link_to_edit(title, link, opts = {}) ⇒ Object
- #link_to_icon(title, link, ico, opts = {}) ⇒ Object
- #link_to_new(title, link, opts = {}) ⇒ Object
- #link_to_self(link, opts = {}) ⇒ Object
- #link_to_self_blank(link) ⇒ Object
- #page_section(title, options = {}) ⇒ Object
- #page_section_fluid(title, options = {}) ⇒ Object
- #popover(title, content, options = {}) ⇒ Object
- #row(options = { :class => "" }, &block) ⇒ Object
- #row_fluid(options = { :class => "" }, &block) ⇒ Object
- #show_notice ⇒ Object
- #show_notifications(val) ⇒ Object
- #span(cols, options = {}, &block) ⇒ Object
- #toolbar(&block) ⇒ Object
- #tooltip_link(title, link, tooltip, opts = {}) ⇒ Object
- #yes_no_label(val) ⇒ Object
Instance Method Details
#active_inactive_label(val) ⇒ Object
191 192 193 194 195 196 197 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 191 def active_inactive_label val if val then label_success "Ativo" else label_important "Inativo" end end |
#alert_block(title, alert_context = :alert, &block) ⇒ Object
205 206 207 208 209 210 211 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 205 def alert_block title, alert_context = :alert, &block raw '<div class="alert alert-block alert-' + alert_context.to_s + '" >' + ' <a class="close" data-dismiss="alert" href="#">×</a>' + ' <h4 class="alert-heading">' + title + '</h4>' + capture(&block) + '</div>' end |
#alert_inline(title, alert_context = :alert, &block) ⇒ Object
213 214 215 216 217 218 219 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 213 def alert_inline title, alert_context = :alert, &block raw '<div class="alert alert-' + alert_context.to_s + '" >' + ' <a class="close" data-dismiss="alert" href="#">×</a>' + ' <strong class="alert-heading">' + title + '</strong>' + capture(&block) + '</div>' end |
#badge_default(value) ⇒ Object
38 39 40 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 38 def badge_default value bootstrap_badge value, :default end |
#badge_important(value) ⇒ Object
50 51 52 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 50 def badge_important value bootstrap_badge value, :important end |
#badge_info(value) ⇒ Object
54 55 56 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 54 def badge_info value bootstrap_badge value, :info end |
#badge_inverse(value) ⇒ Object
58 59 60 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 58 def badge_inverse value bootstrap_badge value, :inverse end |
#badge_success(value) ⇒ Object
42 43 44 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 42 def badge_success value bootstrap_badge value, :success end |
#badge_warning(value) ⇒ Object
46 47 48 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 46 def badge_warning value bootstrap_badge value, :warning end |
#bootstrap_badge(value, type) ⇒ Object
34 35 36 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 34 def bootstrap_badge value, type raw(content_tag :span, value, :class => "badge badge-#{type.to_s}") end |
#bootstrap_label(value, type) ⇒ Object
62 63 64 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 62 def bootstrap_label value, type raw(content_tag :span, value, :class => "label label-#{type.to_s}") end |
#button_to_cancel(title, link, opts = {}) ⇒ Object
162 163 164 165 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 162 def title, link, opts={} opts[:class] = "btn-default" title, link, :arrow_left, :black, opts end |
#button_to_crud(title, link, ico, color, opts = {}) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 144 def title, link, ico, color, opts={} opts[:class] += " btn " unless opts[:small].nil? then opts[:class] += " btn-small " opts.delete(:small) end unless opts[:mini].nil? then opts[:class] += " btn-mini " opts.delete(:mini) end link_to raw( icon(ico.to_sym, color.to_sym) + " " + title ).to_s, link, opts end |
#button_to_delete(title, link, opts = {}) ⇒ Object
Cria um botao para novos registros
174 175 176 177 178 179 180 181 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 174 def title, link, opts={} opts = { method: :delete, data: { confirm: 'Tem certeza que deseja apagar este registro?' } } opts[:class] = "btn-danger" title, link, :trash, :white, opts end |
#button_to_edit(title, link, opts = {}) ⇒ Object
157 158 159 160 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 157 def title, link, opts={} opts[:class] = "btn-warning" title, link, :pencil, :white, opts end |
#button_to_new(title, link, opts = {}) ⇒ Object
167 168 169 170 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 167 def title, link, opts={} opts[:class] = "btn-primary" title, link, :plus, :white, opts end |
#fieldset(title, &block) ⇒ Object
227 228 229 230 231 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 227 def fieldset title, &block raw '<div class="form-inputs"><fieldset><legend>' + title + "</legend>" + capture(&block) + "</fieldset></div>" end |
#form_actions(form, back_url, submit_title = "Gravar", cancel_title = "Cancelar") ⇒ Object
237 238 239 240 241 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 237 def form_actions form, back_url, submit_title = "Gravar", cancel_title = "Cancelar" form_actions_block do (form. :submit, submit_title) + " " + (link_to cancel_title, back_url) end end |
#form_actions_block(&block) ⇒ Object
233 234 235 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 233 def form_actions_block &block content_tag(:div, capture(&block), :class => "form-actions" ) end |
#icon(ico, color = :black) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 27 def icon(ico, color = :black) ico = ico.to_s color = color.to_s ico.gsub!(/_/, "-") raw(content_tag :i, "", :class => "icon icon-#{ico} icon-#{color}") end |
#label_default(value) ⇒ Object
66 67 68 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 66 def label_default value bootstrap_label value, :default end |
#label_important(value) ⇒ Object
78 79 80 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 78 def label_important value bootstrap_label value, :important end |
#label_info(value) ⇒ Object
82 83 84 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 82 def label_info value bootstrap_label value, :info end |
#label_inverse(value) ⇒ Object
86 87 88 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 86 def label_inverse value bootstrap_label value, :inverse end |
#label_success(value) ⇒ Object
70 71 72 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 70 def label_success value bootstrap_label value, :success end |
#label_warning(value) ⇒ Object
74 75 76 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 74 def label_warning value bootstrap_label value, :warning end |
#link_to_back(title, link, opts = {}) ⇒ Object
132 133 134 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 132 def link_to_back title, link, opts={} link_to_cancel title, link, opts end |
#link_to_blank(title, link, opts = {}) ⇒ Object
115 116 117 118 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 115 def link_to_blank title, link, opts={} opts[:target] = :blank link_to raw(title + " " + icon(:share_alt)).to_s, link.to_s.delete('http://').insert(0, 'http://'), opts end |
#link_to_cancel(title, link, opts = {}) ⇒ Object
128 129 130 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 128 def link_to_cancel title, link, opts={} link_to_crud title, link, :arrow_left, opts end |
#link_to_crud(title, link, ico, opts = {}) ⇒ Object
120 121 122 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 120 def link_to_crud title, link, ico, opts={} link_to raw( icon(ico.to_sym) + " " + title ).to_s, link, opts end |
#link_to_delete(title, link, opts = {}) ⇒ Object
140 141 142 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 140 def link_to_delete title, link, opts={} link_to_crud title, link, :trash, method: :delete, data: { confirm: 'Tem certeza que deseja apagar este registro?' } end |
#link_to_edit(title, link, opts = {}) ⇒ Object
124 125 126 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 124 def link_to_edit title, link, opts={} link_to_crud title, link, :pencil, opts end |
#link_to_icon(title, link, ico, opts = {}) ⇒ Object
102 103 104 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 102 def link_to_icon title, link, ico, opts={} link_to raw( icon(ico.to_sym) + " " + title ).to_s, link, opts end |
#link_to_new(title, link, opts = {}) ⇒ Object
136 137 138 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 136 def link_to_new title, link, opts={} link_to_crud title, link, :plus, opts end |
#link_to_self(link, opts = {}) ⇒ Object
106 107 108 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 106 def link_to_self link, opts={} link_to link, link.to_s.delete('http://').insert(0, 'http://'), opts end |
#link_to_self_blank(link) ⇒ Object
110 111 112 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 110 def link_to_self_blank link link_to_blank link, link end |
#page_section(title, options = {}) ⇒ Object
272 273 274 275 276 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 272 def page_section title, = {} if [:class].nil? then [:class] = "" end [:class].insert(-1, " row-fluid") raw content_tag(:div, (content_tag(:h3, title) << content_tag(:br)), ) end |
#page_section_fluid(title, options = {}) ⇒ Object
266 267 268 269 270 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 266 def page_section_fluid title, = {} if [:class].nil? then [:class] = "" end [:class].insert(-1, " row-fluid") raw content_tag(:div, (content_tag(:hr) << content_tag(:h3, title) << content_tag(:br)), ) end |
#popover(title, content, options = {}) ⇒ Object
90 91 92 93 94 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 90 def popover title, content, ={} [:rel] = "popover" [:data] = { :content => content, "original-title" => title } link_to icon(:info_sign), "#", end |
#row(options = { :class => "" }, &block) ⇒ Object
243 244 245 246 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 243 def row = { :class => "" }, &block [:class].insert(-1, " row") content_tag(:div, capture(&block), ) end |
#row_fluid(options = { :class => "" }, &block) ⇒ Object
248 249 250 251 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 248 def row_fluid = { :class => "" }, &block [:class].insert(-1, " row-fluid") content_tag(:div, capture(&block), ) end |
#show_notice ⇒ Object
221 222 223 224 225 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 221 def show_notice unless notice.nil? then raw(content_tag :div, (alert_inline "Notificação: ", :info do content_tag(:span, notice) end), :id => "notice") end end |
#show_notifications(val) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 16 def show_notifications val out = "<div class=\alert\">" << "<button class=\"close\" data-dismiss=\"alert\">×</button>" << "<strong>Warning!</strong> #{val}." << "</div>" raw out end |
#span(cols, options = {}, &block) ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 253 def span cols, ={}, &block offset = "" unless [:offset].nil? then offset = " offset#{[:offset]} " end if [:class].nil? then [:class] = "" end .delete(:offset) [:class].insert(-1, " span#{cols}" + offset) content_tag(:div, capture(&block), ) end |
#toolbar(&block) ⇒ Object
199 200 201 202 203 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 199 def &block raw '<div class="well">' + capture(&block) + "</div>" end |
#tooltip_link(title, link, tooltip, opts = {}) ⇒ Object
96 97 98 99 100 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 96 def tooltip_link title, link, tooltip, opts={} opts[:rel] = "tooltip" opts[:tooltip] = tooltip link_to title, link, opts end |
#yes_no_label(val) ⇒ Object
183 184 185 186 187 188 189 |
# File 'lib/orangeweb_bootstrap_helper/view_helper.rb', line 183 def yes_no_label val if val then label_success "Sim" else label_default "Não" end end |