Added feature setting for auto-save, defaulting to enabled.

This commit is contained in:
Andrew Manning
2018-04-08 19:44:21 -04:00
parent 4760dc9bcb
commit f9ec3c66ff
6 changed files with 68 additions and 36 deletions

View File

@@ -167,9 +167,13 @@ function handle_comment_form(e) {
$('#' + commentElm).attr('tabindex','9');
$('#' + submitElm).attr('tabindex','10');
var commentBody = localStorage.getItem("comment_body");
if(commentBody && $('#' + commentElm).val() === '') {
$('#' + commentElm).val(commentBody);
if(auto_save_draft) {
var commentBody = localStorage.getItem("comment_body");
if(commentBody && $('#' + commentElm).val() === '') {
$('#' + commentElm).val(commentBody);
}
} else {
localStorage.removeItem("comment_body");
}
form.find(':not(:visible)').show();
@@ -207,10 +211,12 @@ function handle_comment_form(e) {
},10000);
});
function commentSaveChanges(isFinal = false, type) {
localStorage.setItem("comment_body", $('#' + emptyCommentElm).val());
if( !isFinal) {
commentSaveTimer = setTimeout(commentSaveChanges,10000);
function commentSaveChanges(isFinal = false) {
if(auto_save_draft) {
localStorage.setItem("comment_body", $('#' + emptyCommentElm).val());
if( !isFinal) {
commentSaveTimer = setTimeout(commentSaveChanges,10000);
}
}
}
}