1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-28 18:15:47 +02:00

Fix middle-clicking GIFs not opening the tweet externally

Closes 
This commit is contained in:
chylex 2017-09-24 23:35:31 +02:00
parent 6eeb3f9895
commit 00d8538726

View File

@ -878,19 +878,38 @@
$TD.playVideo(url); $TD.playVideo(url);
}; };
app.delegate(".js-gif-play", "click", function(e){ var getVideoTweetLink = function(obj){
let parent = obj.closest(".js-tweet").first();
let link = (parent.hasClass("tweet-detail") ? parent.find("a[rel='url']") : parent.find("time").first().children("a")).first();
return link.attr("href");
}
app.delegate(".js-gif-play", {
click: function(e){
let src = !e.ctrlKey && $(this).closest(".js-media-gif-container").find("video").attr("src"); let src = !e.ctrlKey && $(this).closest(".js-media-gif-container").find("video").attr("src");
if (src){ if (src){
playVideo(src); playVideo(src);
} }
else{ else{
let parent = $(e.target).closest(".js-tweet").first(); $TD.openBrowser(getVideoTweetLink($(this)));
let link = (parent.hasClass("tweet-detail") ? parent.find("a[rel='url']") : parent.find("time").first().children("a")).first();
$TD.openBrowser(link.attr("href"));
} }
e.stopPropagation(); e.stopPropagation();
},
mousedown: function(e){
if (e.button === 1){
e.preventDefault();
}
},
mouseup: function(e){
if (e.button === 1){
$TD.openBrowser(getVideoTweetLink($(this)));
e.preventDefault();
}
}
}); });
TD.mustaches["status/media_thumb.mustache"] = TD.mustaches["status/media_thumb.mustache"].replace("is-gif", "is-gif is-paused"); TD.mustaches["status/media_thumb.mustache"] = TD.mustaches["status/media_thumb.mustache"].replace("is-gif", "is-gif is-paused");