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
31 32 33 34 |
# File 'app/helpers/modal_helper.rb', line 31 def (dismiss) #It doesn't seem to like content_tag, so we do this instead. raw("<button class=\"close\" data-dismiss=\"#{dismiss}\">×</button>") end |
#modal_body(options = {}, &block) ⇒ Object
23 24 25 |
# File 'app/helpers/modal_helper.rb', line 23 def modal_body( = {}, &block) content_tag :div, , :class => 'modal-body', &block end |
#modal_cancel_button(content, options = {}) ⇒ Object
48 49 50 51 52 |
# File 'app/helpers/modal_helper.rb', line 48 def content, = {} = { :class => "btn bootstrap-modal-cancel-button" } content_tag_string "a", content, .merge() end |
#modal_dialog(options = {}, &block) ⇒ Object
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( = {}, &block) content_tag :div, :id => [:id], :class => "bootstrap-modal modal hide fade" do modal_header([:header]) + modal_body([:body]) + ([:footer]) end end |
#modal_footer(options = {}, &block) ⇒ Object
27 28 29 |
# File 'app/helpers/modal_helper.rb', line 27 def ( = {}, &block) content_tag :div, , :class => 'modal-footer', &block end |
#modal_header(options = {}, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/modal_helper.rb', line 12 def modal_header( = {}, &block) content_tag :div, :class => 'modal-header' do if [:show_close] ([:dismiss]) + content_tag(:h3, [:title], &block) else content_tag(:h3, [:title], &block) end end end |
#modal_toggle(content_or_options = nil, options = {}, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/modal_helper.rb', line 36 def modal_toggle( = nil, = {}, &block) if block_given? = if .is_a?(Hash) = { :class => 'btn', "data-toggle" => "modal", "href" => [:dialog] }.merge() content_tag :a, nil, , true, &block else = { :class => 'btn', "data-toggle" => "modal", "href" => [:dialog] }.merge() content_tag :a, , , true end end |