Add Index/Reply Navigation.

This code is so old.
Are these features even used?
This commit is contained in:
Nicolas Stepien 2013-02-17 21:49:32 +01:00
parent bbd96ad959
commit 70bb35950f
4 changed files with 130 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -54,7 +54,7 @@ a[href="javascript:;"] {
/* fixed, z-index */
#qp, #ihover,
#updater, #thread-stats,
#header,
#navlinks, #header,
#qr, #watcher {
position: fixed;
}
@ -67,7 +67,7 @@ a[href="javascript:;"] {
#menu {
z-index: 60;
}
#updater, #thread-stats {
#navlinks, #updater, #thread-stats {
z-index: 50;
}
#header:hover {
@ -304,6 +304,13 @@ a[href="javascript:;"] {
padding-bottom: 16px;
}
/* Index/Reply Navigation */
#navlinks {
font-size: 16px;
top: 25px;
right: 10px;
}
/* Filter */
.opContainer.filter-highlight {
box-shadow: inset 5px 0 rgba(255, 0, 0, .5);

View File

@ -1025,6 +1025,58 @@ ArchiveLink =
open: open
}
Nav =
init: ->
span = $.el 'span',
id: 'navlinks'
prev = $.el 'a',
textContent: ''
href: 'javascript:;'
next = $.el 'a',
textContent: ''
href: 'javascript:;'
$.on prev, 'click', @prev
$.on next, 'click', @next
$.add span, [prev, $.tn(' '), next]
$.on d, '4chanXInitFinished', -> $.add d.body, span
prev: ->
if g.VIEW is 'reply'
window.scrollTo 0, 0
else
Nav.scroll -1
next: ->
if g.VIEW is 'reply'
window.scrollTo 0, d.body.scrollHeight
else
Nav.scroll +1
getThread: (full) ->
headRect = $.id('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
Redirect =
image: (board, filename) ->
# Do not use g.BOARD, the image url can originate from a cross-quote.

View File

@ -344,6 +344,7 @@ Main =
initFeature 'Thread Stats', ThreadStats
initFeature 'Thread Updater', ThreadUpdater
initFeature 'Thread Watcher', ThreadWatcher
initFeature 'Index/Reply Navigation', Nav
console.timeEnd 'All initializations'
$.on d, '4chanMainInit', Main.initStyle