From 3e399fa5de3943eaead77a29088df96797d0ccb4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 17 Dec 2006 22:13:36 +0000 Subject: [PATCH] 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) --- chrome/content/zotero/itemPane.js | 25 +++++++++++++++++++++++++ chrome/content/zotero/itemPane.xul | 15 +++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index b4596c68b7..3f2b64f6b8 100644 --- a/chrome/content/zotero/itemPane.js +++ b/chrome/content/zotero/itemPane.js @@ -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; } } diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul index 65e9d56445..ac395db92c 100644 --- a/chrome/content/zotero/itemPane.xul +++ b/chrome/content/zotero/itemPane.xul @@ -28,7 +28,7 @@