Skip to content

Instantly share code, notes, and snippets.

@pawelgur
Created August 4, 2014 20:32
Show Gist options
  • Save pawelgur/d0ba0e95b9faafedeb15 to your computer and use it in GitHub Desktop.
Save pawelgur/d0ba0e95b9faafedeb15 to your computer and use it in GitHub Desktop.
Standard sharing buttons insert script
////////////////////////////////////////////
//
// SHARING BUTTONS SCRIPTS
// Included with _standard_PostSharingButtons.cshtml
//
////////////////////////////////////////////
window.onload = function () //add after document has fully loaded
{
/* ************* tweet it button ******************** */
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
js.async = true;
fjs.parentNode.insertBefore(js, fjs);
}
})(document, "script", "twitter-wjs");
/* ************ share on linkedin button ******************** */
(function () {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://platform.linkedin.com/in.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
/* ************ facebook like button ******************** */
(function (d, s, id) {
//adds needed div
var body = d.getElementsByTagName("body")[0];
var div = d.createElement("div");
div.id = "fb-root";
body.appendChild(div);
//adds actual script tag
var js,
fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.async = true;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=114891398711423";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
/* ************ google+ button ******************** */
(function () {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment