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.
* 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
// ==/UserScript==
/*
* 4chan X - Version 1.2.8 - 2013-05-20
* 4chan X - Version 1.2.8 - 2013-05-21
*
* Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -6184,7 +6184,7 @@
}
},
toggle: function(post) {
var headRect, rect, root, thumb, top;
var headRect, node, rect, root, thumb, top;
thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
@ -6192,7 +6192,21 @@
return;
}
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)) {
return;
}

View File

@ -19,7 +19,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript==
/*
* 4chan X - Version 1.2.8 - 2013-05-20
* 4chan X - Version 1.2.8 - 2013-05-21
*
* Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -6193,7 +6193,7 @@
}
},
toggle: function(post) {
var headRect, rect, root, thumb, top;
var headRect, node, rect, root, thumb, top;
thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
@ -6201,7 +6201,21 @@
return;
}
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)) {
return;
}

View File

@ -1,6 +1,6 @@
// 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.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -6171,7 +6171,7 @@
}
},
toggle: function(post) {
var headRect, rect, root, thumb, top;
var headRect, node, rect, root, thumb, top;
thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
@ -6179,7 +6179,21 @@
return;
}
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)) {
return;
}

View File

@ -68,8 +68,14 @@ ImageExpand =
ImageExpand.expand post
return
ImageExpand.contract post
rect = if Conf['Advance on contract'] and !($.hasClass doc, 'fappeTyme')
post.nodes.root.nextSibling.getBoundingClientRect()
node = post.nodes.root
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
post.nodes.root.getBoundingClientRect()
return unless rect.top <= 0 or rect.left <= 0