Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active November 30, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/cf4136e4ff77cb3db008d869ef3826e3 to your computer and use it in GitHub Desktop.
Save billerickson/cf4136e4ff77cb3db008d869ef3826e3 to your computer and use it in GitHub Desktop.
jQuery(function($){
// Tweet Blockquote
$('blockquote.tweet').each(function(){
via = 'billerickson';
if( $('.author-box .icon-twitter').length ) {
via = $('.author-summary .icon-twitter').parent().attr('href').split('/').pop();
}
quote = $(this).text();
if( quote.length > 120 ) {
quote = jQuery.trim($(this).text()).substring(0, 120).split(" ").slice(0, -1).join(" ") + '...';
}
url = 'https://twitter.com/intent/tweet?&text=' + encodeURIComponent( quote ) + '&via=' + via;
$(this).append( '<a href="' + url + '" class="twitter-share-button" target="_blank"><i class="icon-twitter"></i> Tweet this</a>' );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment