Permalink
Browse files

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

  • Loading branch information...
Rossiani Wijaya
Rossiani Wijaya committed Jan 15, 2013
1 parent d63a406 commit 999a5940394bd0bc15446c5edde709dcb5ae2194
Showing with 14 additions and 1 deletion.
  1. +10 −0 lib/javascript-static.js
  2. +3 −1 login/index.php
  3. +1 −0 login/index_form.html
View
@@ -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.
*
View
@@ -345,7 +345,9 @@
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);
}
View
@@ -31,6 +31,7 @@ <h2><?php print_string("returningtosite") ?></h2>
<?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>';
}

0 comments on commit 999a594

Please sign in to comment.