From c77a6cc54fe02635689ab1ffefb2706f2d80cb1a Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Sun, 17 Nov 2024 16:08:15 +0300 Subject: [PATCH] add posts scrolling function and ability to disabl --- Web/Models/Repositories/Posts.php | 4 ++-- Web/Presenters/templates/@layout.xml | 1 + Web/Presenters/templates/Search/Index.xml | 2 +- Web/Presenters/templates/User/Groups.xml | 4 ++-- Web/Presenters/templates/Wall/Feed.xml | 10 ++++++---- Web/Presenters/templates/Wall/Wall.xml | 6 +++--- .../templates/components/comments.xml | 2 -- Web/Presenters/templates/components/wall.xml | 6 +++--- Web/static/js/al_comments.js | 4 +++- Web/static/js/al_feed.js | 19 +++++++++++++++++-- Web/static/js/al_mentions.js | 3 ++- Web/static/js/al_wall.js | 9 ++++++++- locales/en.strings | 1 + locales/ru.strings | 1 + 14 files changed, 50 insertions(+), 22 deletions(-) diff --git a/Web/Models/Repositories/Posts.php b/Web/Models/Repositories/Posts.php index 36082f24..da1f9c8d 100644 --- a/Web/Models/Repositories/Posts.php +++ b/Web/Models/Repositories/Posts.php @@ -53,9 +53,9 @@ class Posts $offset--; } } - } else if(!is_null($offset)) { + } /*else if(!is_null($offset)) { $offset--; - } + }*/ $sel = $this->posts->where([ "wall" => $user, diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index ca356901..0e514bb8 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -391,6 +391,7 @@ {script "js/al_polls.js"} {script "js/al_suggestions.js"} {script "js/al_navigation.js"} + {script "js/al_comments.js"} {ifset $thisUser} {script "js/al_notifs.js"} diff --git a/Web/Presenters/templates/Search/Index.xml b/Web/Presenters/templates/Search/Index.xml index a515fd16..a1d49b1c 100644 --- a/Web/Presenters/templates/Search/Index.xml +++ b/Web/Presenters/templates/Search/Index.xml @@ -29,7 +29,7 @@
-
+
{if $count > 0} {if $section === 'users'}
diff --git a/Web/Presenters/templates/User/Groups.xml b/Web/Presenters/templates/User/Groups.xml index 281447ba..d3528268 100644 --- a/Web/Presenters/templates/User/Groups.xml +++ b/Web/Presenters/templates/User/Groups.xml @@ -122,8 +122,8 @@

{_search_group}

{_search_group_desc}
- - + +
diff --git a/Web/Presenters/templates/Wall/Feed.xml b/Web/Presenters/templates/Wall/Feed.xml index e609419c..33a70533 100644 --- a/Web/Presenters/templates/Wall/Feed.xml +++ b/Web/Presenters/templates/Wall/Feed.xml @@ -23,10 +23,12 @@ {include "../components/textArea.xml", route => "/wall" . $thisUser->getId() . "/makePost", graffiti => true, polls => true, notes => true, hasSource => true}
- {foreach $posts as $post} - - {include "../components/post.xml", post => $post, onWallOf => true, commentSection => true} - {/foreach} +
+
+ + {include "../components/post.xml", post => $post, onWallOf => true, commentSection => true} +
+
diff --git a/Web/Presenters/templates/Wall/Wall.xml b/Web/Presenters/templates/Wall/Wall.xml index 80452295..73801632 100644 --- a/Web/Presenters/templates/Wall/Wall.xml +++ b/Web/Presenters/templates/Wall/Wall.xml @@ -31,13 +31,13 @@ {include "../components/textArea.xml", route => "/wall$owner/makePost", hasSource => true}
-
+
{if sizeof($posts) > 0} - {foreach $posts as $post} +
{include "../components/post.xml", post => $post, commentSection => true} - {/foreach} +
{include "../components/paginator.xml", conf => $paginatorConf} {else} {_no_posts_abstract} diff --git a/Web/Presenters/templates/components/comments.xml b/Web/Presenters/templates/components/comments.xml index a4bf59da..53253b5f 100644 --- a/Web/Presenters/templates/components/comments.xml +++ b/Web/Presenters/templates/components/comments.xml @@ -20,5 +20,3 @@ {else} {_comments_tip} {/if} - -{script "js/al_comments.js"} diff --git a/Web/Presenters/templates/components/wall.xml b/Web/Presenters/templates/components/wall.xml index 91e08fbc..8479041d 100644 --- a/Web/Presenters/templates/components/wall.xml +++ b/Web/Presenters/templates/components/wall.xml @@ -13,13 +13,13 @@ {include "../components/textArea.xml", route => "/wall$owner/makePost", graffiti => true, polls => true, notes => true, hasSource => true}
-
+
{if sizeof($posts) > 0} - {foreach $posts as $post} +
{include "../components/post.xml", post => $post, commentSection => true} - {/foreach} +
{include "../components/paginator.xml", conf => $paginatorConf} {else} {_no_posts_abstract} diff --git a/Web/static/js/al_comments.js b/Web/static/js/al_comments.js index 70c7210d..ad398637 100644 --- a/Web/static/js/al_comments.js +++ b/Web/static/js/al_comments.js @@ -8,6 +8,8 @@ u(document).on("click", ".comment-reply", function(e) { let mention = ("[" + (fromGroup ? "club" : "id") + authorId + "|" + authorNm + "], "); // Substitute pervious mention if present, prepend otherwise - inputbox.nodes[0].value = inputbox.nodes[0].value.replace(/(^\[([A-Za-z0-9]+)\|([\p{L} 0-9@]+)\], |^)/u, mention); + inputbox.nodes.forEach(node => { + node.value = node.value.replace(/(^\[([A-Za-z0-9]+)\|([\p{L} 0-9@]+)\], |^)/u, mention); + }) inputbox.trigger("focusin"); }); diff --git a/Web/static/js/al_feed.js b/Web/static/js/al_feed.js index 2831d6f1..7ca8a798 100644 --- a/Web/static/js/al_feed.js +++ b/Web/static/js/al_feed.js @@ -84,6 +84,7 @@ u(document).on('click', '#__feed_settings_link', (e) => { const CURRENT_PERPAGE = Number(__temp_url.searchParams.get('posts') ?? 10) const CURRENT_PAGE = Number(__temp_url.searchParams.get('p') ?? 1) const CURRENT_RETURN_BANNED = Number(__temp_url.searchParams.get('return_banned') ?? 0) + const CURRENT_AUTO_SCROLL = Number(localStorage.getItem('ux.auto_scroll') ?? 1) const COUNT = [1, 5, 10, 20, 30, 40, 50] u('#_feed_settings_container #__content').html(` @@ -107,11 +108,21 @@ u(document).on('click', '#__feed_settings_link', (e) => { + + + + @@ -268,3 +279,7 @@ u(document).on('click', '#__feed_settings_link', (e) => { __switchTab('main') }) + +u(document).on('change', `input[data-act='localstorage_item']`, (e) => { + localStorage.setItem(e.target.name, Number(e.target.checked)) +}) diff --git a/Web/static/js/al_mentions.js b/Web/static/js/al_mentions.js index 1be77563..d324cca6 100644 --- a/Web/static/js/al_mentions.js +++ b/Web/static/js/al_mentions.js @@ -19,7 +19,8 @@ var tooltipTemplate = Handlebars.compile(`
- + - ${tr('show_ignored_sources')} + +
+ + + + +
`); -tippy(".mention", { +tippy.delegate("body", { + target: '.mention', theme: "light vk", content: "⌛", allowHTML: true, diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 3dba201d..53617dd4 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -399,6 +399,7 @@ async function OpenVideo(video_arr = [], init_player = true) details.find('.media-page-wrapper-description b').remove() u('#ovk-player-info').html(details.html()) + bsdnHydrate() } }) @@ -542,7 +543,8 @@ var tooltipClientNoInfoTemplate = Handlebars.compile(` `); -tippy(".client_app", { +tippy.delegate("body", { + target: '.client_app', theme: "light vk", content: "⌛", allowHTML: true, @@ -2039,6 +2041,10 @@ async function __processPaginatorNextPage(page) const showMoreObserver = new IntersectionObserver(entries => { entries.forEach(async x => { if(x.isIntersecting) { + if(Number(localStorage.getItem('ux.auto_scroll') ?? 1) == 0) { + return + } + if(u('.scroll_container').length < 1) { return } @@ -2063,6 +2069,7 @@ const showMoreObserver = new IntersectionObserver(entries => { const page_number = Number(next_page.html()) await __processPaginatorNextPage(page_number) + bsdnHydrate() u('.paginator:not(.paginator-at-top)').removeClass('lagged') } }) diff --git a/locales/en.strings b/locales/en.strings index 7a84ae09..c1ff0822 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -220,6 +220,7 @@ "all_news" = "All news"; "posts_per_page" = "Number of posts per page"; "show_ignored_sources" = "Show ignored sources"; +"auto_scroll" = "Autoscroll"; "attachment" = "Attachment"; "post_as_group" = "Post as group"; diff --git a/locales/ru.strings b/locales/ru.strings index 33dd70d1..8a2d4e8c 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -205,6 +205,7 @@ "all_news" = "Все новости"; "posts_per_page" = "Количество записей на странице"; "show_ignored_sources" = "Показывать игнорируемые источники"; +"auto_scroll" = "Автоматическая прокрутка"; "attachment" = "Вложение"; "post_as_group" = "От имени сообщества"; "comment_as_group" = "От имени сообщества";