Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9c21f06f53
Fetching contributors…

Cannot retrieve contributors at this time

36 lines (30 sloc) 1.245 kb
require 'jquery-rails'
require 'jquery-rails-cdn/version'
module Jquery::Rails::Cdn
module ActionViewExtensions
JQUERY_VERSION = Jquery::Rails::JQUERY_VERSION
OFFLINE = (Rails.env.development? or Rails.env.test?)
URL = {
:google => "//ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js",
:microsoft => "//ajax.aspnetcdn.com/ajax/jQuery/jquery-#{JQUERY_VERSION}.min.js",
:jquery => "http://code.jquery.com/jquery-#{JQUERY_VERSION}.min.js",
:yandex => "//yandex.st/jquery/#{JQUERY_VERSION}/jquery.min.js"
}
def jquery_url(name, options = {})
URL[name]
end
def jquery_include_tag(name, options = {})
return javascript_include_tag(:jquery) if OFFLINE and !options[:force]
[ javascript_include_tag(jquery_url(name, options)),
javascript_tag("window.jQuery || document.write(unescape('#{javascript_include_tag(:jquery).gsub('<','%3C')}'))")
].join("\n").html_safe
end
end
class Railtie < Rails::Railtie
initializer 'jquery_rails_cdn.action_view' do |app|
ActiveSupport.on_load(:action_view) do
include Jquery::Rails::Cdn::ActionViewExtensions
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.