Skip to content

Commit

Permalink
Merge pull request rodrigoprimo#69 from Frique/updated-popup-windows
Browse files Browse the repository at this point in the history
Updated popup windows
  • Loading branch information
rodrigoprimo committed Oct 27, 2014
2 parents 512b314 + 54fbab9 commit 3ca8e83
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions media/js/connect.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,57 @@
(function($) {
(function($) {
$(function() {
// ready to roll
if (social_connect_data.wordpress_enabled) {
var _social_connect_wordpress_form = $($('.social_connect_wordpress_form')[0]);
_social_connect_wordpress_form.dialog({
'dialogClass' : 'wp-dialog',
'modal' : true,
'autoOpen' : false,
'autoOpen' : false
});
}

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) {
Expand All @@ -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")
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);
}
};

Expand Down Expand Up @@ -99,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) {
Expand All @@ -108,7 +132,6 @@
});
})(jQuery);


window.wp_social_connect = function(config) {
jQuery('#loginform').unbind('submit.simplemodal-login');

Expand All @@ -128,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("<input type='hidden' id='" + key + "' name='" + key + "' value='" + value + "'>");
});
});

if(jQuery("#simplemodal-login-form").length) {
var current_url = window.location.href;
Expand All @@ -140,4 +163,4 @@ window.wp_social_connect = function(config) {
}

jQuery(form_id).submit();
}
};

0 comments on commit 3ca8e83

Please sign in to comment.