aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-10-13 23:33:42 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-10-13 23:33:42 +0200
commitb4298f498f8afb5c5ac0bfa65bb628cf47561a21 (patch)
treebff409c02802b28b96e4e508baafee0933734650 /p/scripts
parent8ee61c1f788980f8fb862b4cfd75eba5e78a2547 (diff)
Scroll as read
https://github.com/FreshRSS/FreshRSS/issues/1258
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js31
1 files 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);
}
});