Module: Twitter::Bootswatch::FlashHelper
- Defined in:
- app/helpers/twitter/bootswatch/flash_helper.rb
Instance Method Summary collapse
- #bootswatch_alert_types(alert_type) ⇒ Object
- #bootswatch_flash(alert_dismissable = true) ⇒ Object
- #bootswatch_flash_block(alert_dismissable = true) ⇒ Object
- #bootswatch_flash_container(type, alert_dismissable = true, &message) ⇒ Object
Instance Method Details
#bootswatch_alert_types(alert_type) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/twitter/bootswatch/flash_helper.rb', line 48 def bootswatch_alert_types(alert_type) #Rails 4.1 started using Strings instead of Symbol. case alert_type when :info, 'info' then 'alert-info' when :notice, :success, 'notice', 'success' then 'alert-success' when :alert, :error, 'alert', 'error' then 'alert-danger' else 'alert-warning' # warning end end |
#bootswatch_flash(alert_dismissable = true) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/twitter/bootswatch/flash_helper.rb', line 5 def bootswatch_flash(alert_dismissable=true) alert_dismissable_class = alert_dismissable ? ' alert-dismissable' : '' = '' flash.each do |type, | alert_type_class = bootswatch_alert_types(type) if alert_dismissable alert_div = content_tag(:div, raw('<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>') + , :class => "alert #{alert_type_class}#{alert_dismissable_class}") else alert_div = content_tag(:div, raw(), :class => "alert #{alert_type_class}") end << alert_div if end raw() end |
#bootswatch_flash_block(alert_dismissable = true) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/twitter/bootswatch/flash_helper.rb', line 20 def bootswatch_flash_block(alert_dismissable=true) output = '' flash.each do |type, | output << bootswatch_flash_container(type, alert_dismissable) do end end raw(output) end |
#bootswatch_flash_container(type, alert_dismissable = true, &message) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/twitter/bootswatch/flash_helper.rb', line 31 def bootswatch_flash_container(type, alert_dismissable=true, &) alert_dismissable_class = alert_dismissable ? ' alert-dismissable' : '' alert_type_class = bootswatch_alert_types(type) = capture(&) if alert_dismissable output = content_tag(:div, :class => "alert #{alert_type_class}#{alert_dismissable_class}") do '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'.html_safe.safe_concat() end else output = content_tag(:div, :class => "alert #{alert_type_class}") do .html_safe end end raw(output) end |