Skip to content

Instantly share code, notes, and snippets.

@neara
Last active August 29, 2015 13:56
Show Gist options
  • Save neara/8843101 to your computer and use it in GitHub Desktop.
Save neara/8843101 to your computer and use it in GitHub Desktop.
Dynamic social buttons: twitter, facebook, google plus
$socialBtnsWrapper = $('<div>').addClass('row col-xs-12')
$twitterContainer = $('<div>').addClass('col-xs-4 social-btn')
$twitterShareBtn = $('<a>').attr('href', 'https://twitter.com/share')
.addClass('twitter-share-button')
.attr('data-count', 'vertical')
.attr('data-via', 'fanwaze')
.attr('data-url', urlToShare)
.attr('data-text', 'Discover the world of sports')
.text('Share on Twitter')
$twitterContainer.append($twitterShareBtn)
$socialBtnsWrapper.append($twitterContainer)
$fbContainer = $('<div>').addClass('col-xs-4 social-btn')
$fbShareBtn = $('<div>').addClass('fb-share-button')
.attr('data-href', urlToShare)
.attr('data-type', 'box_count')
$fbContainer.append($fbShareBtn)
$socialBtnsWrapper.append($fbContainer)
$gPlusContainer = $('<div>').addClass('col-xs-4 social-btn')
$gPlusShareBtn = $('<div>').addClass('g-plus')
.attr('data-action', 'share')
.attr('data-annotation', 'vertical-bubble')
.attr('data-href', urlToShare)
.attr('id', 'fsShare')
$gPlusContainer.append($gPlusShareBtn)
$socialBtnsWrapper.append($gPlusContainer)
$modalBody.append($socialBtnsWrapper)
twttr.widgets.load()
FB.XFBML.parse()
gapi.plus.go '#fsShare'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment