diff options
Diffstat (limited to 'p/scripts/main.js')
| -rw-r--r-- | p/scripts/main.js | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js index 92fa8db4c..43753417c 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -237,12 +237,13 @@ function mark_favorite(active) { }); } -function toggleContent(new_active, old_active) { +function toggleContent(new_active, old_active, skipping = false) { + // If skipping, move current without activating or marking as read if (new_active.length === 0) { return; } - if (context.does_lazyload) { + if (context.does_lazyload && !skipping) { new_active.find('img[data-original], iframe[data-original]').each(function () { this.onload = function () { $(document.body).trigger("sticky_kit:recalc"); }; this.setAttribute('src', this.getAttribute('data-original')); @@ -251,15 +252,15 @@ function toggleContent(new_active, old_active) { } if (old_active[0] !== new_active[0]) { - if (isCollapsed) { + if (isCollapsed && !skipping) { // BUG?: isCollapsed can only ever be true new_active.addClass("active"); } old_active.removeClass("active current"); new_active.addClass("current"); - if (context.auto_remove_article && !old_active.hasClass('not_read')) { + if (context.auto_remove_article && !old_active.hasClass('not_read') && !skipping) { auto_remove(old_active); } - } else { + } else { // collapse_entry calls toggleContent(flux_current, flux_current) new_active.toggleClass('active'); } @@ -278,6 +279,10 @@ function toggleContent(new_active, old_active) { } } + if (skipping){ + // when skipping, this feels more natural if it's not so near the top + new_pos -= $(window).height()/4 + } if (context.hide_posts) { if (relative_move) { new_pos += old_scroll; @@ -295,7 +300,7 @@ function toggleContent(new_active, old_active) { } } - if (context.auto_mark_article && new_active.hasClass('active')) { + if (context.auto_mark_article && new_active.hasClass('active') && !skipping) { mark_read(new_active, true); } } @@ -313,13 +318,29 @@ function auto_remove(element) { 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); + 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); + 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(); @@ -637,6 +658,9 @@ function init_shortcuts() { shortcut.add(shortcuts.prev_entry, prev_entry, { 'disable_in_input': true }); + shortcut.add(shortcuts.skip_prev_entry, skip_prev_entry, { + 'disable_in_input': true + }); shortcut.add(shortcuts.first_entry, function () { var old_active = $(".flux.current"), first = $(".flux:first"); @@ -650,6 +674,9 @@ function init_shortcuts() { shortcut.add(shortcuts.next_entry, next_entry, { 'disable_in_input': true }); + shortcut.add(shortcuts.skip_next_entry, skip_next_entry, { + 'disable_in_input': true + }); shortcut.add(shortcuts.last_entry, function () { var old_active = $(".flux.current"), last = $(".flux:last"); |
