From bcfaf522fd7072de8bf4896aff71da80f711d267 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 7 Jan 2014 12:41:20 -0500 Subject: [PATCH] Add spinner when authenticating with 3rd party. Also handle when popup window is closed without making a callback. --- .../discourse/controllers/login_controller.js | 17 ++++++++++++++--- .../templates/modal/login.js.handlebars | 13 +++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/login_controller.js b/app/assets/javascripts/discourse/controllers/login_controller.js index 79601e16748..de982a55d5f 100644 --- a/app/assets/javascripts/discourse/controllers/login_controller.js +++ b/app/assets/javascripts/discourse/controllers/login_controller.js @@ -37,8 +37,12 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona }.property('loginName', 'loginPassword', 'loggingIn'), showSignupLink: function() { - return !Discourse.SiteSettings.invite_only && !this.get('loggingIn'); - }.property('loggingIn'), + return !Discourse.SiteSettings.invite_only && !this.get('loggingIn') && this.blank('authenticate'); + }.property('loggingIn', 'authenticate'), + + showSpinner: function() { + return this.get('loggingIn') || this.get('authenticate'); + }.property('loggingIn', 'authenticate'), actions: { login: function() { @@ -91,8 +95,15 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona var height = loginMethod.get("frameHeight") || 400; var width = loginMethod.get("frameWidth") || 800; - window.open(Discourse.getURL("/auth/" + name), "_blank", + var w = window.open(Discourse.getURL("/auth/" + name), "_blank", "menubar=no,status=no,height=" + height + ",width=" + width + ",left=" + left + ",top=" + top); + var self = this; + var timer = setInterval(function() { + if(w.closed) { + clearInterval(timer); + self.set('authenticate', null); + } + }, 1000); } }, diff --git a/app/assets/javascripts/discourse/templates/modal/login.js.handlebars b/app/assets/javascripts/discourse/templates/modal/login.js.handlebars index 1c6f17ec6ff..85ef001a807 100644 --- a/app/assets/javascripts/discourse/templates/modal/login.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/login.js.handlebars @@ -41,9 +41,6 @@
{{alert}}