www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 0578c01899f6b7933665729fe01f495a7d167886
parent e26b292324a79314d1beb934d1a1b6568e3a0c2e
Author: Simon Kornblith <simon@simonster.com>
Date:   Thu,  3 Feb 2011 20:22:56 +0000

fix some cases where multiple Zotero tabs could be open


Diffstat:
Mchrome/content/zotero/overlay.js | 8++------
Mchrome/content/zotero/tab.js | 24++++++++++++++++++++++++
Mchrome/content/zotero/zoteroPane.js | 1+
3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js @@ -28,7 +28,6 @@ */ var ZoteroOverlay = new function() { - const ZOTERO_TAB_URL = "chrome://zotero/content/tab.xul"; const DEFAULT_ZPANE_HEIGHT = 300; var toolbarCollapseState, isFx36, showInPref; @@ -47,12 +46,9 @@ var ZoteroOverlay = new function() if(!isFx36) { var observerService = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); - var zoteroObserver = {"observe":function(subject, topic, data) { + var zoteroObserver = function(subject, topic, data) { if(subject != window) return; observerService.removeObserver(this, "browser-delayed-startup-finished"); - Zotero.wait(1000); // there ought to be a better way to determine when the tab - // will have a reasonable URI instead of returning about:blank, - // but I'm not sure what it is if(showInPref === 2) { var tabbar = document.getElementById("TabsToolbar"); if(tabbar && window.getComputedStyle(tabbar).display !== "none") { @@ -64,7 +60,7 @@ var ZoteroOverlay = new function() var zoteroTab = ZoteroOverlay.findZoteroTab(); if(zoteroTab) gBrowser.removeTab(zoteroTab); } - }}; + }; observerService.addObserver(zoteroObserver, "browser-delayed-startup-finished", false); } diff --git a/chrome/content/zotero/tab.js b/chrome/content/zotero/tab.js @@ -40,6 +40,17 @@ var ZoteroTab = new function() } if(browserIndex === -1) return; + // if we somehow ended up with other Zotero tabs in the window, close them + var numTabs = window.gBrowser.browsers.length; + for(var index = 0; index < numTabs; index++) { + if(index === browserIndex) continue; + + var currentBrowser = window.gBrowser.browsers[index]; + if(currentBrowser && ZOTERO_TAB_URL == currentBrowser.currentURI.spec) { + window.gBrowser.removeTab(window.gBrowser.tabs[index]); + } + } + // initialize ZoteroPane and swap out old window ZoteroPane object if(window.ZoteroPane) { window.ZoteroPane_Overlay = window.ZoteroPane; @@ -69,6 +80,19 @@ var ZoteroTab = new function() } window.gBrowser.tabContainer.addEventListener("TabSelect", listener, false); } + + if(Zotero && Zotero.isFx4) { + // on Fx 4, add an event listener so the pinned tab isn't restored on close + var pinnedTabCloser = function() { + try { + window.gBrowser.removeTab(tab); + } catch(e) {} + } + var observerService = Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService); + observerService.addObserver(pinnedTabCloser, "quit-application-requested", false); + window.addEventListener("close", pinnedTabCloser, false); + } } this.onUnload = function() { diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -22,6 +22,7 @@ ***** END LICENSE BLOCK ***** */ +const ZOTERO_TAB_URL = "chrome://zotero/content/tab.xul"; /* * This object contains the various functions for the interface