Class: Symphonia::ApplicationHelper::SymphoniaModalDialog
- Inherits:
-
Object
- Object
- Symphonia::ApplicationHelper::SymphoniaModalDialog
- Defined in:
- app/helpers/symphonia/application_helper.rb
Overview
def render_modal_dialog(show = true, options = {}, &block)
tags = SymphoniaModalDialog.new(self, options)
yield tags if block_given?
html = tags.to_html
if show
"$('##{tags.modal_id}').remove();$('body').append('#{j html}'); showModal('##{tags.modal_id}');".html_safe
else
html
end
end
Instance Attribute Summary collapse
- #body(&block) ⇒ Object
- #footer(&block) ⇒ Object
-
#modal_id ⇒ Object
readonly
Returns the value of attribute modal_id.
-
#size ⇒ Object
Returns the value of attribute size.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #header(&block) ⇒ Object
-
#initialize(controller, options = {}) ⇒ SymphoniaModalDialog
constructor
A new instance of SymphoniaModalDialog.
- #submit(name = nil, options = {}) ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(controller, options = {}) ⇒ SymphoniaModalDialog
Returns a new instance of SymphoniaModalDialog.
345 346 347 348 349 350 351 |
# File 'app/helpers/symphonia/application_helper.rb', line 345 def initialize(controller, = {}) @c = controller @title = .delete(:title) @modal_id = .delete(:id) || 'modal-dialog' @form_options = .delete(:form_options) || {} @options = end |
Instance Attribute Details
#body(&block) ⇒ Object
376 377 378 379 380 381 382 |
# File 'app/helpers/symphonia/application_helper.rb', line 376 def body(&block) if block_given? @body = @c.capture(&block) else @body = (@body.is_a?(Proc) ? @body.call.to_s : @body.to_s) end end |
#footer(&block) ⇒ Object
384 385 386 387 388 389 390 |
# File 'app/helpers/symphonia/application_helper.rb', line 384 def (&block) if block_given? @footer = @c.capture(&block) else @footer = (@footer.is_a?(Proc) ? @footer.call.to_s : @footer.to_s) end end |
#modal_id ⇒ Object (readonly)
Returns the value of attribute modal_id.
341 342 343 |
# File 'app/helpers/symphonia/application_helper.rb', line 341 def modal_id @modal_id end |
#size ⇒ Object
Returns the value of attribute size.
343 344 345 |
# File 'app/helpers/symphonia/application_helper.rb', line 343 def size @size end |
#title ⇒ Object
Returns the value of attribute title.
341 342 343 |
# File 'app/helpers/symphonia/application_helper.rb', line 341 def title @title end |
Instance Method Details
#header(&block) ⇒ Object
368 369 370 371 372 373 374 |
# File 'app/helpers/symphonia/application_helper.rb', line 368 def header(&block) if block_given? @header = @c.capture(&block) else @header = (@header.is_a?(Proc) ? @header.call.to_s : @header.to_s) end end |
#submit(name = nil, options = {}) ⇒ Object
392 393 394 395 |
# File 'app/helpers/symphonia/application_helper.rb', line 392 def submit(name = nil, = {}) name ||= @c.t(:button_save) @footer = .to_s + @c.link_to(name, 'javascript:void(0)', { onclick: "$('##{@modal_id}').find('form').submit()", class: 'btn btn-primary' }.merge()).html_safe end |
#to_html ⇒ Object
355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'app/helpers/symphonia/application_helper.rb', line 355 def to_html html = "<div id='#{@modal_id}' style='' class='modal fade' role='dialog'><div class='modal-dialog #{'modal-lg' if size.present?}'><div class='modal-content'>" html << @c.tag.div(class: 'modal-header') do @c.tag.('', class: 'close fa fa-times', data: { dismiss: 'modal' }, 'aria-hidden' => true) + @c.tag.h4(@title, class: 'modal-title') + @header.to_s end content = @c.tag.div(@c.tag.div(body.html_safe, class: 'modal-content-inner-container container-fluid'), class: 'modal-body') content << @c.tag.div(.html_safe, class: 'modal-footer') html << content.html_safe html << '</div></div></div>' html.html_safe end |