diff options
Diffstat (limited to 'plugins/jetpack/modules/gplus-authorship/admin/connect.js')
-rw-r--r-- | plugins/jetpack/modules/gplus-authorship/admin/connect.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/gplus-authorship/admin/connect.js b/plugins/jetpack/modules/gplus-authorship/admin/connect.js new file mode 100644 index 00000000..72798ba2 --- /dev/null +++ b/plugins/jetpack/modules/gplus-authorship/admin/connect.js @@ -0,0 +1,42 @@ +function googlePlusSignInCallback( authResult ) { + var blogID = jQuery( '#current-blog-id' ).attr( 'data-value' ); + if ( authResult['code'] ) { + jQuery.ajax( { + type: 'POST', + url: 'index.php?page=gplus-authorship&blog_id=' + blogID + '&store_token=' + authResult['code'] + '&state=' + state, + contentType: 'application/json; charset=utf-8', + processData: false, + + success: function(result) { + if ( 'undefined' == typeof result.error ) { + googlePlusSendToParent( { success: true } ); + } else { + googlePlusSendToParent( { error: result.error } ); + } + }, + + error: function( result ) { + if ( 'undefined' != typeof result.error ) { + googlePlusSendToParent( { error: result.error } ); + } else { + googlePlusSendToParent( { error: 'unknown' } ); + } + } + } ); + } else if ( authResult['error'] ) { + googlePlusSendToParent( { error: authResult['error'] } ); + } else { + googlePlusSendToParent( { error: 'unknown' } ); + } +} + + function googlePlusSendToParent( data ) { + if ( 'immediate_failed' == data.error ) + return; + pm( { + target: window.parent, + type: 'googlePlusSignInMessage', + data: data, + origin: '*' + } ); +}
\ No newline at end of file |