Created
January 10, 2014 07:29
-
-
Save chrisyour/8348202 to your computer and use it in GitHub Desktop.
CoffeeScript to load Twitter's twitter-wjs JavaScript. Tip: Any link that goes to an intent URL (like http://twitter.com/intent/tweet) acts like a Twitter button with all the Widget-wjs functionality with events, so you can customize the look of your button without having to use the Twitter generated iFrame buttons.
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
# Load Twitter Widgets | |
window.twttr = ((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 | |
window.twttr || t = { _e: [], ready: (f)-> t._e.push(f) } | |
) document, "script", "twitter-wjs" | |
# Twitter Ready | |
twttr.ready((twttr)-> | |
# Twitter Events | |
# Event: Tweet | |
twttr.events.bind 'tweet', (event) -> | |
alert "Twitter tweet just happened!" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment