Merge branch 'w27_MDL-23344_m22_loginfocus' of git://github.com/skodak/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2011-07-11 17:01:58 +02:00
2 changed files with 30 additions and 0 deletions
+28
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() {
+2
View File
@@ -341,6 +341,8 @@ if (isloggedin() and !isguestuser()) {
echo $OUTPUT->box_end();
} else {
include("index_form.html");
//focus username or password
$PAGE->requires->js_init_call('M.util.focus_login_form', null, true);
}
echo $OUTPUT->footer();