Zixaphir 77433f5da8 Merge branch 'v3' into Av2
Conflicts:
	builds/4chan-X.js
	builds/4chan-X.meta.js
	builds/4chan-X.user.js
	builds/crx.crx
	builds/crx/manifest.json
	builds/crx/script.js
	package.json
	src/General/Config.coffee
	src/General/Main.coffee
	src/General/Settings.coffee
	src/General/css/burichan.css
	src/General/css/futaba.css
	src/General/css/photon.css
	src/General/css/style.css
	src/General/css/tomorrow.css
	src/General/css/yotsuba-b.css
	src/General/css/yotsuba.css
	src/General/img/favicons/Original/unreadDead.gif
	src/General/img/favicons/Original/unreadNSFW.gif
	src/General/img/favicons/Original/unreadSFW.gif
	src/General/img/favicons/dead.gif
	src/General/img/favicons/empty.gif
	src/General/img/favicons/ferongr/unreadDead.gif
	src/General/img/favicons/ferongr/unreadNSFW.gif
	src/General/img/favicons/ferongr/unreadSFW.gif
	src/General/meta/metadata.js
	src/Miscellaneous/AnnouncementHiding.coffee
	src/Miscellaneous/Keybinds.coffee
	src/Monitoring/ThreadStats.coffee
	src/Monitoring/ThreadUpdater.coffee
	src/Posting/QuickReply.coffee
	src/features/misc/header.coffee
	src/features/monitoring/favicon.coffee
2013-04-28 21:20:22 -07:00

63 lines
1.7 KiB
CoffeeScript

Nav =
init: ->
switch g.VIEW
when 'index'
return unless Conf['Index Navigation']
when 'thread'
return unless Conf['Reply Navigation']
else # catalog
return
span = $.el 'span',
id: 'navlinks'
prev = $.el 'a',
href: 'javascript:;'
next = $.el 'a',
href: 'javascript:;'
$.on prev, 'click', @prev
$.on next, 'click', @next
$.add span, [prev, $.tn(' '), next]
append = ->
$.off d, '4chanXInitFinished', append
$.add d.body, span
$.on d, '4chanXInitFinished', append
prev: ->
if g.VIEW is 'thread'
window.scrollTo 0, 0
else
Nav.scroll -1
next: ->
if g.VIEW is 'thread'
window.scrollTo 0, d.body.scrollHeight
else
Nav.scroll +1
getThread: (full) ->
if Conf['Bottom header']
topMargin = 0
else
headRect = Header.bar.getBoundingClientRect()
topMargin = headRect.top + headRect.height
threads = $$ '.thread:not([hidden])'
for thread, i in threads
rect = thread.getBoundingClientRect()
if rect.bottom > topMargin # not scrolled past
return if full then [threads, thread, i, rect, topMargin] else thread
return $ '.board'
scroll: (delta) ->
[threads, thread, i, rect, topMargin] = Nav.getThread true
top = rect.top - topMargin
# 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
unless (delta is -1 and Math.ceil(top) < 0) or (delta is +1 and top > 1)
i += delta
top = threads[i]?.getBoundingClientRect().top - topMargin
window.scrollBy 0, top