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 +++++++----------------------------------- view/tpl/build_query.tpl | 2 - view/tpl/item_filer.tpl | 2 +- view/tpl/jot-header.tpl | 13 +++-- view/tpl/settings_display.tpl | 1 - 5 files changed, 25 insertions(+), 102 deletions(-) (limited to 'view') 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']; diff --git a/view/tpl/build_query.tpl b/view/tpl/build_query.tpl index bbe0ac7ee..69c5e301f 100755 --- a/view/tpl/build_query.tpl +++ b/view/tpl/build_query.tpl @@ -18,7 +18,6 @@ var bParam_list = {{$list}}; var bParam_fh = {{$fh}}; var bParam_dm = {{$dm}}; - var bParam_static = {{$static}}; var bParam_search = "{{$search}}"; var bParam_xchan = "{{$xchan}}"; @@ -42,7 +41,6 @@ if(bParam_cmax != (-1)) bCmd = bCmd + "&cmax=" + bParam_cmax; if(bParam_gid != 0) { bCmd = bCmd + "&gid=" + bParam_gid; } else if(bParam_cid != 0) { bCmd = bCmd + "&cid=" + bParam_cid; } - if(bParam_static != 0) { bCmd = bCmd + "&static=" + bParam_static; } if(bParam_star != 0) bCmd = bCmd + "&star=" + bParam_star; if(bParam_liked != 0) bCmd = bCmd + "&liked=" + bParam_liked; if(bParam_conv!= 0) bCmd = bCmd + "&conv=" + bParam_conv; diff --git a/view/tpl/item_filer.tpl b/view/tpl/item_filer.tpl index 4eb621f93..f814b374c 100644 --- a/view/tpl/item_filer.tpl +++ b/view/tpl/item_filer.tpl @@ -1,7 +1,7 @@ {{if $categories}} {{foreach $categories as $cat}} - {{$cat.term}}  + {{$cat.term}}  {{/foreach}} {{/if}} diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index d78907b38..2539c1fdf 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -303,13 +303,9 @@ var activeCommentText = ''; if(reply && reply.length) { reply = reply.replace('#',''); if(reply.length) { - commentBusy = true; $('body').css('cursor', 'wait'); - - $.get('{{$baseurl}}/tagger/' + id + '?term=' + reply); - if(timer) clearTimeout(timer); - timer = setTimeout(updateInit,3000); + $.get('{{$baseurl}}/tagger/' + id + '?term=' + reply, updateInit); liking = 1; } } @@ -358,6 +354,13 @@ var activeCommentText = ''; } + function itemFilerRm(id, term) { + commentBusy = true; + $('body').css('cursor', 'wait'); + $.get('{{$baseurl}}/filerm/' + id + '?f=&term=' + term, updateInit); + liking = 1; + } + function itemBookmark(id) { $.get('{{$baseurl}}/bookmarks?f=&item=' + id); if(timer) clearTimeout(timer); diff --git a/view/tpl/settings_display.tpl b/view/tpl/settings_display.tpl index c93efb4aa..c2dd94175 100755 --- a/view/tpl/settings_display.tpl +++ b/view/tpl/settings_display.tpl @@ -63,7 +63,6 @@ {{include file="field_checkbox.tpl" field=$title_tosource}} {{include file="field_checkbox.tpl" field=$user_scalable}} {{include file="field_checkbox.tpl" field=$preload_images}} - {{include file="field_checkbox.tpl" field=$manual_update}} {{include file="field_checkbox.tpl" field=$start_menu}}
-- cgit v1.2.3