Add Index/Reply Navigation.
This code is so old. Are these features even used?
This commit is contained in:
parent
bbd96ad959
commit
70bb35950f
File diff suppressed because one or more lines are too long
@ -54,7 +54,7 @@ a[href="javascript:;"] {
|
|||||||
/* fixed, z-index */
|
/* fixed, z-index */
|
||||||
#qp, #ihover,
|
#qp, #ihover,
|
||||||
#updater, #thread-stats,
|
#updater, #thread-stats,
|
||||||
#header,
|
#navlinks, #header,
|
||||||
#qr, #watcher {
|
#qr, #watcher {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ a[href="javascript:;"] {
|
|||||||
#menu {
|
#menu {
|
||||||
z-index: 60;
|
z-index: 60;
|
||||||
}
|
}
|
||||||
#updater, #thread-stats {
|
#navlinks, #updater, #thread-stats {
|
||||||
z-index: 50;
|
z-index: 50;
|
||||||
}
|
}
|
||||||
#header:hover {
|
#header:hover {
|
||||||
@ -304,6 +304,13 @@ a[href="javascript:;"] {
|
|||||||
padding-bottom: 16px;
|
padding-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Index/Reply Navigation */
|
||||||
|
#navlinks {
|
||||||
|
font-size: 16px;
|
||||||
|
top: 25px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Filter */
|
/* Filter */
|
||||||
.opContainer.filter-highlight {
|
.opContainer.filter-highlight {
|
||||||
box-shadow: inset 5px 0 rgba(255, 0, 0, .5);
|
box-shadow: inset 5px 0 rgba(255, 0, 0, .5);
|
||||||
|
|||||||
@ -1025,6 +1025,58 @@ ArchiveLink =
|
|||||||
open: open
|
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 =
|
Redirect =
|
||||||
image: (board, filename) ->
|
image: (board, filename) ->
|
||||||
# Do not use g.BOARD, the image url can originate from a cross-quote.
|
# Do not use g.BOARD, the image url can originate from a cross-quote.
|
||||||
|
|||||||
@ -344,6 +344,7 @@ Main =
|
|||||||
initFeature 'Thread Stats', ThreadStats
|
initFeature 'Thread Stats', ThreadStats
|
||||||
initFeature 'Thread Updater', ThreadUpdater
|
initFeature 'Thread Updater', ThreadUpdater
|
||||||
initFeature 'Thread Watcher', ThreadWatcher
|
initFeature 'Thread Watcher', ThreadWatcher
|
||||||
|
initFeature 'Index/Reply Navigation', Nav
|
||||||
console.timeEnd 'All initializations'
|
console.timeEnd 'All initializations'
|
||||||
|
|
||||||
$.on d, '4chanMainInit', Main.initStyle
|
$.on d, '4chanMainInit', Main.initStyle
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user