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
|
{target} = e
|
||||||
if target.nodeName in ['INPUT', 'TEXTAREA']
|
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)
|
return unless /(Esc|Alt|Ctrl|Meta|Shift\+\w{2,})/.test(key) and not /^Alt\+(\d|Up|Down|Left|Right)$/.test(key)
|
||||||
unless (
|
if g.VIEW in ['index', 'thread']
|
||||||
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'
|
|
||||||
)
|
|
||||||
threadRoot = Nav.getThread()
|
threadRoot = Nav.getThread()
|
||||||
if op = $ '.op', threadRoot
|
if op = $ '.op', threadRoot
|
||||||
thread = Get.postFromNode(op).thread
|
thread = Get.postFromNode(op).thread
|
||||||
|
|||||||
@ -39,22 +39,23 @@ Nav =
|
|||||||
Nav.scroll +1
|
Nav.scroll +1
|
||||||
|
|
||||||
getThread: ->
|
getThread: ->
|
||||||
return $ '.board' if $.hasClass doc, 'catalog-mode'
|
return if $.hasClass doc, 'catalog-mode'
|
||||||
for threadRoot in $$ '.thread'
|
for threadRoot in $$ g.SITE.selectors.thread
|
||||||
thread = Get.threadFromRoot threadRoot
|
thread = Get.threadFromRoot threadRoot
|
||||||
continue if thread.isHidden and !thread.stub
|
continue if thread.isHidden and !thread.stub
|
||||||
if Header.getTopOf(threadRoot) >= -threadRoot.getBoundingClientRect().height # not scrolled past
|
if Header.getTopOf(threadRoot) >= -threadRoot.getBoundingClientRect().height # not scrolled past
|
||||||
return threadRoot
|
return threadRoot
|
||||||
return $ '.board'
|
return
|
||||||
|
|
||||||
scroll: (delta) ->
|
scroll: (delta) ->
|
||||||
d.activeElement?.blur()
|
d.activeElement?.blur()
|
||||||
thread = Nav.getThread()
|
thread = Nav.getThread()
|
||||||
|
return unless thread
|
||||||
axis = if delta is +1
|
axis = if delta is +1
|
||||||
'following'
|
'following'
|
||||||
else
|
else
|
||||||
'preceding'
|
'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,
|
# Unless we're not at the beginning of the current thread,
|
||||||
# and thus wanting to move to beginning,
|
# and thus wanting to move to beginning,
|
||||||
# or we're above the first thread and don't want to skip it.
|
# or we're above the first thread and don't want to skip it.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user