Module: BootstrapNavbar::Helpers::Bootstrap2

Defined in:
lib/bootstrap-navbar/helpers/bootstrap2.rb

Instance Method Summary collapse

Instance Method Details



2
3
4
5
6
7
8
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 2

def navbar(options = {}, wrapper_options = {}, &block)
  wrapper options, wrapper_options do
    inner_wrapper do
      container options[:brand], options[:brand_link], options[:responsive], options[:fluid], &block
    end
  end
end


90
91
92
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 90

def navbar_brand_link(name, url = nil)
  prepare_html %(<a href="#{url || '/'}" class="brand">#{name}</a>)
end


76
77
78
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 76

def navbar_divider
  prepare_html %(<li class="divider-vertical"></li>)
end


42
43
44
45
46
47
48
49
50
51
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 42

def navbar_dropdown(name, &block)
  prepare_html <<-HTML.chomp!
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
  #{name} <b class="caret"></b>
</a>
#{dropdown_menu(&block)}
</li>
HTML
end


68
69
70
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 68

def navbar_dropdown_divider
  prepare_html %(<li class="divider"></li>)
end


72
73
74
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 72

def navbar_dropdown_header(text)
  prepare_html %(<li class="nav-header">#{text}</li>)
end


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 10

def navbar_group(options = {}, &block)
  options = options.dup
  options[:class] = [options[:class], 'nav'].compact
  options[:class] << "pull-#{options.delete(:pull)}" if options.key?(:pull)
  options[:class] = options[:class].join(' ')
  attributes = attributes_for_tag(options)
  prepare_html <<-HTML.chomp!
<ul#{attributes}>
#{capture(&block) if block_given?}
</ul>
HTML
end


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 23

def navbar_item(name = nil, path = nil, list_item_options = nil, link_options = nil, &block)
  name, path, list_item_options, link_options = capture(&block), name, path, list_item_options if block_given?
  path ||= '#'
  list_item_options   = list_item_options ? list_item_options.dup : {}
  link_options        = link_options      ? link_options.dup      : {}
  list_item_options[:class] = [list_item_options[:class]].compact
  list_item_options[:class] << 'active' if current_url_or_sub_url?(path)
  list_item_options[:class] = list_item_options[:class].join(' ')
  list_item_attributes = attributes_for_tag(list_item_options)
  link_attributes      = attributes_for_tag(link_options)
  prepare_html <<-HTML.chomp!
<li#{list_item_attributes}>
<a href="#{path}"#{link_attributes}>
  #{name}
</a>
</li>
HTML
end


53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 53

def navbar_sub_dropdown(name, list_item_options = {}, link_options = {}, &block)
  list_item_options, link_options = list_item_options.dup, link_options.dup
  list_item_options[:class] = [list_item_options.delete(:class), 'dropdown-submenu'].compact.join(' ')
  list_item_attributes = attributes_for_tag(list_item_options)
  link_attributes      = attributes_for_tag(link_options)
  prepare_html <<-HTML.chomp!
<li#{list_item_attributes}>
<a href="#"#{link_attributes}>
  #{name}
</a>
#{dropdown_menu(&block)}
</li>
HTML
end


80
81
82
83
84
85
86
87
88
# File 'lib/bootstrap-navbar/helpers/bootstrap2.rb', line 80

def navbar_text(text = nil, pull = nil, &block)
  css_classes = %w(navbar-text)
  css_classes << "pull-#{pull}" if pull
  prepare_html <<-HTML.chomp!
<p class="#{css_classes.join(' ')}">
#{block_given? ? capture(&block) : text}
</p>
HTML
end