From 6d812ada059525772893d3eb5be9c080635c7120 Mon Sep 17 00:00:00 2001 From: David Reagan Date: Tue, 16 Apr 2013 13:03:41 -0700 Subject: [PATCH] Modified how the #lostpassword or #email fields save email addresses on the Personal settings page. It now saves one second after the last keyup event, instead of after a blur event. --- settings/js/personal.js | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/settings/js/personal.js b/settings/js/personal.js index d0a471e56b5..9c960a180a1 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -4,6 +4,24 @@ * See the COPYING-README file. */ +/** + * Post the email address change to the server. + */ +function changeEmailAddress(){ + emailInfo = $('#lostpassword #email'); + console.log("Timout done."); + if (emailInfo.val() === emailInfo.defaultValue){ + return; + } + //event.preventDefault(); + emailInfo.defaultValue = emailInfo.val(); + OC.msg.startSaving('#lostpassword .msg'); + var post = $( "#lostpassword" ).serialize(); + $.post( 'ajax/lostpassword.php', post, function(data){ + OC.msg.finishedSaving('#lostpassword .msg', data); + }); +} + $(document).ready(function(){ $("#passwordbutton").click( function(){ if ($('#pass1').val() != '' && $('#pass2').val() != '') { @@ -62,18 +80,12 @@ $(document).ready(function(){ }); - $('#lostpassword #email').blur(function(event){ - if ($(this).val() == this.defaultValue){ - return; - } - event.preventDefault(); - this.defaultValue = $(this).val(); - OC.msg.startSaving('#lostpassword .msg'); - var post = $( "#lostpassword" ).serialize(); - $.post( 'ajax/lostpassword.php', post, function(data){ - OC.msg.finishedSaving('#lostpassword .msg', data); - }); - }); + $('#lostpassword #email').keyup(function(){ + if(typeof timeout !== 'undefined'){ + clearTimeout(timeout); + } + timeout = setTimeout('changeEmailAddress()',1000); + }); $("#languageinput").chosen(); -- 2.39.5