Skip to content

A free, self-hostable news aggregator…

Merge branch 'dev' into dev-1.14.0

Alexandre Alapetiteef6df8aeca9f
diff --cc p/scripts/main.js
index 4939bf7dd,6cab2e55a..82dc79ce7
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@@ -297,9 -237,12 +297,12 @@@ function mark_favorite(div)
});
}
+ var freshrssOpenArticleEvent = document.createEvent('Event');
+ freshrssOpenArticleEvent.initEvent('freshrss:openArticle', true, true);
+
function toggleContent(new_active, old_active, skipping) {
// If skipping, move current without activating or marking as read
- if (new_active.length === 0) {
+ if (!new_active) {
return;
}
@@@ -340,30 -283,73 +343,33 @@@
if (skipping) {
// when skipping, this feels more natural if it's not so near the top
- new_pos -= $(window).height() / 4;
+ new_pos -= document.body.clientHeight / 4;
}
- if (context.hide_posts) {
- if (relative_move) {
- new_pos += old_scroll;
- }
-
- new_active.children(".flux_content").first().each(function () {
- box_to_move.scrollTop(new_pos).scrollTop();
- });
- } else {
- if (relative_move) {
- new_pos += old_scroll;
- }
-
- box_to_move.scrollTop(new_pos).scrollTop();
+ if (relative_move) {
+ new_pos += old_scroll;
}
+ box_to_move.scrollTop = new_pos;
}
- if (context.auto_mark_article && new_active.classList.contains('active') && !skipping) {
- mark_read(new_active, true);
- if (new_active.hasClass('active') && !skipping) {
++ if (new_active.classList.contains('active') && !skipping) {
+ if (context.auto_mark_article) {
+ mark_read(new_active, true);
+ }
+ new_active[0].dispatchEvent(freshrssOpenArticleEvent);
}
+ onScroll();
}
-function auto_remove(element) {
- var p = element.prev();
- var n = element.next();
- if (p.hasClass('day') && n.hasClass('day')) {
- p.remove();
- }
- element.remove();
- $('#stream > .flux:not(.not_read):not(.active)').remove();
+function prev_entry(skipping) {
+ const old_active = document.querySelector('.flux.current'),
+ new_active = old_active ? old_active.previousElementSibling : document.querySelector('.flux');
+ toggleContent(new_active, old_active, skipping);
}
-function prev_entry() {
- var old_active = $(".flux.current"),
- new_active = old_active.length === 0 ? $(".flux:last") : old_active.prevAll(".flux:first");
- toggleContent(new_active, old_active, false);
-}
-
-function next_entry() {
- var old_active = $(".flux.current"),
- new_active = old_active.length === 0 ? $(".flux:first") : old_active.nextAll(".flux:first");
- toggleContent(new_active, old_active, false);
-
- if (new_active.nextAll().length < 3) {
- load_more_posts();
- }
-}
-
-function skip_prev_entry() {
- var old_active = $(".flux.current"),
- new_active = old_active.length === 0 ? $(".flux:last") : old_active.prevAll(".flux:first");
- toggleContent(new_active, old_active, true);
-}
-
-function skip_next_entry() {
- var old_active = $(".flux.current"),
- new_active = old_active.length === 0 ? $(".flux:first") : old_active.nextAll(".flux:first");
- toggleContent(new_active, old_active, true);
-
- if (new_active.nextAll().length < 3) {
- load_more_posts();
- }
+function next_entry(skipping) {
+ const old_active = document.querySelector('.flux.current'),
+ new_active = old_active ? old_active.nextElementSibling : document.querySelector('.flux');
+ toggleContent(new_active, old_active, skipping);
}
function prev_feed() {