commit e312fc0bb6b6ab095a8e77bb8448a8308602384b
parent bd5d3af9830bce823e5cd4c15723e06d2c6e1c9c
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 8 Mar 2011 23:14:19 +0000
- fix restoration selection when switching between tab and pane
- don't serialize persistent data from Zotero Pane on window close unless pane was showing
Diffstat:
3 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/chrome/content/zotero/tab.js b/chrome/content/zotero/tab.js
@@ -38,6 +38,11 @@ var ZoteroTab = new function()
.chromeEventHandler.ownerDocument.defaultView;
if(!this.containerWindow) return;
+ if(this.containerWindow.ZoteroPane && this.containerWindow.ZoteroPane.itemsView) {
+ this.containerWindow.ZoteroPane.itemsView.unregister();
+ delete this.containerWindow.ZoteroPane.itemsView;
+ }
+
var tabs = (this.containerWindow.gBrowser.tabs
? this.containerWindow.gBrowser.tabs : this.containerWindow.gBrowser.mTabs);
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -304,11 +304,8 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
this.selection.selectEventsSuppressed = true;
// See if we're in the active window
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- if (wm.getMostRecentWindow("navigator:browser") == this._ownerDocument.defaultView){
- var activeWindow = true;
- }
+ var zp = Zotero.getActiveZoteroPane();
+ var activeWindow = zp && zp.itemsView == this;
var quicksearch = this._ownerDocument.getElementById('zotero-tb-search');
@@ -1537,21 +1534,7 @@ Zotero.ItemTreeView.prototype.saveSelection = function()
* Sets the selection based on saved selection ids (see above)
*/
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
@@ -310,7 +310,9 @@ var ZoteroPane = new function()
return;
}
- this.serializePersist();
+ if(this.isShowing()) {
+ this.serializePersist();
+ }
var tagSelector = document.getElementById('zotero-tag-selector');
tagSelector.unregister();
@@ -349,9 +351,14 @@ var ZoteroPane = new function()
var containerWindow = (window.ZoteroTab ? window.ZoteroTab.containerWindow : window);
if(containerWindow.zoteroSavedSelection) {
- Zotero.debug("ZoteroPane: Remembering selection");
- this.itemsView.rememberSelection(containerWindow.zoteroSavedSelection);
- delete containerWindow.zoteroSavedSelection;
+ var me = this;
+ // hack to restore saved selection after itemTreeView finishes loading
+ window.setTimeout(function() {
+ if(containerWindow.zoteroSavedSelection) {
+ me.itemsView.rememberSelection(containerWindow.zoteroSavedSelection)
+ delete containerWindow.zoteroSavedSelection;
+ }
+ }, 51);
}
this.updateTagSelectorSize();