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 |
# File 'app/helpers/modal_helper.rb', line 36 def (dismiss) content_tag :button, "×".html_safe, :class => "close", "data-dismiss" => "#{dismiss}", "aria-hidden" => "true" end |
#modal_body(options = {}, &block) ⇒ Object
28 29 30 |
# File 'app/helpers/modal_helper.rb', line 28 def modal_body( = {}, &block) content_tag :div, , :class => 'modal-body', &block end |
#modal_cancel_button(content, options = {}) ⇒ Object
52 53 54 55 56 |
# File 'app/helpers/modal_helper.rb', line 52 def content, = {} = { :class => "btn btn-default", :data => { dismiss: "modal" } } content_tag_string :button, 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 11 12 13 14 |
# File 'app/helpers/modal_helper.rb', line 4 def modal_dialog( = {}, &block) content_tag :div, :id => [:id], :class => "modal fade", :role => "dialog" do content_tag :div, class: 'modal-dialog' do content_tag :div, class: 'modal-content' do modal_header([:header]) + modal_body([:body]) + ([:footer]) 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, , :class => 'modal-footer', &block end |
#modal_header(options = {}, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/modal_helper.rb', line 16 def modal_header( = {}, &block) dismiss = .delete(:dismiss) || 'modal' 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
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/modal_helper.rb', line 40 def modal_toggle( = nil, = {}, &block) if block_given? = if .is_a?(Hash) = { :class => 'btn', "data-toggle" => "modal", "data-target" => .delete[:dialog] }.merge() content_tag :a, nil, , true, &block else = { :class => 'btn', "data-toggle" => "modal", "data-target" => .delete(:dialog) }.merge() content_tag :a, , , true end end |