Sha256: a133f80cad1526d5012cc7c07dc94c244fd7bbad6494310745068486f1d55697
Contents?: true
Size: 1.72 KB
Versions: 3
Compression:
Stored size: 1.72 KB
Contents
module ModalHelper #modals have a header, a body, a footer for options. def modal_dialog(options = {}, &block) content_tag :div, :id => options[:id], :class => "bootstrap-modal modal hide fade" do modal_header(options[:header]) + modal_body(options[:body]) + modal_footer(options[:footer]) end end def modal_header(options = {}, &block) content_tag :div, :class => 'modal-header' do if options[:show_close] close_button(options[:dismiss]) + content_tag(:h3, options[:title], &block) else content_tag(:h3, options[:title], &block) end end end def modal_body(options = {}, &block) content_tag :div, options, :class => 'modal-body', &block end def modal_footer(options = {}, &block) content_tag :div, options, :class => 'modal-footer', &block end def close_button(dismiss) #It doesn't seem to like content_tag, so we do this instead. raw("<button class=\"close\" data-dismiss=\"#{dismiss}\">×</button>") end def modal_toggle(content_or_options = nil, 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) content_tag :a, nil, default_options, true, &block else default_options = { :class => 'btn', "data-toggle" => "modal", "href" => options[:dialog] }.merge(options) content_tag :a, content_or_options, default_options, true end end def modal_cancel_button content, options = {} default_options = { :class => "btn bootstrap-modal-cancel-button" } content_tag_string "a", content, default_options.merge(options) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bootstrap-sass-extras-0.0.5 | app/helpers/modal_helper.rb |
bootstrap-sass-extras-0.0.4 | app/helpers/modal_helper.rb |
bootstrap-sass-extras-0.0.3 | app/helpers/modal_helper.rb |