- fix restoration selection when switching between tab and pane

- don't serialize persistent data from Zotero Pane on window close unless pane was showing
This commit is contained in:
Simon Kornblith 2011-03-08 23:14:19 +00:00
parent bd5d3af983
commit e312fc0bb6
3 changed files with 19 additions and 24 deletions

View file

@ -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);

View file

@ -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++)

View file

@ -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();