From d0157f7fef6d57e91eddb48a3491e5004f07ea59 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Wed, 30 Dec 2015 07:35:23 +0100 Subject: [PATCH] baculum: Hide users input on ESC key press --- gui/baculum/protected/JavaScript/misc.js | 14 +++++++++----- gui/baculum/protected/Pages/Home.page | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gui/baculum/protected/JavaScript/misc.js b/gui/baculum/protected/JavaScript/misc.js index b5d3706b1b..6bd86a28da 100644 --- a/gui/baculum/protected/JavaScript/misc.js +++ b/gui/baculum/protected/JavaScript/misc.js @@ -247,17 +247,21 @@ var Users = { $(this.ids.create_user.add_user).show(); $(this.ids.create_user.newuser).focus(); }.bind(this)); - document.getElementById(this.ids.create_user.newuser).addEventListener('keypress', function(e) { + document.getElementById(this.ids.create_user.newuser).addEventListener('keydown', function(e) { var target = e.target || e.srcElement; if (e.keyCode == 13) { - target.parentNode.getElementsByTagName('A')[0].click(); + $(target.nextElementSibling).click(); + } else if (e.keyCode == 27) { + this.cancelAddUser(); } return false; }.bind(this)); - document.getElementById(this.ids.create_user.newpwd).addEventListener('keypress', function(e) { + document.getElementById(this.ids.create_user.newpwd).addEventListener('keydown', function(e) { var target = e.target || e.srcElement; if (e.keyCode == 13) { $(target.nextElementSibling).click(); + } else if (e.keyCode == 27) { + this.cancelAddUser(); } return false; }.bind(this)); @@ -301,7 +305,7 @@ var Users = { }, changePwd: function(el, user) { var valid = true; - var pwd = el.previousElementSibling.value; + var pwd = el.value; if (this.pwdValidator(pwd) === false) { alert(this.txt.invalid_pwd); @@ -313,7 +317,7 @@ var Users = { this.action_callback('chpwd', user, pwd); } }, - cancelAddUser: function(el) { + cancelAddUser: function() { $(this.ids.create_user.add_user).hide(); }, cancelChangePwd: function(el) { diff --git a/gui/baculum/protected/Pages/Home.page b/gui/baculum/protected/Pages/Home.page index 7fa7da3e26..0dd34c3df9 100644 --- a/gui/baculum/protected/Pages/Home.page +++ b/gui/baculum/protected/Pages/Home.page @@ -319,8 +319,8 @@ <%[ Change password ]%> - - + + <%[ Save ]%> -- 2.39.5