Module: NavbarHelper

Defined in:
app/helpers/navbar_helper.rb

Overview

Instance Method Summary collapse

Instance Method Details



27
28
29
30
31
# File 'app/helpers/navbar_helper.rb', line 27

def drop_down(name)
   :li, :class => "dropdown" do
    drop_down_link(name) + drop_down_list { yield }
  end
end


49
50
51
# File 'app/helpers/navbar_helper.rb', line 49

def drop_down_divider
   :li, "", :class => "divider"
end


53
54
55
# File 'app/helpers/navbar_helper.rb', line 53

def drop_down_header(text)
   :li, text, :class => "nav-header"
end


39
40
41
# File 'app/helpers/navbar_helper.rb', line 39

def drop_down_sublist(&block)
   :ul, :class => "dropdown-menu", &block
end


43
44
45
46
47
# File 'app/helpers/navbar_helper.rb', line 43

def drop_down_submenu(name, &block)
   :li, :class => "dropdown-submenu" do
    link_to(name, "") + drop_down_list(&block)
  end
end


33
34
35
36
37
# File 'app/helpers/navbar_helper.rb', line 33

def drop_down_with_submenu(name, &block)
   :li, :class => "dropdown" do
    drop_down_link(name) + drop_down_sublist(&block)
  end
end


57
58
59
# File 'app/helpers/navbar_helper.rb', line 57

def menu_divider
   :li, "", :class => "divider-vertical"
end


13
14
15
16
# File 'app/helpers/navbar_helper.rb', line 13

def menu_group(options={}, &block)
  pull_class = "pull-#{options[:pull].to_s}" if options[:pull].present?
  (:ul, :class => "nav #{pull_class}", &block)
end


18
19
20
21
22
23
24
25
# File 'app/helpers/navbar_helper.rb', line 18

def menu_item(name=nil, path="#", *args, &block)
  path = name || path if block_given?
  options = args.extract_options!
   :li, :class => is_active?(path, options) do
    name, path = path, options if block_given?
    link_to name, path, options, &block
  end
end


61
62
63
64
65
66
67
68
69
# File 'app/helpers/navbar_helper.rb', line 61

def menu_text(text=nil, options={}, &block)
  pull       = options.delete(:pull)
  pull_class = pull.present? ? "pull-#{pull.to_s}" : nil
  options.append_merge!(:class, pull_class)
  options.append_merge!(:class, "navbar-text")
   :p, options do
    text || yield
  end
end


3
4
5
6
7
8
9
10
11
# File 'app/helpers/navbar_helper.rb', line 3

def nav_bar(options={}, &block)
  nav_bar_div(options) do
    navbar_inner_div do
      container_div(options[:brand], options[:brand_link], options[:responsive], options[:fluid]) do
        yield if block_given?
      end
    end
  end
end

#uri_state(uri, options = {}) ⇒ Object

Returns current url or path state (useful for buttons). Example:

# Assume we'r currently at blog/categories/test
uri_state('/blog/categories/test', {})               # :active
uri_state('/blog/categories', {})                    # :chosen
uri_state('/blog/categories/test', {method: delete}) # :inactive
uri_state('/blog/categories/test/3', {})             # :inactive


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'app/helpers/navbar_helper.rb', line 78

def uri_state(uri, options={})
  root_url = request.host_with_port + '/'
  root = uri == '/' || uri == root_url

  request_uri = if uri.start_with?(root_url)
    request.url
  else
    request.path
  end

  if !options[:method].nil? || !options["data-method"].nil?
    :inactive
  elsif uri == request_uri
    :active
  else
    if request_uri.start_with?(uri) and not(root)
      :chosen
    else
      :inactive
    end
  end
end