Skip to content

Instantly share code, notes, and snippets.

@pjschreifels
Forked from mathias/buttons.coffee
Created February 2, 2013 21:01
Show Gist options
  • Save pjschreifels/4699219 to your computer and use it in GitHub Desktop.
Save pjschreifels/4699219 to your computer and use it in GitHub Desktop.
#social-buttons #coffeescript Facebook and Twitter social media buttons using coffeescript for rails projects.
((d, s, id) ->
js = undefined
fjs = d.getElementsByTagName(s)[0]
return if d.getElementById(id)
js = d.createElement(s)
js.id = id
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"
fjs.parentNode.insertBefore js, fjs
) document, "script", "facebook-jssdk"
not ((d, s, id) ->
js = undefined
fjs = d.getElementsByTagName(s)[0]
unless d.getElementById(id)
js = d.createElement(s)
js.id = id
js.src = "//platform.twitter.com/widgets.js"
fjs.parentNode.insertBefore js, fjs
) document, "script", "twitter-wjs"
%a.twitter-share-button{"data-related" => "YourUserNameOnTwitter", "data-size" => "large", "data-text" => "I just tweeted about this site!", "data-via" => "YourUserNameOnTWitter", :href => "https://twitter.com/share"} Tweet
.fb-like{"data-action" => "like", "data-colorscheme" => "light", "data-layout" => "standard", "data-send" => "false", "data-show-faces" => "false", "data-width" => "450"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment