diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 0abc5b8a5..8dffd00db 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -34,6 +34,9 @@ var ZoteroOverlay = new function() this.isTab = false; this.onLoad = function() { + ZoteroPane_Overlay = ZoteroPane; + ZoteroPane.init(); + var appInfo = Components.classes["@mozilla.org/xre/app-info;1"] .getService(Components.interfaces.nsIXULAppInfo); isFx36 = appInfo.platformVersion.indexOf('1.9') === 0; @@ -134,9 +137,6 @@ var ZoteroOverlay = new function() setTimeout("gBrowser.selectedTab = gBrowser.addTab(Zotero.initialURL); Zotero.initialURL = null;", 1); } - ZoteroPane_Overlay = ZoteroPane; - ZoteroPane.init(); - // Hide browser chrome on Zotero tab if(Zotero.isFx4) { XULBrowserWindow.inContentWhitelist.push("chrome://zotero/content/tab.xul"); @@ -272,7 +272,7 @@ var ZoteroOverlay = new function() for(var index = 0; index < numTabs; index++) { var currentBrowser = gBrowser.getBrowserAtIndex(index); if(ZOTERO_TAB_URL == currentBrowser.currentURI.spec) { - tab = gBrowser.tabs[index]; + tab = (gBrowser.tabs ? gBrowser.tabs : gBrowser.mTabs)[index]; break; } } @@ -303,7 +303,7 @@ var ZoteroOverlay = new function() if(tab) { // Zotero is running in a tab if(setMode) return; // don't do anything if Zotero tab is the only tab - if(tab && gBrowser.tabs.length === 1) return; + if(tab && (gBrowser.tabs ? gBrowser.tabs : gBrowser.mTabs).length === 1) return; // swap ZoteroPane object ZoteroPane = ZoteroPane_Overlay; diff --git a/chrome/content/zotero/tab.js b/chrome/content/zotero/tab.js index 481e19452..65a2de89b 100644 --- a/chrome/content/zotero/tab.js +++ b/chrome/content/zotero/tab.js @@ -47,7 +47,7 @@ var ZoteroTab = new function() var currentBrowser = window.gBrowser.browsers[index]; if(currentBrowser && ZOTERO_TAB_URL == currentBrowser.currentURI.spec) { - window.gBrowser.removeTab(window.gBrowser.tabs[index]); + window.gBrowser.removeTab((window.gBrowser.tabs ? window.gBrowser.tabs : window.gBrowser.mTabs)[index]); } } @@ -64,15 +64,16 @@ var ZoteroTab = new function() }, false); } - var browser = window.gBrowser.getBrowserForDocument(document); - if(window.gBrowser.selectedBrowser === browser) { + // get tab for browser + var tab = (window.gBrowser.tabs ? window.gBrowser.tabs : window.gBrowser.mTabs)[browserIndex]; + if(window.gBrowser.selectedTab === tab) { // if tab is already selected, init now ZoteroPane.init(); ZoteroPane.makeVisible(); } else { // otherwise, add a handler to wait until this tab is selected var listener = function(event) { - if(window.gBrowser.getBrowserForTab(event.target) !== browser) return; + if(event.target !== tab) return; window.gBrowser.tabContainer.removeEventListener("TabSelect", listener, false); ZoteroPane.init(); ZoteroPane.makeVisible(); @@ -81,7 +82,6 @@ var ZoteroTab = new function() } if(Zotero && Zotero.isFx4) { - var tab = window.gBrowser.tabs[browserIndex]; // on Fx 4, add an event listener so the pinned tab isn't restored on close var pinnedTabCloser = function() { try {