Skip to content

Instantly share code, notes, and snippets.

@jun9
Created February 13, 2012 04:41
Show Gist options
  • Save jun9/1813738 to your computer and use it in GitHub Desktop.
Save jun9/1813738 to your computer and use it in GitHub Desktop.
google plus bookmarklet
/**
* @author Jesse Lucas <jesse@forestgiant.com>
*/
var j = document.createElement("script");
j.type = "text/javascript";
j.onload = loadGPlus;
j.src = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName("head")[0].appendChild(j);
/**
* function to load google plus api
*/
function loadGPlus()
{
var g = document.createElement("script");
g.type = "text/javascript";
g.onload = init;
g.src = "https://apis.google.com/js/plusone.js";
document.getElementsByTagName("head")[0].appendChild(g);
}//end loadGPlus function
/**
* init function
*/
function init()
{
//get page url
var href = encodeURIComponent(document.location.href);
//create module to store form
$("body").append("\
<div id='gPlusFrame'>\
<div id='gPlusFrameBack' style=''>\
</div>\
<div id='gPlusContent'>\
<div class='g-plusone' data-annotation='inline' data-width='150'>\
</div>\
</div>\
<style type='text/css'>\
#gPlusFrameBack{ display: none; position: fixed; width: 100%; height: 100%; top: 0; left: 0; background-color: rgba(0,0,0,.5); cursor: pointer; z-index: 900; }\
#gPlusContent { display: none; position: fixed; top: 0; right: 20px; width: 106px; height: 24px; z-index: 999; background-color: rgba(255, 255, 255, .75); border: 2px solid #1e4e52; padding: 10px; }\
</style>\
</div>"
);
$("#gPlusFrameBack").fadeIn(750);
$('#gPlusContent').slideDown(500);
$("#gPlusFrameBack").click(function(e){
$("#gPlusFrameBack").fadeOut(750);
$("#gPlusContent").slideUp(500);
setTimeout("$('#gPlusFrame').remove()", 750);
});
}//end init function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment