Screw reply navigation, there are top and bottom links on 4chan itself. Also return guard.

This commit is contained in:
Nicolas Stepien 2013-02-17 21:57:20 +01:00
parent e001cd3c98
commit d546654cf2
4 changed files with 11 additions and 22 deletions

View File

@ -60,7 +60,6 @@
'Comment Expansion': [true, 'Can expand too long comments.'], 'Comment Expansion': [true, 'Can expand too long comments.'],
'Thread Expansion': [true, 'Can expand threads to view all replies.'], 'Thread Expansion': [true, 'Can expand threads to view all replies.'],
'Index Navigation': [false, 'Navigate to previous / next thread.'], 'Index Navigation': [false, 'Navigate to previous / next thread.'],
'Reply Navigation': [false, 'Navigate to top / bottom of thread.'],
'Check for Updates': [true, 'Check for updated versions of 4chan X Alpha.'] 'Check for Updates': [true, 'Check for updated versions of 4chan X Alpha.']
}, },
Filtering: { Filtering: {
@ -2237,6 +2236,9 @@
Nav = { Nav = {
init: function() { init: function() {
var next, prev, span; var next, prev, span;
if (g.VIEW !== 'index' || !Conf['Index Navigation']) {
return;
}
span = $.el('span', { span = $.el('span', {
id: 'navlinks' id: 'navlinks'
}); });
@ -2256,18 +2258,10 @@
}); });
}, },
prev: function() { prev: function() {
if (g.VIEW === 'thread') { return Nav.scroll(-1);
return window.scrollTo(0, 0);
} else {
return Nav.scroll(-1);
}
}, },
next: function() { next: function() {
if (g.VIEW === 'thread') { return Nav.scroll(+1);
return window.scrollTo(0, d.body.scrollHeight);
} else {
return Nav.scroll(+1);
}
}, },
getThread: function(full) { getThread: function(full) {
var headRect, i, rect, thread, threads, topMargin, _i, _len; var headRect, i, rect, thread, threads, topMargin, _i, _len;
@ -6153,7 +6147,7 @@
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); initFeature('Index Navigation', Nav);
console.timeEnd('All initializations'); console.timeEnd('All initializations');
$.on(d, '4chanMainInit', Main.initStyle); $.on(d, '4chanMainInit', Main.initStyle);
return $.ready(Main.initReady); return $.ready(Main.initReady);

View File

@ -10,7 +10,6 @@ Config =
'Comment Expansion': [true, 'Can expand too long comments.'] 'Comment Expansion': [true, 'Can expand too long comments.']
'Thread Expansion': [true, 'Can expand threads to view all replies.'] 'Thread Expansion': [true, 'Can expand threads to view all replies.']
'Index Navigation': [false, 'Navigate to previous / next thread.'] 'Index Navigation': [false, 'Navigate to previous / next thread.']
'Reply Navigation': [false, 'Navigate to top / bottom of thread.']
'Check for Updates': [true, 'Check for updated versions of <%= meta.name %>.'] 'Check for Updates': [true, 'Check for updated versions of <%= meta.name %>.']
Filtering: Filtering:
'Anonymize': [false, 'Turn everyone Anonymous.'] 'Anonymize': [false, 'Turn everyone Anonymous.']

View File

@ -1027,6 +1027,8 @@ ArchiveLink =
Nav = Nav =
init: -> init: ->
return if g.VIEW isnt 'index' or !Conf['Index Navigation']
span = $.el 'span', span = $.el 'span',
id: 'navlinks' id: 'navlinks'
prev = $.el 'a', prev = $.el 'a',
@ -1043,16 +1045,10 @@ Nav =
$.on d, '4chanXInitFinished', -> $.add d.body, span $.on d, '4chanXInitFinished', -> $.add d.body, span
prev: -> prev: ->
if g.VIEW is 'thread' Nav.scroll -1
window.scrollTo 0, 0
else
Nav.scroll -1
next: -> next: ->
if g.VIEW is 'thread' Nav.scroll +1
window.scrollTo 0, d.body.scrollHeight
else
Nav.scroll +1
getThread: (full) -> getThread: (full) ->
headRect = $.id('header-bar').getBoundingClientRect() headRect = $.id('header-bar').getBoundingClientRect()

View File

@ -344,7 +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 initFeature 'Index Navigation', Nav
console.timeEnd 'All initializations' console.timeEnd 'All initializations'
$.on d, '4chanMainInit', Main.initStyle $.on d, '4chanMainInit', Main.initStyle