Sha256: 96a957c4de3096a6fc203046870dde198b975d8a573c05e1308a6bde958ebb72
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
module Remotipart # Responder used to automagically wrap any non-xml replies in a text-area # as expected by iframe-transport. module RenderOverrides include ERB::Util include ActionView::Helpers::JavaScriptHelper def self.included(base) base.class_eval do if respond_to? :prepend base.prepend Prependable else base.include Includable # Do not use alias_method_chain for compatibility alias render_without_remotipart render alias render render_with_remotipart end end end module Prependable def render(*args, &block) treat_render_for_remotipart super(*args, &block) end end module Includable def render_with_remotipart(*args, &block) treat_render_for_remotipart render_without_remotipart(*args, &block) end end private def treat_render_for_remotipart(render_return_value) if remotipart_submitted? response.body = %{<script type="text/javascript">try{window.parent.document;}catch(err){document.domain=document.domain;}</script><textarea data-type="#{response.content_type}" data-status="#{response.response_code}" data-statusText="#{response.message}"></textarea><script type="text/javascript">document.querySelector("textarea").value="#{escape_javascript(response.body)}";</script>} response.content_type = ::Rails.version >= '5' ? Mime[:html] : Mime::HTML response_body else render_return_value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remotipart-1.4.4 | lib/remotipart/render_overrides.rb |