Some more Linux focus fixes, and fix panel size

This commit is contained in:
Simon Kornblith 2012-01-16 23:49:35 -05:00
parent 189b3cd146
commit 7a52b65e85

View File

@ -28,7 +28,7 @@ var Zotero_QuickFormat = new function () {
showEditor, referencePanel, referenceBox, referenceHeight = 0, separatorHeight = 0, showEditor, referencePanel, referenceBox, referenceHeight = 0, separatorHeight = 0,
currentLocator, currentLocatorLabel, currentSearchTime, dragging, panel, currentLocator, currentLocatorLabel, currentSearchTime, dragging, panel,
panelPrefix, panelSuffix, panelSuppressAuthor, panelLocatorLabel, panelLocator, panelInfo, panelPrefix, panelSuffix, panelSuppressAuthor, panelLocatorLabel, panelLocator, panelInfo,
panelRefersToBubble; panelRefersToBubble, panelFrameHeight = 0;
// A variable that contains the timeout object for the latest onKeyPress event // A variable that contains the timeout object for the latest onKeyPress event
var eventTimeout = null; var eventTimeout = null;
@ -143,9 +143,9 @@ var Zotero_QuickFormat = new function () {
}; };
function _refocusQfe() { function _refocusQfe() {
referencePanel.blur();
window.focus(); window.focus();
qfe.focus(); qfe.focus();
referencePanel.blur();
} }
/** /**
@ -715,8 +715,8 @@ var Zotero_QuickFormat = new function () {
var panelShowing = referencePanel.state === "open" || referencePanel.state === "showing"; var panelShowing = referencePanel.state === "open" || referencePanel.state === "showing";
if(numReferences || numSeparators) { if(numReferences || numSeparators) {
if(((!referenceHeight && firstReference) || (!separatorHeight && firstSeparator)) if(((!referenceHeight && firstReference) || (!separatorHeight && firstSeparator)
&& !panelShowing) { || !panelFrameHeight) && !panelShowing) {
_openReferencePanel(); _openReferencePanel();
if(!Zotero.isFx4) { if(!Zotero.isFx4) {
referencePanel.addEventListener("popupshown", function() { referencePanel.addEventListener("popupshown", function() {
@ -740,12 +740,17 @@ var Zotero_QuickFormat = new function () {
if(firstSeparator === referenceBox.lastChild) separatorHeight += 1; if(firstSeparator === referenceBox.lastChild) separatorHeight += 1;
} }
if(!panelFrameHeight) {
panelFrameHeight = referencePanel.boxObject.height - referencePanel.clientHeight;
}
referencePanel.sizeTo(window.outerWidth-30, referencePanel.sizeTo(window.outerWidth-30,
numReferences*referenceHeight+numSeparators*separatorHeight); numReferences*referenceHeight+numSeparators*separatorHeight+2*panelFrameHeight-1);
if(!panelShowing) _openReferencePanel(); if(!panelShowing) _openReferencePanel();
} else if(panelShowing) { } else if(panelShowing) {
referencePanel.hidePopup(); referencePanel.hidePopup();
referencePanel.sizeTo(window.outerWidth-30, 0); referencePanel.sizeTo(window.outerWidth-30, 0);
_refocusQfe();
} }
} }
@ -760,6 +765,13 @@ var Zotero_QuickFormat = new function () {
referencePanel.addEventListener("popupshown", function() { referencePanel.addEventListener("popupshown", function() {
referencePanel.removeEventListener("popupshown", arguments.callee, false); referencePanel.removeEventListener("popupshown", arguments.callee, false);
_refocusQfe(); _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); }, false);
} }
} }