preserve collection when switching between pane and tab

This commit is contained in:
Simon Kornblith 2011-03-25 03:38:42 +00:00
parent 7da0313a8b
commit 87bf3f21e4
2 changed files with 15 additions and 7 deletions

View File

@ -302,7 +302,8 @@ var ZoteroOverlay = new function()
*/ */
this.toggleTab = function(setMode) { this.toggleTab = function(setMode) {
var tab = this.findZoteroTab(); var tab = this.findZoteroTab();
window.zoteroSavedSelection = ZoteroPane.itemsView.saveSelection(); window.zoteroSavedItemSelection = ZoteroPane.itemsView.saveSelection();
window.zoteroSavedCollectionSelection = ZoteroPane.collectionsView.saveSelection();
if(tab) { // Zotero is running in a tab if(tab) { // Zotero is running in a tab
if(setMode) return; if(setMode) return;
// don't do anything if Zotero tab is the only tab // don't do anything if Zotero tab is the only tab

View File

@ -347,21 +347,28 @@ var ZoteroPane = new function()
return false; return false;
} }
this.unserializePersist(); this.updateTagSelectorSize();
// restore saved row selection (for tab switching)
var containerWindow = (window.ZoteroTab ? window.ZoteroTab.containerWindow : window); var containerWindow = (window.ZoteroTab ? window.ZoteroTab.containerWindow : window);
if(containerWindow.zoteroSavedSelection) { if(containerWindow.zoteroSavedCollectionSelection) {
this.collectionsView.rememberSelection(containerWindow.zoteroSavedCollectionSelection);
delete containerWindow.zoteroSavedCollectionSelection;
}
// restore saved item selection (for tab switching)
if(containerWindow.zoteroSavedItemSelection) {
var me = this; var me = this;
// hack to restore saved selection after itemTreeView finishes loading // hack to restore saved selection after itemTreeView finishes loading
window.setTimeout(function() { window.setTimeout(function() {
if(containerWindow.zoteroSavedSelection) { if(containerWindow.zoteroSavedItemSelection) {
me.itemsView.rememberSelection(containerWindow.zoteroSavedSelection) me.itemsView.rememberSelection(containerWindow.zoteroSavedItemSelection);
delete containerWindow.zoteroSavedSelection; delete containerWindow.zoteroSavedItemSelection;
} }
}, 51); }, 51);
} }
this.updateTagSelectorSize(); this.unserializePersist();
// Focus the quicksearch on pane open // Focus the quicksearch on pane open
setTimeout("document.getElementById('zotero-tb-search').inputField.select();", 1); setTimeout("document.getElementById('zotero-tb-search').inputField.select();", 1);