Skip to content
Browse files

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

  • Loading branch information...
1 parent ca48fe5 commit c316c3944ed3ab72257b5e795c0c1a0f1d06191a @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
@@ -855,6 +855,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
@@ -341,7 +341,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 c316c39

Please sign in to comment.
Something went wrong with that request. Please try again.