aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl/jot-header.tpl
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2018-04-10 11:17:20 +0200
committerMario Vavti <mario@mariovavti.com>2018-04-10 11:17:20 +0200
commit91aeb2552308d782970ccff2eaa2ac814bc4a223 (patch)
tree131a9e5d1712e8ff92d4015175f83f5445e4057f /view/tpl/jot-header.tpl
parent887a59066bafeb3061091515970359e702443654 (diff)
downloadvolse-hubzilla-91aeb2552308d782970ccff2eaa2ac814bc4a223.tar.gz
volse-hubzilla-91aeb2552308d782970ccff2eaa2ac814bc4a223.tar.bz2
volse-hubzilla-91aeb2552308d782970ccff2eaa2ac814bc4a223.zip
fix autosave content not cleaned after post submission
Diffstat (limited to 'view/tpl/jot-header.tpl')
-rwxr-xr-xview/tpl/jot-header.tpl71
1 files changed, 47 insertions, 24 deletions
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl
index 7af344681..68f7e7a41 100755
--- a/view/tpl/jot-header.tpl
+++ b/view/tpl/jot-header.tpl
@@ -563,35 +563,43 @@ $( document ).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-del
<script>
-
var postSaveTimer = null;
- $(document).on('focusout',"#profile-jot-wrapper",function(e){
- if(postSaveTimer)
- clearTimeout(postSaveTimer);
- postSaveChanges(true);
- postSaveTimer = null;
- });
+ function postSaveChanges(action, type) {
+ if({{$auto_save_draft}}) {
+ console.log(action);
+ if(action != 'clean') {
+ localStorage.setItem("post_title", $("#jot-title").val());
+ localStorage.setItem("post_body", $("#profile-jot-text").val());
+ localStorage.setItem("post_category", $("#jot-category").val());
+ }
- $(document).on('focusin',"#profile-jot-wrapper",function(e){
- postSaveTimer = setTimeout(function () {
- postSaveChanges(false);
- },10000);
- });
+ if(action == 'start') {
+ postSaveTimer = setTimeout(function () {
+ postSaveChanges('start');
+ },10000);
+ }
- function postSaveChanges(isFinal = false, type) {
- if({{$auto_save_draft}}) {
- localStorage.setItem("post_title", $("#jot-title").val());
- localStorage.setItem("post_body", $("#profile-jot-text").val());
- localStorage.setItem("post_category", $("#jot-category").val());
- if( !isFinal) {
- postSaveTimer = setTimeout(postSaveChanges,10000);
+ if(action == 'stop') {
+ clearTimeout(postSaveTimer);
+ postSaveTimer = null;
+ }
+
+ if(action == 'clean') {
+ clearTimeout(postSaveTimer);
+ postSaveTimer = null;
+ localStorage.removeItem("post_title");
+ localStorage.removeItem("post_body");
+ localStorage.removeItem("post_category");
}
}
}
$(document).ready(function() {
+
+ var cleaned = false;
+
if({{$auto_save_draft}}) {
var postTitle = localStorage.getItem("post_title");
var postBody = localStorage.getItem("post_body");
@@ -616,10 +624,25 @@ $( document ).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-del
initEditor();
}
} else {
- localStorage.removeItem("post_title");
- localStorage.removeItem("post_body");
- localStorage.removeItem("post_category");
+ autoSaveCleanup();
}
- });
-</script> \ No newline at end of file
+ $(document).on('submit', '#profile-jot-form', function() {
+ postSaveChanges('clean');
+ cleaned = true;
+ });
+
+ $(document).on('focusout',"#profile-jot-wrapper",function(e){
+ if(! cleaned)
+ postSaveChanges('stop');
+ });
+
+ $(document).on('focusin',"#profile-jot-wrapper",function(e){
+ postSaveTimer = setTimeout(function () {
+ postSaveChanges('start');
+ },10000);
+ });
+
+
+ });
+</script>