diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index c22ef101d..732c51e73 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -25,10 +25,10 @@ var Zotero_QuickFormat = new function () { var initialized, io, qfs, qfi, qfiWindow, qfiDocument, qfe, qfb, qfbHeight, keepSorted, - showEditor, referencePanel, referenceBox, referenceHeight = 0, separatorHeight = 0, + showEditor, referencePanel, referenceBox, referenceHeight = 0, separatorHeight = 0, currentLocator, currentLocatorLabel, currentSearchTime, dragging, panel, panelPrefix, panelSuffix, panelSuppressAuthor, panelLocatorLabel, panelLocator, panelInfo, - panelRefersToBubble; + panelRefersToBubble, panelFrameHeight = 0; // A variable that contains the timeout object for the latest onKeyPress event var eventTimeout = null; @@ -143,9 +143,9 @@ var Zotero_QuickFormat = new function () { }; function _refocusQfe() { + referencePanel.blur(); window.focus(); qfe.focus(); - referencePanel.blur(); } /** @@ -715,8 +715,8 @@ var Zotero_QuickFormat = new function () { var panelShowing = referencePanel.state === "open" || referencePanel.state === "showing"; if(numReferences || numSeparators) { - if(((!referenceHeight && firstReference) || (!separatorHeight && firstSeparator)) - && !panelShowing) { + if(((!referenceHeight && firstReference) || (!separatorHeight && firstSeparator) + || !panelFrameHeight) && !panelShowing) { _openReferencePanel(); if(!Zotero.isFx4) { referencePanel.addEventListener("popupshown", function() { @@ -740,12 +740,17 @@ var Zotero_QuickFormat = new function () { if(firstSeparator === referenceBox.lastChild) separatorHeight += 1; } + if(!panelFrameHeight) { + panelFrameHeight = referencePanel.boxObject.height - referencePanel.clientHeight; + } + referencePanel.sizeTo(window.outerWidth-30, - numReferences*referenceHeight+numSeparators*separatorHeight); + numReferences*referenceHeight+numSeparators*separatorHeight+2*panelFrameHeight-1); if(!panelShowing) _openReferencePanel(); } else if(panelShowing) { referencePanel.hidePopup(); referencePanel.sizeTo(window.outerWidth-30, 0); + _refocusQfe(); } } @@ -760,6 +765,13 @@ var Zotero_QuickFormat = new function () { referencePanel.addEventListener("popupshown", function() { referencePanel.removeEventListener("popupshown", arguments.callee, false); _refocusQfe(); + + // This is a nasty hack, but seems to be necessary to fix loss of focus on Linux + window.setTimeout(function() { _refocusQfe(); }, 25); + window.setTimeout(function() { _refocusQfe(); }, 50); + window.setTimeout(function() { _refocusQfe(); }, 100); + window.setTimeout(function() { _refocusQfe(); }, 175); + window.setTimeout(function() { _refocusQfe(); }, 250); }, false); } }