Module: ModalHelper

Defined in:
app/helpers/modal_helper.rb

Instance Method Summary collapse

Instance Method Details

#close_button(dismiss) ⇒ Object



31
32
33
34
# File 'app/helpers/modal_helper.rb', line 31

def close_button(dismiss)
  #It doesn't seem to like content_tag, so we do this instead.	
  raw("<button class=\"close\" data-dismiss=\"#{dismiss}\">&times;</button>")
end


23
24
25
# File 'app/helpers/modal_helper.rb', line 23

def modal_body(options = {}, &block)
   :div, options, :class => 'modal-body', &block
end


48
49
50
51
52
# File 'app/helpers/modal_helper.rb', line 48

def modal_cancel_button content, options = {}
  default_options = { :class => "btn bootstrap-modal-cancel-button" }

   "a", content, default_options.merge(options)
end

modals have a header, a body, a footer for options.



4
5
6
7
8
9
10
# File 'app/helpers/modal_helper.rb', line 4

def modal_dialog(options = {}, &block)
   :div, :id => options[:id], :class => "bootstrap-modal modal hide fade" do
    modal_header(options[:header]) +
    modal_body(options[:body]) +
    modal_footer(options[:footer])
  end
end


27
28
29
# File 'app/helpers/modal_helper.rb', line 27

def modal_footer(options = {}, &block)
   :div, options, :class => 'modal-footer', &block
end


12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/modal_helper.rb', line 12

def modal_header(options = {}, &block)
   :div, :class => 'modal-header' do
    if options[:show_close] 
      close_button(options[:dismiss]) +
      (:h3, options[:title], &block)
    else
      (:h3, options[:title], &block)
    end	
  end
end


36
37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/modal_helper.rb', line 36

def modal_toggle(content_or_options = nil, options = {}, &block)
  if block_given?
    options = content_or_options if content_or_options.is_a?(Hash)
    default_options = { :class => 'btn', "data-toggle" => "modal", "href" => options[:dialog] }.merge(options)

     :a, nil, default_options, true, &block
  else
    default_options = { :class => 'btn', "data-toggle" => "modal", "href" => options[:dialog] }.merge(options)
     :a, content_or_options, default_options, true
  end
end