MDL-35817 Login: set page focus to error message for login error

This commit is contained in:
Rossiani Wijaya
2013-01-17 13:05:33 +08:00
parent d63a406b02
commit 999a594039
3 changed files with 14 additions and 1 deletions
+10
View File
@@ -854,6 +854,16 @@ M.util.focus_login_form = function(Y) {
}
}
/**
* Set focus on login error message
*/
M.util.focus_login_error = function(Y) {
var errorlog = Y.one('#errormsg');
if (errorlog) {
errorlog.focus();
}
}
/**
* Adds lightbox hidden element that covers the whole node.
*
+3 -1
View File
@@ -345,7 +345,9 @@ if (isloggedin() and !isguestuser()) {
echo $OUTPUT->box_end();
} else {
include("index_form.html");
if (!empty($CFG->loginpageautofocus)) {
if ($errormsg) {
$PAGE->requires->js_init_call('M.util.focus_login_error', null, true);
} else if (!empty($CFG->loginpageautofocus)) {
//focus username or password
$PAGE->requires->js_init_call('M.util.focus_login_form', null, true);
}
+1
View File
@@ -31,6 +31,7 @@ if (!empty($CFG->loginpasswordautocomplete)) {
<?php
if (!empty($errormsg)) {
echo '<div class="loginerrors">';
echo '<a id="errormsg" class="accesshide" href="#">'.$OUTPUT->error_text($errormsg).'</a>';
echo $OUTPUT->error_text($errormsg);
echo '</div>';
}