From 6c3e4fa5a674063e61fb92f5d9001649476c9cc0 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 26 Feb 2016 18:10:32 +0100 Subject: Replace several alerts with friendlier messages --- js/codeq/change_password.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'js/codeq/change_password.js') diff --git a/js/codeq/change_password.js b/js/codeq/change_password.js index 562f4b2..6311764 100644 --- a/js/codeq/change_password.js +++ b/js/codeq/change_password.js @@ -22,24 +22,26 @@ along with this program. If not, see . */ */ (function(){ "use strict"; - var jqScreen = $('#screen-change-pass'), + var jqScreen = $('#screen-change-password'), + jqChangePassForm = $('#change-password-form'), jqNew = $('#change-password-new'), jqVerify = $('#change-password-verify'), jqCancelBtn = $('#change-password-cancel'), - jqChangePassForm = $('#change-password-form'); + jqErrorMismatch = jqChangePassForm.find('.error.mismatch'); codeq.globalStateMachine.register('changePassword',{ 'jqScreen': jqScreen, 'isModal': true, - 'enter': function(){ + 'enter': function() { + jqErrorMismatch.hide(); jqCancelBtn.on('click',function(){ history.back();//forces a transition to the previous state }); - jqChangePassForm.on('submit',function(event) { - + jqChangePassForm.on('submit', function (e) { + jqErrorMismatch.hide(); if (jqNew.val() != jqVerify.val()) { - alert('Passwords do not match.'); + jqErrorMismatch.show(); } else { codeq.comms.changePassword(jqNew.val()) @@ -54,7 +56,7 @@ along with this program. If not, see . */ }) .done(); } - event.preventDefault(); // Prevent the form from submitting via the browser. + e.preventDefault(); // Prevent the form from submitting via the browser. }); @@ -62,6 +64,7 @@ along with this program. If not, see . */ $('#disabled').css('display', 'none'); }, 'exit' : function(){ + jqErrorMismatch.hide(); jqChangePassForm.off('submit'); jqCancelBtn.off('click'); jqScreen.css('display', 'none'); -- cgit v1.2.1