Class: TwitterBootstrapMarkup::TabContent

Inherits:
Tag
  • Object
show all
Defined in:
lib/twitter_bootstrap_markup/tab_content.rb

Constant Summary

Constants included from Popover

Popover::POSITIONS

Constants included from Tooltip

TwitterBootstrapMarkup::Tooltip::POSITIONS

Instance Attribute Summary

Attributes inherited from Tag

#attributes, #children, #name

Instance Method Summary collapse

Methods inherited from Tag

block, inline, #prepend, #to_s

Methods included from SidePosition

#pull_left, #pull_right

Methods included from Popover

#popover

Methods included from Tooltip

#tooltip

Constructor Details

#initialize(attributes = {}, &block) ⇒ TabContent

Returns a new instance of TabContent.



5
6
7
8
9
10
11
# File 'lib/twitter_bootstrap_markup/tab_content.rb', line 5

def initialize(attributes={}, &block)
  if block_given?
    super(:div, attributes.prepend!(:class, 'tab-content'), &block)
  else
    super(:div, attributes.prepend!(:class, 'tab-content')) {}
  end
end

Instance Method Details

#append(*args, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/twitter_bootstrap_markup/tab_content.rb', line 13

def append(*args, &block)
  id = args.shift
  element = block_given? ? instance_eval(&block) : args.shift
  mode = args.shift || :inactive

  if element.is_a?(Tag) && element.name == :div && element.attributes[:class].include?('tab-pane')
    element.attributes[:id] = id
    element.attributes.append!(:class, 'active') if mode == :active
    internal_append element
  else
    attributes = {:class => 'tab-pane', :id => id}
    attributes.append!(:class, :active) if mode == :active
    internal_append Tag.block(:div, element, attributes)
  end
end

#internal_appendObject



3
# File 'lib/twitter_bootstrap_markup/tab_content.rb', line 3

alias :internal_append :append