allow to press enter to update the password

This commit is contained in:
Björn Schießle 2013-06-05 14:51:51 +02:00
parent be324fad1c
commit 036732c249
1 changed files with 23 additions and 15 deletions

View File

@ -4,7 +4,25 @@
* See the COPYING-README file. * 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(){ $(document).ready(function(){
// Trigger ajax on recoveryAdmin status change // Trigger ajax on recoveryAdmin status change
$( 'input:radio[name="userEnableRecovery"]' ).change( $( 'input:radio[name="userEnableRecovery"]' ).change(
function() { function() {
@ -63,28 +81,18 @@ $(document).ready(function(){
$('input:password[name="changePrivateKeyPassword"]').keyup(function(event) { $('input:password[name="changePrivateKeyPassword"]').keyup(function(event) {
var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val(); var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val();
var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val(); var newPrivateKeyPassword = $('input:password[id="newPrivateKeyPassword"]').val();
if (newPrivateKeyPassword != '' && oldPrivateKeyPassword != '' ) { if (newPrivateKeyPassword !== '' && oldPrivateKeyPassword !== '' ) {
$('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled"); $('button:button[name="submitChangePrivateKeyPassword"]').removeAttr("disabled");
if(event.which === 13) {
updatePrivateKeyPasswd();
}
} else { } else {
$('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true"); $('button:button[name="submitChangePrivateKeyPassword"]').attr("disabled", "true");
} }
}); });
$('button:button[name="submitChangePrivateKeyPassword"]').click(function() { $('button:button[name="submitChangePrivateKeyPassword"]').click(function() {
var oldPrivateKeyPassword = $('input:password[id="oldPrivateKeyPassword"]').val(); updatePrivateKeyPasswd();
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);
}
}
);
}); });
}); });