Class: BootstrapHelpers::AccordionBuilder
- Inherits:
-
Object
- Object
- BootstrapHelpers::AccordionBuilder
- Defined in:
- lib/bootstrap-helpers.rb
Overview
Accordion =
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(opts, parent) ⇒ AccordionBuilder
constructor
A new instance of AccordionBuilder.
- #pane(title, pane_id = nil, &block) ⇒ Object
Constructor Details
#initialize(opts, parent) ⇒ AccordionBuilder
Returns a new instance of AccordionBuilder.
281 282 283 284 285 |
# File 'lib/bootstrap-helpers.rb', line 281 def initialize(opts, parent) @first = true @parent = parent @opts = opts end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
278 279 280 |
# File 'lib/bootstrap-helpers.rb', line 278 def parent @parent end |
Instance Method Details
#pane(title, pane_id = nil, &block) ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/bootstrap-helpers.rb', line 287 def pane(title, pane_id = nil, &block) css_class = (@first && @opts[:open]) ? 'in' : '' pane_id ||= "#{title.parameterize}_pane" @first = false content_tag :div, :class => 'accordion-group' do heading = content_tag :div, :class => 'accordion-heading' do link_to title, "##{pane_id}", :class => 'accordion-toggle', :'data-toggle' => 'collapse', :'data-parent' => "##{@opts[:accordion_id]}" end body = content_tag :div, :class => "accordion-body collapse #{css_class}", :id => "#{pane_id}" do content_tag :div, :class => 'accordion-inner' do capture(&block) end end heading + body end end |