diff --git a/browserid/static/dialog/controllers/dialog_controller.js b/browserid/static/dialog/controllers/dialog_controller.js index d9c67b6b9167a3b07a2273ddf2ea5d530652316b..da7f322d57f09efedfa38e0b439669b492d1872f 100644 --- a/browserid/static/dialog/controllers/dialog_controller.js +++ b/browserid/static/dialog/controllers/dialog_controller.js @@ -7,7 +7,7 @@ (function() { "use strict"; -$.Controller("Dialog", {}, { +PageController.extend("Dialog", {}, { init: function(el) { var html = $.View("//dialog/views/body.ejs", {}); this.element.html(html); @@ -20,21 +20,6 @@ $.Controller("Dialog", {}, { this.stateMachine(); }, - renderTemplates: function(body, body_vars, footer, footer_vars) { - if (body) { - var bodyHtml = $.View("//dialog/views/" + body, body_vars); - $('#dialog').html(bodyHtml).hide().fadeIn(300, function() { - $('#dialog input').eq(0).focus(); - }); - } - - if (footer) { - var footerHtml = $.View("//dialog/views/" + footer, footer_vars); - $('#bottom-bar').html(footerHtml); - } - setupEnterKey(); - }, - "#suggest_signin click": function(event) { this.doAuthenticate(); }, @@ -76,7 +61,7 @@ $.Controller("Dialog", {}, { self.doConfirmEmail(email, keypair); }, function() { - runErrorDialog(BrowserIDErrors.addEmail); + self.runErrorDialog(BrowserIDErrors.addEmail); }); }, @@ -111,6 +96,7 @@ $.Controller("Dialog", {}, { stateMachine: function() { var self=this, hub = OpenAjax.hub, el = this.element; + hub.subscribe("createaccount:created", function(info) { self.doConfirmEmail(info.email, info.keypair); }); @@ -127,7 +113,6 @@ $.Controller("Dialog", {}, { self.doForgotPassword(); }); - hub.subscribe("checkregistration:confirmed", function() { // this is a secondary registration from browserid.org, persist // email, keypair, and that fact @@ -136,7 +121,7 @@ $.Controller("Dialog", {}, { self.syncidentities(); }); - hub.subscribe("checkregistration:confirmed", function() { + hub.subscribe("checkregistration:complete", function() { self.doSignIn(); }); @@ -237,14 +222,15 @@ $.Controller("Dialog", {}, { self.persistAddressAndKeyPair(email, keypair, "browserid.org:443"); }, function onKeySyncFailure() { - runErrorDialog(BrowserIDErrors.syncAddress); + self.runErrorDialog(BrowserIDErrors.syncAddress); }, function onSuccess() { self.doSignIn(); }, function onFailure(jqXHR, textStatus, errorThrown) { - runErrorDialog(BrowserIDErrors.signIn); - }); + self.runErrorDialog(BrowserIDErrors.signIn); + } + ); }, @@ -258,35 +244,11 @@ $.Controller("Dialog", {}, { authcb(); } }, function() { - runErrorDialog(BrowserIDErrors.checkAuthentication); + self.runErrorDialog(BrowserIDErrors.checkAuthentication); }); } }); - function runErrorDialog(info) { - $(".dialog").hide(); - - $("#error_dialog div.title").text(info.message); - $("#error_dialog div.content").text(info.description); - - $("#back").hide(); - $("#cancel").hide(); - $("#submit").show().unbind('click').click(function() { - }).text("Close"); - - $("#error_dialog").fadeIn(500); - } - - function setupEnterKey() { - $("input").keyup(function(e) { - if(e.which == 13) { - $('.submit').click(); - e.preventDefault(); - } - }); - } - - }()); diff --git a/browserid/static/dialog/dialog.js b/browserid/static/dialog/dialog.js index b1efa30d611fbb0915a56311eb9681d9b51e352a..ac61d495a10358578f34d625b5a6ec0950f5d934 100644 --- a/browserid/static/dialog/dialog.js +++ b/browserid/static/dialog/dialog.js @@ -20,8 +20,8 @@ steal.plugins( .models() // loads files in models folder - .controllers('dialog', - 'page', + .controllers('page', + 'dialog', 'authenticate', 'createaccount', 'checkregistration',