Class: BootstrapHelpers::AccordionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/bootstrap-helpers.rb

Overview

Accordion =

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#parentObject (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
   :div, :class => 'accordion-group' do
    heading =  :div, :class => 'accordion-heading' do
      link_to title, "##{pane_id}", :class => 'accordion-toggle', :'data-toggle' => 'collapse',
      :'data-parent' => "##{@opts[:accordion_id]}"
    end
    body =  :div, :class => "accordion-body collapse #{css_class}", :id => "#{pane_id}" do
       :div, :class => 'accordion-inner' do
        capture(&block)
      end
    end
    heading + body
  end
end