Fixes #753, Adding item to last-used collection doesn't work until Zotero pane has been opened

This commit is contained in:
Dan Stillman 2007-09-15 20:54:57 +00:00
parent fa6390f65f
commit d0f53c52b1

View File

@ -1218,11 +1218,17 @@ var ZoteroPane = new function()
&& this.collectionsView.selection.currentIndex != -1) {
var collection = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
if (collection && collection.isCollection()) {
if (asID) {
return collection.ref.getID();
}
else {
return collection.ref;
return asID ? collection.ref.getID() : collection.ref;
}
}
// If the Zotero pane hasn't yet been opened, use the lastViewedFolder pref
else {
var lastViewedFolder = Zotero.Prefs.get('lastViewedFolder');
var matches = lastViewedFolder.match(/^(?:(C|S)([0-9]+)|L)$/);
if (matches && matches[1] == 'C') {
var col = Zotero.Collections.get(matches[2]);
if (col) {
return asID ? col.getID() : col;
}
}
}
@ -1234,11 +1240,17 @@ var ZoteroPane = new function()
if (this.collectionsView.selection.count > 0 && this.collectionsView.selection.currentIndex != -1) {
var collection = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
if (collection && collection.isSearch()) {
if (asID) {
return collection.ref.id;
}
else {
return collection.ref;
return asID ? collection.ref.id : collection.ref;
}
}
// If the Zotero pane hasn't yet been opened, use the lastViewedFolder pref
else {
var lastViewedFolder = Zotero.Prefs.get('lastViewedFolder');
var matches = lastViewedFolder.match(/^(?:(C|S)([0-9]+)|L)$/);
if (matches && matches[1] == 'S') {
var search = Zotero.Search.get(matches[2]);
if (search) {
return asID ? search.id : search;
}
}
}