Skip to content

Instantly share code, notes, and snippets.

@andyshora
Created March 30, 2014 09:45
Show Gist options
  • Save andyshora/9870313 to your computer and use it in GitHub Desktop.
Save andyshora/9870313 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
// enable on mouseover
$('.twitter-share-button-placeholder').bind('mouseover', function() {
enableShareButton($(this));
});
// auto enable for mobile
if (Modernizr.touch) {
enableShareButton($('.twitter-share-button-placeholder'));
}
});
function enableShareButton(elm) {
elm.addClass('twitter-share-button')
.removeClass('twitter-share-button-placeholder')
.attr('href', 'https://twitter.com/share')
.unbind('click');
!function(d,s,id){
var js,
fjs=d.getElementsByTagName(s)[0],
p=/^http:/.test(d.location)?'http':'https';
if(!d.getElementById(id)){
js=d.createElement(s);
js.id=id;
js.src=p+'://platform.twitter.com/widgets.js';
fjs.parentNode.insertBefore(js,fjs);
}
}(document, 'script', 'twitter-wjs');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment