Fix "Advance on contract" option with Quote Threading

This commit is contained in:
Zixaphir 2013-08-06 13:33:57 -07:00
parent d02ce2ff0f
commit 7939d24640
3 changed files with 24 additions and 51 deletions

View File

@ -6283,7 +6283,7 @@
} }
}, },
toggle: function(post) { toggle: function(post) {
var headRect, node, rect, thumb, x, y; var headRect, rect, root, thumb, x, y;
thumb = post.file.thumb; thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) { if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
@ -6291,28 +6291,17 @@
return; return;
} }
ImageExpand.contract(post); ImageExpand.contract(post);
node = post.nodes.root; root = post.nodes.root;
rect = Conf['Advance on contract'] ? (function() { rect = (Conf['Advance on contract'] ? (function() {
while (node.nextElementSibling) { var next;
if (!(node = node.nextElementSibling)) {
return post.nodes.root; next = $.x("following::div[contains(@class,'postContainer')][1]", root);
} return next || root;
if (!$.hasClass(node, 'postContainer')) { })() : root).getBoundingClientRect();
continue;
}
if (node.offsetHeight > 0 && !$('.stub', node)) {
break;
}
}
return node.getBoundingClientRect();
})() : post.nodes.root.getBoundingClientRect();
if (!(rect.top <= 0 || rect.left <= 0)) {
return;
}
if (rect.top < 0) { if (rect.top < 0) {
y = rect.top; y = rect.top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) { if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.toggle.getBoundingClientRect(); headRect = Header.bar.getBoundingClientRect();
y -= headRect.top + headRect.height; y -= headRect.top + headRect.height;
} }
} }

View File

@ -6263,7 +6263,7 @@
} }
}, },
toggle: function(post) { toggle: function(post) {
var headRect, node, rect, thumb, x, y; var headRect, rect, root, thumb, x, y;
thumb = post.file.thumb; thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) { if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
@ -6271,28 +6271,17 @@
return; return;
} }
ImageExpand.contract(post); ImageExpand.contract(post);
node = post.nodes.root; root = post.nodes.root;
rect = Conf['Advance on contract'] ? (function() { rect = (Conf['Advance on contract'] ? (function() {
while (node.nextElementSibling) { var next;
if (!(node = node.nextElementSibling)) {
return post.nodes.root; next = $.x("following::div[contains(@class,'postContainer')][1]", root);
} return next || root;
if (!$.hasClass(node, 'postContainer')) { })() : root).getBoundingClientRect();
continue;
}
if (node.offsetHeight > 0 && !$('.stub', node)) {
break;
}
}
return node.getBoundingClientRect();
})() : post.nodes.root.getBoundingClientRect();
if (!(rect.top <= 0 || rect.left <= 0)) {
return;
}
if (rect.top < 0) { if (rect.top < 0) {
y = rect.top; y = rect.top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) { if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.toggle.getBoundingClientRect(); headRect = Header.bar.getBoundingClientRect();
y -= headRect.top + headRect.height; y -= headRect.top + headRect.height;
} }
} }

View File

@ -59,24 +59,19 @@ ImageExpand =
ImageExpand.expand post ImageExpand.expand post
return return
ImageExpand.contract post ImageExpand.contract post
node = post.nodes.root
# Scroll back to the thumbnail when contracting the image # Scroll back to the thumbnail when contracting the image
# to avoid being left miles away from the relevant post. # to avoid being left miles away from the relevant post.
rect = if Conf['Advance on contract'] then do -> {root} = post.nodes
# FIXME does not work with Quote Threading rect = (if Conf['Advance on contract'] then do ->
while node.nextElementSibling next = $.x "following::div[contains(@class,'postContainer')][1]", root
return post.nodes.root unless node = node.nextElementSibling next or root
continue unless $.hasClass node, 'postContainer'
break if node.offsetHeight > 0 and not $ '.stub', node
node.getBoundingClientRect()
else else
post.nodes.root.getBoundingClientRect() root).getBoundingClientRect()
return unless rect.top <= 0 or rect.left <= 0
if rect.top < 0 if rect.top < 0
y = rect.top y = rect.top
if Conf['Fixed Header'] and not Conf['Bottom Header'] if Conf['Fixed Header'] and not Conf['Bottom Header']
headRect = Header.toggle.getBoundingClientRect() headRect = Header.bar.getBoundingClientRect()
y -= headRect.top + headRect.height y -= headRect.top + headRect.height
if rect.left < 0 if rect.left < 0