Class: NavbarHelper::NavbarGroup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ NavbarGroup

Returns a new instance of NavbarGroup.



132
133
134
# File 'app/helpers/navbar_helper.rb', line 132

def initialize(parent)
	self.parent = parent
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



130
131
132
# File 'app/helpers/navbar_helper.rb', line 130

def parent
  @parent
end

Instance Method Details



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'app/helpers/navbar_helper.rb', line 152

def dropdown(text, options={}, &block)
	dropdown_builder = Dropdown.new self.parent
	content = []
	content << link_to("#{text} #{caret}".html_safe, '#', class: 'dropdown-toggle', data: {toggle: 'dropdown'})
	items = capture dropdown_builder, &block
	content << (:ul, items, class: 'dropdown-menu')

	dropdown_options = options.dup
	dropdown_options[:class] = parse_html_classes_to_arr dropdown_options[:class]
	dropdown_options[:class] << 'dropdown'

	if dropdown_builder.chosen
		dropdown_options[:class] << 'active'
	end

	 :li, content.join("\n").html_safe, dropdown_options
end

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



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'app/helpers/navbar_helper.rb', line 138

def item(text, uri, options={})
	menu_item_options = options.dup
	menu_item_options[:class] = parse_html_classes_to_arr menu_item_options[:class]

	state = uri_state uri

	if state == :active || state == :chosen
		menu_item_options[:class] << 'active'
	end

	content = link_to text, uri
	 :li, content, menu_item_options
end