Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// sharethis plugin by paul irish
// usage:
// $('a.sharethistrigger').shareThis();
// for ShareThis
$.fn.shareThis = function(){
if (!$(this).length) return this; // quit if theres nothing.
// this path should come out of the configurator
var mycustom = document.location.protocol + '//';
// this needs to be in the query string.
mycustom = mycustom.replace('&button=false','')+'&button=false';
var elems = this;
if (typeof SHARETHIS != 'undefined') attachButtons();
else $.getScript(mycustom,attachButtons);
},700); // 700 ms delay.
function attachButtons(){
if (typeof SHARETHIS == 'undefined') debug('SHARETHIS is undefined after scriptgrab',arguments);
var left = $(this).offset().left + $(this).width() - 354; // 354 is the hardcoded width of .stwrapper, the sharethis box.
SHARETHIS.addEntry({ title: document.title}, { button: false, offsetLeft: left }).attachButton(this);
return $(this).click(function(e){ e.preventDefault(); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment