Skip to content

Instantly share code, notes, and snippets.

@prestarocket
Forked from yannickcr/social.js
Created September 15, 2012 20:02
Show Gist options
  • Save prestarocket/3729520 to your computer and use it in GitHub Desktop.
Save prestarocket/3729520 to your computer and use it in GitHub Desktop.
Insert GooglePlus and Facebook buttons (use the HTML5 embedding code)
/*
* Google Plus
*
* Include Google Plus One if there is a "g-plusone" button in the page
*
*/
$(document).ready(function() {
if (!$('.g-plusone').length) return;
window.___gcfg = {lang: 'fr-FR'};
var g = document.createElement('script');
g.async = true;
g.src = document.location.protocol + 'apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(g, s);
});
/*
* Facebook
*
* Include Facebook API if there is a "fb-like" button in the page
*
*/
$(document).ready(function() {
if (!$('.fb-like').length) return;
$('<div></div>').attr('class', 'fb-root').appendTo(document.body);
var f = document.createElement('script');
f.async = true;
f.src = document.location.protocol + 'connect.facebook.net/fr_FR/all.js#xfbml=1';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(f, s);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment