Class: Spark::ModalHelper::ModalPanel
- Defined in:
- app/helpers/spark/modal_helper.rb
Instance Method Summary collapse
- #display(body) ⇒ Object
- #footer(options = {}, &block) ⇒ Object
- #header(text = nil, options = {}, &block) ⇒ Object
-
#initialize(options = {}) ⇒ ModalPanel
constructor
A new instance of ModalPanel.
Constructor Details
#initialize(options = {}) ⇒ ModalPanel
Returns a new instance of ModalPanel.
5 6 7 8 9 |
# File 'app/helpers/spark/modal_helper.rb', line 5 def initialize( = {} ) @options = add_class( , 'modal-panel' ) @options = Spark::Helpers.set_aria_keys( @options ) @options = ({ 'aria-modal'=> true, 'aria-hidden'=> true }).merge(@options) end |
Instance Method Details
#display(body) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/spark/modal_helper.rb', line 11 def display( body ) if first_header = body.scan(/\A<header.+?\/header>/m).first body = body.sub( first_header, '' ).html_safe first_header = first_header.html_safe end if = body.scan(/<footer.+?\/footer>\z/m).first body = body.sub(, '').html_safe = .html_safe end content_tag( :section, @options ) do concat first_header concat content_tag( :div, class: 'modal-panel-content' ) { concat body } concat end end |
#footer(options = {}, &block) ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/helpers/spark/modal_helper.rb', line 42 def ( = {}, &block ) = add_class , "modal-panel-footer" content_tag( :footer, ) { concat capture( &block ).html_safe if block_given? } end |
#header(text = nil, options = {}, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/helpers/spark/modal_helper.rb', line 31 def header( text = nil, = {}, &block ) , text = text, nil if text.is_a? Hash = add_class( , "modal-panel-header" ) content_tag( :header, ) { concat content_tag( :h4, text, class: 'modal-panel-title' ) if text concat capture( &block ).html_safe if block_given? } end |