Sha256: 5275223a52769b60b2054ee9df359e29d3b52e58eed9f6d6813c118778e9e495

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

module Compass
  module SassExtensions
    module Sprites
      module ImageMethods
        # Fetches the Sprite::Image object for the supplied name
         def image_for(name)
          if name.is_a?(Sass::Script::Value::String)
            name = name.value
          end
          name = name.to_s
          @images.detect { |img| img.name.downcase == name.downcase}
         end

         # Returns true if the image name has a hover selector image
         def has_hover?(name)
           !get_magic_selector_image(name, 'hover').nil?
         end

         # Returns true if the image name has a target selector image
         def has_target?(name)
           !get_magic_selector_image(name, 'target').nil?
         end

         # Returns true if the image name has a focus selector image
         def has_focus?(name)
           !get_magic_selector_image(name, 'focus').nil?
         end

         # Returns true if the image name has an active selector image
         def has_active?(name)
           !get_magic_selector_image(name, 'active').nil?
         end

         SEPERATORS = ['_', '-']

         def get_magic_selector_image(name, selector)
          SEPERATORS.each do |seperator|
            file = image_for("#{name}#{seperator}#{selector}")
            return file if !file.nil?
          end

          nil
        end

         # Return and array of image names that make up this sprite
         def sprite_names
           image_names.map { |f| File.basename(f, '.png') }
         end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/compass-1.0.3/lib/compass/sass_extensions/sprites/image_methods.rb
compass-1.0.3 lib/compass/sass_extensions/sprites/image_methods.rb
compass-1.1.0.alpha.3 lib/compass/sass_extensions/sprites/image_methods.rb
compass-1.1.0.alpha.2 lib/compass/sass_extensions/sprites/image_methods.rb
compass-1.1.0.alpha.1 lib/compass/sass_extensions/sprites/image_methods.rb
compass-1.1.0.alpha.0 lib/compass/sass_extensions/sprites/image_methods.rb
compass-1.0.1 lib/compass/sass_extensions/sprites/image_methods.rb
compass-1.0.0 lib/compass/sass_extensions/sprites/image_methods.rb
compass-1.0.0.rc.1 lib/compass/sass_extensions/sprites/image_methods.rb