From 8926de5795dcc1f5d2b86f69e13ac130edb43d84 Mon Sep 17 00:00:00 2001 From: Berend de Jong Date: Thu, 25 Sep 2014 16:38:54 +0700 Subject: [PATCH 1/2] Specifically sized and centered popup windows --- media/js/connect.js | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/media/js/connect.js b/media/js/connect.js index 85956bb..f1d26e1 100644 --- a/media/js/connect.js +++ b/media/js/connect.js @@ -13,29 +13,45 @@ var _do_google_connect = function() { var google_auth = $('#social_connect_google_auth'); var redirect_uri = google_auth.find('input[type=hidden][name=redirect_uri]').val(); + var width = 460; + var height = 650; + var top = (screen.height / 2) - (height / 2); + var left = (screen.width / 2 ) - (width / 2); - window.open(redirect_uri,'','scrollbars=no,menubar=no,height=400,width=800,resizable=yes,toolbar=no,status=no'); + window.open(redirect_uri, '', 'scrollbars=no,menubar=no,height=' + height + ',width=' + width + ',resizable=yes,toolbar=no,status=no,top=' + top + ',left=' + left); }; var _do_google_plus_connect = function() { var google_plus_auth = $('#social_connect_google_plus_auth'); var redirect_uri = google_plus_auth.find('input[type=hidden][name=redirect_uri]').val(); + var width = 440; + var height = 630; + var top = (screen.height / 2) - (height / 2); + var left = (screen.width / 2 ) - (width / 2); - window.open(redirect_uri,'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no'); + window.open(redirect_uri, '', 'scrollbars=no,menubar=no,height=' + height + ',width=' + width + ',resizable=yes,toolbar=no,status=no,top=' + top + ',left=' + left); }; var _do_yahoo_connect = function() { var yahoo_auth = $('#social_connect_yahoo_auth'); var redirect_uri = yahoo_auth.find('input[type=hidden][name=redirect_uri]').val(); + var width = 500; + var height = 548; + var top = (screen.height / 2) - (height / 2); + var left = (screen.width / 2 ) - (width / 2); - window.open(redirect_uri,'','scrollbars=no,menubar=no,height=400,width=800,resizable=yes,toolbar=no,status=no'); + window.open(redirect_uri, '', 'scrollbars=no,menubar=no,height=' + height + ',width=' + width + ',resizable=yes,toolbar=no,status=no,top=' + top + ',left=' + left); }; var _do_twitter_connect = function() { var twitter_auth = $('#social_connect_twitter_auth'); var redirect_uri = twitter_auth.find('input[type=hidden][name=redirect_uri]').val(); + var width = 800; + var height = 800; + var top = (screen.height / 2) - (height / 2); + var left = (screen.width / 2 ) - (width / 2); - window.open(redirect_uri,'','scrollbars=no,menubar=no,height=400,width=800,resizable=yes,toolbar=no,status=no'); + window.open(redirect_uri, '', 'scrollbars=no,menubar=no,height=' + height + ',width=' + width + ',resizable=yes,toolbar=no,status=no,top=' + top + ',left=' + left); }; var _do_wordpress_connect = function(e) { @@ -45,20 +61,28 @@ var blog_name = $('.wordpress_blog_url', context).val(); var blog_url = "http://" + blog_name + ".wordpress.com"; redirect_uri = redirect_uri + "&wordpress_blog_url=" + encodeURIComponent(blog_url); + var width = 800; + var height = 400; + var top = (screen.height / 2) - (height / 2); + var left = (screen.width / 2 ) - (width / 2); - window.open(redirect_uri,'','scrollbars=yes,menubar=no,height=400,width=800,resizable=yes,toolbar=no,status=no'); + window.open(redirect_uri, '', 'scrollbars=yes,menubar=no,height=' + height + ',width=' + width + ',resizable=yes,toolbar=no,status=no,top=' + top + ',left=' + left); }; var _do_facebook_connect = function() { var facebook_auth = $('#social_connect_facebook_auth'); var client_id = facebook_auth.find('input[type=hidden][name=client_id]').val(); var redirect_uri = facebook_auth.find('input[type=hidden][name=redirect_uri]').val(); + var width = 1280; + var height = 540; + var top = (screen.height / 2) - (height / 2); + var left = (screen.width / 2 ) - (width / 2); if(client_id == "") { alert("Social Connect plugin has not been configured for this provider") } else { window.open('https://graph.facebook.com/oauth/authorize?client_id=' + client_id + '&redirect_uri=' + redirect_uri + '&scope=email', - '','scrollbars=no,menubar=no,height=400,width=800,resizable=yes,toolbar=no,status=no'); + '', 'scrollbars=no,menubar=no,height=' + height + ',width=' + width + ',resizable=yes,toolbar=no,status=no,top=' + top + ',left=' + left); } }; From 54fbab90e6093c5c7057e7930da3ced045a02749 Mon Sep 17 00:00:00 2001 From: Berend de Jong Date: Thu, 25 Sep 2014 16:54:29 +0700 Subject: [PATCH 2/2] Minor syntax cleanups --- media/js/connect.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/media/js/connect.js b/media/js/connect.js index f1d26e1..c067fdc 100644 --- a/media/js/connect.js +++ b/media/js/connect.js @@ -1,4 +1,4 @@ -(function($) { +(function($) { $(function() { // ready to roll if (social_connect_data.wordpress_enabled) { @@ -6,7 +6,7 @@ _social_connect_wordpress_form.dialog({ 'dialogClass' : 'wp-dialog', 'modal' : true, - 'autoOpen' : false, + 'autoOpen' : false }); } @@ -78,8 +78,8 @@ var top = (screen.height / 2) - (height / 2); var left = (screen.width / 2 ) - (width / 2); - if(client_id == "") { - alert("Social Connect plugin has not been configured for this provider") + if(client_id === "") { + alert("Social Connect plugin has not been configured for this provider"); } else { window.open('https://graph.facebook.com/oauth/authorize?client_id=' + client_id + '&redirect_uri=' + redirect_uri + '&scope=email', '', 'scrollbars=no,menubar=no,height=' + height + ',width=' + width + ',resizable=yes,toolbar=no,status=no,top=' + top + ',left=' + left); @@ -123,7 +123,7 @@ }); $(".social_connect_login_wordpress").on("click", function() { - _social_connect_wordpress_form.dialog('open'); + _social_connect_wordpress_form.dialog('open'); }); $(".social_connect_wordpress_proceed").on("click", function(e) { @@ -132,7 +132,6 @@ }); })(jQuery); - window.wp_social_connect = function(config) { jQuery('#loginform').unbind('submit.simplemodal-login'); @@ -152,10 +151,10 @@ window.wp_social_connect = function(config) { } } - jQuery.each(config, function(key, value) { + jQuery.each(config, function(key, value) { jQuery("#" + key).remove(); jQuery(form_id).append(""); - }); + }); if(jQuery("#simplemodal-login-form").length) { var current_url = window.location.href; @@ -164,4 +163,4 @@ window.wp_social_connect = function(config) { } jQuery(form_id).submit(); -} +};