Sha256: 9de5f06a4d3fa0e393b348bcf549cd6cd3a7da661287d850ad8bddc1d1993222
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
module Symphonia module BootstrapModalHelper # Ruby shortcut for generate modals # # <%= render_modal title: t(:title) do %> # <% render(template: 'path_to_template_or_partial', formats: [:html]) %> # <% end %> # template_or_partial example: # <%= title(@entity, back: !request.xhr?) %> # # <%= symphonia_form_for(@entity, remote: request.xhr?) do |f| %> # # <%= render(partial: 'form', locals: { f: f }) %> # # <%= f.primary unless request.xhr? %> # <% end -%> # def render_modal(options = {}, &block) opts = options.slice(:id, :title, :submit, :large) opts[:submit] = t(:button_submit) unless opts.has_key?(:submit) id = options.delete(:id) || 'ad_hoc_modal' script = <<SCRIPT if (typeof(renderModal) == "undefined") var renderModal = {} if (renderModal["#{id}"]) renderModal["#{id}"].destroy(); renderModal["#{id}"] = new SymphoniaDialog("#{id}", #{raw opts.to_json}); renderModal["#{id}"].body.innerHTML = "#{j(capture(&block))}"; var submitButton = renderModal["#{id}"].body.querySelector("input[type=submit]") if (submitButton) submitButton.remove() SCRIPT unless opts[:title] script.concat <<EOF var title = document.getElementById(renderModal["#{id}"].id).querySelector("#page_header"); if (title) { title.className = 'modal-title'; title.id = null; $(renderModal["#{id}"].title).replaceWith($(title)); renderModal["#{id}"].title = title; } EOF end # script << %q{} script << %Q{renderModal["#{id}"].show();} unless opts.has_key?(:render_only) script.html_safe end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
symphonia-2.1.7 | app/helpers/symphonia/bootstrap_modal_helper.rb |