From b4298f498f8afb5c5ac0bfa65bb628cf47561a21 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 13 Oct 2016 23:33:42 +0200 Subject: Scroll as read https://github.com/FreshRSS/FreshRSS/issues/1258 --- p/scripts/main.js | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/p/scripts/main.js b/p/scripts/main.js index d42704f7a..b2bd994ad 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -116,21 +116,18 @@ function incUnreadsFeed(article, feed_id, nb) { var pending_entries = {}; function mark_read(active, only_not_read) { - if (active.length === 0 || + if (active.length === 0 || active.attr('id') == '' || (only_not_read === true && !active.hasClass("not_read"))) { return false; } - var url = active.find("a.read").attr("href"); - if (url === undefined) { - return false; - } - if (pending_entries[active.attr('id')]) { return false; } pending_entries[active.attr('id')] = true; + var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, ''); + $.ajax({ type: 'POST', url: url, @@ -150,10 +147,11 @@ function mark_read(active, only_not_read) { } $r.find('.icon').replaceWith(data.icon); - var feed_url = active.find(".website>a").attr("href"), - feed_id = feed_url.substr(feed_url.lastIndexOf('f_')); - - incUnreadsFeed(active, feed_id, inc); + var feed_url = active.find(".website>a").attr("href"); + if (feed_url) { + var feed_id = feed_url.substr(feed_url.lastIndexOf('f_')); + incUnreadsFeed(active, feed_id, inc); + } faviconNbUnread(); delete pending_entries[active.attr('id')]; @@ -451,14 +449,9 @@ function auto_share(key) { } function inMarkViewport(flux, box_to_follow) { - var top = flux.offset().top; - var height = flux.height(), - begin = top + 3 * height / 4, - bot = Math.min(begin + 75, top + height), - windowTop = box_to_follow.scrollTop(), - windowBot = windowTop + box_to_follow.height() / 2; - - return (windowBot >= begin && bot >= windowBot); + var bottom = flux.offset().top + flux.height(), + windowTop = box_to_follow.scrollTop(); + return bottom < windowTop + 40; } function init_posts() { @@ -470,7 +463,7 @@ function init_posts() { if (context.auto_mark_scroll) { box_to_follow.scroll(function () { $('.not_read:visible').each(function () { - if ($(this).children(".flux_content").is(':visible') && inMarkViewport($(this), box_to_follow)) { + if (inMarkViewport($(this), box_to_follow)) { mark_read($(this), true); } }); -- cgit v1.2.3 From f766f34775c7162058b929b397ac7fd20dc885b2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 13 Oct 2016 23:38:25 +0200 Subject: Scroll as read minor variable --- p/scripts/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/p/scripts/main.js b/p/scripts/main.js index b2bd994ad..75d194906 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -463,8 +463,9 @@ function init_posts() { if (context.auto_mark_scroll) { box_to_follow.scroll(function () { $('.not_read:visible').each(function () { - if (inMarkViewport($(this), box_to_follow)) { - mark_read($(this), true); + var $this = $(this); + if (inMarkViewport($this, box_to_follow)) { + mark_read($this, true); } }); }); -- cgit v1.2.3 From 626d9cbccbd0a52c7ece4ffeaab9bd09f62a3761 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 14 Oct 2016 09:20:11 +0200 Subject: Scroll as read: mark as unread bug --- p/scripts/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/p/scripts/main.js b/p/scripts/main.js index 75d194906..b3531e884 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -126,7 +126,8 @@ function mark_read(active, only_not_read) { } pending_entries[active.attr('id')] = true; - var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, ''); + var url = '.?c=entry&a=read&id=' + active.attr('id').replace(/^flux_/, '') + + (active.hasClass('not_read') ? '' : '&is_read=0'); $.ajax({ type: 'POST', -- cgit v1.2.3 From 3366945a90b58929cc3b9e980ce9a52027151556 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 14 Oct 2016 17:49:33 +0200 Subject: Default option mark as read during scroll --- CHANGELOG.md | 1 + data/users/_/config.default.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3178e6ae7..a21e4a093 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Experimental support for PostgreSQL [#1195](https://github.com/FreshRSS/FreshRSS/pull/1195) * New client supporting FreshRSS on Linux: FeedReader 2.0+ [#1252](https://github.com/FreshRSS/FreshRSS/issues/1252) * Features + * Rework the “mark as read during scroll” option, now enabled by default [#1258](https://github.com/FreshRSS/FreshRSS/issues/1258), [#1309](https://github.com/FreshRSS/FreshRSS/pull/1309) * Better control of number of entries per page or RSS feed [#1249](https://github.com/FreshRSS/FreshRSS/issues/1249) * Since X hours: `https://freshrss.example/i/?a=rss&hours=3` * Explicit number: `https://freshrss.example/i/?a=rss&nb=10` diff --git a/data/users/_/config.default.php b/data/users/_/config.default.php index 280b13422..f28ef9724 100644 --- a/data/users/_/config.default.php +++ b/data/users/_/config.default.php @@ -35,7 +35,7 @@ return array ( 'mark_when' => array ( 'article' => true, 'site' => true, - 'scroll' => false, + 'scroll' => true, 'reception' => false, ), 'theme' => 'Origine', -- cgit v1.2.3 From 6d7ebaeb3b75969fbf44a8f36dbb5e9993f0c623 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 14 Oct 2016 17:50:27 +0200 Subject: Readme mark as read during scroll --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a21e4a093..4aa5ada8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ * Experimental support for PostgreSQL [#1195](https://github.com/FreshRSS/FreshRSS/pull/1195) * New client supporting FreshRSS on Linux: FeedReader 2.0+ [#1252](https://github.com/FreshRSS/FreshRSS/issues/1252) * Features - * Rework the “mark as read during scroll” option, now enabled by default [#1258](https://github.com/FreshRSS/FreshRSS/issues/1258), [#1309](https://github.com/FreshRSS/FreshRSS/pull/1309) + * Rework the “mark as read during scroll” option, enabled by default for new users [#1258](https://github.com/FreshRSS/FreshRSS/issues/1258), [#1309](https://github.com/FreshRSS/FreshRSS/pull/1309) * Better control of number of entries per page or RSS feed [#1249](https://github.com/FreshRSS/FreshRSS/issues/1249) * Since X hours: `https://freshrss.example/i/?a=rss&hours=3` * Explicit number: `https://freshrss.example/i/?a=rss&nb=10` -- cgit v1.2.3