/** * Element Pack Google OAuth Admin JavaScript - Server-side flow */ (function($) { 'use strict'; $(document).ready(function() { var EPGoogleOAuth = { clientId: '', ajaxUrl: '', ajaxNonce: '', init: function() { if (typeof element_pack_oauth_admin !== 'undefined') { this.clientId = element_pack_oauth_admin.client_id || ''; this.ajaxUrl = element_pack_oauth_admin.ajaxurl || ajaxurl; this.ajaxNonce = element_pack_oauth_admin.nonce || ''; } else { return; } this.bindEvents(); }, bindEvents: function() { var self = this; $('#ep-connect-google').on('click', function(e) { e.preventDefault(); self.connectToGoogle($(this)); }); $('#ep-disconnect-google').on('click', function(e) { e.preventDefault(); self.disconnectFromGoogle($(this)); }); }, connectToGoogle: function($button) { if (!this.clientId) { alert('Please configure your Google OAuth Client ID first.'); return; } $button.prop('disabled', true).text('Connecting...'); $('#ep-oauth-status').html( '