diff --git a/public/language/en-GB/world.json b/public/language/en-GB/world.json index e6694bf507..427135352d 100644 --- a/public/language/en-GB/world.json +++ b/public/language/en-GB/world.json @@ -21,5 +21,7 @@ "onboard.why": "There's a lot that goes on outside of this forum, and not all of it is relevant to your interests. That's why following people is the best way to signal that you want to see more from someone.", "onboard.how": "In the meantime, you can click on the shortcut buttons at the top to see what else this forum knows about, and start discovering some new content!", - "category-search": "Find a category..." + "category-search": "Find a category...", + "see-more": "See more", + "see-less": "See less" } \ No newline at end of file diff --git a/public/src/client/world.js b/public/src/client/world.js index 1318195060..faa9de0310 100644 --- a/public/src/client/world.js +++ b/public/src/client/world.js @@ -22,6 +22,7 @@ define('forum/world', [ handleImages(); handleButtons(); handleHelp(); + handleShowMoreButtons(); categoryTools.init($('#world-feed')); socket.on('event:new_post', onNewPost); @@ -208,6 +209,31 @@ define('forum/world', [ $('[component="post/content"] img:not(.not-responsive)').addClass('img-fluid'); } + function handleShowMoreButtons() { + const feedEl = document.getElementById('world-feed'); + if (!feedEl) { + return; + } + + feedEl.querySelectorAll('[component="post/content"]').forEach((el) => { + if (el.clientHeight < el.scrollHeight - 1) { + el.parentNode.querySelector('[component="show/more"]').classList.remove('hidden'); + } + }); + + feedEl.addEventListener('click', (e) => { + const subselector = e.target.closest('[component="show/more"]'); + if (subselector) { + const postContent = subselector.closest('.post-body').querySelector('[component="post/content"]'); + const isShowingMore = parseInt(subselector.getAttribute('ismore'), 10) === 1; + postContent.classList.toggle('line-clamp-6', isShowingMore); + postContent.classList.toggle('clamp-fade-6', isShowingMore); + $(subselector).translateText(isShowingMore ? '[[world:see-more]]' : '[[world:see-less]]'); + subselector.setAttribute('ismore', isShowingMore ? 0 : 1); + } + }); + } + function updateDropdowns(modified_cids, state) { modified_cids.forEach(function (cid) { const category = $('[data-cid="' + cid + '"]'); diff --git a/src/views/partials/feed/item.tpl b/src/views/partials/feed/item.tpl index f46b9e87c5..0c6f7ae919 100644 --- a/src/views/partials/feed/item.tpl +++ b/src/views/partials/feed/item.tpl @@ -54,12 +54,12 @@ -