Make Index Navigation keybinds/buttons work on Tinyboard/vichan. #2171
This commit is contained in:
parent
285cd4cb72
commit
35e7500afe
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user