From 90eace9fcb2f32701bab68a050ab3b28f12ac80c Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 23 Feb 2013 01:32:15 +0100 Subject: [PATCH] Fix contracting replies when contracting a thread too. #764 --- 4chan_x.user.js | 20 ++++++++++++++------ src/features.coffee | 8 +++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 65769b4d9..abc2f7810 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -4720,7 +4720,7 @@ if (!post.nodes.shortComment) { return; } - a = a = $('.abbr > a', post.nodes.shortComment); + a = $('.abbr > a', post.nodes.shortComment); a.textContent = 'here'; $.replace(post.nodes.longComment, post.nodes.shortComment); return post.nodes.comment = post.nodes.shortComment; @@ -4815,7 +4815,7 @@ return ExpandThread.toggle(op.thread); }, toggle: function(thread) { - var a, inlined, num, replies, reply, text, threadRoot, url, _i, _len; + var a, inlined, num, post, replies, reply, text, threadRoot, url, _i, _j, _k, _len, _len1, _len2, _ref, _ref1; threadRoot = thread.OP.nodes.root.parentNode; url = "//api.4chan.org/" + thread.board + "/res/" + thread + ".json"; a = $('.summary', threadRoot); @@ -4826,14 +4826,17 @@ $.cache(url, function() { return ExpandThread.parse(this, thread, a); }); - ExpandComment.expand(thread.OP); + _ref = $$('.thread > .postContainer', threadRoot); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + post = _ref[_i]; + ExpandComment.expand(Get.postFromRoot(post)); + } break; case '×': a.textContent = text.replace('× Loading...', '+'); break; case '-': a.textContent = text.replace('-', '+'); - ExpandComment.contract(thread.OP); num = (function() { if (thread.isSticky) { return 1; @@ -4851,8 +4854,8 @@ } })(); replies = $$('.thread > .replyContainer', threadRoot).slice(0, -num); - for (_i = 0, _len = replies.length; _i < _len; _i++) { - reply = replies[_i]; + for (_j = 0, _len1 = replies.length; _j < _len1; _j++) { + reply = replies[_j]; if (Conf['Quote Inlining']) { while (inlined = $('.inlined', reply)) { inlined.click(); @@ -4860,6 +4863,11 @@ } $.rm(reply); } + _ref1 = $$('.thread > .postContainer', threadRoot); + for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) { + post = _ref1[_k]; + ExpandComment.contract(Get.postFromRoot(post)); + } } }, parse: function(req, thread, a) { diff --git a/src/features.coffee b/src/features.coffee index 82beb4c4e..f0449c0ac 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -3127,7 +3127,7 @@ ExpandComment = $.cache "//api.4chan.org#{a.pathname}.json", -> ExpandComment.parse @, a, post contract: (post) -> return unless post.nodes.shortComment - a = a = $ '.abbr > a', post.nodes.shortComment + a = $ '.abbr > a', post.nodes.shortComment a.textContent = 'here' $.replace post.nodes.longComment, post.nodes.shortComment post.nodes.comment = post.nodes.shortComment @@ -3203,14 +3203,14 @@ ExpandThread = when '+' a.textContent = text.replace '+', '× Loading...' $.cache url, -> ExpandThread.parse @, thread, a - ExpandComment.expand thread.OP + for post in $$ '.thread > .postContainer', threadRoot + ExpandComment.expand Get.postFromRoot post when '×' a.textContent = text.replace '× Loading...', '+' when '-' a.textContent = text.replace '-', '+' - ExpandComment.contract thread.OP #goddamit moot num = if thread.isSticky 1 @@ -3225,6 +3225,8 @@ ExpandThread = # rm clones inlined.click() while inlined = $ '.inlined', reply $.rm reply + for post in $$ '.thread > .postContainer', threadRoot + ExpandComment.contract Get.postFromRoot post return parse: (req, thread, a) ->