Module: ContourHelper

Defined in:
app/helpers/contour_helper.rb

Instance Method Summary collapse

Instance Method Details

#cancelObject



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_blockObject

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, message|
    unless session["user_return_to"] == root_path and I18n.t("devise.failure.unauthenticated") == message
      output += flash_container(type, message) 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, message)
  type = 'success' if type.to_s == 'notice'
  type = 'danger' if ['alert', 'error'].include?(type.to_s)

  (:div, class: "navbar-alert alert alert-#{type}") do
    (:a, raw("×"), href: '#', class: 'close', data: { dismiss: 'alert' }) + message
  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' : '')
  (: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