From 7aa3d9f87309620b54dc9ff5f726dc22d1e6ea0c Mon Sep 17 00:00:00 2001 From: maTh <1645099+math-GH@users.noreply.github.com> Date: Mon, 1 Jul 2024 01:13:54 +0200 Subject: New: Sharing articles from the article title line (#6395) * enable option * Update entry_header.phtml * frss.css * fix print sharing * Light refactoring * fix --------- Co-authored-by: Alexandre Alapetite --- p/scripts/main.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 2bc0f5337..5690eb532 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -402,6 +402,13 @@ function mark_favorite(div) { const freshrssOpenArticleEvent = document.createEvent('Event'); freshrssOpenArticleEvent.initEvent('freshrss:openArticle', true, true); +function loadLazyImages(rootElement) { + rootElement.querySelectorAll('img[data-original], iframe[data-original]').forEach(function (el) { + el.src = el.getAttribute('data-original'); + el.removeAttribute('data-original'); + }); +} + function toggleContent(new_active, old_active, skipping) { // If skipping, move current without activating or marking as read if (!new_active) { @@ -409,10 +416,7 @@ function toggleContent(new_active, old_active, skipping) { } if (context.does_lazyload && !skipping) { - new_active.querySelectorAll('img[data-original], iframe[data-original]').forEach(function (el) { - el.src = el.getAttribute('data-original'); - el.removeAttribute('data-original'); - }); + loadLazyImages(new_active); } if (old_active !== new_active) { @@ -1101,7 +1105,16 @@ function init_stream(stream) { for (let i = 0; i < document.styleSheets.length; i++) { tmp_window.document.writeln(''); } - tmp_window.document.writeln(el.closest('.flux_content').querySelector('.content').innerHTML); + const flux_content = el.closest('.flux_content'); + let content_el = null; + if (flux_content) { + content_el = el.closest('.flux_content').querySelector('.content'); + } + if (content_el === null) { + content_el = el.closest('.flux').querySelector('.flux_content .content'); + } + loadLazyImages(content_el); + tmp_window.document.writeln(content_el.innerHTML); tmp_window.document.close(); tmp_window.focus(); tmp_window.print(); -- cgit v1.2.3