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
This commit is contained in:
Dan Stillman 2009-08-09 22:15:48 +00:00
parent 820d1cf28f
commit dc2fba7b12
5 changed files with 89 additions and 94 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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');
this.viewItem = function (item, mode, index) {
if (!index) {
index = 0;
}
Zotero.debug('Viewing item in pane ' + index);
switch (index) {
case 0:
var box = _itemBox;
break;
case 1:
var box = _tagsBox;
break;
case 2:
var box = _relatedBox;
break;
}
// 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
if (_lastItem && _lastItem != item) {
switch (index) {
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');
case 1:
box.blurOpenField();
// DEBUG: Currently broken
//box.scrollToTop();
break;
}
if (boxes && boxes.length == 1) {
//boxes[0].inputField.blur();
}
}
_itemBeingEdited = thisItem;
_loaded = {};
_lastItem = item;
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;
if (mode) {
box.mode = mode;
}
_lastPane = index;
if (_loaded[index]) {
return;
}
_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';
}
_itemBox.item = _itemBeingEdited;
}
// Tags pane
else if (index == 1) {
if (mode) {
_tagsBox.mode = mode;
}
else {
_tagsBox.mode = 'edit';
}
var focusMode = 'tags';
var focusBox = _tagsBox;
_tagsBox.item = _itemBeingEdited;
}
// Related pane
else if (index == 2) {
_relatedBox.item = _itemBeingEdited;
else {
box.mode = 'edit';
}
box.item = item;
}
}

View file

@ -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;
}
}
}

View file

@ -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;"/>