RocketFuelLeak/RocketFuelLeakSite

View on GitHub
app/assets/javascripts/social.js.coffee.erb

Summary

Maintainability
Test Coverage
twttr_events_bound = false

$ ->
    bindTwitterEventHandlers() unless twttr_events_bound
    window.___gcfg = {lang: 'en-GB'}
    gapi.plusone.go()
    $(document).on 'page:load', ->
        gapi.plusone.go()

$(document).on 'ready page:load', ->
    $('.news-post-social-container input.news-post-url-box').on 'focus', ->
        $(this).select()

bindTwitterEventHandlers = ->
    $(document).on 'page:load', renderTweetButtons
    twttr_events_bound = true

renderTweetButtons = ->
    $('.twitter-share-button').each ->
        button = $(this)
        button.attr('data-url', document.location.href) unless button.data('url')?
        button.attr('data-text', document.title) unless button.data('text')?
    twttr.widgets.load()