Fix toggle

This commit is contained in:
Zixaphir 2014-01-06 09:37:23 -07:00
parent 3a776fb5e1
commit a7ce01cb61
3 changed files with 21 additions and 43 deletions

View File

@ -5030,35 +5030,26 @@
return true; return true;
}, },
toggle: function() { toggle: function() {
var container, containers, node, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref; var container, containers, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref;
if (Conf['Unread Count']) { if (Conf['Unread Count']) {
Unread.posts = new RandomAccessList; Unread.posts = new RandomAccessList;
Unread.ready(); Unread.ready();
} }
thread = $('.thread'); thread = $('.thread');
replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread); replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread);
QuoteThreading.enabled = this.checked; if (QuoteThreading.enabled = this.checked) {
if (this.checked) {
QuoteThreading.hasRun = false; QuoteThreading.hasRun = false;
for (_i = 0, _len = replies.length; _i < _len; _i++) { for (_i = 0, _len = replies.length; _i < _len; _i++) {
reply = replies[_i]; reply = replies[_i];
node = Get.postFromRoot(reply); post = Get.postFromRoot(reply);
if (node.cb) { if (post.cb) {
node.cb(); post.cb();
} else {
QuoteThreading.node.call(node);
if (node.cb) {
node.cb();
}
} }
} }
QuoteThreading.hasRun = true; QuoteThreading.hasRun = true;
} else { } else {
replies.sort(function(a, b) { replies.sort(function(a, b) {
var aID, bID; return Number(a.id.slice(2)) - Number(b.id.slice(2));
aID = Number(a.id.slice(2));
bID = Number(b.id.slice(2));
return aID - bID;
}); });
$.add(thread, replies); $.add(thread, replies);
containers = $$('.threadContainer', thread); containers = $$('.threadContainer', thread);

View File

@ -5033,35 +5033,26 @@
return true; return true;
}, },
toggle: function() { toggle: function() {
var container, containers, node, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref; var container, containers, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref;
if (Conf['Unread Count']) { if (Conf['Unread Count']) {
Unread.posts = new RandomAccessList; Unread.posts = new RandomAccessList;
Unread.ready(); Unread.ready();
} }
thread = $('.thread'); thread = $('.thread');
replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread); replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread);
QuoteThreading.enabled = this.checked; if (QuoteThreading.enabled = this.checked) {
if (this.checked) {
QuoteThreading.hasRun = false; QuoteThreading.hasRun = false;
for (_i = 0, _len = replies.length; _i < _len; _i++) { for (_i = 0, _len = replies.length; _i < _len; _i++) {
reply = replies[_i]; reply = replies[_i];
node = Get.postFromRoot(reply); post = Get.postFromRoot(reply);
if (node.cb) { if (post.cb) {
node.cb(); post.cb();
} else {
QuoteThreading.node.call(node);
if (node.cb) {
node.cb();
}
} }
} }
QuoteThreading.hasRun = true; QuoteThreading.hasRun = true;
} else { } else {
replies.sort(function(a, b) { replies.sort(function(a, b) {
var aID, bID; return Number(a.id.slice(2)) - Number(b.id.slice(2));
aID = Number(a.id.slice(2));
bID = Number(b.id.slice(2));
return aID - bID;
}); });
$.add(thread, replies); $.add(thread, replies);
containers = $$('.threadContainer', thread); containers = $$('.threadContainer', thread);

View File

@ -28,7 +28,6 @@ QuoteThreading =
$.off d, '4chanXInitFinished', QuoteThreading.setup $.off d, '4chanXInitFinished', QuoteThreading.setup
post.cb() for ID, post of g.posts when post.cb post.cb() for ID, post of g.posts when post.cb
QuoteThreading.hasRun = true QuoteThreading.hasRun = true
node: -> node: ->
@ -92,22 +91,19 @@ QuoteThreading =
thread = $ '.thread' thread = $ '.thread'
replies = $$ '.thread > .replyContainer, .threadContainer > .replyContainer', thread replies = $$ '.thread > .replyContainer, .threadContainer > .replyContainer', thread
QuoteThreading.enabled = @checked
if @checked if QuoteThreading.enabled = @checked
QuoteThreading.hasRun = false QuoteThreading.hasRun = false
for reply in replies for reply in replies
node = Get.postFromRoot reply post = Get.postFromRoot reply
if node.cb # QuoteThreading calculates whether or not posts should be threaded based on content
node.cb() # and then threads them based on thread context, so regardless of whether or not it
else # actually threads them all eligible posts WILL have a cb. Magic.
QuoteThreading.node.call node post.cb() if post.cb
node.cb() if node.cb
QuoteThreading.hasRun = true QuoteThreading.hasRun = true
else else
replies.sort (a, b) -> replies.sort (a, b) -> Number(a.id[2..]) - Number(b.id[2..])
aID = Number a.id[2..]
bID = Number b.id[2..]
aID - bID
$.add thread, replies $.add thread, replies
containers = $$ '.threadContainer', thread containers = $$ '.threadContainer', thread
$.rm container for container in containers $.rm container for container in containers