Module: InsteddRails::ApplicationHelper

Defined in:
app/helpers/instedd_rails/application_helper.rb

Defined Under Namespace

Classes: BreadcrumbBuilder

Instance Method Summary collapse

Instance Method Details

#application_nameObject



55
56
57
# File 'app/helpers/instedd_rails/application_helper.rb', line 55

def application_name
    InsteddRails.config.application_name
end


27
28
29
# File 'app/helpers/instedd_rails/application_helper.rb', line 27

def breadcrumb
  raw render_breadcrumbs :builder => BreadcrumbBuilder
end

#css_sort_class_for(column) ⇒ Object



47
48
49
# File 'app/helpers/instedd_rails/application_helper.rb', line 47

def css_sort_class_for column
  column == sort_column ? "sort #{css_sort_direction}" : "sort"
end

#css_sort_directionObject



51
52
53
# File 'app/helpers/instedd_rails/application_helper.rb', line 51

def css_sort_direction
  sort_direction == "asc" ? "up" : "down"
end

#google_analyticsObject



59
60
61
# File 'app/helpers/instedd_rails/application_helper.rb', line 59

def google_analytics
    InsteddRails.config.google_analytics
end


15
16
17
18
19
20
# File 'app/helpers/instedd_rails/application_helper.rb', line 15

def link_button_to(body, url, html_options = {})
  default_options = { :type => 'button', :class => 'white' }
  onclick = "window.location='#{url}';return false;"

  (:button, body, default_options.merge(html_options.merge(:onclick => onclick)))
end

#section(title, url, name, active_controllers = [name]) ⇒ Object



22
23
24
25
# File 'app/helpers/instedd_rails/application_helper.rb', line 22

def section title, url, name, active_controllers = [name]
  active = active_controllers.any?{|controller| controller_name == controller.to_s }
  raw "<li class=\"#{active ? "active" : ""}\">#{link_to title, url}</li>"
end

#sortable(column, title = nil) ⇒ Object



40
41
42
43
44
45
# File 'app/helpers/instedd_rails/application_helper.rb', line 40

def sortable(column, title = nil)
  title ||= column.titleize
  page_number = params[:page]
  direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
  (link_to title, :sort => column, :direction => direction, :page => params[:page]) + '<span></span>'.html_safe
end

#tab(label, path = nil) ⇒ Object



31
32
33
34
35
36
37
38
# File 'app/helpers/instedd_rails/application_helper.rb', line 31

def tab(label, path = nil)
  s = "<li"
  s << ' class="active"' if path && current_page?(path)
  s << ">"
  s << (link_to label, path)
  s << "</li>"
  raw s
end

#version_nameObject



63
64
65
# File 'app/helpers/instedd_rails/application_helper.rb', line 63

def version_name
  InsteddRails.config.version_name
end