Module: Jquery::Rails::Cdn::ActionViewExtensions
- Defined in:
- lib/jquery-rails-cdn.rb
Constant Summary collapse
- JQUERY_VERSION =
Jquery::Rails::JQUERY_VERSION
- JQUERY_UI_VERSION =
Jquery::Rails::JQUERY_UI_VERSION
- OFFLINE =
(Rails.env.development? or Rails.env.test?)
- CDNS =
{ :jquery => { :google => "//ajax.googleapis.com/ajax/libs/jquery/#{JQUERY_VERSION}/jquery.min.js", :microsoft => "//ajax.aspnetcdn.com/ajax/jQuery/jquery-#{JQUERY_VERSION}.min.js", :jquery => "//code.jquery.com/jquery-#{JQUERY_VERSION}.min.js", :yandex => "//yandex.st/jquery/#{JQUERY_VERSION}/jquery.min.js" }, :jquery_ui => { :google => "//ajax.googleapis.com/ajax/libs/jqueryui/#{JQUERY_UI_VERSION}/jquery-ui.min.js", :microsoft => "//ajax.aspnetcdn.com/ajax/jquery.ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js", :jquery => "//code.jquery.com/ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js", :yandex => "//yandex.st/jquery-ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js" }, }
Instance Method Summary collapse
- #jquery_include_tag(name, options = {}) ⇒ Object
- #jquery_ui_include_tag(name, options = {}) ⇒ Object
- #jquery_ui_url(name) ⇒ Object
- #jquery_url(name) ⇒ Object
Instance Method Details
#jquery_include_tag(name, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jquery-rails-cdn.rb', line 33 def jquery_include_tag(name, = {}) .reverse_merge! :local_copy => false jquery = 'jquery' jquery = jquery + '.min' if .delete(:compressed) if OFFLINE and !.delete(:force) .delete(:local_copy) # not used in OFFLINE mode return javascript_include_tag(jquery, ) else j = [ javascript_include_tag(jquery_url(name), ) ] if .delete(:local_copy) j << javascript_tag("window.jQuery || document.write(unescape('#{javascript_include_tag(jquery, ).gsub('<','%3C')}'))") end j.join("\n").html_safe end end |
#jquery_ui_include_tag(name, options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/jquery-rails-cdn.rb', line 51 def jquery_ui_include_tag(name, = {}) .reverse_merge! :local_copy => false jqueryui = 'jquery-ui' jqueryui = jqueryui + '.min' if .delete(:compressed) if OFFLINE and !.delete(:force) .delete(:local_copy) # not used in OFFLINE mode return javascript_include_tag(jqueryui, ) else j = [ javascript_include_tag(jquery_ui_url(name), ) ] if .delete(:local_copy) j << javascript_tag("window.jQuery.ui || document.write(unescape('#{javascript_include_tag(jqueryui, ).gsub('<','%3C')}'))") end j.join("\n").html_safe end end |
#jquery_ui_url(name) ⇒ Object
29 30 31 |
# File 'lib/jquery-rails-cdn.rb', line 29 def jquery_ui_url(name) return CDNS[:jquery_ui][name] end |
#jquery_url(name) ⇒ Object
25 26 27 |
# File 'lib/jquery-rails-cdn.rb', line 25 def jquery_url(name) return CDNS[:jquery][name] end |