1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-29 11:30:20 +12:00

Firefox: initialize buttons when DOM is ready

This commit is contained in:
Deathamns 2014-12-16 18:09:55 +01:00 committed by gorhill
parent f432dfa856
commit e0d742b040

View file

@ -248,9 +248,9 @@ var windowWatcher = {
e.target.ownerDocument.defaultView e.target.ownerDocument.defaultView
); );
}, },
onLoad: function(e) { onReady: function(e) {
if (e) { if (e) {
this.removeEventListener('load', windowWatcher.onLoad); this.removeEventListener(e.type, windowWatcher.onReady);
} }
var docElement = this.document.documentElement; var docElement = this.document.documentElement;
@ -275,7 +275,7 @@ var windowWatcher = {
}, },
observe: function(win, topic) { observe: function(win, topic) {
if (topic === 'domwindowopened') { if (topic === 'domwindowopened') {
win.addEventListener('load', this.onLoad); win.addEventListener('DOMContentLoaded', this.onReady);
} }
} }
}; };
@ -318,12 +318,11 @@ vAPI.tabs.registerListeners = function() {
// onClosed - handled in windowWatcher.onTabClose // onClosed - handled in windowWatcher.onTabClose
// onPopup ? // onPopup ?
Services.ww.registerNotification(windowWatcher);
for (var win of this.getWindows()) { for (var win of this.getWindows()) {
windowWatcher.onLoad.call(win); windowWatcher.onReady.call(win);
} }
Services.ww.registerNotification(windowWatcher);
vAPI.toolbarButton.init(); vAPI.toolbarButton.init();
vAPI.unload.push(function() { vAPI.unload.push(function() {
@ -332,7 +331,7 @@ vAPI.tabs.registerListeners = function() {
for (var win of vAPI.tabs.getWindows()) { for (var win of vAPI.tabs.getWindows()) {
vAPI.toolbarButton.remove(win.document); vAPI.toolbarButton.remove(win.document);
win.removeEventListener('load', windowWatcher.onLoad); win.removeEventListener('load', windowWatcher.onReady);
win.gBrowser.removeTabsProgressListener(tabsProgressListener); win.gBrowser.removeTabsProgressListener(tabsProgressListener);
var tC = win.gBrowser.tabContainer; var tC = win.gBrowser.tabContainer;