Skip to content

Instantly share code, notes, and snippets.

@Vlasterx
Forked from Takazudo/dynamic_gplus.js
Last active August 29, 2015 14:17
Show Gist options
  • Save Vlasterx/a5d077ee99b452f531c0 to your computer and use it in GitHub Desktop.
Save Vlasterx/a5d077ee99b452f531c0 to your computer and use it in GitHub Desktop.
Google+ follow in dropdown menu
var $ = jQuery;
var gapi;
var googlePlusAdded = false;
var gplusoneLoaded = false;
var gplusClass = ".button__googlePlus"; // Class where you want to insert G+ button
var gplusPage = "http://your_google_plus_page";
// Add Google+ on menu hover
$('#menu').hover(function() { // ID or Class of your menu hover
if (!googlePlusAdded) {
$(gplusClass).append('<div class="g-follow" data-annotation="bubble" data-height="20" data-width="120" data-href="'+ gplusPage + '" data-rel="publisher"></div>');
googlePlusAdded = true;
if(!gplusoneLoaded){
gplusoneLoaded = true;
$.getScript("//apis.google.com/js/platform.js");
}else{
if(gapi){ // IE7 can't handle it
gapi.plusone.go();
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment