MDL-23344 new option to autofocus username or password on the login form

Nearly everybody else does this login page autofocus. Once we switch to HMTL 5 we should use the new autofocus input option. I believe the admin setting should be enabled by default but it would not be possible to get it through the reviews.
This commit is contained in:
Petr Skoda
2011-07-14 15:58:01 +02:00
parent ecb8829273
commit 2d16dad0e1
4 changed files with 35 additions and 0 deletions

View File

@@ -739,6 +739,34 @@ M.util.get_string = function(identifier, component, a) {
return stringvalue;
};
/**
* Set focus on username or password field of the login form
*/
M.util.focus_login_form = function(Y) {
var username = Y.one('#username');
var password = Y.one('#password');
if (username == null || password == null) {
// something is wrong here
return;
}
var curElement = document.activeElement
if (curElement == 'undefined') {
// legacy browser - skip refocus protection
} else if (curElement.tagName == 'INPUT') {
// user was probably faster to focus something, do not mess with focus
return;
}
if (username.get('value') == '') {
username.focus();
} else {
password.focus();
}
}
//=== old legacy JS code, hopefully to be replaced soon by M.xx.yy and YUI3 code ===
function checkall() {