From f17f9fd441a6649bf20f50701faaddf6f9d95561 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 9 Dec 2013 11:38:32 +0100 Subject: [PATCH] Anchor hidden threads on the index. --- CHANGELOG.md | 3 +++ src/General/Config.coffee | 1 + src/General/Index.coffee | 27 ++++++++++++++++++++------- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14584f327..060462cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +- More index navigation improvements: + - New setting: `Anchor Hidden Threads`, enabled by default. Hidden threads will be moved at the end of the index to fill the first pages. + ### 3.14.3 - *2013-12-09* - Minor bug fixes. diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 086bb7262..39b025920 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -143,6 +143,7 @@ Config = 'Index Mode': 'paged' 'Index Sort': 'bump' 'Show Replies': true + 'Anchor Hidden Threads': true Header: 'Header auto-hide': false 'Header auto-hide on scroll': false diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 81c04d9bb..cae8482a7 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -38,17 +38,25 @@ Index = repliesEntry = el: $.el 'label', innerHTML: ' Show replies' - input = repliesEntry.el.firstChild - input.checked = Conf['Show Replies'] - $.on input, 'change', $.cb.checked - $.on input, 'change', @cb.replies + anchorEntry = + el: $.el 'label', innerHTML: ' Anchor hidden threads' + for label in [repliesEntry, anchorEntry] + input = label.el.firstChild + {name} = input + input.checked = Conf[name] + $.on input, 'change', $.cb.checked + switch name + when 'Show Replies' + $.on input, 'change', @cb.replies + when 'Anchor Hidden Threads' + $.on input, 'change', @cb.sort $.event 'AddMenuEntry', type: 'header' el: $.el 'span', textContent: 'Index Navigation' order: 90 - subEntries: [modeEntry, sortEntry, repliesEntry] + subEntries: [modeEntry, sortEntry, repliesEntry, anchorEntry] $.addClass doc, 'index-loading' @update() @@ -318,12 +326,17 @@ Index = Index.sortedNodes.push Index.nodes[i], Index.nodes[i + 1] if Index.isSearching Index.sortedNodes = Index.querySearch(Index.searchInput.value) or Index.sortedNodes - # Put the sticky threads on top of the index. + # Move non-hidden threads on top of the index. + if Conf['Anchor Hidden Threads'] + offset = 0 + for threadRoot, i in Index.sortedNodes by 2 when not Get.threadFromRoot(threadRoot).isHidden + Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... + # Move sticky threads on top of the index. offset = 0 for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isSticky Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... return unless Conf['Filter'] - # Put the highlighted thread &
on top of the index + # Move highlighted threads &
on top of the index # while keeping the original order they appear in. offset = 0 for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isOnTop