Module: Compass::Core::SassExtensions::Functions::CrossBrowserSupport

### Home Classes Methods

### In Files

- lib/compass/core/sass_extensions/functions/cross_browser_support.rb

### Namespace

- CLASS Compass::Core::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue

### Methods

- #browser_capabilities
- #browser_prefix
- #browser_prefixes
- #browser_ranges
- #browser_requires_prefix
- #browser_versions
- #browsers
- #compare_browser_versions
- #css2_fallback
- #next_version
- #omitted_usage
- #prefix
- #prefix_usage
- #prefixed
- #previous_version

### Class/Module Index

Quicksearch

- Compass
- Compass::BrowserSupport
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Watch
- Compass::Core
- Compass::Core::CanIUse
- Compass::Core::SassExtensions
- Compass::Core::SassExtensions::Functions
- Compass::Core::SassExtensions::Functions::Colors
- Compass::Core::SassExtensions::Functions::Configuration
- Compass::Core::SassExtensions::Functions::Constants
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::Core::SassExtensions::Functions::Display
- Compass::Core::SassExtensions::Functions::Enumerate
- Compass::Core::SassExtensions::Functions::Env
- Compass::Core::SassExtensions::Functions::Files
- Compass::Core::SassExtensions::Functions::FontFiles
- Compass::Core::SassExtensions::Functions::GradientSupport
- Compass::Core::SassExtensions::Functions::GradientSupport::Assertions
- Compass::Core::SassExtensions::Functions::GradientSupport::CSS3AngleToSVGConverter
- Compass::Core::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::Core::SassExtensions::Functions::GradientSupport::Functions
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::Core::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::Core::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::Core::SassExtensions::Functions::ImageSize
- Compass::Core::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::Core::SassExtensions::Functions::ImageSize::JPEG
- Compass::Core::SassExtensions::Functions::InlineImage
- Compass::Core::SassExtensions::Functions::Lists
- Compass::Core::SassExtensions::Functions::Math
- Compass::Core::SassExtensions::Functions::SassDeclarationHelper
- Compass::Core::SassExtensions::Functions::Selectors
- Compass::Core::SassExtensions::Functions::Urls
- Compass::Core::SassExtensions::Functions::Urls::FontUrl
- Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::Core::SassExtensions::Functions::Urls::ImageUrl
- Compass::Core::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::Error
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::HasDeprecatedConstantsFromCore
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::Util
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Tree
- Sass::Tree::Node

No matching classes.

# Compass::Core::SassExtensions::Functions::CrossBrowserSupport

### Constants

CAPABILITY_OPTION_KEYS
CAPABILITY_OPTION_UNBOXER

### Public Instance Methods

browser_capabilities() click to toggle source

The known capabilities of browsers.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 89
    def browser_capabilities
      list(Compass::Core::CanIUse.instance.capabilities.map{|c| identifier(c)}, :comma)
    end

browser_prefix(browser, version = nil) click to toggle source

the prefix for the given browser.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 120
    def browser_prefix(browser, version = nil)
      assert_type browser, :String
      identifier(Compass::Core::CanIUse.instance.prefix(browser.value))
    rescue ArgumentError => e
      raise Sass::SyntaxError.new(e.message)
    end

browser_prefixes(browsers) click to toggle source

The prefixes used by the given browsers.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 130
    def browser_prefixes(browsers)
      browsers = list(browsers, :comma) if browsers.is_a?(Sass::Script::Value::String)
      assert_type browsers, :List
      browser_strings = browsers.value.map {|b| assert_type(b, :String); b.value }
      prefix_strings = Compass::Core::CanIUse.instance.prefixes(browser_strings)
      list(prefix_strings.map {|p| identifier(p)}, :comma)
    rescue ArgumentError => e
      raise Sass::SyntaxError.new(e.message)
    end

browser_ranges(capability, prefix = null(), include_unprefixed_versions = bool(true)) click to toggle source

Returns a map of browsers to the first version the capability became available without a prefix.

If a prefix is provided, only those browsers using that prefix will be returned and the minimum version will be when it first became available as a prefix or without a prefix.

If a browser does not have the capability, it will not included in the map.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 217
    def browser_ranges(capability, prefix = null(), include_unprefixed_versions = bool(true))
      assert_type capability, :String
      assert_type(prefix, :String) unless prefix == null()
      mins = Compass::Core::CanIUse.instance.browser_ranges(capability.value,
                                                            prefix.value,
                                                            include_unprefixed_versions.to_bool)
      Sass::Script::Value::Map.new(mins.inject({}) do |m, (h, range)|
        m[identifier(h)] = list(range.map{|version| quoted_string(version)}, :space)
        m
      end)
    end

browser_requires_prefix(browser, version, capability, capability_options) click to toggle source

