1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-21 23:34:07 +02:00

Add EventTarget.addBubbledEventListener to notification.js for convenience

This commit is contained in:
chylex 2016-05-11 17:54:07 +02:00
parent bea158b0d9
commit af7657e3f8

View File

@ -13,6 +13,17 @@
return false; return false;
}; };
//
// Function: Adds an event listener which calls listener(event, element) when an event was triggered by an element of the specified type or one of its children.
//
EventTarget.prototype.addBubbledEventListener = function(element, type, listener){
this.addEventListener(type,function(e){
bubbleParents(e.target,element.toUpperCase(),function(ele){
listener(e,ele);
});
});
};
// //
// Block: Hook into links to bypass default open function. // Block: Hook into links to bypass default open function.
// //
@ -27,9 +38,7 @@
// //
// Block: Allow bypassing of t.co in context menus. // Block: Allow bypassing of t.co in context menus.
// //
document.body.addEventListener("contextmenu",function(e){ document.body.addBubbledEventListener("a","contextmenu",function(e, ele){
bubbleParents(e.target,"A",function(ele){ $TD.setLastRightClickedLink(ele.getAttribute("data-full-url") || "");
$TD.setLastRightClickedLink(ele.getAttribute("data-full-url") || "");
});
}); });
})($TD); })($TD);