fix hover/expand so it works when switching between catalog/paged modes
This commit is contained in:
parent
b3f5011bcf
commit
938479ea09
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 4chan X - Version 1.5.2 - 2014-04-05
|
||||
* 4chan X - Version 1.5.2 - 2014-04-06
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
// ==/UserScript==
|
||||
|
||||
/*
|
||||
* 4chan X - Version 1.5.2 - 2014-04-05
|
||||
* 4chan X - Version 1.5.2 - 2014-04-06
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||
@ -8057,38 +8057,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;
|
||||
@ -8294,7 +8292,7 @@
|
||||
return $.on(this.nodes.thumb, 'mouseover', ImageHover.mouseover);
|
||||
},
|
||||
mouseover: function(e) {
|
||||
var el, isVideo, naturalHeight, post, thumb;
|
||||
var el, isVideo, naturalHeight, position, post, thumb;
|
||||
post = $.hasClass(this, 'thumb') ? g.posts[this.parentNode.dataset.fullID] : Get.postFromNode(this);
|
||||
isVideo = post.file.isVideo;
|
||||
if (post.file.fullImage) {
|
||||
@ -8307,9 +8305,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript
|
||||
/*
|
||||
* 4chan X - Version 1.5.2 - 2014-04-05
|
||||
* 4chan X - Version 1.5.2 - 2014-04-06
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||
@ -8096,38 +8096,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;
|
||||
@ -8322,7 +8320,7 @@
|
||||
return $.on(this.nodes.thumb, 'mouseover', ImageHover.mouseover);
|
||||
},
|
||||
mouseover: function(e) {
|
||||
var el, isVideo, naturalHeight, post, thumb;
|
||||
var el, isVideo, naturalHeight, position, post, thumb;
|
||||
post = $.hasClass(this, 'thumb') ? g.posts[this.parentNode.dataset.fullID] : Get.postFromNode(this);
|
||||
isVideo = post.file.isVideo;
|
||||
if (post.file.fullImage) {
|
||||
@ -8335,9 +8333,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,24 +103,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
|
||||
|
||||
@ -29,10 +29,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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user