Class: TwitterBootstrap::ButtonGroupBuilder
- Inherits:
-
Object
- Object
- TwitterBootstrap::ButtonGroupBuilder
show all
- Defined in:
- lib/twitter_bootstrap_helpers/button_group_builder.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ButtonGroupBuilder.
8
9
10
11
12
|
# File 'lib/twitter_bootstrap_helpers/button_group_builder.rb', line 8
def initialize(id,view_context)
@id = id
@view_context = view_context
@buttons = ""
end
|
Instance Method Details
#build(block) ⇒ Object
14
15
16
17
|
# File 'lib/twitter_bootstrap_helpers/button_group_builder.rb', line 14
def build(block)
block.call(self)
@view_context.content_tag(:div, @buttons.html_safe, class: 'btn-group',id: @id);
end
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/twitter_bootstrap_helpers/button_group_builder.rb', line 19
def button(label, options = {})
button_class = ['btn']
button_class << options[:class] if options[:class]
button_class << 'active' if options[:active]
button_class = button_class.join(' ')
data = {toggle: 'button'}
data[:target] = "##{options[:target]}" if options[:target]
@buttons << @view_context.content_tag(:button, label, class: button_class, data: data)
""
end
|
35
36
37
38
39
40
|
# File 'lib/twitter_bootstrap_helpers/button_group_builder.rb', line 35
def dropdown_button(item_title,)
title = (item_title << ' ' << content_tag(:span, nil, class: 'caret')).html_safe
link = content_tag(:a, title, :href => '#', :class => 'btn btn-mini dropdown-toggle', 'data-toggle' => 'dropdown')
@buttons << (link << )
end
|