Skip to content

Instantly share code, notes, and snippets.

@iamnader
Created June 26, 2012 16:43
Show Gist options
  • Save iamnader/2996988 to your computer and use it in GitHub Desktop.
Save iamnader/2996988 to your computer and use it in GitHub Desktop.
sprite helper
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