fix hover/expand so it works when switching between catalog/paged modes

Conflicts:
	builds/4chan-X.user.js
	builds/crx/script.js
This commit is contained in:
ccd0 2014-04-06 02:49:38 -07:00
parent 0f770459c0
commit 52949b545e
4 changed files with 65 additions and 62 deletions

View File

@ -7695,38 +7695,36 @@
return post.file.isExpanded = false;
},
expand: function(post, src) {
var el, isVideo, naturalHeight, thumb, _ref;
var el, isVideo, position, thumb, _ref;
_ref = post.file, thumb = _ref.thumb, isVideo = _ref.isVideo;
if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) {
return;
}
$.addClass(thumb, 'expanding');
naturalHeight = isVideo ? 'videoHeight' : 'naturalHeight';
if (el = post.file.fullImage) {
TrashQueue.remove(el);
el.controls = el.parentNode !== thumb.parentNode;
$.asap((function() {
return el[naturalHeight];
}), function() {
return ImageExpand.completeExpand(post);
} else {
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
className: 'full-image',
src: src || post.file.URL
});
return;
if (isVideo) {
el.loop = true;
}
$.on(el, 'error', ImageExpand.error);
}
post.file.fullImage = el = $.el((isVideo ? 'video' : 'img'), {
className: 'full-image',
src: src || post.file.URL
});
if (isVideo) {
el.loop = true;
if (el.isVideo) {
el.controls = Conf['Show Controls'];
}
$.on(el, 'error', ImageExpand.error);
$.asap((function() {
return post.file.fullImage[naturalHeight];
position = el.controls ? thumb.parentNode : thumb;
if (el !== position.nextSibling) {
$.after(position, el);
}
return $.asap((function() {
return isVideo || el.naturalHeight;
}), function() {
return ImageExpand.completeExpand(post);
});
return $.after((el.controls ? thumb.parentNode : thumb), el);
},
completeExpand: function(post) {
var bottom, thumb;
@ -7920,7 +7918,7 @@
return $.on(this.file.thumb, 'mouseover', ImageHover.mouseover);
},
mouseover: function(e) {
var el, isVideo, naturalHeight, post, thumb;
var el, isVideo, naturalHeight, position, post, thumb;
post = Get.postFromNode(this);
isVideo = post.file.isVideo;
if (post.file.fullImage) {
@ -7933,9 +7931,14 @@
});
post.file.fullImage = el;
thumb = post.file.thumb;
if (d.body.contains(thumb)) {
$.after((isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb), el);
} else {
}
if (d.body.contains(thumb)) {
position = isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb;
if (el !== position.nextSibling) {
$.after(position, el);
}
} else {
if (el.parentNode !== Header.hover) {
$.add(Header.hover, el);
}
}

View File

@ -7714,38 +7714,36 @@
return post.file.isExpanded = false;
},
expand: function(post, src) {
var el, isVideo, naturalHeight, thumb, _ref;
var el, isVideo, position, thumb, _ref;
_ref = post.file, thumb = _ref.thumb, isVideo = _ref.isVideo;
if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) {
return;
}
$.addClass(thumb, 'expanding');
naturalHeight = isVideo ? 'videoHeight' : 'naturalHeight';
if (el = post.file.fullImage) {
TrashQueue.remove(el);
el.controls = el.parentNode !== thumb.parentNode;
$.asap((function() {
return el[naturalHeight];
}), function() {
return ImageExpand.completeExpand(post);
} else {
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
className: 'full-image',
src: src || post.file.URL
});
return;
if (isVideo) {
el.loop = true;
}
$.on(el, 'error', ImageExpand.error);
}
post.file.fullImage = el = $.el((isVideo ? 'video' : 'img'), {
className: 'full-image',
src: src || post.file.URL
});
if (isVideo) {
el.loop = true;
if (el.isVideo) {
el.controls = Conf['Show Controls'];
}
$.on(el, 'error', ImageExpand.error);
$.asap((function() {
return post.file.fullImage[naturalHeight];
position = el.controls ? thumb.parentNode : thumb;
if (el !== position.nextSibling) {
$.after(position, el);
}
return $.asap((function() {
return isVideo || el.naturalHeight;
}), function() {
return ImageExpand.completeExpand(post);
});
return $.after((el.controls ? thumb.parentNode : thumb), el);
},
completeExpand: function(post) {
var bottom, thumb;
@ -7928,7 +7926,7 @@
return $.on(this.file.thumb, 'mouseover', ImageHover.mouseover);
},
mouseover: function(e) {
var el, isVideo, naturalHeight, post, thumb;
var el, isVideo, naturalHeight, position, post, thumb;
post = Get.postFromNode(this);
isVideo = post.file.isVideo;
if (post.file.fullImage) {
@ -7941,9 +7939,14 @@
});
post.file.fullImage = el;
thumb = post.file.thumb;
if (d.body.contains(thumb)) {
$.after((isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb), el);
} else {
}
if (d.body.contains(thumb)) {
position = isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb;
if (el !== position.nextSibling) {
$.after(position, el);
}
} else {
if (el.parentNode !== Header.hover) {
$.add(Header.hover, el);
}
}

View File

@ -106,24 +106,20 @@ ImageExpand =
{thumb, isVideo} = post.file
return if post.isHidden or post.file.isExpanded or $.hasClass thumb, 'expanding'
$.addClass thumb, 'expanding'
naturalHeight = if isVideo then 'videoHeight' else 'naturalHeight'
if el = post.file.fullImage
# Expand already-loaded/ing picture.
TrashQueue.remove el
el.controls = (el.parentNode isnt thumb.parentNode)
$.asap (-> el[naturalHeight]), ->
ImageExpand.completeExpand post
return
post.file.fullImage = el = $.el (if isVideo then 'video' else 'img'),
className: 'full-image'
src: src or post.file.URL
if isVideo
el.loop = true
el.controls = Conf['Show Controls']
$.on el, 'error', ImageExpand.error
$.asap (-> post.file.fullImage[naturalHeight]), ->
else
el = post.file.fullImage = $.el (if isVideo then 'video' else 'img'),
className: 'full-image'
src: src or post.file.URL
el.loop = true if isVideo
$.on el, 'error', ImageExpand.error
el.controls = Conf['Show Controls'] if el.isVideo
position = if el.controls then thumb.parentNode else thumb
$.after position, el unless el is position.nextSibling
$.asap (-> isVideo or el.naturalHeight), ->
ImageExpand.completeExpand post
$.after (if el.controls then thumb.parentNode else thumb), el
completeExpand: (post) ->
{thumb} = post.file

View File

@ -20,10 +20,11 @@ ImageHover =
src: post.file.URL
post.file.fullImage = el
{thumb} = post.file
if d.body.contains thumb
$.after (if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb), el
else
$.add Header.hover, el
if d.body.contains thumb
position = if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb
$.after position, el unless el is position.nextSibling
else
$.add Header.hover, el if el.parentNode isnt Header.hover
el.id = 'ihover'
el.dataset.fullID = post.fullID
if isVideo