maintain selection across tab/pane switch
This commit is contained in:
parent
47f57509e5
commit
7448e2ac6a
|
@ -204,11 +204,6 @@ var ZoteroOverlay = new function()
|
||||||
// Make visible
|
// Make visible
|
||||||
ZoteroPane.makeVisible();
|
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
|
// Make sure tags splitter isn't missing for people upgrading from <2.0b7
|
||||||
document.getElementById('zotero-tags-splitter').collapsed = false;
|
document.getElementById('zotero-tags-splitter').collapsed = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -307,6 +302,7 @@ var ZoteroOverlay = new function()
|
||||||
*/
|
*/
|
||||||
this.toggleTab = function(setMode) {
|
this.toggleTab = function(setMode) {
|
||||||
var tab = this.findZoteroTab();
|
var tab = this.findZoteroTab();
|
||||||
|
window.zoteroSavedSelection = ZoteroPane.itemsView.saveSelection();
|
||||||
if(tab) { // Zotero is running in a tab
|
if(tab) { // Zotero is running in a tab
|
||||||
if(setMode) return;
|
if(setMode) return;
|
||||||
// don't do anything if Zotero tab is the only tab
|
// don't do anything if Zotero tab is the only tab
|
||||||
|
|
|
@ -1538,6 +1538,20 @@ Zotero.ItemTreeView.prototype.saveSelection = function()
|
||||||
*/
|
*/
|
||||||
Zotero.ItemTreeView.prototype.rememberSelection = function(selection)
|
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();
|
this.selection.clearSelection();
|
||||||
|
|
||||||
for(var i=0; i < selection.length; i++)
|
for(var i=0; i < selection.length; i++)
|
||||||
|
|
|
@ -311,14 +311,14 @@ var ZoteroPane = new function()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_serializePersist();
|
||||||
|
|
||||||
var tagSelector = document.getElementById('zotero-tag-selector');
|
var tagSelector = document.getElementById('zotero-tag-selector');
|
||||||
tagSelector.unregister();
|
tagSelector.unregister();
|
||||||
|
|
||||||
this.collectionsView.unregister();
|
this.collectionsView.unregister();
|
||||||
if (this.itemsView)
|
if (this.itemsView)
|
||||||
this.itemsView.unregister();
|
this.itemsView.unregister();
|
||||||
|
|
||||||
_serializePersist();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -348,6 +348,13 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
_unserializePersist();
|
_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();
|
this.updateTagSelectorSize();
|
||||||
|
|
||||||
// Focus the quicksearch on pane open
|
// 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) {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user