diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-02-26 18:10:32 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-02-26 18:10:32 +0100 |
commit | 6c3e4fa5a674063e61fb92f5d9001649476c9cc0 (patch) | |
tree | 73b794ea979ac17e1166cb304b97249b1fcaacb0 /js/codeq/change_password.js | |
parent | af6f38e8ad6bfcc5410646ee070d05f8ab0783db (diff) |
Replace several alerts with friendlier messages
Diffstat (limited to 'js/codeq/change_password.js')
-rw-r--r-- | js/codeq/change_password.js | 17 |
1 files changed, 10 insertions, 7 deletions
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 <http://www.gnu.org/licenses/>. */ */ (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 <http://www.gnu.org/licenses/>. */ }) .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 <http://www.gnu.org/licenses/>. */ $('#disabled').css('display', 'none'); }, 'exit' : function(){ + jqErrorMismatch.hide(); jqChangePassForm.off('submit'); jqCancelBtn.off('click'); jqScreen.css('display', 'none'); |