lib/jquery-rails-cdn.rb in jquery-rails-cdn-yjchen-0.3.3 vs lib/jquery-rails-cdn.rb in jquery-rails-cdn-yjchen-0.3.4
- old
+ new
@@ -29,31 +29,41 @@
def jquery_ui_url(name)
return CDNS[:jquery_ui][name]
end
def jquery_include_tag(name, options = {})
+ options.reverse_merge! :local_copy => false
+
jquery = 'jquery'
jquery = jquery + '.min' if options.delete(:compressed)
if OFFLINE and !options.delete(:force)
+ options.delete(:local_copy) # not used in OFFLINE mode
return javascript_include_tag(jquery, options)
else
- [ javascript_include_tag(jquery_url(name), options),
- javascript_tag("window.jQuery || document.write(unescape('#{javascript_include_tag(jquery, options).gsub('<','%3C')}'))")
- ].join("\n").html_safe
+ j = [ javascript_include_tag(jquery_url(name), options) ]
+ if options.delete(:local_copy)
+ j << javascript_tag("window.jQuery || document.write(unescape('#{javascript_include_tag(jquery, options).gsub('<','%3C')}'))")
+ end
+ j.join("\n").html_safe
end
end
def jquery_ui_include_tag(name, options = {})
+ options.reverse_merge! :local_copy => false
+
jqueryui = 'jquery-ui'
jqueryui = jqueryui + '.min' if options.delete(:compressed)
if OFFLINE and !options.delete(:force)
+ options.delete(:local_copy) # not used in OFFLINE mode
return javascript_include_tag(jqueryui, options)
else
- [ javascript_include_tag(jquery_ui_url(name), options),
- javascript_tag("window.jQuery.ui || document.write(unescape('#{javascript_include_tag(jqueryui, options).gsub('<','%3C')}'))")
- ].join("\n").html_safe
+ j = [ javascript_include_tag(jquery_ui_url(name), options) ]
+ if options.delete(:local_copy)
+ j << javascript_tag("window.jQuery.ui || document.write(unescape('#{javascript_include_tag(jqueryui, options).gsub('<','%3C')}'))")
+ end
+ j.join("\n").html_safe
end
end
end
class Railtie < Rails::Railtie