Class: Spurs::Modal::Builder

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/spurs/modal/builder.rb

Instance Method Summary collapse

Instance Method Details

#build_modal(modal_id, content, options = { }) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/spurs/modal/builder.rb', line 8

def build_modal(modal_id, content, options={ })

  if !options[:class] then
    options[:class] = ""
  end
  options[:class].concat(" modal fade #{modal_id}")

  c = String.new

  if options[:header]
    header_options = options.delete(:header)
    if header_options[:title]
      c.concat(build_modal_title(header_options[:title], header_options[:icon]))
    end
  end


  #body
  c.concat((:div, content, :class => "modal-body"))

  if options[:actions]
    actions_options = options.delete(:actions)
    c.concat(build_modal_footer(actions_options).html_safe)
  end


  (:div, c.html_safe, :class => options[:class], 'data-modal-id' => "#{modal_id}")

end