Merge branch 'v3' of git://github.com/MayhemYDG/4chan-x into v3

Conflicts:
	src/General/Header.coffee
	src/Images/ImageExpand.coffee
	src/Monitoring/ThreadUpdater.coffee
This commit is contained in:
Zixaphir 2013-08-06 13:12:41 -07:00
commit d02ce2ff0f
6 changed files with 50 additions and 50 deletions

View File

@ -1787,9 +1787,9 @@
top = post.getBoundingClientRect().top; top = post.getBoundingClientRect().top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) { if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.bar.getBoundingClientRect(); headRect = Header.bar.getBoundingClientRect();
top += -headRect.top - headRect.height; top -= headRect.top + headRect.height;
} }
return doc.scrollTop += top; return window.scrollBy(0, top);
}, },
addShortcut: function(el) { addShortcut: function(el) {
var shortcut; var shortcut;
@ -2351,8 +2351,8 @@
$.add(Header.hover, menu); $.add(Header.hover, menu);
mRect = menu.getBoundingClientRect(); mRect = menu.getBoundingClientRect();
bRect = button.getBoundingClientRect(); bRect = button.getBoundingClientRect();
bTop = doc.scrollTop + d.body.scrollTop + bRect.top; bTop = window.scrollY + bRect.top;
bLeft = doc.scrollLeft + d.body.scrollLeft + bRect.left; bLeft = window.scrollX + bRect.left;
cHeight = doc.clientHeight; cHeight = doc.clientHeight;
cWidth = doc.clientWidth; cWidth = doc.clientWidth;
_ref1 = bRect.top + bRect.height + mRect.height < cHeight ? [bRect.bottom, null] : [null, cHeight - bRect.top], top = _ref1[0], bottom = _ref1[1]; _ref1 = bRect.top + bRect.height + mRect.height < cHeight ? [bRect.bottom, null] : [null, cHeight - bRect.top], top = _ref1[0], bottom = _ref1[1];
@ -6283,7 +6283,7 @@
} }
}, },
toggle: function(post) { toggle: function(post) {
var headRect, node, rect, root, thumb, top; var headRect, node, rect, 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'))) {
@ -6309,17 +6309,18 @@
if (!(rect.top <= 0 || rect.left <= 0)) { if (!(rect.top <= 0 || rect.left <= 0)) {
return; return;
} }
top = rect.top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.bar.getBoundingClientRect();
top += -headRect.top - headRect.height;
}
root = doc;
if (rect.top < 0) { if (rect.top < 0) {
root.scrollTop += top; y = rect.top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.toggle.getBoundingClientRect();
y -= headRect.top + headRect.height;
}
} }
if (rect.left < 0) { if (rect.left < 0) {
return root.scrollLeft = 0; x = -window.scrollX;
}
if (x || y) {
return window.scrollBy(x, y);
} }
}, },
contract: function(post) { contract: function(post) {
@ -6370,16 +6371,15 @@
} }
prev = post.nodes.root.getBoundingClientRect(); prev = post.nodes.root.getBoundingClientRect();
return $.queueTask(function() { return $.queueTask(function() {
var curr, root; var curr;
$.addClass(post.nodes.root, 'expanded-image'); $.addClass(post.nodes.root, 'expanded-image');
$.rmClass(post.file.thumb, 'expanding'); $.rmClass(post.file.thumb, 'expanding');
if (!(prev.top + prev.height <= 0)) { if (!(prev.top + prev.height <= 0)) {
return; return;
} }
root = doc;
curr = post.nodes.root.getBoundingClientRect(); curr = post.nodes.root.getBoundingClientRect();
return root.scrollTop += curr.height - prev.height + curr.top - prev.top; return window.scrollBy(0, curr.height - prev.height + curr.top - prev.top);
}); });
}, },
error: function() { error: function() {
@ -7613,7 +7613,7 @@
} }
if (scroll) { if (scroll) {
if (Conf['Bottom Scroll']) { if (Conf['Bottom Scroll']) {
doc.scrollTop = d.body.clientHeight; window.scrollTo(0, d.body.clientHeight);
} else { } else {
if (root) { if (root) {
Header.scrollToPost(root); Header.scrollToPost(root);

View File

@ -1798,9 +1798,9 @@
top = post.getBoundingClientRect().top; top = post.getBoundingClientRect().top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) { if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.bar.getBoundingClientRect(); headRect = Header.bar.getBoundingClientRect();
top += -headRect.top - headRect.height; top -= headRect.top + headRect.height;
} }
return d.body.scrollTop += top; return window.scrollBy(0, top);
}, },
addShortcut: function(el) { addShortcut: function(el) {
var shortcut; var shortcut;
@ -2362,8 +2362,8 @@
$.add(Header.hover, menu); $.add(Header.hover, menu);
mRect = menu.getBoundingClientRect(); mRect = menu.getBoundingClientRect();
bRect = button.getBoundingClientRect(); bRect = button.getBoundingClientRect();
bTop = doc.scrollTop + d.body.scrollTop + bRect.top; bTop = window.scrollY + bRect.top;
bLeft = doc.scrollLeft + d.body.scrollLeft + bRect.left; bLeft = window.scrollX + bRect.left;
cHeight = doc.clientHeight; cHeight = doc.clientHeight;
cWidth = doc.clientWidth; cWidth = doc.clientWidth;
_ref1 = bRect.top + bRect.height + mRect.height < cHeight ? [bRect.bottom, null] : [null, cHeight - bRect.top], top = _ref1[0], bottom = _ref1[1]; _ref1 = bRect.top + bRect.height + mRect.height < cHeight ? [bRect.bottom, null] : [null, cHeight - bRect.top], top = _ref1[0], bottom = _ref1[1];
@ -6263,7 +6263,7 @@
} }
}, },
toggle: function(post) { toggle: function(post) {
var headRect, node, rect, root, thumb, top; var headRect, node, rect, 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'))) {
@ -6289,17 +6289,18 @@
if (!(rect.top <= 0 || rect.left <= 0)) { if (!(rect.top <= 0 || rect.left <= 0)) {
return; return;
} }
top = rect.top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.bar.getBoundingClientRect();
top += -headRect.top - headRect.height;
}
root = d.body;
if (rect.top < 0) { if (rect.top < 0) {
root.scrollTop += top; y = rect.top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.toggle.getBoundingClientRect();
y -= headRect.top + headRect.height;
}
} }
if (rect.left < 0) { if (rect.left < 0) {
return root.scrollLeft = 0; x = -window.scrollX;
}
if (x || y) {
return window.scrollBy(x, y);
} }
}, },
contract: function(post) { contract: function(post) {
@ -6350,16 +6351,15 @@
} }
prev = post.nodes.root.getBoundingClientRect(); prev = post.nodes.root.getBoundingClientRect();
return $.queueTask(function() { return $.queueTask(function() {
var curr, root; var curr;
$.addClass(post.nodes.root, 'expanded-image'); $.addClass(post.nodes.root, 'expanded-image');
$.rmClass(post.file.thumb, 'expanding'); $.rmClass(post.file.thumb, 'expanding');
if (!(prev.top + prev.height <= 0)) { if (!(prev.top + prev.height <= 0)) {
return; return;
} }
root = d.body;
curr = post.nodes.root.getBoundingClientRect(); curr = post.nodes.root.getBoundingClientRect();
return root.scrollTop += curr.height - prev.height + curr.top - prev.top; return window.scrollBy(0, curr.height - prev.height + curr.top - prev.top);
}); });
}, },
error: function() { error: function() {
@ -7593,7 +7593,7 @@
} }
if (scroll) { if (scroll) {
if (Conf['Bottom Scroll']) { if (Conf['Bottom Scroll']) {
d.body.scrollTop = d.body.clientHeight; window.scrollTo(0, d.body.clientHeight);
} else { } else {
if (root) { if (root) {
Header.scrollToPost(root); Header.scrollToPost(root);

View File

@ -302,8 +302,8 @@ Header =
{top} = post.getBoundingClientRect() {top} = post.getBoundingClientRect()
if Conf['Fixed Header'] and not Conf['Bottom Header'] if Conf['Fixed Header'] and not Conf['Bottom Header']
headRect = Header.bar.getBoundingClientRect() headRect = Header.bar.getBoundingClientRect()
top += - headRect.top - headRect.height top -= headRect.top + headRect.height
<% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop += top window.scrollBy 0, top
addShortcut: (el) -> addShortcut: (el) ->
shortcut = $.el 'span', shortcut = $.el 'span',

View File

@ -70,8 +70,8 @@ UI = do ->
# Position # Position
mRect = menu.getBoundingClientRect() mRect = menu.getBoundingClientRect()
bRect = button.getBoundingClientRect() bRect = button.getBoundingClientRect()
bTop = doc.scrollTop + d.body.scrollTop + bRect.top bTop = window.scrollY + bRect.top
bLeft = doc.scrollLeft + d.body.scrollLeft + bRect.left bLeft = window.scrollX + bRect.left
cHeight = doc.clientHeight cHeight = doc.clientHeight
cWidth = doc.clientWidth cWidth = doc.clientWidth
[top, bottom] = if bRect.top + bRect.height + mRect.height < cHeight [top, bottom] = if bRect.top + bRect.height + mRect.height < cHeight

View File

@ -60,6 +60,8 @@ ImageExpand =
return return
ImageExpand.contract post ImageExpand.contract post
node = post.nodes.root node = post.nodes.root
# Scroll back to the thumbnail when contracting the image
# to avoid being left miles away from the relevant post.
rect = if Conf['Advance on contract'] then do -> rect = if Conf['Advance on contract'] then do ->
# FIXME does not work with Quote Threading # FIXME does not work with Quote Threading
while node.nextElementSibling while node.nextElementSibling
@ -71,15 +73,15 @@ ImageExpand =
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
{top} = rect if rect.top < 0
if Conf['Fixed Header'] and not Conf['Bottom Header'] y = rect.top
headRect = Header.bar.getBoundingClientRect() if Conf['Fixed Header'] and not Conf['Bottom Header']
top += - headRect.top - headRect.height headRect = Header.toggle.getBoundingClientRect()
y -= headRect.top + headRect.height
root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %> if rect.left < 0
x = -window.scrollX
root.scrollTop += top if rect.top < 0 window.scrollBy x, y if x or y
root.scrollLeft = 0 if rect.left < 0
contract: (post) -> contract: (post) ->
$.rmClass post.nodes.root, 'expanded-image' $.rmClass post.nodes.root, 'expanded-image'
@ -119,9 +121,8 @@ ImageExpand =
$.addClass post.nodes.root, 'expanded-image' $.addClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding' $.rmClass post.file.thumb, 'expanding'
return unless prev.top + prev.height <= 0 return unless prev.top + prev.height <= 0
root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>
curr = post.nodes.root.getBoundingClientRect() curr = post.nodes.root.getBoundingClientRect()
root.scrollTop += curr.height - prev.height + curr.top - prev.top window.scrollBy 0, curr.height - prev.height + curr.top - prev.top
error: -> error: ->
post = Get.postFromNode @ post = Get.postFromNode @

View File

@ -293,7 +293,6 @@ ThreadUpdater =
unless count unless count
ThreadUpdater.set 'status', null, null ThreadUpdater.set 'status', null, null
ThreadUpdater.outdateCount++ ThreadUpdater.outdateCount++
else else
ThreadUpdater.set 'status', "+#{count}", 'new' ThreadUpdater.set 'status', "+#{count}", 'new'
ThreadUpdater.outdateCount = 0 ThreadUpdater.outdateCount = 0
@ -319,7 +318,7 @@ ThreadUpdater =
if scroll if scroll
if Conf['Bottom Scroll'] if Conf['Bottom Scroll']
<% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop = d.body.clientHeight window.scrollTo 0, d.body.clientHeight
else else
Header.scrollToPost root if root Header.scrollToPost root if root