Advance on contract

This commit is contained in:
Zixaphir 2013-05-21 18:40:27 -07:00
parent dd4520fecf
commit cdade63440
5 changed files with 60 additions and 12 deletions

View File

@ -1,5 +1,5 @@
/* /*
* 4chan X - Version 1.2.8 - 2013-05-20 * 4chan X - Version 1.2.8 - 2013-05-21
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE

View File

@ -19,7 +19,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.2.8 - 2013-05-20 * 4chan X - Version 1.2.8 - 2013-05-21
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -6184,7 +6184,7 @@
} }
}, },
toggle: function(post) { toggle: function(post) {
var headRect, rect, root, thumb, top; var headRect, node, rect, root, thumb, top;
thumb = post.file.thumb; thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) { if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
@ -6192,7 +6192,21 @@
return; return;
} }
ImageExpand.contract(post); ImageExpand.contract(post);
rect = Conf['Advance on contract'] && !($.hasClass(doc, 'fappeTyme')) ? post.nodes.root.nextSibling.getBoundingClientRect() : post.nodes.root.getBoundingClientRect(); node = post.nodes.root;
rect = Conf['Advance on contract'] ? (function() {
while (node.nextElementSibling) {
if (!(node = node.nextElementSibling)) {
return post.nodes.root;
}
if (!$.hasClass(node, 'postContainer')) {
continue;
}
if (node.offsetHeight > 0 && !$('.stub', node)) {
break;
}
}
return node.getBoundingClientRect();
})() : post.nodes.root.getBoundingClientRect();
if (!(rect.top <= 0 || rect.left <= 0)) { if (!(rect.top <= 0 || rect.left <= 0)) {
return; return;
} }

View File

@ -19,7 +19,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.2.8 - 2013-05-20 * 4chan X - Version 1.2.8 - 2013-05-21
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -6193,7 +6193,7 @@
} }
}, },
toggle: function(post) { toggle: function(post) {
var headRect, rect, root, thumb, top; var headRect, node, rect, root, thumb, top;
thumb = post.file.thumb; thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) { if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
@ -6201,7 +6201,21 @@
return; return;
} }
ImageExpand.contract(post); ImageExpand.contract(post);
rect = Conf['Advance on contract'] && !($.hasClass(doc, 'fappeTyme')) ? post.nodes.root.nextSibling.getBoundingClientRect() : post.nodes.root.getBoundingClientRect(); node = post.nodes.root;
rect = Conf['Advance on contract'] ? (function() {
while (node.nextElementSibling) {
if (!(node = node.nextElementSibling)) {
return post.nodes.root;
}
if (!$.hasClass(node, 'postContainer')) {
continue;
}
if (node.offsetHeight > 0 && !$('.stub', node)) {
break;
}
}
return node.getBoundingClientRect();
})() : post.nodes.root.getBoundingClientRect();
if (!(rect.top <= 0 || rect.left <= 0)) { if (!(rect.top <= 0 || rect.left <= 0)) {
return; return;
} }

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // Generated by CoffeeScript
/* /*
* 4chan X - Version 1.2.8 - 2013-05-20 * 4chan X - Version 1.2.8 - 2013-05-21
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -6171,7 +6171,7 @@
} }
}, },
toggle: function(post) { toggle: function(post) {
var headRect, rect, root, thumb, top; var headRect, node, rect, root, thumb, top;
thumb = post.file.thumb; thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) { if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
@ -6179,7 +6179,21 @@
return; return;
} }
ImageExpand.contract(post); ImageExpand.contract(post);
rect = Conf['Advance on contract'] && !($.hasClass(doc, 'fappeTyme')) ? post.nodes.root.nextSibling.getBoundingClientRect() : post.nodes.root.getBoundingClientRect(); node = post.nodes.root;
rect = Conf['Advance on contract'] ? (function() {
while (node.nextElementSibling) {
if (!(node = node.nextElementSibling)) {
return post.nodes.root;
}
if (!$.hasClass(node, 'postContainer')) {
continue;
}
if (node.offsetHeight > 0 && !$('.stub', node)) {
break;
}
}
return node.getBoundingClientRect();
})() : post.nodes.root.getBoundingClientRect();
if (!(rect.top <= 0 || rect.left <= 0)) { if (!(rect.top <= 0 || rect.left <= 0)) {
return; return;
} }

View File

@ -68,8 +68,14 @@ ImageExpand =
ImageExpand.expand post ImageExpand.expand post
return return
ImageExpand.contract post ImageExpand.contract post
rect = if Conf['Advance on contract'] and !($.hasClass doc, 'fappeTyme') node = post.nodes.root
post.nodes.root.nextSibling.getBoundingClientRect() rect = if Conf['Advance on contract'] then do ->
# FIXME does not work with Quote Threading
while node.nextElementSibling
return post.nodes.root unless node = node.nextElementSibling
continue unless $.hasClass node, 'postContainer'
break if node.offsetHeight > 0 and not $ '.stub', node
node.getBoundingClientRect()
else else
post.nodes.root.getBoundingClientRect() post.nodes.root.getBoundingClientRect()
return unless rect.top <= 0 or rect.left <= 0 return unless rect.top <= 0 or rect.left <= 0