Module: BootstrapRailsHelpers::ModalHelper

Defined in:
app/helpers/bootstrap_rails_helpers/modal_helper.rb

Instance Method Summary collapse

Instance Method Details



29
30
31
32
33
34
35
# File 'app/helpers/bootstrap_rails_helpers/modal_helper.rb', line 29

def modal_body(options = {}, escape = true, &block)
  default_options = { :class => 'modal-body' }
  render :layout => 'bootstrap_rails_helpers/modal_body', :locals => {
    options: default_options.merge(options),
    escape: escape
  }, &block
end


56
57
58
59
# File 'app/helpers/bootstrap_rails_helpers/modal_helper.rb', line 56

def modal_cancel_button content, options = {}
  default_options = { :class => "btn bootstrap-modal-cancel-button", :data => { dismiss: "modal" }, :aria => { hidden: 'true' }}
   "a", content, default_options.merge(options)
end


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

def modal_dialog(options = {}, escape = true, &block)
  default_options = { :class => 'modal hide fade' }
  render :layout => 'bootstrap_rails_helpers/modal_dialog', :locals => {
    options: default_options.merge(options),
    escape: escape
  }, &block
end


37
38
39
40
41
42
43
# File 'app/helpers/bootstrap_rails_helpers/modal_helper.rb', line 37

def modal_footer(options = {}, escape = true, &block)
  default_options = { :class => 'modal-footer' }
  render :layout => 'bootstrap_rails_helpers/modal_footer', :locals => {
    options: default_options.merge(options),
    escape: escape
  }, &block
end


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/bootstrap_rails_helpers/modal_helper.rb', line 11

def modal_header(content_or_options_with_block = nil, options = {}, escape = true, &block)
  default_options = { :class => 'modal-header' }
  if block_given?
    options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
    render :layout => 'bootstrap_rails_helpers/modal_header', :locals => {
      options: default_options.merge(options),
      escape: escape
    }, &block
  else
    render :layout => 'bootstrap_rails_helpers/modal_header', :locals => {
      options: default_options.merge(options),
      escape: escape
    } do
       :h3, content_or_options_with_block
    end
  end
end


45
46
47
48
49
50
51
52
53
54
# File 'app/helpers/bootstrap_rails_helpers/modal_helper.rb', line 45

def modal_toggle(content_or_options = {}, 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