diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-05-04 09:46:27 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-05-04 09:46:27 +0200 |
commit | be4c9a9598350fb4333480f0c7b302acebcddfd4 (patch) | |
tree | fb0c2606ad4ca0bc1a710d6fdf82f55c326b3427 /view/tpl/jot-header.tpl | |
parent | f15c12376adad6534c8c0ea547a7548697eb8379 (diff) | |
parent | be852ba857f4cb8e75574a762945b50c8bddcff9 (diff) | |
download | volse-hubzilla-3.4.tar.gz volse-hubzilla-3.4.tar.bz2 volse-hubzilla-3.4.zip |
Merge branch '3.4RC'3.4
Diffstat (limited to 'view/tpl/jot-header.tpl')
-rwxr-xr-x | view/tpl/jot-header.tpl | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index c1dab52d5..df67e9b2d 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -560,3 +560,96 @@ $( document ).on( "click", ".wall-item-delete-link,.page-delete-link,.layout-del } }); </script> + + +<script> + var postSaveTimer = null; + + function postSaveChanges(action, type) { + if({{$auto_save_draft}}) { + + var doctype = $('#jot-webpage').val(); + var postid = '-' + doctype + '-' + $('#jot-postid').val(); + + if(action != 'clean') { + localStorage.setItem("post_title" + postid, $("#jot-title").val()); + localStorage.setItem("post_body" + postid, $("#profile-jot-text").val()); + if($("#jot-category").length) + localStorage.setItem("post_category + postid", $("#jot-category").val()); + } + + if(action == 'start') { + postSaveTimer = setTimeout(function () { + postSaveChanges('start'); + },10000); + } + + if(action == 'stop') { + clearTimeout(postSaveTimer); + postSaveTimer = null; + } + + if(action == 'clean') { + clearTimeout(postSaveTimer); + postSaveTimer = null; + localStorage.removeItem("post_title" + postid); + localStorage.removeItem("post_body" + postid); + localStorage.removeItem("post_category" + postid); + } + } + + } + + $(document).ready(function() { + + var cleaned = false; + + if({{$auto_save_draft}}) { + var doctype = $('#jot-webpage').val(); + var postid = '-' + doctype + '-' + $('#jot-postid').val(); + var postTitle = localStorage.getItem("post_title" + postid); + var postBody = localStorage.getItem("post_body" + postid); + var postCategory = (($("#jot-category").length) ? localStorage.getItem("post_category" + postid) : ''); + var openEditor = false; + + if(postTitle) { + $('#jot-title').val(postTitle); + openEditor = true; + } + if(postBody) { + $('#profile-jot-text').val(postBody); + openEditor = true; + } + if(postCategory) { + var categories = postCategory.split(','); + categories.forEach(function(cat) { + $('#jot-category').tagsinput('add', cat); + }); + openEditor = true; + } + if(openEditor) { + initEditor(); + } + } else { + postSaveChanges('clean'); + } + + $(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> |