mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-19 18:15:47 +02:00
Refactor delegating multiple events at once in code.js
This commit is contained in:
parent
9539eb076a
commit
ad6240a067
@ -356,10 +356,9 @@
|
|||||||
var prevMouseX = -1, prevMouseY = -1;
|
var prevMouseX = -1, prevMouseY = -1;
|
||||||
var tooltipTimer, tooltipDisplayed;
|
var tooltipTimer, tooltipDisplayed;
|
||||||
|
|
||||||
$(document.body).delegate("a[data-full-url]", "mouseenter mouseleave mousemove", function(e){
|
$(document.body).delegate("a[data-full-url]", {
|
||||||
var me = $(this);
|
mouseenter: function(){
|
||||||
|
let me = $(this);
|
||||||
if (e.type === "mouseenter"){
|
|
||||||
let text = me.text();
|
let text = me.text();
|
||||||
return if text.charCodeAt(text.length-1) !== 8230; // horizontal ellipsis
|
return if text.charCodeAt(text.length-1) !== 8230; // horizontal ellipsis
|
||||||
|
|
||||||
@ -380,14 +379,13 @@
|
|||||||
tooltipDisplayed = true;
|
tooltipDisplayed = true;
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
else if (e.type === "mouseleave"){
|
|
||||||
if ($TDX.expandLinksOnHover){
|
mouseleave: function(){
|
||||||
let prevText = me.attr("td-prev-text");
|
let me = $(this);
|
||||||
|
|
||||||
if (prevText){
|
if (me[0].hasAttribute("td-prev-text")){
|
||||||
me.text(prevText);
|
me.text(me.attr("td-prev-text"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.clearTimeout(tooltipTimer);
|
window.clearTimeout(tooltipTimer);
|
||||||
@ -396,10 +394,11 @@
|
|||||||
tooltipDisplayed = false;
|
tooltipDisplayed = false;
|
||||||
$TD.displayTooltip(null, false);
|
$TD.displayTooltip(null, false);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
else if (e.type === "mousemove"){
|
|
||||||
|
mousemove: function(e){
|
||||||
if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){
|
if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){
|
||||||
$TD.displayTooltip(me.attr("data-full-url"), false);
|
$TD.displayTooltip($(this).attr("data-full-url"), false);
|
||||||
prevMouseX = e.clientX;
|
prevMouseX = e.clientX;
|
||||||
prevMouseY = e.clientY;
|
prevMouseY = e.clientY;
|
||||||
}
|
}
|
||||||
@ -472,19 +471,20 @@
|
|||||||
return media.filter(item => !item.isAnimatedGif).map(item => item.entity.media_url_https+":small").join(";");
|
return media.filter(item => !item.isAnimatedGif).map(item => item.entity.media_url_https+":small").join(";");
|
||||||
};
|
};
|
||||||
|
|
||||||
app.delegate("section.js-column", "mouseenter mouseleave", function(e){
|
app.delegate("section.js-column", {
|
||||||
if (e.type === "mouseenter"){
|
mouseenter: function(){
|
||||||
if (!highlightedColumnObj){
|
if (!highlightedColumnObj){
|
||||||
updateHighlightedColumn($(this));
|
updateHighlightedColumn($(this));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
else if (e.type === "mouseleave"){
|
|
||||||
|
mouseleave: function(){
|
||||||
updateHighlightedColumn(null);
|
updateHighlightedColumn(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delegate("article.js-stream-item", "mouseenter mouseleave", function(e){
|
app.delegate("article.js-stream-item", {
|
||||||
if (e.type === "mouseenter"){
|
mouseenter: function(){
|
||||||
let me = $(this);
|
let me = $(this);
|
||||||
return if !me[0].hasAttribute("data-account-key") || (!highlightedColumnObj && !updateHighlightedColumn(me.closest("section.js-column")));
|
return if !me[0].hasAttribute("data-account-key") || (!highlightedColumnObj && !updateHighlightedColumn(me.closest("section.js-column")));
|
||||||
|
|
||||||
@ -502,8 +502,9 @@
|
|||||||
else{
|
else{
|
||||||
updateHighlightedTweet(me, tweet, "", "", "", "");
|
updateHighlightedTweet(me, tweet, "", "", "", "");
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
else if (e.type === "mouseleave"){
|
|
||||||
|
mouseleave: function(){
|
||||||
updateHighlightedTweet(null, null, "", "", "", "");
|
updateHighlightedTweet(null, null, "", "", "", "");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user