From 35e7500afe29704b0b70ed897376b84a9d0a597e Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 22 Jul 2019 16:30:12 -0700 Subject: [PATCH] Make Index Navigation keybinds/buttons work on Tinyboard/vichan. #2171 --- src/Miscellaneous/Keybinds.coffee | 6 +----- src/Miscellaneous/Nav.coffee | 9 +++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index a10896f59..ee1643ba1 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -21,11 +21,7 @@ Keybinds = {target} = e if target.nodeName in ['INPUT', 'TEXTAREA'] return unless /(Esc|Alt|Ctrl|Meta|Shift\+\w{2,})/.test(key) and not /^Alt\+(\d|Up|Down|Left|Right)$/.test(key) - unless ( - g.VIEW not in ['index', 'thread'] or - g.VIEW is 'index' and Conf['JSON Index'] and Conf['Index Mode'] is 'catalog' or - g.VIEW is 'index' and g.BOARD.ID is 'f' - ) + if g.VIEW in ['index', 'thread'] threadRoot = Nav.getThread() if op = $ '.op', threadRoot thread = Get.postFromNode(op).thread diff --git a/src/Miscellaneous/Nav.coffee b/src/Miscellaneous/Nav.coffee index 6b9de63c5..ff2a0885f 100644 --- a/src/Miscellaneous/Nav.coffee +++ b/src/Miscellaneous/Nav.coffee @@ -39,22 +39,23 @@ Nav = Nav.scroll +1 getThread: -> - return $ '.board' if $.hasClass doc, 'catalog-mode' - for threadRoot in $$ '.thread' + return if $.hasClass doc, 'catalog-mode' + for threadRoot in $$ g.SITE.selectors.thread thread = Get.threadFromRoot threadRoot continue if thread.isHidden and !thread.stub if Header.getTopOf(threadRoot) >= -threadRoot.getBoundingClientRect().height # not scrolled past return threadRoot - return $ '.board' + return scroll: (delta) -> d.activeElement?.blur() thread = Nav.getThread() + return unless thread axis = if delta is +1 'following' else 'preceding' - if next = $.x "#{axis}-sibling::div[contains(@class,'thread') and not(@hidden)][1]", thread + if next = $.x "#{axis}-sibling::#{g.SITE.xpath.thread}[not(@hidden)][1]", thread # Unless we're not at the beginning of the current thread, # and thus wanting to move to beginning, # or we're above the first thread and don't want to skip it.