appropriately handle case where tab is loaded before window finishes loading
This commit is contained in:
parent
b001c5433f
commit
fbb7f79689
1 changed files with 13 additions and 6 deletions
|
@ -41,23 +41,30 @@ var ZoteroTab = new function()
|
||||||
if(browserIndex === -1) return;
|
if(browserIndex === -1) return;
|
||||||
|
|
||||||
// initialize ZoteroPane and swap out old window ZoteroPane object
|
// initialize ZoteroPane and swap out old window ZoteroPane object
|
||||||
ZoteroPane.init();
|
if(window.ZoteroPane) {
|
||||||
|
window.ZoteroPane_Overlay = window.ZoteroPane;
|
||||||
// swap window ZoteroPane with ZoteroPane from tab
|
window.ZoteroPane_Tab = ZoteroPane;
|
||||||
window.ZoteroPane_Overlay = window.ZoteroPane;
|
window.ZoteroPane = ZoteroPane;
|
||||||
window.ZoteroPane_Tab = ZoteroPane;
|
} else {
|
||||||
window.ZoteroPane = ZoteroPane;
|
window.addEventListener("load", function() {
|
||||||
|
window.ZoteroPane_Overlay = window.ZoteroPane;
|
||||||
|
window.ZoteroPane_Tab = ZoteroPane;
|
||||||
|
window.ZoteroPane = ZoteroPane;
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
|
||||||
// get tab for browser
|
// get tab for browser
|
||||||
var tab = window.gBrowser.tabs[browserIndex];
|
var tab = window.gBrowser.tabs[browserIndex];
|
||||||
if(window.gBrowser.selectedTab === tab) {
|
if(window.gBrowser.selectedTab === tab) {
|
||||||
// if tab is already selected, init now
|
// if tab is already selected, init now
|
||||||
|
ZoteroPane.init();
|
||||||
ZoteroPane.makeVisible();
|
ZoteroPane.makeVisible();
|
||||||
} else {
|
} else {
|
||||||
// otherwise, add a handler to wait until this tab is selected
|
// otherwise, add a handler to wait until this tab is selected
|
||||||
var listener = function(event) {
|
var listener = function(event) {
|
||||||
if(event.target !== tab) return;
|
if(event.target !== tab) return;
|
||||||
window.gBrowser.tabContainer.removeEventListener("TabSelect", listener, false);
|
window.gBrowser.tabContainer.removeEventListener("TabSelect", listener, false);
|
||||||
|
ZoteroPane.init();
|
||||||
ZoteroPane.makeVisible();
|
ZoteroPane.makeVisible();
|
||||||
}
|
}
|
||||||
window.gBrowser.tabContainer.addEventListener("TabSelect", listener, false);
|
window.gBrowser.tabContainer.addEventListener("TabSelect", listener, false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue