This commit is contained in:
Zixaphir 2014-04-10 22:28:27 -07:00
parent 79bc4e751d
commit 08aa9b4624
5 changed files with 55 additions and 64 deletions

View File

@ -1,5 +1,5 @@
/*
* 4chan X - Version 1.7.3 - 2014-04-08
* 4chan X - Version 1.7.3 - 2014-04-10
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE

View File

@ -24,7 +24,7 @@
// ==/UserScript==
/*
* 4chan X - Version 1.7.3 - 2014-04-08
* 4chan X - Version 1.7.3 - 2014-04-10
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -8021,9 +8021,8 @@
}
},
toggle: function(post) {
var headRect, left, root, thumb, top, x, y, _ref;
thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
var headRect, left, root, top, x, y, _ref;
if (!(post.file.isExpanded || $.hasClass(post.file.thumb, 'expanding'))) {
ImageExpand.expand(post);
return;
}
@ -8055,12 +8054,13 @@
return ImageExpand.contract(post);
},
contract: function(post) {
var cb, eventName, video, _ref;
var cb, eventName, thumb, video, _ref;
thumb = post.file.thumb;
if (post.file.isVideo && (video = post.file.fullImage)) {
video.pause();
TrashQueue.add(video, post);
post.file.thumb.parentNode.href = video.src;
post.file.thumb.parentNode.target = '_blank';
thumb.parentNode.href = video.src;
thumb.parentNode.target = '_blank';
_ref = ImageExpand.videoCB;
for (eventName in _ref) {
cb = _ref[eventName];
@ -8070,7 +8070,7 @@
delete post.file.videoControls;
}
$.rmClass(post.nodes.root, 'expanded-image');
$.rmClass(post.file.thumb, 'expanding');
$.rmClass(thumb, 'expanding');
return post.file.isExpanded = false;
},
expand: function(post, src, disableAutoplay) {
@ -8086,21 +8086,17 @@
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
className: 'full-image'
});
$.on(el, 'error', ImageExpand.error);
el.src = src || post.file.URL;
if (isVideo) {
el.loop = true;
}
$.on(el, 'error', ImageExpand.error);
el.src = src || post.file.URL;
}
if (el !== thumb.nextSibling) {
$.after(thumb, el);
}
return $.asap((function() {
if (isVideo) {
return el.videoHeight;
} else {
return el.naturalHeight;
}
return el.videoHeight || el.naturalHeight;
}), function() {
return ImageExpand.completeExpand(post, disableAutoplay);
});
@ -8128,9 +8124,9 @@
$.rmClass(post.file.thumb, 'expanding');
post.file.isExpanded = true;
if (post.file.isVideo) {
ImageExpand.setupVideoControls(post);
post.file.fullImage.muted = !Conf['Allow Sound'];
post.file.fullImage.controls = Conf['Show Controls'];
ImageExpand.setupVideoControls(post);
if (Conf['Autoplay'] && !disableAutoplay) {
return ImageExpand.startVideo(post);
}
@ -8160,19 +8156,19 @@
},
click: function(e) {
if (this.paused && !this.controls) {
e.stopPropagation();
return this.play();
this.play();
return e.preventDefault();
}
}
};
})(),
setupVideoControls: function(post) {
var cb, contract, eventName, file, video, _ref;
var cb, contract, eventName, file, thumb, video, _ref;
file = post.file;
thumb = file.thumb;
video = file.fullImage;
file.thumb.parentNode.removeAttribute('href');
file.thumb.parentNode.removeAttribute('target');
video.dataset.mousedown = 'false';
_ref = ImageExpand.videoCB;
for (eventName in _ref) {
cb = _ref[eventName];
@ -8196,8 +8192,7 @@
},
startVideo: function(post) {
var controls, file, video;
file = post.file;
video = file.fullImage;
video = (file = post.file).fullImage;
controls = video.controls;
video.controls = false;
video.play();

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
* 4chan X - Version 1.7.3 - 2014-04-08
* 4chan X - Version 1.7.3 - 2014-04-10
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -8060,9 +8060,8 @@
}
},
toggle: function(post) {
var headRect, left, root, thumb, top, x, y, _ref;
thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
var headRect, left, root, top, x, y, _ref;
if (!(post.file.isExpanded || $.hasClass(post.file.thumb, 'expanding'))) {
ImageExpand.expand(post);
return;
}
@ -8094,12 +8093,13 @@
return ImageExpand.contract(post);
},
contract: function(post) {
var cb, eventName, video, _ref;
var cb, eventName, thumb, video, _ref;
thumb = post.file.thumb;
if (post.file.isVideo && (video = post.file.fullImage)) {
video.pause();
TrashQueue.add(video, post);
post.file.thumb.parentNode.href = video.src;
post.file.thumb.parentNode.target = '_blank';
thumb.parentNode.href = video.src;
thumb.parentNode.target = '_blank';
_ref = ImageExpand.videoCB;
for (eventName in _ref) {
cb = _ref[eventName];
@ -8109,7 +8109,7 @@
delete post.file.videoControls;
}
$.rmClass(post.nodes.root, 'expanded-image');
$.rmClass(post.file.thumb, 'expanding');
$.rmClass(thumb, 'expanding');
return post.file.isExpanded = false;
},
expand: function(post, src, disableAutoplay) {
@ -8125,21 +8125,17 @@
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
className: 'full-image'
});
$.on(el, 'error', ImageExpand.error);
el.src = src || post.file.URL;
if (isVideo) {
el.loop = true;
}
$.on(el, 'error', ImageExpand.error);
el.src = src || post.file.URL;
}
if (el !== thumb.nextSibling) {
$.after(thumb, el);
}
return $.asap((function() {
if (isVideo) {
return el.videoHeight;
} else {
return el.naturalHeight;
}
return el.videoHeight || el.naturalHeight;
}), function() {
return ImageExpand.completeExpand(post, disableAutoplay);
});
@ -8167,9 +8163,9 @@
$.rmClass(post.file.thumb, 'expanding');
post.file.isExpanded = true;
if (post.file.isVideo) {
ImageExpand.setupVideoControls(post);
post.file.fullImage.muted = !Conf['Allow Sound'];
post.file.fullImage.controls = Conf['Show Controls'];
ImageExpand.setupVideoControls(post);
if (Conf['Autoplay'] && !disableAutoplay) {
return ImageExpand.startVideo(post);
}
@ -8199,19 +8195,19 @@
},
click: function(e) {
if (this.paused && !this.controls) {
e.stopPropagation();
return this.play();
this.play();
return e.preventDefault();
}
}
};
})(),
setupVideoControls: function(post) {
var cb, contract, eventName, file, video, _ref;
var cb, contract, eventName, file, thumb, video, _ref;
file = post.file;
thumb = file.thumb;
video = file.fullImage;
file.thumb.parentNode.removeAttribute('href');
file.thumb.parentNode.removeAttribute('target');
video.dataset.mousedown = 'false';
_ref = ImageExpand.videoCB;
for (eventName in _ref) {
cb = _ref[eventName];
@ -8235,8 +8231,7 @@
},
startVideo: function(post) {
var controls, file, video;
file = post.file;
video = file.fullImage;
video = (file = post.file).fullImage;
controls = video.controls;
video.controls = false;
video.play();

View File

@ -50,8 +50,8 @@ ImageExpand =
return unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root
if ImageExpand.on and
(!Conf['Expand spoilers'] and file.isSpoiler or
!Conf['Expand videos'] and file.isVideo or
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
!Conf['Expand videos'] and file.isVideo or
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
return
$.queueTask func, post
@ -72,8 +72,7 @@ ImageExpand =
(if @checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-'
toggle: (post) ->
{thumb} = post.file
unless post.file.isExpanded or $.hasClass thumb, 'expanding'
unless post.file.isExpanded or $.hasClass post.file.thumb, 'expanding'
ImageExpand.expand post
return
@ -102,17 +101,18 @@ ImageExpand =
ImageExpand.contract post
contract: (post) ->
{thumb} = post.file
if post.file.isVideo and video = post.file.fullImage
video.pause()
TrashQueue.add video, post
post.file.thumb.parentNode.href = video.src
post.file.thumb.parentNode.target = '_blank'
thumb.parentNode.href = video.src
thumb.parentNode.target = '_blank'
for eventName, cb of ImageExpand.videoCB
$.off video, eventName, cb
$.rm post.file.videoControls
$.rm post.file.videoControls
delete post.file.videoControls
$.rmClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding'
$.rmClass thumb, 'expanding'
post.file.isExpanded = false
expand: (post, src, disableAutoplay) ->
@ -126,11 +126,12 @@ ImageExpand =
else
el = post.file.fullImage = $.el (if isVideo then 'video' else 'img'),
className: 'full-image'
el.loop = true if isVideo
$.on el, 'error', ImageExpand.error
el.src = src or post.file.URL
if isVideo
el.loop = true
$.after thumb, el unless el is thumb.nextSibling
$.asap (-> if isVideo then el.videoHeight else el.naturalHeight), ->
$.asap (-> el.videoHeight or el.naturalHeight), ->
ImageExpand.completeExpand post, disableAutoplay
completeExpand: (post, disableAutoplay) ->
@ -151,9 +152,9 @@ ImageExpand =
$.rmClass post.file.thumb, 'expanding'
post.file.isExpanded = true
if post.file.isVideo
ImageExpand.setupVideoControls post
post.file.fullImage.muted = !Conf['Allow Sound']
post.file.fullImage.controls = Conf['Show Controls']
ImageExpand.setupVideoControls post
ImageExpand.startVideo post if Conf['Autoplay'] and not disableAutoplay
videoCB: do ->
@ -165,19 +166,19 @@ ImageExpand =
mouseout: (e) -> ImageExpand.contract(Get.postFromNode @) if mousedown and e.clientX <= @getBoundingClientRect().left
click: (e) ->
if @paused and not @controls
e.stopPropagation()
@play()
e.preventDefault()
setupVideoControls: (post) ->
{file} = post
video = file.fullImage
{file} = post
{thumb} = file
video = file.fullImage
# disable link to file so native controls can work
file.thumb.parentNode.removeAttribute 'href'
file.thumb.parentNode.removeAttribute 'target'
# setup callbacks on video element
video.dataset.mousedown = 'false'
$.on video, eventName, cb for eventName, cb of ImageExpand.videoCB
# setup controls in file info
@ -193,8 +194,7 @@ ImageExpand =
$.add file.text, file.videoControls
startVideo: (post) ->
{file} = post
video = file.fullImage
video = (file = post.file).fullImage
{controls} = video
video.controls = false
video.play()

View File

@ -29,6 +29,7 @@ ImageHover =
src: post.file.URL
post.file.fullImage = el
{thumb} = post.file
if d.body.contains thumb
$.after thumb, el unless el is thumb.nextSibling
else
@ -36,9 +37,9 @@ ImageHover =
el.id = 'ihover'
el.dataset.fullID = post.fullID
if isVideo
el.loop = true
el.loop = true
el.controls = false
el.muted = not Conf['Allow Sound']
el.muted = not Conf['Allow Sound']
el.play() if Conf['Autoplay']
UI.hover
root: @