Skip to content

keithchu/respond-rails

 
 

Repository files navigation

This repository is based upon the respond-rails gem by gevans (https://github.com/gevans/respond-rails). Thanks for your efforts!

As the gem uses an outdated respond.js (1.0.0), this repository is the effort to keep respond.js up to date.

respond-rails

Respond.js provides a fast and lightweight script to enable responsive web designs in browsers that don't support CSS3 media queries. You can find the original source repository at https://github.com/scottjehl/Respond.

Installation

Include the gem in your Gemfile:

    gem 'respond-rails', git: 'git:https://github.com/acristinziani/respond-rails.git', tag: 'update-respond-js-1.4.2'

Include Respond.js in your application layout like so:

    <%= respond_include_tags %>

And add respond.js to the list of precompiled assets:

# config/environments/production.rb

config.assets.precompile += %w( modernizr.js respond.js respond-proxy.html respond.proxy.js )

CDN/X-Domain Setup

If you store your assets on a separate host, you'll need to edit asset_host like so:

# config/environments/production.rb

config.action_controller.asset_host = Proc.new { |source, request|
  if source =~ /respond\.proxy.+(js|gif)$/
    "#{request.protocol}#{request.host_with_port}"
  else
    "//assets.example.com"
  end
}

This will skip the asset_host for respond.proxy.js and respond.proxy.gif which need to be on the same domain. After that, you'll need to make an addition to the precompiled assets:

config.assets.precompile += %w( respond.js respond-proxy.html respond.proxy.js )

Copyright

Copyright (c) 2011 Scott Jehl, scottjehl.com

See https://github.com/scottjehl/Respond for details.