From 189b3cd146a7d095ae9fedeee1bb02420a39b26d Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 16 Jan 2012 22:58:32 -0500 Subject: [PATCH] Fix refocusing of Quick Format window on Linux --- .../content/zotero/integration/quickFormat.js | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 1f507d9129..c22ef101d1 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -717,13 +717,13 @@ var Zotero_QuickFormat = new function () { if(numReferences || numSeparators) { if(((!referenceHeight && firstReference) || (!separatorHeight && firstSeparator)) && !panelShowing) { - referencePanel.openPopup(document.documentElement, "after_start", 15, - null, false, false, null); + _openReferencePanel(); if(!Zotero.isFx4) { - window.setTimeout(function() { + referencePanel.addEventListener("popupshown", function() { + referencePanel.removeEventListener("popupshown", arguments.callee, false); panelShowing = true; _resize(); - }, 0); + }, false); return; } else { panelShowing = true; @@ -741,15 +741,29 @@ var Zotero_QuickFormat = new function () { } referencePanel.sizeTo(window.outerWidth-30, - numReferences*referenceHeight+1+numSeparators*separatorHeight-1); - if(!panelShowing) referencePanel.openPopup(document.documentElement, "after_start", 15, - null, false, false, null); + numReferences*referenceHeight+numSeparators*separatorHeight); + if(!panelShowing) _openReferencePanel(); } else if(panelShowing) { referencePanel.hidePopup(); referencePanel.sizeTo(window.outerWidth-30, 0); } } + /** + * Opens the reference panel and potentially refocuses the main text box + */ + function _openReferencePanel() { + referencePanel.openPopup(document.documentElement, "after_start", 15, + null, false, false, null); + if(!Zotero.isMac && !Zotero.isWin) { + // When it opens, we will lose focus + referencePanel.addEventListener("popupshown", function() { + referencePanel.removeEventListener("popupshown", arguments.callee, false); + _refocusQfe(); + }, false); + } + } + /** * Clears all citations */ @@ -1146,4 +1160,4 @@ var Zotero_QuickFormat = new function () { } window.addEventListener("DOMContentLoaded", Zotero_QuickFormat.onDOMContentLoaded, false); -window.addEventListener("load", Zotero_QuickFormat.onLoad, false); \ No newline at end of file +window.addEventListener("load", Zotero_QuickFormat.onLoad, false);