Sha256: f3ba787793b17905f3a042297ab359e712dab7e6593097b86fa38b97bdd99622

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

module MobileFu
  module MobilizedStyles

    # This logic was taken from Michael Bleigh's browserized styles
    # with modification to work for mobile browsers.

    def device_name
      @device_name ||= request.headers['X_MOBILE_DEVICE']
    end

    def stylesheet_link_tag_with_mobilization(*sources)
      mobilized_sources = Array.new
      sources.each do |source|
        mobilized_sources << source

        path = File.join config.stylesheets_dir, "#{source.to_s.gsub '.css', ''}_#{device_name}.css"
        mobilized_sources << possible_source if File.exist?(path)
      end

      stylesheet_link_tag *mobilized_sources
    end
  end
end

ActionView::Base.send :include, MobileFu::MobilizedStyles
ActionView::Base.send :alias_method_chain, :stylesheet_link_tag, :mobilization

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mobile-fu-0.1.2 lib/mobile-fu/mobilized_styles.rb
mobile-fu-0.1.1 lib/mobile-fu/mobilized_styles.rb