Fixes #137, When you scroll down in item info, and click another item, the scroll is still down.

Also:

- Ensures that buttons and fields in metadata pane are visible when you tab to them (e.g. off the bottom)
- Returns focus to items pane after updating field (without using tab)
This commit is contained in:
Dan Stillman 2006-12-17 22:13:36 +00:00
parent fa23389d2c
commit 3e399fa5de
2 changed files with 36 additions and 4 deletions

View File

@ -53,6 +53,8 @@ var ZoteroItemPane = new function()
this.onLoad = onLoad;
this.viewItem = viewItem;
this.scrollToTop = scrollToTop;
this.ensureElementIsVisible = ensureElementIsVisible;
this.loadPane = loadPane;
this.changeTypeTo = changeTypeTo;
this.onOpenURLClick = onOpenURLClick;
@ -119,6 +121,9 @@ var ZoteroItemPane = new function()
// Info
case 0:
var boxes = _dynamicFields.getElementsByTagName('textbox');
// When coming from another element, scroll pane to top
scrollToTop();
break;
// Tags
@ -414,6 +419,21 @@ var ZoteroItemPane = new function()
}
}
function scrollToTop() {
var sbo = document.getElementById('zotero-info').boxObject;
sbo.QueryInterface(Components.interfaces.nsIScrollBoxObject);
sbo.scrollTo(0,0);
}
function ensureElementIsVisible(elem) {
var sbo = document.getElementById('zotero-info').boxObject;
sbo.QueryInterface(Components.interfaces.nsIScrollBoxObject);
sbo.ensureElementIsVisible(elem);
}
function changeTypeTo(id)
{
if(id != _itemBeingEdited.getType() && confirm(Zotero.getString('pane.item.changeType')))
@ -1169,6 +1189,10 @@ var ZoteroItemPane = new function()
}
_focusNextField(focusMode, focusBox, _lastTabIndex, _tabDirection==-1);
}
// If not tab, return focus to items pane
else {
document.getElementById('zotero-items-tree').focus();
}
}
function modifyField(field, value)
@ -1466,6 +1490,7 @@ var ZoteroItemPane = new function()
}
next[0].click();
ensureElementIsVisible(next[0]);
return true;
}
}

View File

@ -28,7 +28,7 @@
<script src="itemPane.js"/>
<deck id="zotero-view-item" flex="1" onselect="if (this.selectedIndex!==''){ ZoteroItemPane.loadPane(this.selectedIndex) }">
<vbox id="zotero-info" flex="1">
<scrollbox id="zotero-info" flex="1" orient="vertical" style="overflow:auto">
<popupset>
<popup id="zotero-creator-type-menu" position="after_start"
oncommand="var otherFields = ZoteroItemPane.getCreatorFields(document.popupNode.parentNode);
@ -40,11 +40,18 @@
'typeID', typeID, otherFields)"/>
</popupset>
<hbox align="center">
<button id="zotero-tb-go-to-url" label="&zotero.toolbar.goToURL.label;" tooltiptext="&zotero.toolbar.goToURL.tooltip;" flex="1" oncommand="window.loadURI(this.getAttribute('viewURL'))" disabled="false"/>
<button id="zotero-tb-openurl" label="&zotero.toolbar.openURL.label;" tooltiptext="&zotero.toolbar.openURL.tooltip;" flex="1" oncommand="ZoteroItemPane.onOpenURLClick();"/>
<button id="zotero-tb-go-to-url" label="&zotero.toolbar.goToURL.label;"
onfocus="ZoteroItemPane.ensureElementIsVisible(this)"
tooltiptext="&zotero.toolbar.goToURL.tooltip;" flex="1"
oncommand="window.loadURI(this.getAttribute('viewURL'))" disabled="false"/>
<button id="zotero-tb-openurl" label="&zotero.toolbar.openURL.label;"
tooltiptext="&zotero.toolbar.openURL.tooltip;" flex="1"
onfocus="ZoteroItemPane.ensureElementIsVisible(this)"
oncommand="ZoteroItemPane.onOpenURLClick();"/>
</hbox>
<hbox align="center">
<menulist id="zotero-editpane-type-menu" oncommand="ZoteroItemPane.changeTypeTo(this.value)" flex="1"
onfocus="ZoteroItemPane.ensureElementIsVisible(this)"
onkeypress="if (event.keyCode == event.DOM_VK_TAB){ if (!event.shiftKey) { ZoteroItemPane.focusFirstField('info'); event.preventDefault(); } }">
<menupopup/>
</menulist>
@ -56,7 +63,7 @@
</columns>
<rows id="zotero-editpane-dynamic-fields" flex="1"/>
</grid>
</vbox>
</scrollbox>
<vbox flex="1">
<hbox align="center">
<label id="zotero-editpane-notes-label"/>