Class: NavbarHelper::Navbar

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/navbar_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Navbar

Returns a new instance of Navbar.



69
70
71
# File 'app/helpers/navbar_helper.rb', line 69

def initialize(parent)
	self.parent = parent
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



67
68
69
# File 'app/helpers/navbar_helper.rb', line 67

def parent
  @parent
end

Instance Method Details

#button(text, options = {}) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
# File 'app/helpers/navbar_helper.rb', line 92

def button(text, options={})
	button_options = options.dup
	button_options[:class] = parse_html_classes_to_arr button_options[:class]
	button_options[:class] << 'btn'
	button_options[:class] << 'navbar-btn'

	unless button_options[:class].join =~ /btn-(?>default|primary|warning|success|info|danger|link)/
		button_options[:class] << 'btn-default'
	end

	 :button, text, button_options
end

#group(options = {}, &block) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/helpers/navbar_helper.rb', line 75

def group(options={}, &block)
	navbar_group_builder = NavbarGroup.new self.parent
	content = capture navbar_group_builder, &block

	menu_group_options = options.dup
	menu_group_options[:class] = parse_html_classes_to_arr menu_group_options[:class]
	menu_group_options[:class] << 'nav'
	menu_group_options[:class] << 'navbar-nav'
	pull = menu_group_options.delete(:pull).to_s

	if pull == 'left' || pull == 'right'
		menu_group_options[:class] << "navbar-#{pull}"
	end

	 :ul, content, menu_group_options
end


119
120
121
122
123
124
125
126
# File 'app/helpers/navbar_helper.rb', line 119

def link(text, uri, options={})
	link_options = options.dup
	link_options[:class] = parse_html_classes_to_arr link_options[:class]
	link_options[:class] << 'navbar-link'
	link_options[:href] = uri

	 :a, text, link_options
end

#text(text, options = {}) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'app/helpers/navbar_helper.rb', line 105

def text(text, options={})
	text_options = options.dup
	text_options[:class] = parse_html_classes_to_arr text_options[:class]
	text_options[:class] << 'navbar-text'

	pull = text_options.delete(:pull).to_s

	if pull == 'left' || pull  == 'right'
		text_options[:class] << "navbar-#{pull}"
	end

	 :p, text, text_options
end