cleanup?
This commit is contained in:
parent
79bc4e751d
commit
08aa9b4624
2
LICENSE
2
LICENSE
@ -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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.7.3 - 2014-04-08
|
* 4chan X - Version 1.7.3 - 2014-04-10
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||||
@ -8021,9 +8021,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggle: function(post) {
|
toggle: function(post) {
|
||||||
var headRect, left, root, thumb, top, x, y, _ref;
|
var headRect, left, root, top, x, y, _ref;
|
||||||
thumb = post.file.thumb;
|
if (!(post.file.isExpanded || $.hasClass(post.file.thumb, 'expanding'))) {
|
||||||
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
|
|
||||||
ImageExpand.expand(post);
|
ImageExpand.expand(post);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -8055,12 +8054,13 @@
|
|||||||
return ImageExpand.contract(post);
|
return ImageExpand.contract(post);
|
||||||
},
|
},
|
||||||
contract: function(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)) {
|
if (post.file.isVideo && (video = post.file.fullImage)) {
|
||||||
video.pause();
|
video.pause();
|
||||||
TrashQueue.add(video, post);
|
TrashQueue.add(video, post);
|
||||||
post.file.thumb.parentNode.href = video.src;
|
thumb.parentNode.href = video.src;
|
||||||
post.file.thumb.parentNode.target = '_blank';
|
thumb.parentNode.target = '_blank';
|
||||||
_ref = ImageExpand.videoCB;
|
_ref = ImageExpand.videoCB;
|
||||||
for (eventName in _ref) {
|
for (eventName in _ref) {
|
||||||
cb = _ref[eventName];
|
cb = _ref[eventName];
|
||||||
@ -8070,7 +8070,7 @@
|
|||||||
delete post.file.videoControls;
|
delete post.file.videoControls;
|
||||||
}
|
}
|
||||||
$.rmClass(post.nodes.root, 'expanded-image');
|
$.rmClass(post.nodes.root, 'expanded-image');
|
||||||
$.rmClass(post.file.thumb, 'expanding');
|
$.rmClass(thumb, 'expanding');
|
||||||
return post.file.isExpanded = false;
|
return post.file.isExpanded = false;
|
||||||
},
|
},
|
||||||
expand: function(post, src, disableAutoplay) {
|
expand: function(post, src, disableAutoplay) {
|
||||||
@ -8086,21 +8086,17 @@
|
|||||||
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
|
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
|
||||||
className: 'full-image'
|
className: 'full-image'
|
||||||
});
|
});
|
||||||
|
$.on(el, 'error', ImageExpand.error);
|
||||||
|
el.src = src || post.file.URL;
|
||||||
if (isVideo) {
|
if (isVideo) {
|
||||||
el.loop = true;
|
el.loop = true;
|
||||||
}
|
}
|
||||||
$.on(el, 'error', ImageExpand.error);
|
|
||||||
el.src = src || post.file.URL;
|
|
||||||
}
|
}
|
||||||
if (el !== thumb.nextSibling) {
|
if (el !== thumb.nextSibling) {
|
||||||
$.after(thumb, el);
|
$.after(thumb, el);
|
||||||
}
|
}
|
||||||
return $.asap((function() {
|
return $.asap((function() {
|
||||||
if (isVideo) {
|
return el.videoHeight || el.naturalHeight;
|
||||||
return el.videoHeight;
|
|
||||||
} else {
|
|
||||||
return el.naturalHeight;
|
|
||||||
}
|
|
||||||
}), function() {
|
}), function() {
|
||||||
return ImageExpand.completeExpand(post, disableAutoplay);
|
return ImageExpand.completeExpand(post, disableAutoplay);
|
||||||
});
|
});
|
||||||
@ -8128,9 +8124,9 @@
|
|||||||
$.rmClass(post.file.thumb, 'expanding');
|
$.rmClass(post.file.thumb, 'expanding');
|
||||||
post.file.isExpanded = true;
|
post.file.isExpanded = true;
|
||||||
if (post.file.isVideo) {
|
if (post.file.isVideo) {
|
||||||
ImageExpand.setupVideoControls(post);
|
|
||||||
post.file.fullImage.muted = !Conf['Allow Sound'];
|
post.file.fullImage.muted = !Conf['Allow Sound'];
|
||||||
post.file.fullImage.controls = Conf['Show Controls'];
|
post.file.fullImage.controls = Conf['Show Controls'];
|
||||||
|
ImageExpand.setupVideoControls(post);
|
||||||
if (Conf['Autoplay'] && !disableAutoplay) {
|
if (Conf['Autoplay'] && !disableAutoplay) {
|
||||||
return ImageExpand.startVideo(post);
|
return ImageExpand.startVideo(post);
|
||||||
}
|
}
|
||||||
@ -8160,19 +8156,19 @@
|
|||||||
},
|
},
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
if (this.paused && !this.controls) {
|
if (this.paused && !this.controls) {
|
||||||
e.stopPropagation();
|
this.play();
|
||||||
return this.play();
|
return e.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(),
|
})(),
|
||||||
setupVideoControls: function(post) {
|
setupVideoControls: function(post) {
|
||||||
var cb, contract, eventName, file, video, _ref;
|
var cb, contract, eventName, file, thumb, video, _ref;
|
||||||
file = post.file;
|
file = post.file;
|
||||||
|
thumb = file.thumb;
|
||||||
video = file.fullImage;
|
video = file.fullImage;
|
||||||
file.thumb.parentNode.removeAttribute('href');
|
file.thumb.parentNode.removeAttribute('href');
|
||||||
file.thumb.parentNode.removeAttribute('target');
|
file.thumb.parentNode.removeAttribute('target');
|
||||||
video.dataset.mousedown = 'false';
|
|
||||||
_ref = ImageExpand.videoCB;
|
_ref = ImageExpand.videoCB;
|
||||||
for (eventName in _ref) {
|
for (eventName in _ref) {
|
||||||
cb = _ref[eventName];
|
cb = _ref[eventName];
|
||||||
@ -8196,8 +8192,7 @@
|
|||||||
},
|
},
|
||||||
startVideo: function(post) {
|
startVideo: function(post) {
|
||||||
var controls, file, video;
|
var controls, file, video;
|
||||||
file = post.file;
|
video = (file = post.file).fullImage;
|
||||||
video = file.fullImage;
|
|
||||||
controls = video.controls;
|
controls = video.controls;
|
||||||
video.controls = false;
|
video.controls = false;
|
||||||
video.play();
|
video.play();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// 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.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||||
@ -8060,9 +8060,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggle: function(post) {
|
toggle: function(post) {
|
||||||
var headRect, left, root, thumb, top, x, y, _ref;
|
var headRect, left, root, top, x, y, _ref;
|
||||||
thumb = post.file.thumb;
|
if (!(post.file.isExpanded || $.hasClass(post.file.thumb, 'expanding'))) {
|
||||||
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
|
|
||||||
ImageExpand.expand(post);
|
ImageExpand.expand(post);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -8094,12 +8093,13 @@
|
|||||||
return ImageExpand.contract(post);
|
return ImageExpand.contract(post);
|
||||||
},
|
},
|
||||||
contract: function(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)) {
|
if (post.file.isVideo && (video = post.file.fullImage)) {
|
||||||
video.pause();
|
video.pause();
|
||||||
TrashQueue.add(video, post);
|
TrashQueue.add(video, post);
|
||||||
post.file.thumb.parentNode.href = video.src;
|
thumb.parentNode.href = video.src;
|
||||||
post.file.thumb.parentNode.target = '_blank';
|
thumb.parentNode.target = '_blank';
|
||||||
_ref = ImageExpand.videoCB;
|
_ref = ImageExpand.videoCB;
|
||||||
for (eventName in _ref) {
|
for (eventName in _ref) {
|
||||||
cb = _ref[eventName];
|
cb = _ref[eventName];
|
||||||
@ -8109,7 +8109,7 @@
|
|||||||
delete post.file.videoControls;
|
delete post.file.videoControls;
|
||||||
}
|
}
|
||||||
$.rmClass(post.nodes.root, 'expanded-image');
|
$.rmClass(post.nodes.root, 'expanded-image');
|
||||||
$.rmClass(post.file.thumb, 'expanding');
|
$.rmClass(thumb, 'expanding');
|
||||||
return post.file.isExpanded = false;
|
return post.file.isExpanded = false;
|
||||||
},
|
},
|
||||||
expand: function(post, src, disableAutoplay) {
|
expand: function(post, src, disableAutoplay) {
|
||||||
@ -8125,21 +8125,17 @@
|
|||||||
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
|
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
|
||||||
className: 'full-image'
|
className: 'full-image'
|
||||||
});
|
});
|
||||||
|
$.on(el, 'error', ImageExpand.error);
|
||||||
|
el.src = src || post.file.URL;
|
||||||
if (isVideo) {
|
if (isVideo) {
|
||||||
el.loop = true;
|
el.loop = true;
|
||||||
}
|
}
|
||||||
$.on(el, 'error', ImageExpand.error);
|
|
||||||
el.src = src || post.file.URL;
|
|
||||||
}
|
}
|
||||||
if (el !== thumb.nextSibling) {
|
if (el !== thumb.nextSibling) {
|
||||||
$.after(thumb, el);
|
$.after(thumb, el);
|
||||||
}
|
}
|
||||||
return $.asap((function() {
|
return $.asap((function() {
|
||||||
if (isVideo) {
|
return el.videoHeight || el.naturalHeight;
|
||||||
return el.videoHeight;
|
|
||||||
} else {
|
|
||||||
return el.naturalHeight;
|
|
||||||
}
|
|
||||||
}), function() {
|
}), function() {
|
||||||
return ImageExpand.completeExpand(post, disableAutoplay);
|
return ImageExpand.completeExpand(post, disableAutoplay);
|
||||||
});
|
});
|
||||||
@ -8167,9 +8163,9 @@
|
|||||||
$.rmClass(post.file.thumb, 'expanding');
|
$.rmClass(post.file.thumb, 'expanding');
|
||||||
post.file.isExpanded = true;
|
post.file.isExpanded = true;
|
||||||
if (post.file.isVideo) {
|
if (post.file.isVideo) {
|
||||||
ImageExpand.setupVideoControls(post);
|
|
||||||
post.file.fullImage.muted = !Conf['Allow Sound'];
|
post.file.fullImage.muted = !Conf['Allow Sound'];
|
||||||
post.file.fullImage.controls = Conf['Show Controls'];
|
post.file.fullImage.controls = Conf['Show Controls'];
|
||||||
|
ImageExpand.setupVideoControls(post);
|
||||||
if (Conf['Autoplay'] && !disableAutoplay) {
|
if (Conf['Autoplay'] && !disableAutoplay) {
|
||||||
return ImageExpand.startVideo(post);
|
return ImageExpand.startVideo(post);
|
||||||
}
|
}
|
||||||
@ -8199,19 +8195,19 @@
|
|||||||
},
|
},
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
if (this.paused && !this.controls) {
|
if (this.paused && !this.controls) {
|
||||||
e.stopPropagation();
|
this.play();
|
||||||
return this.play();
|
return e.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(),
|
})(),
|
||||||
setupVideoControls: function(post) {
|
setupVideoControls: function(post) {
|
||||||
var cb, contract, eventName, file, video, _ref;
|
var cb, contract, eventName, file, thumb, video, _ref;
|
||||||
file = post.file;
|
file = post.file;
|
||||||
|
thumb = file.thumb;
|
||||||
video = file.fullImage;
|
video = file.fullImage;
|
||||||
file.thumb.parentNode.removeAttribute('href');
|
file.thumb.parentNode.removeAttribute('href');
|
||||||
file.thumb.parentNode.removeAttribute('target');
|
file.thumb.parentNode.removeAttribute('target');
|
||||||
video.dataset.mousedown = 'false';
|
|
||||||
_ref = ImageExpand.videoCB;
|
_ref = ImageExpand.videoCB;
|
||||||
for (eventName in _ref) {
|
for (eventName in _ref) {
|
||||||
cb = _ref[eventName];
|
cb = _ref[eventName];
|
||||||
@ -8235,8 +8231,7 @@
|
|||||||
},
|
},
|
||||||
startVideo: function(post) {
|
startVideo: function(post) {
|
||||||
var controls, file, video;
|
var controls, file, video;
|
||||||
file = post.file;
|
video = (file = post.file).fullImage;
|
||||||
video = file.fullImage;
|
|
||||||
controls = video.controls;
|
controls = video.controls;
|
||||||
video.controls = false;
|
video.controls = false;
|
||||||
video.play();
|
video.play();
|
||||||
|
|||||||
@ -50,8 +50,8 @@ ImageExpand =
|
|||||||
return unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root
|
return unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root
|
||||||
if ImageExpand.on and
|
if ImageExpand.on and
|
||||||
(!Conf['Expand spoilers'] and file.isSpoiler or
|
(!Conf['Expand spoilers'] and file.isSpoiler or
|
||||||
!Conf['Expand videos'] and file.isVideo or
|
!Conf['Expand videos'] and file.isVideo or
|
||||||
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
|
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
|
||||||
return
|
return
|
||||||
$.queueTask func, post
|
$.queueTask func, post
|
||||||
|
|
||||||
@ -72,8 +72,7 @@ ImageExpand =
|
|||||||
(if @checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-'
|
(if @checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-'
|
||||||
|
|
||||||
toggle: (post) ->
|
toggle: (post) ->
|
||||||
{thumb} = post.file
|
unless post.file.isExpanded or $.hasClass post.file.thumb, 'expanding'
|
||||||
unless post.file.isExpanded or $.hasClass thumb, 'expanding'
|
|
||||||
ImageExpand.expand post
|
ImageExpand.expand post
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -102,17 +101,18 @@ ImageExpand =
|
|||||||
ImageExpand.contract post
|
ImageExpand.contract post
|
||||||
|
|
||||||
contract: (post) ->
|
contract: (post) ->
|
||||||
|
{thumb} = post.file
|
||||||
if post.file.isVideo and video = post.file.fullImage
|
if post.file.isVideo and video = post.file.fullImage
|
||||||
video.pause()
|
video.pause()
|
||||||
TrashQueue.add video, post
|
TrashQueue.add video, post
|
||||||
post.file.thumb.parentNode.href = video.src
|
thumb.parentNode.href = video.src
|
||||||
post.file.thumb.parentNode.target = '_blank'
|
thumb.parentNode.target = '_blank'
|
||||||
for eventName, cb of ImageExpand.videoCB
|
for eventName, cb of ImageExpand.videoCB
|
||||||
$.off video, eventName, cb
|
$.off video, eventName, cb
|
||||||
$.rm post.file.videoControls
|
$.rm post.file.videoControls
|
||||||
delete post.file.videoControls
|
delete post.file.videoControls
|
||||||
$.rmClass post.nodes.root, 'expanded-image'
|
$.rmClass post.nodes.root, 'expanded-image'
|
||||||
$.rmClass post.file.thumb, 'expanding'
|
$.rmClass thumb, 'expanding'
|
||||||
post.file.isExpanded = false
|
post.file.isExpanded = false
|
||||||
|
|
||||||
expand: (post, src, disableAutoplay) ->
|
expand: (post, src, disableAutoplay) ->
|
||||||
@ -126,11 +126,12 @@ ImageExpand =
|
|||||||
else
|
else
|
||||||
el = post.file.fullImage = $.el (if isVideo then 'video' else 'img'),
|
el = post.file.fullImage = $.el (if isVideo then 'video' else 'img'),
|
||||||
className: 'full-image'
|
className: 'full-image'
|
||||||
el.loop = true if isVideo
|
|
||||||
$.on el, 'error', ImageExpand.error
|
$.on el, 'error', ImageExpand.error
|
||||||
el.src = src or post.file.URL
|
el.src = src or post.file.URL
|
||||||
|
if isVideo
|
||||||
|
el.loop = true
|
||||||
$.after thumb, el unless el is thumb.nextSibling
|
$.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
|
ImageExpand.completeExpand post, disableAutoplay
|
||||||
|
|
||||||
completeExpand: (post, disableAutoplay) ->
|
completeExpand: (post, disableAutoplay) ->
|
||||||
@ -151,9 +152,9 @@ ImageExpand =
|
|||||||
$.rmClass post.file.thumb, 'expanding'
|
$.rmClass post.file.thumb, 'expanding'
|
||||||
post.file.isExpanded = true
|
post.file.isExpanded = true
|
||||||
if post.file.isVideo
|
if post.file.isVideo
|
||||||
ImageExpand.setupVideoControls post
|
|
||||||
post.file.fullImage.muted = !Conf['Allow Sound']
|
post.file.fullImage.muted = !Conf['Allow Sound']
|
||||||
post.file.fullImage.controls = Conf['Show Controls']
|
post.file.fullImage.controls = Conf['Show Controls']
|
||||||
|
ImageExpand.setupVideoControls post
|
||||||
ImageExpand.startVideo post if Conf['Autoplay'] and not disableAutoplay
|
ImageExpand.startVideo post if Conf['Autoplay'] and not disableAutoplay
|
||||||
|
|
||||||
videoCB: do ->
|
videoCB: do ->
|
||||||
@ -165,19 +166,19 @@ ImageExpand =
|
|||||||
mouseout: (e) -> ImageExpand.contract(Get.postFromNode @) if mousedown and e.clientX <= @getBoundingClientRect().left
|
mouseout: (e) -> ImageExpand.contract(Get.postFromNode @) if mousedown and e.clientX <= @getBoundingClientRect().left
|
||||||
click: (e) ->
|
click: (e) ->
|
||||||
if @paused and not @controls
|
if @paused and not @controls
|
||||||
e.stopPropagation()
|
|
||||||
@play()
|
@play()
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
setupVideoControls: (post) ->
|
setupVideoControls: (post) ->
|
||||||
{file} = post
|
{file} = post
|
||||||
video = file.fullImage
|
{thumb} = file
|
||||||
|
video = file.fullImage
|
||||||
|
|
||||||
# disable link to file so native controls can work
|
# disable link to file so native controls can work
|
||||||
file.thumb.parentNode.removeAttribute 'href'
|
file.thumb.parentNode.removeAttribute 'href'
|
||||||
file.thumb.parentNode.removeAttribute 'target'
|
file.thumb.parentNode.removeAttribute 'target'
|
||||||
|
|
||||||
# setup callbacks on video element
|
# setup callbacks on video element
|
||||||
video.dataset.mousedown = 'false'
|
|
||||||
$.on video, eventName, cb for eventName, cb of ImageExpand.videoCB
|
$.on video, eventName, cb for eventName, cb of ImageExpand.videoCB
|
||||||
|
|
||||||
# setup controls in file info
|
# setup controls in file info
|
||||||
@ -193,8 +194,7 @@ ImageExpand =
|
|||||||
$.add file.text, file.videoControls
|
$.add file.text, file.videoControls
|
||||||
|
|
||||||
startVideo: (post) ->
|
startVideo: (post) ->
|
||||||
{file} = post
|
video = (file = post.file).fullImage
|
||||||
video = file.fullImage
|
|
||||||
{controls} = video
|
{controls} = video
|
||||||
video.controls = false
|
video.controls = false
|
||||||
video.play()
|
video.play()
|
||||||
|
|||||||
@ -29,6 +29,7 @@ ImageHover =
|
|||||||
src: post.file.URL
|
src: post.file.URL
|
||||||
post.file.fullImage = el
|
post.file.fullImage = el
|
||||||
{thumb} = post.file
|
{thumb} = post.file
|
||||||
|
|
||||||
if d.body.contains thumb
|
if d.body.contains thumb
|
||||||
$.after thumb, el unless el is thumb.nextSibling
|
$.after thumb, el unless el is thumb.nextSibling
|
||||||
else
|
else
|
||||||
@ -36,9 +37,9 @@ ImageHover =
|
|||||||
el.id = 'ihover'
|
el.id = 'ihover'
|
||||||
el.dataset.fullID = post.fullID
|
el.dataset.fullID = post.fullID
|
||||||
if isVideo
|
if isVideo
|
||||||
el.loop = true
|
el.loop = true
|
||||||
el.controls = false
|
el.controls = false
|
||||||
el.muted = not Conf['Allow Sound']
|
el.muted = not Conf['Allow Sound']
|
||||||
el.play() if Conf['Autoplay']
|
el.play() if Conf['Autoplay']
|
||||||
UI.hover
|
UI.hover
|
||||||
root: @
|
root: @
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user