diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2013-11-10 18:16:52 +0100 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2013-11-10 18:16:52 +0100 |
commit | 8c74925df1af4b1d3f7351edae3523dccf6b8b75 (patch) | |
tree | e1930a0676db6abac55b260c52cbbab9baceaa7e /program/js/app.js | |
parent | 85e60ada1558798669b29225aa530b4ba9310cdc (diff) |
Track typing in compose screen and only update local storage on activity
Diffstat (limited to 'program/js/app.js')
-rw-r--r-- | program/js/app.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/program/js/app.js b/program/js/app.js index 81c66ba3e..79436adf6 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3618,10 +3618,19 @@ function rcube_webmail() if (this.env.draft_autosave) this.save_timer = setTimeout(function(){ ref.command("savedraft"); }, this.env.draft_autosave * 1000); - // save compose form content to local storage every 10 seconds - // TODO: track typing activity and only save on changes - if (!this.local_save_timer && window.localStorage) - this.local_save_timer = setInterval(function(){ ref.save_compose_form_local(); }, 10000); + // save compose form content to local storage every 5 seconds + if (!this.local_save_timer && window.localStorage) { + // track typing activity and only save on changes + this.compose_type_activity = this.compose_type_activity_last = 0; + $(document).bind('keypress', function(e){ ref.compose_type_activity++; }); + + this.local_save_timer = setInterval(function(){ + if (ref.compose_type_activity > ref.compose_type_activity_last) { + ref.save_compose_form_local(); + ref.compose_type_activity_last = ref.compose_type_activity; + } + }, 5000); + } // Unlock interface now that saving is complete this.busy = false; @@ -3680,6 +3689,8 @@ function rcube_webmail() default: formdata[elem.name] = $(elem).val(); + if (formdata[elem.name] != '') + empty = false; } }); @@ -4285,8 +4296,10 @@ function rcube_webmail() if (this.ksearch_input.setSelectionRange) this.ksearch_input.setSelectionRange(cpos, cpos); - if (trigger) + if (trigger) { this.triggerEvent('autocomplete_insert', { field:this.ksearch_input, insert:insert }); + this.compose_type_activity++; + } }; this.replace_group_recipients = function(id, recipients) @@ -4295,6 +4308,7 @@ function rcube_webmail() this.group2expand[id].input.value = this.group2expand[id].input.value.replace(this.group2expand[id].name, recipients); this.triggerEvent('autocomplete_insert', { field:this.group2expand[id].input, insert:recipients }); this.group2expand[id] = null; + this.compose_type_activity++; } }; |