Class: TwitterBootstrap::ButtonGroupWithTabsBuilder

Inherits:
ButtonGroupBuilder show all
Defined in:
lib/twitter_bootstrap_helpers/button_group_builder.rb

Instance Method Summary collapse

Methods inherited from ButtonGroupBuilder

#dropdown_button

Constructor Details

#initialize(view_context) ⇒ ButtonGroupWithTabsBuilder

Returns a new instance of ButtonGroupWithTabsBuilder.



44
45
46
47
# File 'lib/twitter_bootstrap_helpers/button_group_builder.rb', line 44

def initialize(view_context)
  super(:radio, view_context)
  @tabs = ""
end

Instance Method Details

#build(block) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/twitter_bootstrap_helpers/button_group_builder.rb', line 49

def build(block)
  block.call(self)

  buttons = @view_context.(:div, @buttons.html_safe, class: 'btn-group', data: {toggle: 'buttons-radio'})
  tabs = @view_context.(:div, @tabs.html_safe, class: 'tab-content')

  @view_context.(:div, buttons << tabs, class: 'tabbable')
end

#button(label, target, options = {}, &block) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/twitter_bootstrap_helpers/button_group_builder.rb', line 58

def button(label, target, options = {}, &block)
  super(label, options.merge!(target: target))

  tab_class = ['tab-pane']
  tab_class << 'active' if options[:active]

  tab_class = tab_class.join(' ')

  @tabs << @view_context.(:div, @view_context.capture(&block), id: target, class: tab_class)

  ""
end