Class: Interview::Dropdown

Inherits:
Control
  • Object
show all
Includes:
HasHtmlOptions
Defined in:
lib/interview/controls/dropdown.rb

Instance Attribute Summary collapse

Attributes included from HasHtmlOptions

#html_class, #html_options

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods included from HasHtmlOptions

#initialize

Methods inherited from Control

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

Instance Attribute Details

#captionObject

Returns the value of attribute caption.



6
7
8
# File 'lib/interview/controls/dropdown.rb', line 6

def caption
  @caption
end

#container_tagObject

Returns the value of attribute container_tag.



6
7
8
# File 'lib/interview/controls/dropdown.rb', line 6

def container_tag
  @container_tag
end

#imageObject

Returns the value of attribute image.



6
7
8
# File 'lib/interview/controls/dropdown.rb', line 6

def image
  @image
end

#styleObject

Returns the value of attribute style.



6
7
8
# File 'lib/interview/controls/dropdown.rb', line 6

def style
  @style
end

Instance Method Details

#build(b) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/interview/controls/dropdown.rb', line 8

def build(b)
  container_tag = @container_tag || 'div'
  html_class = @html_class.dup
  html_class << 'dropdown'
  b.section style: container_tag, html_class: html_class, html_options: @html_options do
    html_class = %w(dropdown-toggle)
    html_class += %w(btn btn-default) if @style == 'button'
    b.link image: @image, caption: @caption, url: '#', html_class: html_class, 
           html_options: { data: { toggle: 'dropdown' } } do
      b.space if @image or @caption
      b.glyphicon image: 'caret'
    end
    b.section style: 'ul', html_class: 'dropdown-menu' do
      b.meta_control pointer: self do
        yield if block_given?
      end
    end
  end
end

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



28
29
30
31
32
# File 'lib/interview/controls/dropdown.rb', line 28

def build_child(b, control, &block)
  b.section style: 'li' do
    super
  end
end