diff --git a/lms/static/js/student_account/views/AccessView.js b/lms/static/js/student_account/views/AccessView.js index 8b5debc93e..0d79171b59 100644 --- a/lms/static/js/student_account/views/AccessView.js +++ b/lms/static/js/student_account/views/AccessView.js @@ -141,6 +141,7 @@ var edx = edx || {}; this.element.hide( this.$header ); this.element.hide( $(this.el).find('.form-type') ); this.loadForm('reset'); + this.element.scrollTop( $('#password-reset-wrapper') ); }, showFormError: function() { @@ -162,11 +163,7 @@ var edx = edx || {}; this.element.hide( $(this.el).find('.form-wrapper') ); this.element.show( $form ); - - // Scroll to top of selected form - $('html,body').animate({ - scrollTop: $anchor.offset().top - },'slow'); + this.element.scrollTop( $anchor ); }, /** @@ -261,7 +258,7 @@ var edx = edx || {}; } }, - /* Helper method ot toggle display + /* Helper method to toggle display * including accessibility considerations */ element: { @@ -270,6 +267,13 @@ var edx = edx || {}; .attr('aria-hidden', true); }, + scrollTop: function( $el ) { + // Scroll to top of selected element + $('html,body').animate({ + scrollTop: $el.offset().top + },'slow'); + }, + show: function( $el ) { $el.removeClass('hidden') .attr('aria-hidden', false); diff --git a/lms/static/js/student_account/views/FormView.js b/lms/static/js/student_account/views/FormView.js index 9142eb9284..32b3e87472 100644 --- a/lms/static/js/student_account/views/FormView.js +++ b/lms/static/js/student_account/views/FormView.js @@ -103,6 +103,13 @@ var edx = edx || {}; } }, + scrollTop: function( $el ) { + // Scroll to top of selected element + $('html,body').animate({ + scrollTop: $el.offset().top + },'slow'); + }, + show: function( $el ) { if ( $el ) { $el.removeClass('hidden') diff --git a/lms/static/js/student_account/views/PasswordResetView.js b/lms/static/js/student_account/views/PasswordResetView.js index 3e573fefc9..cddedfa66f 100644 --- a/lms/static/js/student_account/views/PasswordResetView.js +++ b/lms/static/js/student_account/views/PasswordResetView.js @@ -21,24 +21,26 @@ var edx = edx || {}; submitButton: '.js-reset', - preRender: function( data ) { + preRender: function() { this.listenTo( this.model, 'sync', this.saveSuccess ); }, toggleErrorMsg: function( show ) { if ( show ) { this.setErrors(); - this.toggleDisableButton(false) + this.toggleDisableButton(false); } else { this.element.hide( this.$errors ); } }, saveSuccess: function() { - var $el = $(this.el); + var $el = $(this.el), + $msg = $el.find('.js-reset-success'); this.element.hide( $el.find('#password-reset-form') ); - this.element.show( $el.find('.js-reset-success') ); + this.element.show( $msg ); + this.element.scrollTop( $msg ); } });