Sha256: f3bb295706cff1a48998970fd3d4c19a2650e1e7ea3bb43de49221d1bb38d4d5
Contents?: true
Size: 1.99 KB
Versions: 11
Compression:
Stored size: 1.99 KB
Contents
# The following options can be changed by creating an initializer in config/initializers/jrails.rb # jRails does NOT use jQuery.noConflict() by default # to use jQuery.noConflict() , use: # ActionView::Helpers::JqueryHelper::JQUERY_VAR = 'jQuery' JRails.load_config if JRails.google? ActionView::Helpers::AssetTagHelper.register_javascript_expansion :jrails => ["jrails/jrails#{".min" if JRails.compressed?}"] else ActionView::Helpers::AssetTagHelper.register_javascript_expansion :jrails => ["jquery/jquery#{".min" if JRails.compressed?}","jquery/jquery-ui#{".min" if JRails.compressed?}","jquery/jquery-ui-i18n#{".min" if JRails.compressed?}","jrails/jrails#{".min" if JRails.compressed?}"] end ActionView::Helpers::AssetTagHelper.module_eval do def yield_authenticity_javascript <<JAVASCRIPT <script type='text/javascript'> //<![CDATA[ window._auth_token = '#{form_authenticity_token}'; $(document).ajaxSend(function(event, xhr, s) { if (typeof(window._auth_token) == "undefined") return; if (s.data && s.data.match(new RegExp("\\bauthenticity_token="))) return; if (s.data) s.data += "&"; else { s.data = ""; xhr.setRequestHeader("Content-Type", s.contentType); } s.data += "authenticity_token=" + encodeURIComponent(window._auth_token); }); //]]> </script> JAVASCRIPT end def javascript_include_tag_with_jquery(*source) if source.first == :jrails javascripts = [] if JRails.google? javascripts \ << javascript_include_tag_without_jquery(JRails.jquery_path) \ << javascript_include_tag_without_jquery(JRails.jqueryui_path) \ << javascript_include_tag_without_jquery(JRails.jqueryui_i18n_path) \ end javascripts << javascript_include_tag_without_jquery(*source) javascripts << yield_authenticity_javascript if protect_against_forgery? javascripts.join("\n") else javascript_include_tag_without_jquery(*source) end end alias_method_chain :javascript_include_tag, :jquery end
Version data entries
11 entries across 11 versions & 1 rubygems