commit 7448e2ac6a11d5a1aec10367f27e4feaf3f384ea
parent 47f57509e53216a1d2fc110f3c7c7dfb37135bec
Author: Simon Kornblith <simon@simonster.com>
Date: Fri, 11 Feb 2011 22:39:13 +0000
maintain selection across tab/pane switch
Diffstat:
3 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
@@ -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
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -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++)
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -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) {};
+ }
}
/**