Created
June 26, 2012 16:43
-
-
Save iamnader/2996988 to your computer and use it in GitHub Desktop.
sprite helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def link_type_sprite(image, options = {}) | |
sprites = { | |
ReferrerClassifier::FACEBOOK => {:w => 20, :h => 20, :x => 5, :y => 0}, | |
ReferrerClassifier::TWITTER => {:w => 20, :h => 20, :x => 30, :y => 0}, | |
ReferrerClassifier::SEARCH => {:w => 20, :h => 20, :x => 55, :y => 0}, | |
ReferrerClassifier::BASIC => {:w => 20, :h => 20, :x => 80, :y => 0} | |
} | |
%(<div class="#{options[:class]}" style="background: url(#{path_to_image('/images/sn_icons/link-type-icon-sprite.png')}) no-repeat -#{sprites[image][:x]}px -#{sprites[image][:y]}px; width: #{sprites[image][:w]}px; height: #{sprites[image][:w]}px; #{options[:style]}" title="#{options[:title]}">#{options[:title]}</div>).html_safe | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment