maintain selection across tab/pane switch

This commit is contained in:
Simon Kornblith 2011-02-11 22:39:13 +00:00
parent 47f57509e5
commit 7448e2ac6a
3 changed files with 30 additions and 8 deletions

View file

@ -204,11 +204,6 @@ var ZoteroOverlay = new function()
// Make visible
ZoteroPane.makeVisible();
// Restore fullscreen mode if necessary
if (ZoteroPane.isFullScreen()) {
this.fullScreen(true);
}
// Make sure tags splitter isn't missing for people upgrading from <2.0b7
document.getElementById('zotero-tags-splitter').collapsed = false;
} else {
@ -307,6 +302,7 @@ var ZoteroOverlay = new function()
*/
this.toggleTab = function(setMode) {
var tab = this.findZoteroTab();
window.zoteroSavedSelection = ZoteroPane.itemsView.saveSelection();
if(tab) { // Zotero is running in a tab
if(setMode) return;
// don't do anything if Zotero tab is the only tab

View file

@ -1538,6 +1538,20 @@ Zotero.ItemTreeView.prototype.saveSelection = function()
*/
Zotero.ItemTreeView.prototype.rememberSelection = function(selection)
{
// if itemRowMap not yet defined, remember once it is
if(!this._itemRowMap) {
var me = this;
var callback = function() {
// remember selection
me.rememberSelection(selection);
// remove callback
me._callbacks.splice(me._callbacks.indexOf(callback), 1);
}
this.addCallback(callback);
return;
}
this.selection.clearSelection();
for(var i=0; i < selection.length; i++)

View file

@ -311,14 +311,14 @@ var ZoteroPane = new function()
return;
}
_serializePersist();
var tagSelector = document.getElementById('zotero-tag-selector');
tagSelector.unregister();
this.collectionsView.unregister();
if (this.itemsView)
this.itemsView.unregister();
_serializePersist();
}
/**
@ -348,6 +348,13 @@ var ZoteroPane = new function()
_unserializePersist();
var containerWindow = (window.ZoteroTab ? window.ZoteroTab.containerWindow : window);
if(containerWindow.zoteroSavedSelection) {
Zotero.debug("ZoteroPane: Remembering selection");
this.itemsView.rememberSelection(containerWindow.zoteroSavedSelection);
delete containerWindow.zoteroSavedSelection;
}
this.updateTagSelectorSize();
// Focus the quicksearch on pane open
@ -3451,7 +3458,12 @@ var ZoteroPane = new function()
}
}
if(this.itemsView) this.itemsView.sort();
if(this.itemsView) {
// may not yet be initialized
try {
this.itemsView.sort();
} catch(e) {};
}
}
/**