From a59dc25d6d18c357b58256a5386dffe72573df8d Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Tue, 15 Jan 2013 15:45:15 +0800 Subject: [PATCH 1/2] MDL-35817 Login: set page focus to error message for login error --- lib/javascript-static.js | 10 ++++++++++ login/index.php | 4 +++- login/index_form.html | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 858fe246dda..64f59f425bd 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -813,6 +813,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. * diff --git a/login/index.php b/login/index.php index 1847544b75a..4526ba6832a 100644 --- a/login/index.php +++ b/login/index.php @@ -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); } diff --git a/login/index_form.html b/login/index_form.html index 1765064cd10..93988100f6a 100644 --- a/login/index_form.html +++ b/login/index_form.html @@ -31,6 +31,7 @@ if (empty($CFG->xmlstrictheaders) and !empty($CFG->loginpasswordautocomplete)) { '; + echo ''.$OUTPUT->error_text($errormsg).''; echo $OUTPUT->error_text($errormsg); echo ''; } From e99486c448986551699f8acda41e45ec9cf61213 Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Thu, 17 Jan 2013 13:01:27 +0800 Subject: [PATCH 2/2] MDL-35817 login: convert html tag to use html_writer and change tag id to be more specific to login --- lib/javascript-static.js | 2 +- login/index_form.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 64f59f425bd..5d6f4ee81ac 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -817,7 +817,7 @@ 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'); + var errorlog = Y.one('#loginerrormessage'); if (errorlog) { errorlog.focus(); diff --git a/login/index_form.html b/login/index_form.html index 93988100f6a..f7557a57e3f 100644 --- a/login/index_form.html +++ b/login/index_form.html @@ -30,10 +30,10 @@ if (empty($CFG->xmlstrictheaders) and !empty($CFG->loginpasswordautocomplete)) { '; - echo ''.$OUTPUT->error_text($errormsg).''; + echo html_writer::start_tag('div', array('class' => 'loginerrors')); + echo html_writer::link('#', $errormsg, array('id' => 'loginerrormessage', 'class' => 'accesshide')); echo $OUTPUT->error_text($errormsg); - echo ''; + echo html_writer::end_tag('div'); } ?>
>