Sha256: 67db7c0f265c39e63beea161bc1a4046b5fe309012030bce8ecfc4af99ea4552

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 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 ||= 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

1 entries across 1 versions & 1 rubygems

Version Path
mobile-fu-0.1.0 lib/mobile-fu/mobilized_styles.rb