]> source.dussan.org Git - nextcloud-server.git/commitdiff
allow to press enter to update the password
authorBjörn Schießle <schiessle@owncloud.com>
Wed, 5 Jun 2013 12:51:51 +0000 (14:51 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Wed, 5 Jun 2013 12:51:51 +0000 (14:51 +0200)
apps/files_encryption/js/settings-personal.js

index 46105176c298e252127e18f01b25467be416dbce..d6535a25b704b85efb0f6eed02536dd3396c3f9c 100644 (file)
@@ -4,7 +4,25 @@
  * See the COPYING-README file.
  */
 
+function updatePrivateKeyPasswd() {
+       var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
+       var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
+       OC.msg.startSaving('#encryption .msg');
+       $.post(
+       OC.filePath( 'files_encryption', 'ajax', 'updatePrivateKeyPassword.php' )
+               , { oldPassword: oldPrivateKeyPassword, newPassword: newPrivateKeyPassword }
+               ,  function( data ) {
+                       if (data.status === "error") {
+                               OC.msg.finishedSaving('#encryption .msg', data);
+                       } else {
+                               OC.msg.finishedSaving('#encryption .msg', data);
+                       }
+               }
+       );
+}
+
 $(document).ready(function(){
+
        // Trigger ajax on recoveryAdmin status change
        $( 'input:radio[name="userEnableRecovery"]' ).change( 
                function() {
@@ -63,28 +81,18 @@ $(document).ready(function(){
        $('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
                var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
                var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
-               if (newPrivateKeyPassword != '' && oldPrivateKeyPassword != '' ) {
+               if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '' ) {
                        $('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled");
+                       if(event.which === 13) {
+                               updatePrivateKeyPasswd();
+                       }
                } else {
                        $('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true");
                }
        });
 
        $('button:button[name="submitChangePrivateKeyPassword"]').click(function() {
-               var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
-               var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
-               OC.msg.startSaving('#encryption .msg');
-               $.post(
-               OC.filePath( 'files_encryption', 'ajax', 'updatePrivateKeyPassword.php' )
-                       , { oldPassword: oldPrivateKeyPassword, newPassword: newPrivateKeyPassword }
-                       ,  function( data ) {
-                               if (data.status == "error") {
-                                       OC.msg.finishedSaving('#encryption .msg', data);
-                               } else {
-                                       OC.msg.finishedSaving('#encryption .msg', data);
-                               }
-                       }
-               );
+               updatePrivateKeyPasswd();
        });
 
 });
\ No newline at end of file