From 3ffcddde2356966986c9cff10f8009b5e1452b2d Mon Sep 17 00:00:00 2001 From: Alex Vasilenko Date: Fri, 28 Sep 2012 14:09:01 +0300 Subject: [PATCH 1/3] amd support optional callback instead of tracking closed state --- src/jquery.oauthpopup.js | 64 +++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/src/jquery.oauthpopup.js b/src/jquery.oauthpopup.js index d06b2e5..f685dc5 100644 --- a/src/jquery.oauthpopup.js +++ b/src/jquery.oauthpopup.js @@ -7,25 +7,47 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ -(function($){ - // inspired by DISQUS - $.oauthpopup = function(options) - { - if (!options || !options.path) { - throw new Error("options.path must not be empty"); - } - options = $.extend({ - windowName: 'ConnectWithOAuth' // should not include space for IE - , windowOptions: 'location=0,status=0,width=800,height=400' - , callback: function(){ window.location.reload(); } - }, options); - - var oauthWindow = window.open(options.path, options.windowName, options.windowOptions); - var oauthInterval = window.setInterval(function(){ - if (oauthWindow.closed) { - window.clearInterval(oauthInterval); - options.callback(); +(function(factory) { + // Support three module loading scenarios + if (typeof define === 'function' && define['amd']) { + // AMD anonymous module + define(['jquery'], factory); + } else { + // No module loader (plain