Module: Railsstrap::ModalHelper
- Defined in:
- app/helpers/railsstrap/modal_helper.rb
Instance Method Summary collapse
- #close_button(dismiss) ⇒ Object
- #default_options ⇒ 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
41 42 43 44 |
# File 'app/helpers/railsstrap/modal_helper.rb', line 41 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 |
#default_options ⇒ Object
4 5 6 |
# File 'app/helpers/railsstrap/modal_helper.rb', line 4 def return {:id => 'modal', :size => '', :show_close => true, :dismiss => true} end |
#modal_body(options, &block) ⇒ Object
33 34 35 |
# File 'app/helpers/railsstrap/modal_helper.rb', line 33 def modal_body(, &block) content_tag :div, [:content], :class => 'modal-body', :style => [:style], &block end |
#modal_cancel_button(content, options) ⇒ Object
58 59 60 61 62 |
# File 'app/helpers/railsstrap/modal_helper.rb', line 58 def (content, ) default_opts = { :class => "btn railsstrap-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.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/railsstrap/modal_helper.rb', line 9 def modal_dialog( = {}, &block) opts = .merge() content_tag :div, :id => [:id], :class => "railsstrap-modal modal fade" do content_tag :div, :class => "modal-dialog #{opts['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
37 38 39 |
# File 'app/helpers/railsstrap/modal_helper.rb', line 37 def (, &block) content_tag :div, [:content], :class => 'modal-footer', &block end |
#modal_header(options, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/railsstrap/modal_helper.rb', line 22 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
46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/railsstrap/modal_helper.rb', line 46 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 |