Fix some (but not all) sizing and focus issues

This commit is contained in:
Simon Kornblith 2011-08-01 04:27:47 +00:00
parent f2f7bf00f7
commit d8cd5cf7ae
3 changed files with 22 additions and 10 deletions

View file

@ -40,10 +40,11 @@ var Zotero_QuickFormat = new function () {
qfb = document.getElementById("quick-format-entry"); qfb = document.getElementById("quick-format-entry");
qfbHeight = qfb.scrollHeight; qfbHeight = qfb.scrollHeight;
referencePanel = document.getElementById("quick-format-reference-panel"); referencePanel = document.getElementById("quick-format-reference-panel");
referencePanel.addEventListener("popuphidden", function() { referencePanel.addEventListener("popuphidden", _refocusQfe, false);
window.focus(); referencePanel.addEventListener("popupshown", _refocusQfe, false);
qfe.focus(); referencePanel.addEventListener("focus", _refocusQfe, false);
}, false); referencePanel.addEventListener("activate", _refocusQfe, false);
referencePanel.addEventListener("keypress", _onReferencePanelKeypress, false);
referenceBox = document.getElementById("quick-format-reference-list"); referenceBox = document.getElementById("quick-format-reference-list");
qfiWindow = qfi.contentWindow; qfiWindow = qfi.contentWindow;
qfiDocument = qfi.contentDocument; qfiDocument = qfi.contentDocument;
@ -99,6 +100,11 @@ var Zotero_QuickFormat = new function () {
} }
}; };
function _refocusQfe() {
window.focus();
qfe.focus();
}
/** /**
* Gets the content of the text node that the cursor is currently within * Gets the content of the text node that the cursor is currently within
*/ */
@ -223,12 +229,12 @@ var Zotero_QuickFormat = new function () {
for(var i=0, n=items.length; i<n; i++) { for(var i=0, n=items.length; i<n; i++) {
referenceBox.appendChild(_buildListItem(items[i])); referenceBox.appendChild(_buildListItem(items[i]));
} }
referenceBox.ensureIndexIsVisible(0);
} }
_resize(); _resize();
referenceBox.selectedIndex = 0; referenceBox.selectedIndex = 0;
referenceBox.ensureIndexIsVisible(0);
} }
/** /**
@ -432,8 +438,7 @@ var Zotero_QuickFormat = new function () {
var panelShowing = referencePanel.state === "open" || referencePanel.state === "showing"; var panelShowing = referencePanel.state === "open" || referencePanel.state === "showing";
if(numReferences) { if(numReferences) {
const referenceHeight = 39; var height = referenceHeight ? Math.min(numReferences, SHOWN_REFERENCES)*referenceHeight+2 : 39;
var height = (numReferences < SHOWN_REFERENCES ? numReferences : SHOWN_REFERENCES)*referenceHeight+2;
if(panelShowing && height !== referencePanel.clientHeight) { if(panelShowing && height !== referencePanel.clientHeight) {
referencePanel.sizeTo((window.innerWidth-30), height); referencePanel.sizeTo((window.innerWidth-30), height);
@ -444,6 +449,13 @@ var Zotero_QuickFormat = new function () {
referencePanel.sizeTo((window.innerWidth-30), height); referencePanel.sizeTo((window.innerWidth-30), height);
referencePanel.openPopup(document.documentElement, "after_start", 15, null, referencePanel.openPopup(document.documentElement, "after_start", 15, null,
false, false, null); false, false, null);
if(!referenceHeight) {
referenceHeight = referenceBox.firstChild.scrollHeight;
height = Math.min(numReferences, SHOWN_REFERENCES)*referenceHeight+2;
referencePanel.sizeTo((window.innerWidth-30), height);
window.setTimeout(_refocusQfe, 100);
}
} }
} else { } else {
if(panelShowing) { if(panelShowing) {

View file

@ -90,10 +90,10 @@
<label value="&zotero.citation.suffix.label;"/> <label value="&zotero.citation.suffix.label;"/>
<textbox class="citation-textbox" id="suffix" flex="1"/> <textbox class="citation-textbox" id="suffix" flex="1"/>
</row> </row>
<hbox pack="left"> <html:div>
<html:input type="checkbox" id="suppress-author"/> <html:input type="checkbox" id="suppress-author"/>
<html:label for="suppress-author">&zotero.citation.suppressAuthor.label;</html:label> <html:label for="suppress-author">&zotero.citation.suppressAuthor.label;</html:label>
</hbox> </html:div>
</rows> </rows>
</grid> </grid>
</panel> </panel>

View file

@ -193,12 +193,12 @@ richlistitem[selected="true"] {
background: white; background: white;
opacity: 0.9; opacity: 0.9;
-moz-user-focus: ignore; -moz-user-focus: ignore;
height: 37px;
} }
#quick-format-reference-list { #quick-format-reference-list {
margin: 0; margin: 0;
padding: 0; padding: 0;
-moz-user-focus: ignore;
} }
#citation-properties menulist { #citation-properties menulist {