commit 64e7738bd37579661fa0e9a8f3853551cf628cd3
parent 092a0b5560897e630d9569b089d616a4772aa0b5
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 8 Feb 2016 01:37:48 -0500
Fix switching into tab mode
Diffstat:
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
@@ -287,8 +287,8 @@ var ZoteroOverlay = new function()
*/
this.toggleTab = function(setMode) {
var tab = this.findZoteroTab();
+ window.zoteroSavedCollectionSelection = ZoteroPane.collectionsView.selectedTreeRow.id;
window.zoteroSavedItemSelection = ZoteroPane.itemsView.saveSelection();
- window.zoteroSavedCollectionSelection = ZoteroPane.collectionsView.saveSelection();
if(tab) { // Zotero is running in a tab
if(setMode) return;
// if Zotero tab is the only tab, open the home page in a new tab
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -923,6 +923,11 @@ Zotero.ItemTreeView.prototype.unregister = function()
{
Zotero.Notifier.unregisterObserver(this._unregisterID);
if (this.listener) {
+ if (!this._treebox.treeBody) {
+ Zotero.debug("No more tree body in Zotero.ItemTreeView::unregister()");
+ this.listener = null;
+ return;
+ }
let tree = this._treebox.treeBody.parentNode;
tree.removeEventListener('keypress', this.listener, false);
this.listener = null;
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -377,20 +377,18 @@ var ZoteroPane = new function()
// restore saved row selection (for tab switching)
var containerWindow = (window.ZoteroTab ? window.ZoteroTab.containerWindow : window);
if(containerWindow.zoteroSavedCollectionSelection) {
- yield this.collectionsView.rememberSelection(containerWindow.zoteroSavedCollectionSelection);
- delete containerWindow.zoteroSavedCollectionSelection;
- }
-
- // restore saved item selection (for tab switching)
- if(containerWindow.zoteroSavedItemSelection) {
- let self = this;
- // hack to restore saved selection after itemTreeView finishes loading
- window.setTimeout(function() {
- if(containerWindow.zoteroSavedItemSelection) {
- yield self.itemsView.rememberSelection(containerWindow.zoteroSavedItemSelection);
- delete containerWindow.zoteroSavedItemSelection;
+ this.collectionsView.addEventListener('load', Zotero.Promise.coroutine(function* () {
+ yield this.collectionsView.selectByID(containerWindow.zoteroSavedCollectionSelection);
+
+ if (containerWindow.zoteroSavedItemSelection) {
+ this.itemsView.addEventListener('load', function () {
+ this.itemsView.rememberSelection(containerWindow.zoteroSavedItemSelection);
+ delete containerWindow.zoteroSavedItemSelection;
+ }.bind(this));
}
- }, 51);
+
+ delete containerWindow.zoteroSavedCollectionSelection;
+ }.bind(this)));
}
// Focus the quicksearch on pane open