Post body and title are auto-saved

This commit is contained in:
Andrew Manning
2018-04-04 15:22:38 -04:00
parent aca719ac74
commit a5aff7d0c9
4 changed files with 85 additions and 4 deletions

View File

@@ -40,6 +40,38 @@
<input name="category" id="jot-category" type="text" placeholder="{{$placeholdercategory}}" value="{{$category}}" data-role="cat-tagsinput">
</div>
{{/if}}
<script>
var postSaveTimer = null;
$(document).on('focusout',"#profile-jot-text",function(e){
if(postSaveTimer)
clearTimeout(postSaveTimer);
postSaveChanges(true);
postSaveTimer = null;
});
$(document).on('focusin',"#profile-jot-text",function(e){
postSaveTimer = setTimeout(function () {
postSaveChanges(false);
},10000);
});
function postSaveChanges(isFinal = false, type) {
$.post('autosavetext',
{
'type' : 'post',
'body' : $("#profile-jot-text").val(),
'title': $("#jot-title").val()
}
);
if( !isFinal) {
postSaveTimer = setTimeout(postSaveChanges,10000);
}
}
</script>
<div id="jot-text-wrap">
<textarea class="profile-jot-text" id="profile-jot-text" name="body" tabindex="2" placeholder="{{$placeholdtext}}" >{{$content}}</textarea>
</div>