Module: ModalHelper
- Defined in:
- app/helpers/modal_helper.rb
Instance Method Summary collapse
- #close_button(dismiss) ⇒ Object
- #modal_body(options, &block) ⇒ Object
- #modal_cancel_button(content, options) ⇒ Object
-
#modal_dialog(options = {}, &block) ⇒ Object
modals have a header, a body, a footer for options.
- #modal_footer(options, &block) ⇒ Object
- #modal_header(options, &block) ⇒ Object
- #modal_toggle(content_or_options = nil, options, &block) ⇒ Object
Instance Method Details
#close_button(dismiss) ⇒ Object
36 37 38 39 |
# File 'app/helpers/modal_helper.rb', line 36 def (dismiss) #It doesn't seem to like content_tag, so we do this instead. raw("<button class=\"close\" data-dismiss=\"#{dismiss}\" aria-hidden=\"true\">×</button>") end |
#modal_body(options, &block) ⇒ Object
28 29 30 |
# File 'app/helpers/modal_helper.rb', line 28 def modal_body(, &block) content_tag :div, [:content], :class => 'modal-body', :style => [:style], &block end |
#modal_cancel_button(content, options) ⇒ Object
53 54 55 56 57 |
# File 'app/helpers/modal_helper.rb', line 53 def (content, ) default_opts = { :class => "btn bootstrap-modal-cancel-button" } content_tag_string "a", content, default_opts.merge() end |
#modal_dialog(options = {}, &block) ⇒ Object
modals have a header, a body, a footer for options.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/modal_helper.rb', line 4 def modal_dialog( = {}, &block) = {:id => 'modal', :size => '', :show_close => true, :dismiss => true}.merge content_tag :div, :class => "bootstrap-modal modal fade", :id => [:id] do content_tag :div, :class => "modal-dialog #{['size']}" do content_tag :div, :class => "modal-content" do modal_header([:header], &block) + modal_body([:body], &block) + ([:footer], &block) end end end end |
#modal_footer(options, &block) ⇒ Object
32 33 34 |
# File 'app/helpers/modal_helper.rb', line 32 def (, &block) content_tag :div, [:content], :class => 'modal-footer', &block end |
#modal_header(options, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/modal_helper.rb', line 17 def modal_header(, &block) content_tag :div, :class => 'modal-header' do if [:show_close] ([:dismiss]) + content_tag(:h4, [:title], :class => 'modal-title', &block) else content_tag(:h4, [:title], :class => 'modal-title', &block) end end end |
#modal_toggle(content_or_options = nil, options, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/modal_helper.rb', line 41 def modal_toggle( = nil, , &block) if block_given? = if .is_a?(Hash) = { :class => 'btn btn-default', "data-toggle" => "modal", "href" => [:dialog] }.merge() content_tag :a, nil, , true, &block else = { :class => 'btn btn-default', "data-toggle" => "modal", "href" => [:dialog] }.merge() content_tag :a, , , true end end |