Permalink
Browse files

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

  • Loading branch information...
1 parent 2713f92 commit a59dc25d6d18c357b58256a5386dffe72573df8d @rwijaya rwijaya committed Jan 15, 2013
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
10 lib/javascript-static.js
@@ -814,6 +814,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.
*
* @param {YUI} Y
View
4 login/index.php
@@ -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
1 login/index_form.html
@@ -31,6 +31,7 @@
<?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 a59dc25

Please sign in to comment.