Sha256: e9fcb6f11b48e7c3d2eaeeb077cec046ca839db785e48c7cdd79899bacd9e23e

Contents?: true

Size: 1.54 KB

Versions: 9

Compression:

Stored size: 1.54 KB

Contents

module ContourHelper

  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-cancel-inverse'
  end

  def sort_field_helper(order, sort_field, display_name, search_form_id  = 'search_form')
    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), '#', data: { object: 'order', order: sort_field_order, form: "##{search_form_id}" }, style: 'text-decoration:none')
    end.html_safe
  end

  # From Twitter-Bootstrap-Rails
  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

  # From Twitter-Bootstrap-Rails
  def flash_container(type, message)
    type = 'success' if type.to_s == 'notice'
    type = 'error' if type.to_s == 'alert'
    content_tag(:div, class: "navbar-alert alert alert-#{type}") do
      content_tag(:a, raw("×"), href: '#', class: 'close', data: { dismiss: 'alert' }) + message
    end.html_safe
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
contour-2.1.0.beta10 app/helpers/contour_helper.rb
contour-2.1.0.beta9 app/helpers/contour_helper.rb
contour-2.1.0.beta8 app/helpers/contour_helper.rb
contour-2.1.0.beta7 app/helpers/contour_helper.rb
contour-2.1.0.beta6 app/helpers/contour_helper.rb
contour-2.1.0.beta5 app/helpers/contour_helper.rb
contour-2.1.0.beta4 app/helpers/contour_helper.rb
contour-2.1.0.beta3 app/helpers/contour_helper.rb
contour-2.1.0.beta2 app/helpers/contour_helper.rb