javascript: (function () {
/* check if the counter exists. */
if (window.googlePlusOneFloatingCounter == null) {
window.googlePlusOneFloatingCounter = 0;
}
/* check if previous +1 button already exists. */
var appLabel = "__googleplusonefloating__";
var id = appLabel + window.googlePlusOneFloatingCounter;
var doc = document;
var x = doc.getElementById(id);
if (x != null) {
x.disapear();
window.googlePlusOneFloatingCounter++;
}
/* create new id for wrapper div. */
id = appLabel + window.googlePlusOneFloatingCounter;
/* create a wrapper div. */
var div = doc.createElement('div');
div.id = id;
div.style.position = "absolute";
div.style.background = "white";
div.style.top = "" + (pageYOffset + 100) + "px";
div.style.left = "-200px";
div.style.height = "20px";
div.style.width = "150px";
div.style.zIndex = "9999";
div.style.boxShadow = "0 0 7px black";
div.style.borderRadius = "10px";
div.style.padding = "10px";
div.style.webkitTransition = "1500ms";
div.style.MozTransition = "1500ms";
div.style.textAlign = "center";
/* set +1 button source code. */
div.innerHTML = "<div style='float: right'><g:plusone size='medium' href='" + location.href + "'></g:plusone><br /><br /></div>";
/* set disapearing action. */
div.disapear = function () {
var self = this;
self.style.left = '-200px';
setTimeout(function () {
self.parentElement.removeChild(self);
}, 2000);
};
/* create a close button. */
var close = doc.createElement('button');
close.innerHTML = ' « ';
close.style.position = "relative";
close.style.float = 'left';
close.style.boxShadow = "0 0 3px black";
close.style.color = "white";
close.style.borderRadius = "5px";
close.style.border = "solid 0px";
close.style.background = "black";
close.style.margin = "0 7px 0 7px";
close.style.padding = "0";
close.style.width = "35px";
close.style.height = "20px";
close.style.fontFamily = '"Lucida Grande","Hiragino Kaku Gothic Pro","ヒラギノ角ゴ Pro W3","MS Pゴシック",Verdana,Arial,sans-serif';
/* set the close button action.
listener refers to closure's div. */
close.addEventListener('click', function () {
div.disapear();
});
/* insert the close button into the wrapper. */
div.insertBefore(close, div.firstChild);
/* Asynchronously import +1 button JavaScript.
It parse +1 tag and convert it into dom. */
setTimeout(function () {
var po = doc.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
doc.getElementsByTagName('body')[0].appendChild(po);
/* after setting the import code, trigger the transition of the wrapper div. */
setTimeout(function () {
div.style.left = "100px";
}, 30);
}, 30);
/* append wrapper div to body */
document.body.appendChild(div);
})();