Class: Interview::Tabs

Inherits:
Control show all
Defined in:
lib/interview/controls/tabs.rb

Instance Attribute Summary collapse

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods inherited from Control

#ancestors, #build_with_params, #find_attribute, #find_attribute!, #initialize, #set_attributes, #set_defaults

Constructor Details

This class inherits a constructor from Interview::Control

Instance Attribute Details

#activeObject

Returns the value of attribute active.



4
5
6
# File 'lib/interview/controls/tabs.rb', line 4

def active
  @active
end

Instance Method Details

#build(b) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/interview/controls/tabs.rb', line 6

def build(b)
  b.section style: 'ul', html_class: 'nav nav-tabs' do
    b.meta_control pointer: self do
      @index = 0
      yield if block_given?
    end
  end
end

#build_child(b, control, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/interview/controls/tabs.rb', line 15

def build_child(b, control, &block)
  html_class = 'active' if @index == @active
  @index += 1
  b.section style: 'li', html_class: html_class, html_options: { role: 'presentation' } do
    super
  end
end