whether the browser uses a prefix for the given capability at the version specified or a later version. Returns the prefix it requires, or null.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 105
    def browser_requires_prefix(browser, version, capability, capability_options)
      assert_type browser, :String
      assert_type version, :String
      assert_type capability, :String
      p = Compass::Core::CanIUse.instance.requires_prefix(browser.value,
                                                    version.value,
                                                    capability.value,
                                                    unbox_capability_options_list(capability_options))
      p ? identifier(p) : null()
    rescue ArgumentError => e
      raise Sass::SyntaxError.new(e.message)
    end

browser_versions(browser) click to toggle source

The versions for the given browser.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 95
    def browser_versions(browser)
      assert_type browser, :String
      list(Compass::Core::CanIUse.instance.versions(browser.value).map{|v| quoted_string(v)}, :comma)
    rescue ArgumentError => e
      raise Sass::SyntaxError.new(e.message)
    end

browsers(prefix = nil) click to toggle source

The known browsers.

If prefix is given, limits the returned browsers to those using the specified prefix.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 76
    def browsers(prefix = nil)
      browsers = if prefix
                   assert_type prefix, :String
                   Compass::Core::CanIUse.instance.browsers_with_prefix(prefix.value)
                 else
                   Compass::Core::CanIUse.instance.browsers
                 end
      list(browsers.map{|b| identifier(b)}, :comma)
    end

compare_browser_versions(browser, version1, version2) click to toggle source

Compares two browser versions. Returning:

- 0 if they are the same

- <0 if the first version is less than the second

- >0 if the first version is more than the second

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 189
    def compare_browser_versions(browser, version1, version2)
      assert_type browser, :String, :browser
      assert_type version1, :String, :version1
      assert_type version2, :String, :version2
      index1 = index2 = nil
      Compass::Core::CanIUse.instance.versions(browser.value).each_with_index do |v, i|
        index1 = i if v == version1.value
        index2 = i if v == version2.value
        break if index1 && index2
      end
      unless index1
        raise Sass::SyntaxError.new("#{version1} is not a version for #{browser}")
      end
      unless index2
        raise Sass::SyntaxError.new("#{version2} is not a version for #{browser}")
      end
      number(index1 <=> index2)
    end

css2_fallback(value, css2_value) click to toggle source

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 69
    def css2_fallback(value, css2_value)
      CSS2FallbackValue.new(value, css2_value)
    end

next_version(browser, version) click to toggle source

The version before the version for the browser specified

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 164
    def next_version(browser, version)
      assert_type browser, :String
      assert_type version, :String
      next_version = Compass::Core::CanIUse.instance.next_version(browser.value, version.value)
      next_version.nil? ? null() : quoted_string(next_version)
    end

omitted_usage(browser, min_version, max_version = nil) click to toggle source

The percent of users that are omitted by setting the min_version of browser as specified.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 143
    def omitted_usage(browser, min_version, max_version = nil)
      assert_type browser, :String
      assert_type min_version, :String, :min_version
      assert_type(max_version, :String, :max_version) if max_version
      versions = [min_version.value]
      versions << max_version.value if max_version
      number(Compass::Core::CanIUse.instance.omitted_usage(browser.value, *versions))
    end

prefix(prefix, *objects) click to toggle source

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 48
    def prefix(prefix, *objects)
      assert_type prefix, :String if prefix.is_a?(Sass::Script::Value::Base)
      prefix = prefix.value if prefix.is_a?(Sass::Script::Value::String)
      prefix = prefix[1..-1] if prefix[0] == --
      if objects.size > 1
        self.prefix(prefix, list(objects, :comma))
      else
        object = objects.first
        if object.is_a?(Sass::Script::Value::List)
          list(object.value.map{|e|
            self.prefix(prefix, e)
          }, object.separator)
        elsif object.respond_to?(:supports?) && object.supports?(prefix) && object.respond_to?(:"to_#{prefix}")
          object.options = options
          object.send(:"to_#{prefix}")
        else
          object
        end
      end
    end

prefix_usage(prefix, capability, capability_options) click to toggle source

The percent of users relying on a particular prefix

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 173
    def prefix_usage(prefix, capability, capability_options)
      assert_type prefix, :String
      assert_type capability, :String
      number(Compass::Core::CanIUse.instance.prefixed_usage(prefix.value,
                                                      capability.value,
                                                      unbox_capability_options_list(capability_options)))
    rescue ArgumentError => e
      raise Sass::SyntaxError.new(e.message)
    end

prefixed(prefix, *args) click to toggle source

Check if any of the arguments passed require a vendor prefix.

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 31
    def prefixed(prefix, *args)
      assert_type prefix, :String
      aspect = prefix.value.sub(/^-/,"")
      needed = args.any?{|a| a.respond_to?(:supports?) && a.supports?(aspect)}
      bool(needed)
    end

previous_version(browser, version) click to toggle source

The version before the version for the browser specified

    # File lib/compass/core/sass_extensions/functions/cross_browser_support.rb, line 155
    def previous_version(browser, version)
      assert_type browser, :String
      assert_type version, :String
      previous = Compass::Core::CanIUse.instance.previous_version(browser.value, version.value)
      previous.nil? ? null() : quoted_string(previous)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.