Module: NavbarHelper

Defined in:
app/helpers/navbar_helper.rb

Defined Under Namespace

Classes: Dropdown, Navbar, NavbarGroup

Instance Method Summary collapse

Instance Method Details



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/navbar_helper.rb', line 4

def navbar(options={}, &block)
	navbar_options = options.dup
	navbar_options[:class] = parse_html_classes_to_arr navbar_options[:class]
	navbar_options[:class] << 'navbar'
	navbar_options[:class] << 'navbar-default'
	navbar_options[:role] = :navigation

	fixed = navbar_options.delete(:fixed).to_s

	if fixed == 'top' || fixed == 'bottom'
		navbar_options[:class] << "navbar-fixed-#{fixed}"
	end

	static = navbar_options.delete(:static).to_s

	if static == 'top'
		navbar_options[:class] << 'navbar-static-top'
	end

	inverse = navbar_options.delete :inverse

	if inverse == true
		navbar_options[:class] << 'navbar-inverse'
	end

	brand = navbar_options.delete :brand

	navbar_id = SecureRandom.hex

	content = []
	content << render_navbar_header(brand, navbar_id)
	content << render_navbar_body(navbar_id, &block)

	 :nav, content.join("\n").html_safe, navbar_options
end

#uri_state(uri) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/helpers/navbar_helper.rb', line 40

def uri_state(uri)
	root_url = request.host_with_port + '/'
	request_uri = request.path[1..-1]

	uri.gsub(root_url)

	if uri.start_with? '/'
		uri = uri[1..-1]
	end

	if uri == request_uri
		return :active
	end

	uri_parts = uri.split '/'
	request_uri_parts = request_uri.split '/'

	uri_parts.each_with_index do |uri_part, index|
		if uri_part != request_uri_parts[index]
			return :inactive
		end
	end

	:chosen
end