From ac77c2f98c4f8f198a7667dbfeb57c213f4279f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Wed, 5 Jun 2013 14:51:51 +0200 Subject: [PATCH] allow to press enter to update the password --- apps/files_encryption/js/settings-personal.js | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/apps/files_encryption/js/settings-personal.js b/apps/files_encryption/js/settings-personal.js index 46105176c29..d6535a25b70 100644 --- a/apps/files_encryption/js/settings-personal.js +++ b/apps/files_encryption/js/settings-personal.js @@ -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 -- 2.39.5