nitpicking

This commit is contained in:
Zixaphir 2014-04-08 15:01:19 -07:00
parent bc9ce0a434
commit 7658f575f3
3 changed files with 112 additions and 106 deletions

View File

@ -7952,16 +7952,18 @@
} }
thumb = this.file.thumb; thumb = this.file.thumb;
$.on(thumb.parentNode, 'click', ImageExpand.cb.toggle); $.on(thumb.parentNode, 'click', ImageExpand.cb.toggle);
if (this.isClone && $.hasClass(thumb, 'expanding')) { if (this.isClone) {
ImageExpand.contract(this); if ($.hasClass(thumb, 'expanding')) {
return ImageExpand.expand(this); ImageExpand.contract(this);
} else if (this.isClone && this.file.isExpanded && this.file.isVideo) { ImageExpand.expand(this);
clone = this; } else if (this.file.isExpanded && this.file.isVideo) {
ImageExpand.setupVideoControls(clone); clone = this;
if (!clone.origin.file.fullImage.paused) { ImageExpand.setupVideoControls(clone);
return $.queueTask(function() { if (!clone.origin.file.fullImage.paused) {
return ImageExpand.startVideo(clone); $.queueTask(function() {
}); return ImageExpand.startVideo(clone);
});
}
} }
} else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) { } else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) {
return ImageExpand.expand(this, null, true); return ImageExpand.expand(this, null, true);
@ -8104,9 +8106,8 @@
}); });
}, },
completeExpand: function(post, disableAutoplay) { completeExpand: function(post, disableAutoplay) {
var bottom, thumb; var bottom;
thumb = post.file.thumb; if (!$.hasClass(post.file.thumb, 'expanding')) {
if (!$.hasClass(thumb, 'expanding')) {
return; return;
} }
if (!post.nodes.root.parentNode) { if (!post.nodes.root.parentNode) {
@ -8123,8 +8124,6 @@
}); });
}, },
completeExpand2: function(post, disableAutoplay) { completeExpand2: function(post, disableAutoplay) {
var thumb;
thumb = post.file.thumb;
$.addClass(post.nodes.root, 'expanded-image'); $.addClass(post.nodes.root, 'expanded-image');
$.rmClass(post.file.thumb, 'expanding'); $.rmClass(post.file.thumb, 'expanding');
post.file.isExpanded = true; post.file.isExpanded = true;
@ -8137,32 +8136,36 @@
} }
} }
}, },
videoCB: { videoCB: (function() {
click: function(e) { var mousedown;
if (this.paused && !this.controls) { mousedown = false;
this.play(); return {
return e.stopPropagation(); mouseover: function() {
return mousedown = false;
},
mousedown: function(e) {
if (e.button === 0) {
return mousedown = true;
}
},
mouseup: function(e) {
if (e.button === 0) {
return mousedown = false;
}
},
mouseout: function(e) {
if (mousedown && e.clientX <= this.getBoundingClientRect().left) {
return ImageExpand.contract(Get.postFromNode(this));
}
},
click: function(e) {
if (this.paused && !this.controls) {
e.stopPropagation();
return this.play();
}
} }
}, };
mousedown: function(e) { })(),
if (e.button === 0) {
return this.dataset.mousedown = 'true';
}
},
mouseup: function(e) {
if (e.button === 0) {
return this.dataset.mousedown = 'false';
}
},
mouseover: function(e) {
return this.dataset.mousedown = 'false';
},
mouseout: function(e) {
if (this.dataset.mousedown === 'true' && e.clientX <= this.getBoundingClientRect().left) {
return ImageExpand.contract(Get.postFromNode(this));
}
}
},
setupVideoControls: function(post) { setupVideoControls: function(post) {
var cb, contract, eventName, file, video, _ref; var cb, contract, eventName, file, video, _ref;
file = post.file; file = post.file;

View File

@ -7991,16 +7991,18 @@
} }
thumb = this.file.thumb; thumb = this.file.thumb;
$.on(thumb.parentNode, 'click', ImageExpand.cb.toggle); $.on(thumb.parentNode, 'click', ImageExpand.cb.toggle);
if (this.isClone && $.hasClass(thumb, 'expanding')) { if (this.isClone) {
ImageExpand.contract(this); if ($.hasClass(thumb, 'expanding')) {
return ImageExpand.expand(this); ImageExpand.contract(this);
} else if (this.isClone && this.file.isExpanded && this.file.isVideo) { ImageExpand.expand(this);
clone = this; } else if (this.file.isExpanded && this.file.isVideo) {
ImageExpand.setupVideoControls(clone); clone = this;
if (!clone.origin.file.fullImage.paused) { ImageExpand.setupVideoControls(clone);
return $.queueTask(function() { if (!clone.origin.file.fullImage.paused) {
return ImageExpand.startVideo(clone); $.queueTask(function() {
}); return ImageExpand.startVideo(clone);
});
}
} }
} else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) { } else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) {
return ImageExpand.expand(this, null, true); return ImageExpand.expand(this, null, true);
@ -8143,9 +8145,8 @@
}); });
}, },
completeExpand: function(post, disableAutoplay) { completeExpand: function(post, disableAutoplay) {
var bottom, thumb; var bottom;
thumb = post.file.thumb; if (!$.hasClass(post.file.thumb, 'expanding')) {
if (!$.hasClass(thumb, 'expanding')) {
return; return;
} }
if (!post.nodes.root.parentNode) { if (!post.nodes.root.parentNode) {
@ -8162,8 +8163,6 @@
}); });
}, },
completeExpand2: function(post, disableAutoplay) { completeExpand2: function(post, disableAutoplay) {
var thumb;
thumb = post.file.thumb;
$.addClass(post.nodes.root, 'expanded-image'); $.addClass(post.nodes.root, 'expanded-image');
$.rmClass(post.file.thumb, 'expanding'); $.rmClass(post.file.thumb, 'expanding');
post.file.isExpanded = true; post.file.isExpanded = true;
@ -8176,32 +8175,36 @@
} }
} }
}, },
videoCB: { videoCB: (function() {
click: function(e) { var mousedown;
if (this.paused && !this.controls) { mousedown = false;
this.play(); return {
return e.stopPropagation(); mouseover: function() {
return mousedown = false;
},
mousedown: function(e) {
if (e.button === 0) {
return mousedown = true;
}
},
mouseup: function(e) {
if (e.button === 0) {
return mousedown = false;
}
},
mouseout: function(e) {
if (mousedown && e.clientX <= this.getBoundingClientRect().left) {
return ImageExpand.contract(Get.postFromNode(this));
}
},
click: function(e) {
if (this.paused && !this.controls) {
e.stopPropagation();
return this.play();
}
} }
}, };
mousedown: function(e) { })(),
if (e.button === 0) {
return this.dataset.mousedown = 'true';
}
},
mouseup: function(e) {
if (e.button === 0) {
return this.dataset.mousedown = 'false';
}
},
mouseover: function(e) {
return this.dataset.mousedown = 'false';
},
mouseout: function(e) {
if (this.dataset.mousedown === 'true' && e.clientX <= this.getBoundingClientRect().left) {
return ImageExpand.contract(Get.postFromNode(this));
}
}
},
setupVideoControls: function(post) { setupVideoControls: function(post) {
var cb, contract, eventName, file, video, _ref; var cb, contract, eventName, file, video, _ref;
file = post.file; file = post.file;

View File

@ -17,16 +17,20 @@ ImageExpand =
return unless @file?.isImage or @file?.isVideo return unless @file?.isImage or @file?.isVideo
{thumb} = @file {thumb} = @file
$.on thumb.parentNode, 'click', ImageExpand.cb.toggle $.on thumb.parentNode, 'click', ImageExpand.cb.toggle
if @isClone and $.hasClass thumb, 'expanding' if @isClone
# If we clone a post where the image is still loading, if $.hasClass thumb, 'expanding'
# make it loading in the clone too. # If we clone a post where the image is still loading,
ImageExpand.contract @ # make it loading in the clone too.
ImageExpand.expand @ ImageExpand.contract @
else if @isClone and @file.isExpanded and @file.isVideo ImageExpand.expand @
clone = @
ImageExpand.setupVideoControls clone else if @file.isExpanded and @file.isVideo
unless clone.origin.file.fullImage.paused clone = @
$.queueTask -> ImageExpand.startVideo clone ImageExpand.setupVideoControls clone
unless clone.origin.file.fullImage.paused
$.queueTask -> ImageExpand.startVideo clone
return
else if ImageExpand.on and !@isHidden and else if ImageExpand.on and !@isHidden and
(Conf['Expand spoilers'] or !@file.isSpoiler) and (Conf['Expand spoilers'] or !@file.isSpoiler) and
(Conf['Expand videos'] or !@file.isVideo) (Conf['Expand videos'] or !@file.isVideo)
@ -130,8 +134,7 @@ ImageExpand =
ImageExpand.completeExpand post, disableAutoplay ImageExpand.completeExpand post, disableAutoplay
completeExpand: (post, disableAutoplay) -> completeExpand: (post, disableAutoplay) ->
{thumb} = post.file return unless $.hasClass post.file.thumb, 'expanding' # contracted before the image loaded
return unless $.hasClass thumb, 'expanding' # contracted before the image loaded
unless post.nodes.root.parentNode unless post.nodes.root.parentNode
# Image might start/finish loading before the post is inserted. # Image might start/finish loading before the post is inserted.
# Don't scroll when it's expanded in a QP for example. # Don't scroll when it's expanded in a QP for example.
@ -144,29 +147,26 @@ ImageExpand =
window.scrollBy 0, post.nodes.root.getBoundingClientRect().bottom - bottom window.scrollBy 0, post.nodes.root.getBoundingClientRect().bottom - bottom
completeExpand2: (post, disableAutoplay) -> completeExpand2: (post, disableAutoplay) ->
{thumb} = post.file
$.addClass post.nodes.root, 'expanded-image' $.addClass post.nodes.root, 'expanded-image'
$.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 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.startVideo post if Conf['Autoplay'] and not disableAutoplay ImageExpand.startVideo post if Conf['Autoplay'] and not disableAutoplay
videoCB: videoCB: do ->
click: (e) ->
if @paused and not @controls
@play()
e.stopPropagation()
# dragging to the left contracts the video # dragging to the left contracts the video
mousedown: (e) -> @dataset.mousedown = 'true' if e.button is 0 mousedown = false
mouseup: (e) -> @dataset.mousedown = 'false' if e.button is 0 mouseover: -> mousedown = false
mouseover: (e) -> @dataset.mousedown = 'false' mousedown: (e) -> mousedown = true if e.button is 0
mouseout: (e) -> mouseup: (e) -> mousedown = false if e.button is 0
if @dataset.mousedown is 'true' and e.clientX <= @getBoundingClientRect().left mouseout: (e) -> ImageExpand.contract (Get.postFromNode @) if mousedown and e.clientX <= @getBoundingClientRect().left
ImageExpand.contract (Get.postFromNode @) click: (e) ->
if @paused and not @controls
e.stopPropagation()
@play()
setupVideoControls: (post) -> setupVideoControls: (post) ->
{file} = post {file} = post