aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-04-12 22:24:25 -0700
committerzotlabs <mike@macgirvin.com>2018-04-12 22:24:25 -0700
commit7fd882a088b55ccbe16b3f9cc076f916ddb90341 (patch)
treecfa060d00637c628e828f33fc5bd34d385a02a34 /view/js
parentb0396cd646040facbe719d08183d326ccba1b53f (diff)
downloadvolse-hubzilla-7fd882a088b55ccbe16b3f9cc076f916ddb90341.tar.gz
volse-hubzilla-7fd882a088b55ccbe16b3f9cc076f916ddb90341.tar.bz2
volse-hubzilla-7fd882a088b55ccbe16b3f9cc076f916ddb90341.zip
autosave comment enhancements
Diffstat (limited to 'view/js')
-rw-r--r--view/js/main.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/view/js/main.js b/view/js/main.js
index 66a1452e3..c1e7bd4ec 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -190,7 +190,7 @@ function handle_comment_form(e) {
var commentSaveTimer = null;
var emptyCommentElm = form.find('.comment-edit-text').attr('id');
- var convId = emptyCommentElm.replace(/comment-edit-text-/,'');
+ var convId = emptyCommentElm.replace('comment-edit-text-','');
$(document).on('focusout','#' + emptyCommentElm,function(e){
if(commentSaveTimer)
clearTimeout(commentSaveTimer);
@@ -206,7 +206,13 @@ function handle_comment_form(e) {
function commentSaveChanges(convId,isFinal = false) {
if(auto_save_draft) {
- localStorage.setItem("comment_body" + convId, $('#' + emptyCommentElm).val());
+ tmp = $('#' + emptyCommentElm).val();
+ if(tmp) {
+ localStorage.setItem("comment_body-" + convId, tmp);
+ }
+ else {
+ localStorage.removeItem("comment_body-" + convId);
+ }
if( !isFinal) {
commentSaveTimer = setTimeout(commentSaveChanges,10000,convId);
}
@@ -596,8 +602,6 @@ function updateConvItems(mode,data) {
var commentWrap = $('#'+ident+' .collapsed-comments').attr('id');
-
-
var itmId = 0;
var isVisible = false;
@@ -632,17 +636,19 @@ function updateConvItems(mode,data) {
if(isVisible)
showHideComments(itmId);
- var commentBody = localStorage.getItem("comment_body" + convId);
+ var commentBody = localStorage.getItem("comment_body-" + convId);
if(commentBody) {
- var commentElm = $('#comment-edit-text' + convId);
+ var commentElm = $('#comment-edit-text-' + convId);
if(auto_save_draft) {
- if(commentBody && $('#' + commentElm).val() === '') {
+ if($(commentElm).val() === '') {
$('#comment-edit-form-' + convId).show();
- $('#' + commentElm).val(commentBody);
+ $(commentElm).addClass("expanded");
+ openMenu("comment-tools-" + convId);
+ $(commentElm).val(commentBody);
}
} else {
- localStorage.removeItem("comment_body" + convId);
+ localStorage.removeItem("comment_body-" + convId);
}
}