commit dc2fba7b1258bd97c2658259f0e24f4144bc1c28
parent 820d1cf28f39305e6f9281b3524a1ffabb8e9498
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 9 Aug 2009 22:15:48 +0000
Item pane fixes and cleanup
- Restored save when clicking from open text field to another item
- Delay/weirdness when switching items/tabs should be gone
- Tab content updates properly when using Ctrl-arrows to navigate
- Removed some obsolete code
Diffstat:
5 files changed, 89 insertions(+), 94 deletions(-)
diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml
@@ -193,7 +193,6 @@
<field name="_selectField"/>
<field name="_beforeRow"/>
- <field name="_activeScrollbox"/>
<field name="_addCreatorRow"/>
<field name="_creatorCount"/>
@@ -895,10 +894,10 @@
<method name="scrollToTop">
<body>
<![CDATA[
- if (!this._activeScrollbox) {
- return;
- }
- var sbo = this._activeScrollbox.boxObject;
+ // DEBUG: Valid nsIScrollBoxObject but methods return errors
+ return;
+
+ var sbo = document.getAnonymousNodes(this)[0].boxObject;
sbo.QueryInterface(Components.interfaces.nsIScrollBoxObject);
sbo.scrollTo(0,0);
]]>
@@ -910,10 +909,10 @@
<parameter name="elem"/>
<body>
<![CDATA[
- if (!this._activeScrollbox) {
- return;
- }
- var sbo = this._activeScrollbox.boxObject;
+ // DEBUG: Valid nsIScrollBoxObject but methods return errors
+ return;
+
+ var sbo = document.getAnonymousNodes(this)[0].boxObject;
sbo.QueryInterface(Components.interfaces.nsIScrollBoxObject);
sbo.ensureElementIsVisible(elem);
]]>
@@ -2120,6 +2119,19 @@
</body>
</method>
+
+ <method name="blurOpenField">
+ <body>
+ <![CDATA[
+ var textboxes = document.getAnonymousNodes(this)[0].getElementsByTagName('textbox');
+ if (textboxes && textboxes.length) {
+ textboxes[0].inputField.blur();
+ }
+ ]]>
+ </body>
+ </method>
+
+
<method name="_id">
<parameter name="id"/>
<body>
diff --git a/chrome/content/zotero/bindings/tagsbox.xml b/chrome/content/zotero/bindings/tagsbox.xml
@@ -640,6 +640,22 @@
</method>
+ <method name="scrollToTop">
+ <body>
+ <![CDATA[
+ Zotero.debug('SCROLL TO TOP');
+ if (!this._activeScrollbox) {
+ Zotero.debug('NO');
+ return;
+ }
+ var sbo = this._activeScrollbox.boxObject;
+ sbo.QueryInterface(Components.interfaces.nsIScrollBoxObject);
+ sbo.scrollTo(0,0);
+ ]]>
+ </body>
+ </method>
+
+
<method name="ensureElementIsVisible">
<parameter name="elem"/>
<body>
@@ -653,6 +669,18 @@
</method>
+ <method name="blurOpenField">
+ <body>
+ <![CDATA[
+ var textboxes = document.getAnonymousNodes(this)[0].getElementsByTagName('textbox');
+ if (textboxes && textboxes.length) {
+ textboxes[0].inputField.blur();
+ }
+ ]]>
+ </body>
+ </method>
+
+
<method name="id">
<parameter name="id"/>
<body>
diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js
@@ -21,18 +21,9 @@
*/
var ZoteroItemPane = new function() {
- var _itemBeingEdited;
-
- var _lastPane;
- var _loaded;
-
- var _lastTabIndex;
- var _tabDirection;
- var _tabIndexMaxTagsFields = 0;
+ var _lastItem;
this.onLoad = onLoad;
- this.viewItem = viewItem;
- this.loadPane = loadPane;
function onLoad()
@@ -46,95 +37,58 @@ var ZoteroItemPane = new function() {
return;
}
- _deck = document.getElementById('zotero-view-item');
_itemBox = document.getElementById('zotero-editpane-item-box');
_tagsBox = document.getElementById('zotero-editpane-tags');
_relatedBox = document.getElementById('zotero-editpane-related');
}
+
/*
- * Loads an item
+ * Load an item
*/
- function viewItem(thisItem, mode) {
- //Zotero.debug('Viewing item');
-
- // Force blur() when clicking off a textbox to another item in middle
- // pane, since for some reason it's not being called automatically
- if (_itemBeingEdited && _itemBeingEdited != thisItem) {
- switch (_deck.selectedIndex) {
- // Info
- case 0:
- // TODO: fix
- //var boxes = _itemBox.getElementsByTagName('textbox');
-
- // When coming from another element, scroll pane to top
- //scrollToTop();
- break;
-
- // Tags
- case 3:
- var boxes = document.getAnonymousNodes(_tagsBox)[0].getElementsByTagName('textbox');
- break;
- }
-
- if (boxes && boxes.length == 1) {
- //boxes[0].inputField.blur();
- }
+ this.viewItem = function (item, mode, index) {
+ if (!index) {
+ index = 0;
}
- _itemBeingEdited = thisItem;
- _loaded = {};
+ Zotero.debug('Viewing item in pane ' + index);
- loadPane(_deck.selectedIndex, mode);
- }
-
-
- function loadPane(index, mode) {
- //Zotero.debug('Loading item pane ' + index);
-
- // Clear the tab index when switching panes
- if (_lastPane!=index) {
- _lastTabIndex = null;
- }
- _lastPane = index;
-
- if (_loaded[index]) {
- return;
+ switch (index) {
+ case 0:
+ var box = _itemBox;
+ break;
+
+ case 1:
+ var box = _tagsBox;
+ break;
+
+ case 2:
+ var box = _relatedBox;
+ break;
}
- _loaded[index] = true;
- // Info pane
- if (index == 0) {
- // Hack to allow read-only mode in right pane -- probably a better
- // way to allow access to this
- if (mode) {
- _itemBox.mode = mode;
- }
- else {
- _itemBox.mode = 'edit';
+ // Force blur() when clicking off a textbox to another item in middle
+ // pane, since for some reason it's not being called automatically
+ if (_lastItem && _lastItem != item) {
+ switch (index) {
+ case 0:
+ case 1:
+ box.blurOpenField();
+ // DEBUG: Currently broken
+ //box.scrollToTop();
+ break;
}
- _itemBox.item = _itemBeingEdited;
}
+ _lastItem = item;
- // Tags pane
- else if (index == 1) {
- if (mode) {
- _tagsBox.mode = mode;
- }
- else {
- _tagsBox.mode = 'edit';
- }
-
- var focusMode = 'tags';
- var focusBox = _tagsBox;
- _tagsBox.item = _itemBeingEdited;
+ if (mode) {
+ box.mode = mode;
}
-
- // Related pane
- else if (index == 2) {
- _relatedBox.item = _itemBeingEdited;
+ else {
+ box.mode = 'edit';
}
+ box.item = item;
}
}
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
@@ -1073,13 +1073,14 @@ var ZoteroPane = new function()
else
{
document.getElementById('zotero-item-pane-content').selectedIndex = 1;
+ var pane = document.getElementById('zotero-view-tabbox').selectedIndex;
if (this.collectionsView.editable) {
- ZoteroItemPane.viewItem(item.ref);
+ ZoteroItemPane.viewItem(item.ref, null, pane);
tabs.selectedIndex = document.getElementById('zotero-view-item').selectedIndex;
}
else {
- document.getElementById('zotero-view-item').selectedIndex = 0;
- ZoteroItemPane.viewItem(item.ref, 'view');
+ ZoteroItemPane.viewItem(item.ref, 'view', pane);
+ tabs.selectedIndex = document.getElementById('zotero-view-item').selectedIndex;
}
}
}
diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul
@@ -392,7 +392,7 @@
<groupbox pack="center" align="center">
<label id="zotero-view-selected-label"/>
</groupbox>
- <tabbox id="zotero-view-tabbox" flex="1" oncommand="if (this.selectedIndex !== '') { ZoteroItemPane.loadPane(this.selectedIndex); }">
+ <tabbox id="zotero-view-tabbox" flex="1" onselect="if (!ZoteroPane.collectionsView.selection || event.originalTarget.localName != 'tabpanels') { return; }; ZoteroItemPane.viewItem(ZoteroPane.getSelectedItems()[0], ZoteroPane.collectionsView.editable ? 'edit' : 'view', this.selectedIndex)">
<tabs>
<tab label="&zotero.tabs.info.label;"/>
<tab label="&zotero.tabs.tags.label;"/>