From 14c8d15c8619e60166e3d5d4ed8fb04e5d4333fa Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 16 Jun 2011 11:51:58 -0700 Subject: [PATCH 1/2] in-thread thread-nav; closes #147 --- 4chan_x.user.js | 14 +++++++++++--- script.coffee | 13 ++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a8034e42a..cf4f89bff 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -912,6 +912,14 @@ }, scroll: function(delta) { var i, rect, thread, top, _ref; + if (g.REPLY) { + if (delta === -1) { + window.scrollTo(0, 0); + } else { + window.scrollTo(0, d.body.scrollHeight); + } + return; + } _ref = nav.getThread(true), thread = _ref[0], i = _ref[1], rect = _ref[2]; top = rect.top; if (!((delta === -1 && Math.ceil(top) < 0) || (delta === +1 && top > 1))) { @@ -2574,6 +2582,9 @@ if ($.config('Keybinds')) { keybinds.init(); } + if ($.config('Thread Navigation')) { + nav.init(); + } threading.init(); if (g.REPLY) { if ($.config('Thread Updater')) { @@ -2601,9 +2612,6 @@ if ($.config('Thread Hiding')) { threadHiding.init(); } - if ($.config('Thread Navigation')) { - nav.init(); - } if ($.config('Thread Expansion')) { expandThread.init(); } diff --git a/script.coffee b/script.coffee index 556f51e93..5c9712834 100644 --- a/script.coffee +++ b/script.coffee @@ -675,6 +675,13 @@ nav = return null scroll: (delta) -> + if g.REPLY + if delta is -1 + window.scrollTo 0,0 + else + window.scrollTo 0, d.body.scrollHeight + return + [thread, i, rect] = nav.getThread true {top} = rect @@ -1947,6 +1954,9 @@ main = if $.config 'Keybinds' keybinds.init() + if $.config 'Thread Navigation' + nav.init() + threading.init() if g.REPLY @@ -1976,9 +1986,6 @@ main = if $.config 'Thread Hiding' threadHiding.init() - if $.config 'Thread Navigation' - nav.init() - if $.config 'Thread Expansion' expandThread.init() From c4ac4906983d83bf06610a244775a73e71554549 Mon Sep 17 00:00:00 2001 From: James Campos Date: Thu, 16 Jun 2011 11:54:50 -0700 Subject: [PATCH 2/2] split it up --- 4chan_x.user.js | 12 ++++++++---- script.coffee | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index cf4f89bff..67fda4696 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -110,7 +110,8 @@ 'Report Button': [true, 'Add report buttons'], 'Comment Expansion': [true, 'Expand too long comments'], 'Thread Expansion': [true, 'View all replies'], - 'Thread Navigation': [true, 'Navigate to previous / next thread'] + 'Index Navigation': [true, 'Navigate to previous / next thread'], + 'Reply Navigation': [false, 'Navigate to top / bottom of thread'] } }, flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', 'http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url='].join('\n'), @@ -2582,9 +2583,6 @@ if ($.config('Keybinds')) { keybinds.init(); } - if ($.config('Thread Navigation')) { - nav.init(); - } threading.init(); if (g.REPLY) { if ($.config('Thread Updater')) { @@ -2608,7 +2606,13 @@ if ($.config('Auto Watch') && $.config('Thread Watcher') && location.hash === '#watch' && $('img.favicon').src === Favicon.empty) { watcher.watch(null, g.THREAD_ID); } + if ($.config('Reply Navigation')) { + nav.init(); + } } else { + if ($.config('Index Navigation')) { + nav.init(); + } if ($.config('Thread Hiding')) { threadHiding.init(); } diff --git a/script.coffee b/script.coffee index 5c9712834..9cd4448b4 100644 --- a/script.coffee +++ b/script.coffee @@ -42,7 +42,8 @@ config = 'Report Button': [true, 'Add report buttons'] 'Comment Expansion': [true, 'Expand too long comments'] 'Thread Expansion': [true, 'View all replies'] - 'Thread Navigation': [true, 'Navigate to previous / next thread'] + 'Index Navigation': [true, 'Navigate to previous / next thread'] + 'Reply Navigation': [false, 'Navigate to top / bottom of thread'] flavors: [ 'http://regex.info/exif.cgi?url=' 'http://iqdb.org/?url=' @@ -1954,9 +1955,6 @@ main = if $.config 'Keybinds' keybinds.init() - if $.config 'Thread Navigation' - nav.init() - threading.init() if g.REPLY @@ -1982,7 +1980,13 @@ main = location.hash is '#watch' and $('img.favicon').src is Favicon.empty watcher.watch null, g.THREAD_ID + if $.config 'Reply Navigation' + nav.init() + else #not reply + if $.config 'Index Navigation' + nav.init() + if $.config 'Thread Hiding' threadHiding.init()