]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Hide users input on ESC key press
authorMarcin Haba <marcin.haba@bacula.pl>
Wed, 30 Dec 2015 06:35:23 +0000 (07:35 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Wed, 30 Dec 2015 06:35:23 +0000 (07:35 +0100)
gui/baculum/protected/JavaScript/misc.js
gui/baculum/protected/Pages/Home.page

index b5d3706b1bea3667259a52a53c497cacc57a0c0e..6bd86a28da5e219ed4a01432551f51ce82d61902 100644 (file)
@@ -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) {
index 7fa7da3e2605ca046d6d8248e39b75dc6d0d25be..0dd34c3df9043504c31dc7dc15696a5b83490cce 100644 (file)
                                                                <%[ Change password ]%>
                                                        </a>
                                                        <span style="display: none;" rel="chpwd">
-                                                               <input type="password" onkeypress="event.keyCode == 13 ? $(this.nextElementSibling).click(): '';" />
-                                                               <a href="javascript:void(0)" onclick="Users.changePwd(this, '<%=$this->DataItem%>')">
+                                                               <input type="password" onkeydown="event.keyCode == 13 ? Users.changePwd(this, '<%=$this->DataItem%>') : (event.keyCode == 27 ? Users.cancelChangePwd(this.nextElementSibling.nextElementSibling) : '');" />
+                                                               <a href="javascript:void(0)" onclick="Users.changePwd(this.prevousElementSibling, '<%=$this->DataItem%>')">
                                                                        <img src="<%=$this->getPage()->getTheme()->getBaseUrl()%>/icon_ok.png" alt="<%[ Save ]%>" title="<%[ Save ]%>"/>
                                                                </a>
                                                                <a href="javascript:void(0)" onclick="Users.cancelChangePwd(this)">