From b5ab77908e357b027a9298e0258f3c0737f3c721 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 17 Nov 2020 09:09:36 +0000 Subject: implement submit on ctrl-enter for post editor and comments --- view/js/main.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 560868046..3dae45cff 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -56,7 +56,7 @@ $.ajaxSetup({cache: false}); $(document).ready(function() { - $(document).on('click focus', '.comment-edit-form', handle_comment_form); + $(document).on('click', '.comment-edit-form', handle_comment_form); $(document).on('click', '.conversation-settings-link', getConversationSettings); $(document).on('click', '#settings_module_ajax_submit', postConversationSettings); @@ -95,7 +95,6 @@ $(document).ready(function() { jQuery.timeago.settings.allowFuture = true; - if(sse_enabled) { if(typeof(window.SharedWorker) === 'undefined') { // notifications with multiple tabs open will not work very well in this scenario @@ -244,8 +243,6 @@ $(document).ready(function() { cache_next_page(); }); - - }); function getConversationSettings() { @@ -325,7 +322,8 @@ function handle_comment_form(e) { } // handle click outside of form (close empty forms) - $(document).on('click', function(e) { + $(document).one('click', function(e) { + fields.each(function() { if($(this).val() != '') fields_empty = false; @@ -344,23 +342,30 @@ function handle_comment_form(e) { form.find(':button[type=submit]').prop('title', ''); } }); - + var commentSaveTimer = null; var emptyCommentElm = form.find('.comment-edit-text').attr('id'); var convId = emptyCommentElm.replace('comment-edit-text-',''); - $(document).on('focusout','#' + emptyCommentElm,function(e){ + $('#' + emptyCommentElm).on('focusout',function(e){ if(commentSaveTimer) clearTimeout(commentSaveTimer); commentSaveChanges(convId,true); commentSaveTimer = null; + $('#' + emptyCommentElm).off(); }); - $(document).on('focusin','#' + emptyCommentElm,function(e){ + $('#' + emptyCommentElm).on('focusin', function (e){ commentSaveTimer = setTimeout(function () { commentSaveChanges(convId,false); },10000); }); + $('#' + emptyCommentElm).on('keydown', function (e) { + if (e.ctrlKey && e.keyCode === 13) { + post_comment(convId); + } + }); + function commentSaveChanges(convId, isFinal) { if(typeof isFinal === 'undefined') @@ -379,8 +384,11 @@ function handle_comment_form(e) { } } } + } + + function commentClose(obj, id) { if(obj.value === '') { obj.value = aStr.comment; @@ -1414,7 +1422,7 @@ function post_comment(id) { $(document).unbind( "click.commentOpen"); } if(timer) clearTimeout(timer); - timer = setTimeout(updateInit,1500); + timer = setTimeout(updateInit, 500); } if(data.reload) { window.location.href=data.reload; @@ -1425,6 +1433,8 @@ function post_comment(id) { return false; } + + function preview_comment(id) { $("#comment-preview-inp-" + id).val("1"); $("#comment-edit-preview-" + id).show(); -- cgit v1.2.3 From f2fd12fbe544d5e87680aed98489698b4ca9ddd6 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 18 Nov 2020 09:52:44 +0000 Subject: Do away with auto updates except for our own actions. We might consider to re-implement this for single thread view like eg /display. Instead of calculating scroll positions during updates, keep track of expanded items and set the expanded state when updating - this fixes issue #1488 --- view/js/main.js | 109 +++++++++----------------------------------------------- 1 file changed, 16 insertions(+), 93 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 3dae45cff..f807fb366 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -20,11 +20,11 @@ var pageHasMoreContent = true; var divmore_height = 400; var last_filestorage_id = null; var mediaPlaying = false; -var contentHeightDiff = 0; var liveRecurse = 0; var savedTitle = ''; var followUpPageLoad = false; var window_needs_alert = true; +var expanded_items = []; var sse_bs_active = false; var sse_offset = 0; @@ -207,33 +207,6 @@ $(document).ready(function() { updateInit(); - // Allow folks to stop the ajax page updates with the pause/break key - $(document).keydown(function(event) { - if(event.keyCode == '8') { - var target = event.target || event.srcElement; - if (!/input|textarea/i.test(target.nodeName)) { - return false; - } - } - - if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) { - event.preventDefault(); - if(stopped === false) { - stopped = true; - if (event.ctrlKey) { - totStopped = true; - } - $('#pause').html('pause'); - } else { - unpause(); - } - } else { - if (!totStopped) { - unpause(); - } - } - }); - var e = document.getElementById('content-complete'); if(e) pageHasMoreContent = false; @@ -646,7 +619,8 @@ function updatePageItems(mode, data) { function updateConvItems(mode,data) { - $(document).trigger('hz:updateConvItems'); + if(mode !== 'update') + $(document).trigger('hz:updateConvItems'); if(mode === 'update' || mode === 'replace') { prev = 'threads-begin'; @@ -871,25 +845,16 @@ function scrollToItem() { } function collapseHeight() { - var origContentHeight = Math.ceil($("#region_2").height()); - var cDiff = 0; - var i = 0; - var position = $(window).scrollTop(); $(".wall-item-content, .directory-collapse").each(function() { var orgHeight = $(this).outerHeight(true); + var id = $(this).attr('id') + var open = ((expanded_items.indexOf($(this).attr('id')) === -1) ? false : true); if(orgHeight > divmore_height) { if(! $(this).hasClass('divmore') && $(this).has('div.no-collapse').length == 0) { - - // check if we will collapse some content above the visible content and compensate the diff later - if($(this).offset().top + divmore_height - $(window).scrollTop() + cDiff - ($(".divgrow-showmore").outerHeight() * i) < 65) { - diff = orgHeight - divmore_height; - cDiff = cDiff + diff; - i++; - } - $(this).readmore({ speed: 0, + startOpen: open, heightMargin: 50, collapsedHeight: divmore_height, moreLink: '' + aStr.divgrowmore + '', @@ -899,6 +864,10 @@ function collapseHeight() { if((($(element).offset().top + divmore_height) - $(window).scrollTop()) < 65 ) { $(window).scrollTop($(window).scrollTop() - ($(element).outerHeight(true) - divmore_height)); } + expanded_items = expanded_items.filter(expanded_items => expanded_items !== id); + } + else { + expanded_items.push(id); } } }); @@ -907,15 +876,6 @@ function collapseHeight() { } }); - var collapsedContentHeight = Math.ceil($("#region_2").height()); - contentHeightDiff = liking ? 0 : origContentHeight - collapsedContentHeight; - console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px'); - - if(i && !liking){ - var sval = position - cDiff + ($(".divgrow-showmore").outerHeight() * i); - console.log('collapsed above viewport count: ' + i); - $(window).scrollTop(sval); - } } function updateInit() { @@ -950,12 +910,7 @@ function liveUpdate(notify_id) { if((src === null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; } - // if auto updates are enabled and a comment box is open, - // prevent live updates until the comment is submitted - - var lockUpdates = (($('.comment-edit-text.expanded').length && (! bParam_static)) ? true : false); - - if(lockUpdates || in_progress || mediaPlaying) { + if(in_progress || mediaPlaying) { if(livetime) { clearTimeout(livetime); } @@ -1057,11 +1012,6 @@ function liveUpdate(notify_id) { scroll_next = false; updateConvItems(update_mode,data); - // adjust scroll position if new content was added above viewport - if(update_mode === 'update' && !justifiedGalleryActive) { - $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); - } - in_progress = false; $('#image_counter').html(''); @@ -1202,7 +1152,6 @@ function justifyPhotosAjax(id) { // trickery. This still could cause confusion if the "like" ajax call // is delayed and updateInit runs before it completes. function dolike(ident, verb) { - unpause(); $('#like-rotator-' + ident.toString()).show(); $.get('like/' + ident.toString() + '?verb=' + verb, updateInit ); liking = 1; @@ -1309,14 +1258,12 @@ function dropItem(url, object) { } function dosubthread(ident) { - unpause(); $('#like-rotator-' + ident.toString()).show(); $.get('subthread/sub/' + ident.toString(), updateInit ); liking = 1; } function dounsubthread(ident) { - unpause(); $('#like-rotator-' + ident.toString()).show(); $.get('subthread/unsub/' + ident.toString(), updateInit ); liking = 1; @@ -1395,18 +1342,18 @@ function submitPoll(id) { function(data) { $.jGrowl(data.message, { sticky: false, theme: ((data.success) ? 'info' : 'notice'), life: 10000 }); if(timer) clearTimeout(timer); - timer = setTimeout(updateInit,1500); + timer = setTimeout(updateInit, 500); } ); } - function post_comment(id) { - unpause(); + commentBusy = true; $('body').css('cursor', 'wait'); $("#comment-preview-inp-" + id).val("0"); + $.post( "item", $("#comment-edit-form-" + id).serialize(), @@ -1430,7 +1377,9 @@ function post_comment(id) { }, "json" ); + return false; + } @@ -1502,13 +1451,6 @@ function preview_mail() { return true; } -function unpause() { - // unpause auto reloads if they are currently stopped - totStopped = false; - stopped = false; - $('#pause').html(''); -} - function bin2hex(s) { // Converts the binary representation of data to hex // @@ -1605,7 +1547,6 @@ function zFormError(elm,x) { } } - $(window).scroll(function () { if(typeof buildCmd == 'function') { // This is a content page with items and/or conversations @@ -1631,22 +1572,6 @@ $(window).scroll(function () { } }); -var chanviewFullSize = false; - -function chanviewFull() { - if(chanviewFullSize) { - chanviewFullSize = false; - $('#chanview-iframe-border').css({ 'position' : 'relative', 'z-index' : '10' }); - $('#remote-channel').css({ 'position' : 'relative' , 'z-index' : '10' }); - } - else { - chanviewFullSize = true; - $('#chanview-iframe-border').css({ 'position' : 'fixed', 'top' : '0', 'left' : '0', 'z-index' : '150001' }); - $('#remote-channel').css({ 'position' : 'fixed', 'top' : '0', 'left' : '0', 'z-index' : '150000' }); - resize_iframe(); - } -} - function addhtmltext(data) { data = h2b(data); addeditortext(data); @@ -1877,8 +1802,6 @@ function sse_bs_notifications(e, replace, followup) { } } - - function sse_handleNotifications(obj, replace, followup) { var primary_notifications = ['dm', 'home', 'intros', 'register', 'mail', 'notify', 'files']; -- cgit v1.2.3 From 791d5098a047adf67b6da705552e64ef966d0453 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 18 Nov 2020 12:28:20 +0000 Subject: fix regression --- view/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index f807fb366..6d39adc39 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1171,7 +1171,7 @@ function doreply(parent, ident, owner, hint) { var sel = 'wall-item-body-' + ident.toString(); var quote = window.getSelection().toString().trim(); form.find('textarea').val("@{" + owner + "}" + ((($(window.getSelection().anchorNode).closest("#" + sel).attr("id") != sel) || (quote.length === 0))? " " : "\n[quote]" + quote + "[/quote]\n")); - $('#comment-edit-text-' + parent.toString()).focus(); + $('#comment-edit-text-' + parent.toString()).focus().trigger('click'); } function doscroll(parent, hidden) { -- cgit v1.2.3 From 852e456d44d2bffeadd2a22a7d47bb9e2e7f125f Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 18 Nov 2020 20:34:41 +0000 Subject: this is silly but it seems to be required for firefox to stop scrolling in certain conditions --- view/js/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 6d39adc39..09afb4da4 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -364,7 +364,6 @@ function handle_comment_form(e) { function commentClose(obj, id) { if(obj.value === '') { - obj.value = aStr.comment; $("#comment-edit-text-" + id).removeClass("expanded"); $("#mod-cmnt-wrap-" + id).hide(); $("#comment-tools-" + id).hide(); @@ -619,6 +618,8 @@ function updatePageItems(mode, data) { function updateConvItems(mode,data) { + var scroll_position = $(window).scrollTop(); + if(mode !== 'update') $(document).trigger('hz:updateConvItems'); @@ -750,6 +751,8 @@ function updateConvItems(mode,data) { }); + $(window).scrollTop(scroll_position); + if(followUpPageLoad) sse_bs_counts(); else -- cgit v1.2.3 From 011de75706ddd407cadfde89eec891b17db17211 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 20 Nov 2020 09:14:46 +0000 Subject: returning the rendered html when posting a comment will make the following update (and its implication in mod pubstream) obsolete --- view/js/main.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 09afb4da4..380b2bbf7 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1364,15 +1364,20 @@ function post_comment(id) { if(data.success) { localStorage.removeItem("comment_body-" + id); $("#comment-edit-preview-" + id).hide(); - $("#comment-edit-wrapper-" + id).hide(); - $("#comment-edit-text-" + id).val(''); + //$("#comment-edit-wrapper-" + id).hide(); + + $("#comment-edit-text-" + id).val('').blur().attr('placeholder', aStr.comment); var tarea = document.getElementById("comment-edit-text-" + id); if(tarea) { commentClose(tarea, id); $(document).unbind( "click.commentOpen"); } - if(timer) clearTimeout(timer); - timer = setTimeout(updateInit, 500); + + $('#wall-item-comment-wrapper-' + id).before(data.html); + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + $('body').css('cursor', 'unset'); + //if(timer) clearTimeout(timer); + //timer = setTimeout(updateInit, 500); } if(data.reload) { window.location.href=data.reload; -- cgit v1.2.3 From 4c0a26dbf9fca5358320ad11911aac1d5cc530b3 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 20 Nov 2020 10:45:35 +0000 Subject: move post_comment() handling via ctrl-enter out of handle_comment_form() - to many issues with multiple triggers --- view/js/main.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 380b2bbf7..bd595dbb3 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -56,7 +56,7 @@ $.ajaxSetup({cache: false}); $(document).ready(function() { - $(document).on('click', '.comment-edit-form', handle_comment_form); + $(document).on('click focus', '.comment-edit-form', handle_comment_form); $(document).on('click', '.conversation-settings-link', getConversationSettings); $(document).on('click', '#settings_module_ajax_submit', postConversationSettings); @@ -69,6 +69,13 @@ $(document).ready(function() { this.autocomplete_handled = true; } + + }); + + $(document).on('keydown', '.comment-edit-form textarea.expanded', function (e) { + if (e.ctrlKey && e.keyCode === 13) { + post_comment(this.id.replace('comment-edit-text-','')); + } }); var tf = new Function('n', 's', 'var k = s.split("/")['+aStr['plural_func']+']; return (k ? k : s);'); @@ -280,6 +287,7 @@ function handle_comment_form(e) { // handle clicked form var form = $(this); + var fields = form.find(':input[type=text], textarea'); var fields_empty = true; @@ -294,9 +302,9 @@ function handle_comment_form(e) { form.find(':not(:visible)').show(); } + // handle click outside of form (close empty forms) $(document).one('click', function(e) { - fields.each(function() { if($(this).val() != '') fields_empty = false; @@ -333,12 +341,6 @@ function handle_comment_form(e) { },10000); }); - $('#' + emptyCommentElm).on('keydown', function (e) { - if (e.ctrlKey && e.keyCode === 13) { - post_comment(convId); - } - }); - function commentSaveChanges(convId, isFinal) { if(typeof isFinal === 'undefined') @@ -1174,7 +1176,7 @@ function doreply(parent, ident, owner, hint) { var sel = 'wall-item-body-' + ident.toString(); var quote = window.getSelection().toString().trim(); form.find('textarea').val("@{" + owner + "}" + ((($(window.getSelection().anchorNode).closest("#" + sel).attr("id") != sel) || (quote.length === 0))? " " : "\n[quote]" + quote + "[/quote]\n")); - $('#comment-edit-text-' + parent.toString()).focus().trigger('click'); + $('#comment-edit-text-' + parent.toString()).focus(); } function doscroll(parent, hidden) { -- cgit v1.2.3 From 337d8ea78c2e799257fa4cbaf0ba96bc7c3d05d3 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 20 Nov 2020 14:42:46 +0000 Subject: minor cleanup --- view/js/main.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index bd595dbb3..c6460f356 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1366,20 +1366,18 @@ function post_comment(id) { if(data.success) { localStorage.removeItem("comment_body-" + id); $("#comment-edit-preview-" + id).hide(); - //$("#comment-edit-wrapper-" + id).hide(); - $("#comment-edit-text-" + id).val('').blur().attr('placeholder', aStr.comment); + $('#wall-item-comment-wrapper-' + id).before(data.html); + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + $('body').css('cursor', 'unset'); + commentBusy = false; + var tarea = document.getElementById("comment-edit-text-" + id); if(tarea) { commentClose(tarea, id); - $(document).unbind( "click.commentOpen"); + $(document).off( "click.commentOpen"); } - $('#wall-item-comment-wrapper-' + id).before(data.html); - $('#wall-item-ago-' + data.id + ' .autotime').timeago(); - $('body').css('cursor', 'unset'); - //if(timer) clearTimeout(timer); - //timer = setTimeout(updateInit, 500); } if(data.reload) { window.location.href=data.reload; -- cgit v1.2.3 From 2d4064aca4517eac695ba0f0f3618f4a7f7a08cb Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 20 Nov 2020 20:38:10 +0000 Subject: returning the rendered html when liking a post or comment --- view/js/main.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index c6460f356..133d71863 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -633,12 +633,11 @@ function updateConvItems(mode,data) { } if(mode === 'replace') { - $('.thread-wrapper').remove(); // clear existing content + $('.thread-parent').remove(); // clear existing content } $('.thread-wrapper', data).each(function() { if(this.classList.contains('toplevel_item')) { - var ident = this.id; var convId = ident.replace('thread-wrapper-',''); var commentWrap = $('#'+ident+' .collapsed-comments').attr('id'); @@ -1158,7 +1157,21 @@ function justifyPhotosAjax(id) { // is delayed and updateInit runs before it completes. function dolike(ident, verb) { $('#like-rotator-' + ident.toString()).show(); - $.get('like/' + ident.toString() + '?verb=' + verb, updateInit ); + $.get('like/' + ident.toString() + '?verb=' + verb, function (data) { + data = JSON.parse(data); + if(data.success) { + // this is a bit tricky since the top level thread wrapper wraps the whole thread + if($('#thread-wrapper-' + data.id).hasClass('toplevel_item')) { + var wrapper = $('
').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.id).html(wrapper[0].innerHTML); + } + else { + $('#thread-wrapper-' + data.id).replaceWith(data.html); + } + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + liking = 0; + } + }); liking = 1; } -- cgit v1.2.3 From f74cfaec5f48ec37cc1f51e5381a45998ebc70e3 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 21 Nov 2020 10:22:23 +0000 Subject: fix pubstream id issue --- view/js/main.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 133d71863..b7cfb75db 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1146,27 +1146,21 @@ function justifyPhotosAjax(id) { $('#' + id).justifiedGallery('norewind').on('jg.complete', function(e){ justifiedGalleryActive = false; }); } -// Since our ajax calls are asynchronous, we will give a few -// seconds for the first ajax call (setting like/dislike), then -// run the updater to pick up any changes and display on the page. -// The updater will turn any rotators off when it's done. -// This function will have returned long before any of these -// events have completed and therefore there won't be any -// visible feedback that anything changed without all this -// trickery. This still could cause confusion if the "like" ajax call -// is delayed and updateInit runs before it completes. function dolike(ident, verb) { $('#like-rotator-' + ident.toString()).show(); $.get('like/' + ident.toString() + '?verb=' + verb, function (data) { data = JSON.parse(data); if(data.success) { // this is a bit tricky since the top level thread wrapper wraps the whole thread - if($('#thread-wrapper-' + data.id).hasClass('toplevel_item')) { + if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { var wrapper = $('
').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); - $('#wall-item-outside-wrapper-' + data.id).html(wrapper[0].innerHTML); + $('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML); + // those were not replaced - swap the id + $('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id); } else { - $('#thread-wrapper-' + data.id).replaceWith(data.html); + $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); } $('#wall-item-ago-' + data.id + ' .autotime').timeago(); liking = 0; -- cgit v1.2.3 From 7639157a4907e9dbdffe6dd24f4f687f4cce6f01 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 21 Nov 2020 20:15:05 +0000 Subject: restrict returned html usage to local_channel() until some issues will be worked out --- view/js/main.js | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index b7cfb75db..5b6431858 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1148,24 +1148,30 @@ function justifyPhotosAjax(id) { function dolike(ident, verb) { $('#like-rotator-' + ident.toString()).show(); - $.get('like/' + ident.toString() + '?verb=' + verb, function (data) { - data = JSON.parse(data); - if(data.success) { - // this is a bit tricky since the top level thread wrapper wraps the whole thread - if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { - var wrapper = $('
').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); - $('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML); - // those were not replaced - swap the id - $('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id); - $('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id); - } - else { - $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); + + if(! localUser) { + $.get('like/' + ident.toString() + '?verb=' + verb, updateInit); + } + else { + $.get('like/' + ident.toString() + '?verb=' + verb, function (data) { + data = JSON.parse(data); + if(data.success) { + // this is a bit tricky since the top level thread wrapper wraps the whole thread + if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { + var wrapper = $('
').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML); + // those were not replaced - swap the id + $('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id); + } + else { + $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); + } + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + liking = 0; } - $('#wall-item-ago-' + data.id + ' .autotime').timeago(); - liking = 0; - } - }); + }); + } liking = 1; } @@ -1374,10 +1380,16 @@ function post_comment(id) { localStorage.removeItem("comment_body-" + id); $("#comment-edit-preview-" + id).hide(); $("#comment-edit-text-" + id).val('').blur().attr('placeholder', aStr.comment); - $('#wall-item-comment-wrapper-' + id).before(data.html); - $('#wall-item-ago-' + data.id + ' .autotime').timeago(); - $('body').css('cursor', 'unset'); - commentBusy = false; + + if(! localUser) { + updateInit(); + } + else { + $('#wall-item-comment-wrapper-' + id).before(data.html); + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + $('body').css('cursor', 'unset'); + commentBusy = false; + } var tarea = document.getElementById("comment-edit-text-" + id); if(tarea) { -- cgit v1.2.3 From 6c94bbc93fcdbcb729e119bea55f87b5334f650f Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 21 Nov 2020 20:52:38 +0000 Subject: collase the updated content --- view/js/main.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 5b6431858..0bc4261f5 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1168,6 +1168,7 @@ function dolike(ident, verb) { $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); } $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + collapseHeight(); liking = 0; } }); @@ -1388,6 +1389,7 @@ function post_comment(id) { $('#wall-item-comment-wrapper-' + id).before(data.html); $('#wall-item-ago-' + data.id + ' .autotime').timeago(); $('body').css('cursor', 'unset'); + collapseHeight(); commentBusy = false; } -- cgit v1.2.3 From c0adf31da9a0d8f897dc68ab632c736891318ad5 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 22 Nov 2020 13:07:03 +0000 Subject: fix like issue with remote channels --- view/js/main.js | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 0bc4261f5..4c8cd0adf 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1149,30 +1149,28 @@ function justifyPhotosAjax(id) { function dolike(ident, verb) { $('#like-rotator-' + ident.toString()).show(); - if(! localUser) { - $.get('like/' + ident.toString() + '?verb=' + verb, updateInit); - } - else { - $.get('like/' + ident.toString() + '?verb=' + verb, function (data) { - data = JSON.parse(data); - if(data.success) { - // this is a bit tricky since the top level thread wrapper wraps the whole thread - if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { - var wrapper = $('
').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); - $('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML); - // those were not replaced - swap the id - $('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id); - $('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id); - } - else { - $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); - } - $('#wall-item-ago-' + data.id + ' .autotime').timeago(); - collapseHeight(); - liking = 0; + if(typeof conv_mode == typeof undefined) + conv_mode = ''; + + $.get('like/' + ident.toString() + '?verb=' + verb + '&conv_mode=' + conv_mode, function (data) { + data = JSON.parse(data); + if(data.success) { + // this is a bit tricky since the top level thread wrapper wraps the whole thread + if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { + var wrapper = $('
').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML); + // those were not replaced - swap the id + $('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id); } - }); - } + else { + $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); + } + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + collapseHeight(); + liking = 0; + } + }); liking = 1; } -- cgit v1.2.3 From 451468d1297ba41a6c9ea29709444ceb15185bfb Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 22 Nov 2020 16:37:20 +0000 Subject: fix mod item issue with remote channels --- view/js/main.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 4c8cd0adf..35b03e03b 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1371,25 +1371,25 @@ function post_comment(id) { $('body').css('cursor', 'wait'); $("#comment-preview-inp-" + id).val("0"); + if(typeof conv_mode == typeof undefined) + conv_mode = ''; + + var form_data = $("#comment-edit-form-" + id).serialize(); + $.post( "item", - $("#comment-edit-form-" + id).serialize(), + form_data + '&conv_mode=' + conv_mode, function(data) { if(data.success) { + localStorage.removeItem("comment_body-" + id); $("#comment-edit-preview-" + id).hide(); $("#comment-edit-text-" + id).val('').blur().attr('placeholder', aStr.comment); - - if(! localUser) { - updateInit(); - } - else { - $('#wall-item-comment-wrapper-' + id).before(data.html); - $('#wall-item-ago-' + data.id + ' .autotime').timeago(); - $('body').css('cursor', 'unset'); - collapseHeight(); - commentBusy = false; - } + $('#wall-item-comment-wrapper-' + id).before(data.html); + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + $('body').css('cursor', 'unset'); + collapseHeight(); + commentBusy = false; var tarea = document.getElementById("comment-edit-text-" + id); if(tarea) { -- cgit v1.2.3 From 34d54fd3099217ccabcd812b1883ee7882caad77 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 23 Nov 2020 19:57:28 +0000 Subject: simplify code and fix issue with categories --- view/js/main.js | 1 - 1 file changed, 1 deletion(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 35b03e03b..d39e22b1a 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1153,7 +1153,6 @@ function dolike(ident, verb) { conv_mode = ''; $.get('like/' + ident.toString() + '?verb=' + verb + '&conv_mode=' + conv_mode, function (data) { - data = JSON.parse(data); if(data.success) { // this is a bit tricky since the top level thread wrapper wraps the whole thread if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { -- cgit v1.2.3 From 4419c93d8062794e5c2bbc222699881e5b97fc99 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 26 Nov 2020 07:58:57 +0000 Subject: this should not be required anymore --- view/js/main.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index d39e22b1a..ca82e3101 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1380,7 +1380,6 @@ function post_comment(id) { form_data + '&conv_mode=' + conv_mode, function(data) { if(data.success) { - localStorage.removeItem("comment_body-" + id); $("#comment-edit-preview-" + id).hide(); $("#comment-edit-text-" + id).val('').blur().attr('placeholder', aStr.comment); @@ -1395,10 +1394,6 @@ function post_comment(id) { commentClose(tarea, id); $(document).off( "click.commentOpen"); } - - } - if(data.reload) { - window.location.href=data.reload; } }, "json" -- cgit v1.2.3