From 7b3f5e648a3f0e1ae94844d1f69d26b24b64bf56 Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Thu, 19 Sep 2013 13:39:45 -0400 Subject: [PATCH 1/3] manage focus to/from/within password reset modal appropriately --- lms/templates/forgot_password_modal.html | 26 +++++++++++++++++++++--- lms/templates/login.html | 6 +++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lms/templates/forgot_password_modal.html b/lms/templates/forgot_password_modal.html index 5a8cc4f740b9..4eb6d68c0ef3 100644 --- a/lms/templates/forgot_password_modal.html +++ b/lms/templates/forgot_password_modal.html @@ -32,9 +32,7 @@

${_("Password Reset")}

-
-

-
+ ✕
@@ -56,5 +54,27 @@

${_("Password Reset")}

$('#login-modal .close-modal').click(function(e) { e.preventDefault(); }); + + var onModalClose = function() { + $(".forgot-password-modal .close-modal").off("click"); + $("#lean_overlay").off("click"); + $("#forgot-password-modal").attr("aria-hidden", "true"); + $("#forgot-password-link").focus(); + }; + var cycle_modal_tab = function(from_element_name, to_element_name) { + $(from_element_name).on('keydown', function(e) { + var keyCode = e.keyCode || e.which; + if (keyCode === 9) { + e.preventDefault(); + $(to_element_name).focus(); + } + }); + }; + $(".forgot-password-modal .close-modal").click(onModalClose); + $("#forgot-password-modal").focus() + cycle_modal_tab(".forgot-password-modal .close-modal", "#pwd_reset_email") + cycle_modal_tab("#pwd_reset_email", "#pwd_reset_button") + cycle_modal_tab("#pwd_reset_button", ".forgot-password-modal .close-modal") + })(this) diff --git a/lms/templates/login.html b/lms/templates/login.html index ef57044dcf21..535af9c39e54 100644 --- a/lms/templates/login.html +++ b/lms/templates/login.html @@ -67,6 +67,10 @@ $('.message.submission-error .message-copy').html(json.value); } }); + $("#forgot-password-link").click(function() { + $(".forgot-password-modal .close-modal").focus() + }) + })(this); function toggleSubmitButton(enable) { @@ -127,7 +131,7 @@

${_("The following errors occured while logging you in - ${_('Forgot password?')} + ${_('Forgot password?')} From a0d30b25a45d2c5f354e204fcc5a6d88e0f30393 Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Fri, 20 Sep 2013 13:09:30 -0400 Subject: [PATCH 2/3] respond to comments --- lms/templates/forgot_password_modal.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lms/templates/forgot_password_modal.html b/lms/templates/forgot_password_modal.html index 4eb6d68c0ef3..9ca6ca27a05f 100644 --- a/lms/templates/forgot_password_modal.html +++ b/lms/templates/forgot_password_modal.html @@ -56,15 +56,14 @@

${_("Password Reset")}

}); var onModalClose = function() { - $(".forgot-password-modal .close-modal").off("click"); - $("#lean_overlay").off("click"); $("#forgot-password-modal").attr("aria-hidden", "true"); $("#forgot-password-link").focus(); }; var cycle_modal_tab = function(from_element_name, to_element_name) { $(from_element_name).on('keydown', function(e) { var keyCode = e.keyCode || e.which; - if (keyCode === 9) { + var TAB_KEY = 9; // 9 corresponds to the tab key + if (keyCode === TAB_KEY) { e.preventDefault(); $(to_element_name).focus(); } @@ -72,9 +71,9 @@

${_("Password Reset")}

}; $(".forgot-password-modal .close-modal").click(onModalClose); $("#forgot-password-modal").focus() - cycle_modal_tab(".forgot-password-modal .close-modal", "#pwd_reset_email") + cycle_modal_tab("#forgot-password-modal .close-modal", "#pwd_reset_email") cycle_modal_tab("#pwd_reset_email", "#pwd_reset_button") - cycle_modal_tab("#pwd_reset_button", ".forgot-password-modal .close-modal") + cycle_modal_tab("#pwd_reset_button", "#forgot-password-modal .close-modal") })(this) From 1f5d2223208c9960bdb2def73140208682fe0ceb Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Fri, 20 Sep 2013 15:14:04 -0400 Subject: [PATCH 3/3] remove forgot-password-modal class --- lms/templates/forgot_password_modal.html | 4 ++-- lms/templates/login.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lms/templates/forgot_password_modal.html b/lms/templates/forgot_password_modal.html index 9ca6ca27a05f..a23df08cfc71 100644 --- a/lms/templates/forgot_password_modal.html +++ b/lms/templates/forgot_password_modal.html @@ -1,7 +1,7 @@ <%! from django.utils.translation import ugettext as _ %> <%! from django.core.urlresolvers import reverse %> -