Wrap your method calls in an anonymous function like this:
document.getElementById("contextmenu-open").addEventListener("click", ContextMenus.open, false);
to this:
document.getElementById("contextmenu-open").addEventListener("click", function() {ContextMenus.open()}, false);
This preserves the ContextMenus
object as the caller of the method and makes sure that this
is set properly when the method is called.
In addition, I don't think you want to install a DOMContentLoaded
event handler in 'handle_events()because
DOMContentLoadedhas already fired at that point since you're calling
handle_events()from a
DOMContentLoaded` event handler.
For Downloads.init()
, just call it directly in the first line of handle_events()
. The DOM is already loaded so you can just call it, you don't have to wait for an event.