Skip to content

Commit

Permalink
Merge branch 'ctrl_c_email_field' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Tomlinson committed Oct 19, 2011
2 parents bb1ffb2 + 49ab61b commit f96a085
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions browserid/static/dialog/controllers/authenticate_controller.js
Expand Up @@ -40,20 +40,21 @@
var ANIMATION_TIME = 250,
bid = BrowserID,
user = bid.User,
validation = bid.Validation;
validation = bid.Validation,
lastEmail = "";

function checkEmail(el, event) {
var email = $("#email").val(),
self = this;

cancelEvent(event);

if(!validation.email(email)) {
if (!validation.email(email)) {
return;
}

user.isEmailRegistered(email, function onComplete(registered) {
if(registered) {
if (registered) {
enterPasswordState.call(self);
}
else {
Expand All @@ -68,12 +69,12 @@

cancelEvent(event);

if(!validation.email(email)) {
if (!validation.email(email)) {
return;
}

user.createUser(email, function(keypair) {
if(keypair) {
if (keypair) {
self.close("user_staged", {
email: email,
keypair: keypair
Expand All @@ -92,7 +93,7 @@

cancelEvent(event);

if(!validation.emailAndPassword(email, pass)) {
if (!validation.emailAndPassword(email, pass)) {
return;
}

Expand Down Expand Up @@ -145,7 +146,7 @@
}

function enterEmailState(el, event) {
if(event && event.which === 13) {
if (event && event.which === 13) {
// Enter key, do nothing
return;
}
Expand Down Expand Up @@ -204,20 +205,18 @@
this.submit = checkEmail;
// If we already have an email address, check if it is valid, if so, show
// password.
if(options.email) {
if (options.email) {
this.submit();
}
},

"#email keyup": function(el, event) {
// Fixes a bug in IE9 that does not pick up the input event on
// a backspace.
if(event.which === 8) {
var newEmail = el.val();
if (newEmail !== lastEmail) {
lastEmail = newEmail;
enterEmailState.call(this, el);
}
},
// This is part of the HTML5 spec
"#email input": enterEmailState,
"#forgotPassword click": forgotPasswordState,
"#cancel_forgot_password click": cancelForgotPassword
});
Expand Down

0 comments on commit f96a085

Please sign in to comment.