From efc50456fdf201117b7df8044ef06f398d6e3802 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 10 Apr 2011 14:15:32 -0700 Subject: [PATCH] keybind: x: thread hiding --- 4chan_x.js | 20 ++++++++++++++------ script.coffee | 16 ++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index d6ac50273..3cb163f76 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -742,9 +742,11 @@ case 'u': break; case 'w': - thread = nav.getThread()[0]; + thread = nav.getThread(); return watcher.toggle(thread); case 'x': + thread = nav.getThread(); + threadHiding.toggle(thread); } } }; @@ -1436,11 +1438,16 @@ return threadHiding.hide(thread); }, show: function(e) { - var div, thread; - div = e.target.parentNode; - thread = div.parentNode; - threadHiding.show(thread); - return $.remove(div); + var thread; + thread = e.target.parentNode.parentNode; + return threadHiding.show(thread); + } + }, + toggle: function(thread) { + if (thread.className.indexOf('stub') !== -1 || thread.style.display === 'none') { + return threadHiding.show(thread); + } else { + return threadHiding.hide(thread); } }, hide: function(thread) { @@ -1480,6 +1487,7 @@ }, show: function(thread) { var hiddenThreads, id; + $.remove($('div.block', thread)); $.removeClass(thread, 'stub'); $.show(thread); $.show(thread.nextSibling); diff --git a/script.coffee b/script.coffee index 5d136b030..4f5d436f9 100644 --- a/script.coffee +++ b/script.coffee @@ -562,13 +562,13 @@ keybinds = #update now return when 'w' - [thread] = nav.getThread() + thread = nav.getThread() watcher.toggle thread when 'x' - #toggle hide thread + thread = nav.getThread() + threadHiding.toggle thread return - keyModeNormal = (e) -> return if e.ctrlKey or e.altKey char = g.char @@ -1097,11 +1097,14 @@ threadHiding = thread = e.target.parentNode.parentNode threadHiding.hide thread show: (e) -> - div = e.target.parentNode - thread = div.parentNode + thread = e.target.parentNode.parentNode threadHiding.show thread - $.remove div + toggle: (thread) -> + if thread.className.indexOf('stub') != -1 or thread.style.display is 'none' + threadHiding.show thread + else + threadHiding.hide thread hide: (thread) -> threadHiding.hideHide thread @@ -1138,6 +1141,7 @@ threadHiding = $.hide thread.nextSibling show: (thread) -> + $.remove $ 'div.block', thread $.removeClass thread, 'stub' $.show thread $.show thread.nextSibling