Module: ContourHelper
- Defined in:
- app/helpers/contour_helper.rb
Instance Method Summary collapse
- #cancel ⇒ Object
-
#flash_block ⇒ Object
From Twitter-Bootstrap-Rails.
-
#flash_container(type, message) ⇒ Object
From Twitter-Bootstrap-Rails.
- #sort_field_helper(order, sort_field, display_name) ⇒ Object
Instance Method Details
#cancel ⇒ Object
3 4 5 |
# File 'app/helpers/contour_helper.rb', line 3 def cancel link_to 'Cancel', URI.parse(request.referer.to_s).path.blank? ? root_path : (URI.parse(request.referer.to_s).path), class: 'btn btn-default' end |
#flash_block ⇒ Object
From Twitter-Bootstrap-Rails
17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/contour_helper.rb', line 17 def flash_block output = '' flash.each do |type, | unless session["user_return_to"] == root_path and I18n.t("devise.failure.unauthenticated") == output += flash_container(type, ) if ['alert', 'notice', 'error', 'warning', 'success', 'info'].include?(type.to_s) end end raw(output) end |
#flash_container(type, message) ⇒ Object
From Twitter-Bootstrap-Rails
29 30 31 32 33 34 35 36 |
# File 'app/helpers/contour_helper.rb', line 29 def flash_container(type, ) type = 'success' if type.to_s == 'notice' type = 'danger' if ['alert', 'error'].include?(type.to_s) content_tag(:div, class: "navbar-alert alert alert-#{type}") do content_tag(:a, raw("×"), href: '#', class: 'close', data: { dismiss: 'alert' }) + end.html_safe end |
#sort_field_helper(order, sort_field, display_name) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/helpers/contour_helper.rb', line 7 def sort_field_helper(order, sort_field, display_name) sort_field_order = (order == sort_field) ? "#{sort_field} DESC" : sort_field symbol = (order == sort_field) ? '»' : (order == sort_field + ' DESC' ? '«' : '«»') selected_class = (order == sort_field) ? 'selected' : (order == sort_field + ' DESC' ? 'selected' : '') content_tag(:span, class: selected_class) do display_name.to_s.html_safe + ' ' + link_to(raw(symbol), url_for( params.merge( order: sort_field_order ) ), style: 'text-decoration:none') end.html_safe end |