Fix switching out of full mode when started in connector mode
Previously, if Standalone was open and Firefox was opened in connector mode, ZoteroOverlay.onLoad() was never run, which meant that, among other things, the before-reload handler that closed the Zotero pane when switching out of full mode was never added.
This commit is contained in:
parent
3d117c4135
commit
04941f23db
|
@ -36,39 +36,94 @@ var ZoteroOverlay = new function()
|
||||||
this.isTab = false;
|
this.isTab = false;
|
||||||
|
|
||||||
this.onLoad = function () {
|
this.onLoad = function () {
|
||||||
|
Zotero.spawn(function* () {
|
||||||
|
try {
|
||||||
|
//
|
||||||
|
// Code that runs in both full and connector mode
|
||||||
|
//
|
||||||
zoteroPane = document.getElementById('zotero-pane-stack');
|
zoteroPane = document.getElementById('zotero-pane-stack');
|
||||||
zoteroSplitter = document.getElementById('zotero-splitter');
|
zoteroSplitter = document.getElementById('zotero-splitter');
|
||||||
|
|
||||||
var self = this;
|
|
||||||
var iconLoaded = false;
|
var iconLoaded = false;
|
||||||
|
|
||||||
if (Zotero.isConnector) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Zotero.Promise.try(function () {
|
|
||||||
if (!Zotero) {
|
if (!Zotero) {
|
||||||
throw new Error("No Zotero object");
|
throw new Error("No Zotero object");
|
||||||
}
|
}
|
||||||
if (Zotero.skipLoading) {
|
if (Zotero.skipLoading) {
|
||||||
throw new Error("Skipping loading");
|
throw new Error("Skipping loading");
|
||||||
}
|
}
|
||||||
return Zotero.Promise.all([Zotero.initializationPromise, Zotero.unlockPromise]);
|
|
||||||
})
|
ZoteroPane_Overlay = ZoteroPane;
|
||||||
.then(function () {
|
|
||||||
|
// Close pane before reload
|
||||||
|
ZoteroPane_Local.addBeforeReloadListener(function(newMode) {
|
||||||
|
if(newMode == "connector") {
|
||||||
|
// save current state
|
||||||
|
_stateBeforeReload = !zoteroPane.hidden && !zoteroPane.collapsed;
|
||||||
|
// ensure pane is closed
|
||||||
|
if(!zoteroPane.collapsed) ZoteroOverlay.toggleDisplay(false, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close pane if connector is enabled
|
||||||
|
ZoteroPane_Local.addReloadListener(function() {
|
||||||
|
if(!Zotero.isConnector) {
|
||||||
|
// reopen pane if it was open before
|
||||||
|
ZoteroOverlay.toggleDisplay(_stateBeforeReload, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Add only when progress window is open
|
||||||
|
document.getElementById('appcontent').addEventListener('mousemove', Zotero.ProgressWindowSet.updateTimers, false);
|
||||||
|
|
||||||
|
// Hide browser chrome on Zotero tab
|
||||||
|
XULBrowserWindow.inContentWhitelist.push("chrome://zotero/content/tab.xul");
|
||||||
|
|
||||||
|
// Perform additional initialization for full mode
|
||||||
|
if (!Zotero.isConnector) {
|
||||||
|
yield _onLoadFull();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
Zotero.debug(e, 1);
|
||||||
|
|
||||||
|
// Add toolbar icon if still necessary
|
||||||
|
if (!iconLoaded) {
|
||||||
|
try {
|
||||||
|
Services.scriptloader.loadSubScript("chrome://zotero/content/icon.js", {}, "UTF-8");
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
Zotero.logError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize overlay in new windows in full mode
|
||||||
|
*
|
||||||
|
* This is never run in Zotero for Firefox if Standalone is open first and Z4Fx is opened
|
||||||
|
* second, but we don't care.
|
||||||
|
*/
|
||||||
|
var _onLoadFull = function () {
|
||||||
|
return Zotero.spawn(function* () {
|
||||||
|
yield Zotero.Promise.all([Zotero.initializationPromise, Zotero.unlockPromise]);
|
||||||
|
|
||||||
Zotero.debug("Initializing overlay");
|
Zotero.debug("Initializing overlay");
|
||||||
|
|
||||||
if (Zotero.skipLoading) {
|
if (Zotero.skipLoading) {
|
||||||
throw new Error("Skipping loading");
|
throw new Error("Skipping loading");
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoteroPane_Overlay = ZoteroPane;
|
|
||||||
|
|
||||||
// Open Zotero app tab, if in Fx 4 and requested by pref
|
// Open Zotero app tab, if in Fx 4 and requested by pref
|
||||||
showInPref = Components.classes["@mozilla.org/preferences-service;1"]
|
showInPref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
.getService(Components.interfaces.nsIPrefService)
|
.getService(Components.interfaces.nsIPrefService)
|
||||||
.getBranch('extensions.zotero.').getIntPref('showIn');
|
.getBranch('extensions.zotero.').getIntPref('showIn');
|
||||||
self.isTab = showInPref !== 1;
|
this.isTab = showInPref !== 1;
|
||||||
|
|
||||||
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
||||||
.getService(Components.interfaces.nsIObserverService);
|
.getService(Components.interfaces.nsIObserverService);
|
||||||
|
@ -87,7 +142,6 @@ var ZoteroOverlay = new function()
|
||||||
if(zoteroTab) gBrowser.removeTab(zoteroTab);
|
if(zoteroTab) gBrowser.removeTab(zoteroTab);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
observerService.addObserver(zoteroObserver, "browser-delayed-startup-finished", false);
|
observerService.addObserver(zoteroObserver, "browser-delayed-startup-finished", false);
|
||||||
|
|
||||||
ZoteroPane.init();
|
ZoteroPane.init();
|
||||||
|
@ -107,9 +161,6 @@ var ZoteroOverlay = new function()
|
||||||
Zotero.logError(e);
|
Zotero.logError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add only when progress window is open
|
|
||||||
document.getElementById('appcontent').addEventListener('mousemove', Zotero.ProgressWindowSet.updateTimers, false);
|
|
||||||
|
|
||||||
// Used for loading pages from upgrade wizard
|
// Used for loading pages from upgrade wizard
|
||||||
if (Zotero.initialURL) {
|
if (Zotero.initialURL) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
@ -117,43 +168,7 @@ var ZoteroOverlay = new function()
|
||||||
Zotero.initialURL = null;
|
Zotero.initialURL = null;
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
}, this);
|
||||||
// Hide browser chrome on Zotero tab
|
|
||||||
XULBrowserWindow.inContentWhitelist.push("chrome://zotero/content/tab.xul");
|
|
||||||
|
|
||||||
// Close pane before reload
|
|
||||||
ZoteroPane_Local.addBeforeReloadListener(function(newMode) {
|
|
||||||
if(newMode == "connector") {
|
|
||||||
// save current state
|
|
||||||
_stateBeforeReload = !zoteroPane.hidden && !zoteroPane.collapsed;
|
|
||||||
// ensure pane is closed
|
|
||||||
if(!zoteroPane.collapsed) ZoteroOverlay.toggleDisplay(false, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Close pane if connector is enabled
|
|
||||||
ZoteroPane_Local.addReloadListener(function() {
|
|
||||||
if(!Zotero.isConnector) {
|
|
||||||
// reopen pane if it was open before
|
|
||||||
ZoteroOverlay.toggleDisplay(_stateBeforeReload, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(function (e) {
|
|
||||||
Zotero.debug(e, 1);
|
|
||||||
|
|
||||||
// Add toolbar icon if still necessary
|
|
||||||
if (!iconLoaded) {
|
|
||||||
try {
|
|
||||||
Services.scriptloader.loadSubScript("chrome://zotero/content/icon.js", {}, "UTF-8");
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
Zotero.logError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw e;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user