| 1 |
/** |
| 2 |
* Inserts the "Sign in with Google" button. |
| 3 |
*/ |
| 4 |
|
| 5 |
/* global document, signInCallback, gapi */ |
| 6 |
( function() { |
| 7 |
var po = document.createElement( 'script' ); |
| 8 |
po.type = 'text/javascript'; |
| 9 |
po.async = true; |
| 10 |
po.src = 'https://plus.google.com/js/client:plusone.js?onload=render'; |
| 11 |
var scr = document.getElementsByTagName( 'script' )[0]; |
| 12 |
scr.parentNode.insertBefore( po, scr ); |
| 13 |
})(); |
| 14 |
|
| 15 |
/* Executed when the APIs finish loading */ |
| 16 |
// eslint-disable-next-line |
| 17 |
function render() { // jshint ignore:line |
| 18 |
// Additional params including the callback, the rest of the params will |
| 19 |
// come from the page-level configuration. |
| 20 |
var additionalParams = { |
| 21 |
callback: signInCallback, |
| 22 |
}; |
| 23 |
// Attach a click listener to a button to trigger the flow. |
| 24 |
var signinButton = document.getElementById( 'googleplus_button' ); |
| 25 |
signinButton.addEventListener( 'click', function() { |
| 26 |
gapi.auth.signIn( additionalParams ); // Will use page level configuration |
| 27 |
jQuery( '#googleplus_button' ).animate({ opacity: 0.5 }); |
| 28 |
}); |
| 29 |
} |
| 30 |
|