From 3c500b8ebff442e4bbbbb98f3a38112e63c4ec84 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 20 Feb 2012 03:11:53 -0500 Subject: [PATCH] Refocus content when closing Zotero pane by any means besides opening Zotero Standalone --- chrome/content/zotero/overlay.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 7ed07ca6a8..152e2e6c1a 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -156,10 +156,10 @@ var ZoteroOverlay = new function() // save current state _stateBeforeReload = !zoteroPane.hidden && !zoteroPane.collapsed; // ensure pane is closed - if(!zoteroPane.collapsed) ZoteroOverlay.toggleDisplay(false); + if(!zoteroPane.collapsed) ZoteroOverlay.toggleDisplay(false, true); } else { // reopen pane if it was open before - ZoteroOverlay.toggleDisplay(_stateBeforeReload); + ZoteroOverlay.toggleDisplay(_stateBeforeReload, true); } }); } @@ -176,8 +176,12 @@ var ZoteroOverlay = new function() /** * Hides/displays the Zotero interface + * @param {Boolean} makeVisible Whether or not Zotero interface should be visible + * @param {Boolean} dontRefocus If true, don't focus content when closing Zotero pane. Used + * when closing pane because Zotero Standalone is being opened, to avoid pulling Firefox to + * the foreground. */ - this.toggleDisplay = function(makeVisible) + this.toggleDisplay = function(makeVisible, dontRefocus) { if(!Zotero || !Zotero.initialized) { ZoteroPane.displayStartupError(); @@ -245,6 +249,11 @@ var ZoteroOverlay = new function() zoteroPane.height = 0; document.getElementById('content').setAttribute('collapsed', false); + + if(!dontRefocus) { + // Return focus to the browser content pane + window.content.window.focus(); + } } }