Created
February 21, 2011 00:44
-
-
Save tjmcewan/836481 to your computer and use it in GitHub Desktop.
env-aware jQuery includes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= jquery_includes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def jquery_includes | |
jquery_version = "1.4.4" | |
jquery_ui_version = "1.8.9" | |
css_theme = "redmond" | |
if ::Rails.env == 'production' | |
proto = request.ssl? ? 'https://' : 'http://' | |
cdn_url = "ajax.googleapis.com/ajax/libs/jquery" | |
javascript_include_tag("#{proto}#{cdn_url}/#{jquery_version}/jquery.min.js") + | |
javascript_include_tag("#{proto}#{cdn_url}ui/#{jquery_ui_version}/jquery-ui.min.js") + | |
stylesheet_link_tag("#{proto}#{cdn_url}ui/#{jquery_ui_version}/themes/#{css_theme}/jquery-ui.css") | |
else | |
javascript_include_tag("jquery-#{jquery_version}", "jquery-ui-#{jquery_ui_version}") + | |
stylesheet_link_tag("jquery-ui-#{jquery_ui_version}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment