Focus the username box when a login/register popup is shown.

This commit is contained in:
Max Goodman
2011-10-07 11:05:27 -07:00
parent 575b3bd8df
commit b128a46f62
2 changed files with 18 additions and 3 deletions

View File

@@ -131,7 +131,7 @@ r.login.ui = {
}
}
this.popup.show(true, dest && function() {
this.popup.showLogin(true, dest && function() {
window.location = dest
})
@@ -187,6 +187,10 @@ r.ui.LoginForm.prototype = $.extend(new r.ui.Form(), {
} else {
r.ui.Form.prototype._handleResult.call(this, result)
}
},
focus: function() {
this.$el.find('input[name="user"]').focus()
}
})
@@ -199,7 +203,8 @@ r.ui.RegisterForm.prototype = $.extend(new r.ui.Form(), {
r.login.post(this, 'register', $.proxy(this, 'handleResult'))
},
_handleResult: r.ui.LoginForm.prototype._handleResult
_handleResult: r.ui.LoginForm.prototype._handleResult,
focus: r.ui.LoginForm.prototype.focus
})
r.ui.LoginPopup = function(el) {
@@ -215,5 +220,15 @@ r.ui.LoginPopup.prototype = $.extend(new r.ui.Base(), {
this.$el
.find(".cover-msg").toggle(!!notice).end()
.show()
},
showLogin: function() {
this.show.apply(this, arguments)
this.loginForm.focus()
},
showRegister: function() {
this.show.apply(this, arguments)
this.registerForm.focus()
}
})

View File

@@ -63,7 +63,7 @@
%if thing.enable_login_cover and not g.read_only_mode:
<span class="user">
${text_with_js(_("want to join? %(register)s in seconds"),
register=(_("register"), "r.login.ui.popup.show(); return false"))}
register=(_("register"), "r.login.ui.popup.showRegister(); return false"))}
</span>
${separator("|")}
%endif