1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-03 14:34:08 +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;
};
//
// 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.
//
@ -27,9 +38,7 @@
//
// Block: Allow bypassing of t.co in context menus.
//
document.body.addEventListener("contextmenu",function(e){
bubbleParents(e.target,"A",function(ele){
$TD.setLastRightClickedLink(ele.getAttribute("data-full-url") || "");
});
document.body.addBubbledEventListener("a","contextmenu",function(e, ele){
$TD.setLastRightClickedLink(ele.getAttribute("data-full-url") || "");
});
})($TD);