Remove some old Zotero for Firefox code

In particular, remove code related to opening/closing the Zotero pane,
which affects tests. The pane is now opened by default in Firefox, which
brings its behavior closer to the main version.
This commit is contained in:
Dan Stillman 2019-08-26 00:34:06 -04:00
parent 5994e22359
commit 9a49718638
16 changed files with 35 additions and 289 deletions

View file

@ -1,12 +1,3 @@
#zotero-splitter
{
border-top: none;
border-bottom: 1px solid #A3A3A3;
min-height: 1px !important;
max-height: 1px !important;
background-image: none;
}
#zotero-items-toolbar[state=collapsed]
{
margin-left: -8px !important;
@ -107,11 +98,6 @@
padding: 2px 0px 2px 8px !important;
}
#zotero-close-button {
margin: 0px !important;
padding: 0px 0px 0px 10px !important;
}
#zotero-tb-sync {
margin: 0;
}

View file

@ -172,10 +172,6 @@ var ZoteroAdvancedSearch = new function() {
return;
}
if (lastWin.ZoteroOverlay) {
lastWin.ZoteroOverlay.toggleDisplay(true);
}
lastWin.ZoteroPane.selectItem(item.getID(), false, true);
lastWin.focus();
}

View file

@ -511,10 +511,6 @@
var lastWin = window.open();
}
if (lastWin.ZoteroOverlay && !lastWin.ZoteroPane.isShowing()) {
lastWin.ZoteroOverlay.toggleDisplay(true);
}
var zp = lastWin.ZoteroPane;
}

View file

@ -23,166 +23,42 @@
***** END LICENSE BLOCK *****
*/
/*
* This object contains the various functions for the interface
*/
var ZoteroOverlay = new function()
{
const DEFAULT_ZPANE_HEIGHT = 300;
var toolbarCollapseState;
var zoteroPane, zoteroSplitter;
this.isTab = false;
this.onLoad = function () {
Zotero.spawn(function* () {
try {
//
// Code that runs in both full and connector mode
//
zoteroPane = document.getElementById('zotero-pane-stack');
zoteroSplitter = document.getElementById('zotero-splitter');
if (!Zotero) {
throw new Error("No Zotero object");
}
if (Zotero.skipLoading) {
throw new Error("Skipping loading");
}
ZoteroPane_Overlay = ZoteroPane;
// TODO: Add only when progress window is open
document.getElementById('appcontent').addEventListener('mousemove', Zotero.ProgressWindowSet.updateTimers, false);
// Perform additional initialization for full mode
if (!Zotero.isConnector) {
yield _onLoadFull();
}
var ZoteroOverlay = new function () {
this.onLoad = async function () {
try {
if (!Zotero) {
throw new Error("No Zotero object");
}
catch (e) {
Zotero.debug(e, 1);
throw e;
if (Zotero.skipLoading) {
throw new Error("Skipping loading");
}
});
}
/**
* 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]);
await Zotero.Promise.all([Zotero.initializationPromise, Zotero.unlockPromise]);
Zotero.debug("Initializing overlay");
if (Zotero.skipLoading) {
throw new Error("Skipping loading");
}
ZoteroPane.init();
// Clear old Zotero icon pref
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch('extensions.zotero.');
prefBranch.clearUserPref('statusBarIcon');
// Used for loading pages from upgrade wizard
if (Zotero.initialURL) {
setTimeout(function () {
Zotero.launchURL(ZOTERO_CONFIG.START_URL);
Zotero.initialURL = null;
}, 1);
}
}, this);
}
}
catch (e) {
Zotero.debug(e, 1);
throw e;
}
};
this.onUnload = function() {
ZoteroPane.destroy();
}
/**
* Hides/displays the Zotero interface
* @param {Boolean} makeVisible Whether or not Zotero interface should be visible
* @param {Boolean} dontRefocus If true, don't focus content when closing Zotero pane. Used
* when closing pane because Zotero Standalone is being opened, to avoid pulling Firefox to
* the foreground.
*/
this.toggleDisplay = function(makeVisible, dontRefocus)
{
if (!Zotero || Zotero.startupError || Zotero.skipLoading) {
ZoteroPane.displayStartupError();
return;
}
// Don't do anything if pane is already showing
if (makeVisible && ZoteroPane.isShowing()) {
return;
}
if(makeVisible === undefined) makeVisible = zoteroPane.hidden || zoteroPane.collapsed;
/*
Zotero.debug("zoteroPane.boxObject.height: " + zoteroPane.boxObject.height);
Zotero.debug("zoteroPane.getAttribute('height'): " + zoteroPane.getAttribute('height'));
Zotero.debug("zoteroPane.getAttribute('minheight'): " + zoteroPane.getAttribute('minheight'));
Zotero.debug("savedHeight: " + savedHeight);
*/
if(makeVisible) {
zoteroSplitter.setAttribute('hidden', false);
zoteroPane.setAttribute('hidden', false);
zoteroPane.setAttribute('collapsed', false);
// Get saved height (makeVisible() may change it)
if (zoteroPane.hasAttribute('savedHeight')) {
var savedHeight = zoteroPane.getAttribute('savedHeight');
}
else {
var savedHeight = DEFAULT_ZPANE_HEIGHT;
}
// Restore height
var max = document.getElementById('appcontent').boxObject.height
- zoteroSplitter.boxObject.height;
zoteroPane.setAttribute('height', Math.min(savedHeight, max));
// Make visible
ZoteroPane.makeVisible();
// Warn about unsafe data directory on first display
Zotero.DataDirectory.checkForUnsafeLocation(Zotero.DataDirectory.dir); // async
// Make sure tags splitter isn't missing for people upgrading from <2.0b7
document.getElementById('zotero-tags-splitter').collapsed = false;
} else {
ZoteroPane.makeHidden();
// Collapse pane
zoteroSplitter.setAttribute('hidden', true);
zoteroPane.setAttribute('collapsed', true);
zoteroPane.height = 0;
document.getElementById('content').setAttribute('collapsed', false);
if(!dontRefocus) {
// Return focus to the browser content pane
window.content.window.focus();
}
}
}
}
window.addEventListener("load", function(e) {
window.addEventListener("load", async function(e) {
try {
ZoteroOverlay.onLoad(e);
await ZoteroOverlay.onLoad(e);
await ZoteroPane.makeVisible();
}
catch (e) {
Components.utils.reportError(e);

View file

@ -41,10 +41,6 @@
<toolbar id="zotero-toolbar" nowindowdrag="true"/>
<vbox id="appcontent">
<!-- onmouseup shouldn't be necessary but seems to help prevent tag selector from sometimes going off the screen -->
<splitter id="zotero-splitter" resizebefore="closest" resizeafter="closest" hidden="true"
onmouseup="ZoteroPane.updateTagSelectorSize()"/>
<stack id="zotero-pane-stack" persist="savedHeight" savedHeight="300" hidden="true"/>
<stack id="zotero-pane-stack"/>
</vbox>
</overlay>

View file

@ -47,7 +47,6 @@
<preference id="pref-openURL-resolver" name="extensions.zotero.openURL.resolver" type="string"/>
<preference id="pref-openURL-version" name="extensions.zotero.openURL.version" type="string"/>
<preference id="pref-keys-openZotero" name="extensions.zotero.keys.openZotero" type="string"/>
<preference id="pref-keys-saveToZotero" name="extensions.zotero.keys.saveToZotero" type="string"/>
<preference id="pref-keys-library" name="extensions.zotero.keys.library" type="string"/>
<preference id="pref-keys-quicksearch" name="extensions.zotero.keys.quicksearch" type="string"/>

View file

@ -248,10 +248,6 @@ Zotero.ProgressQueueDialog = function (progressQueue) {
let win = Services.wm.getMostRecentWindow("navigator:browser");
if (win) {
if (win.ZoteroOverlay) {
win.ZoteroOverlay.toggleDisplay(true);
}
win.ZoteroPane.selectItem(itemID, false, true);
win.focus();
}

View file

@ -28,7 +28,6 @@ Zotero.ProgressWindowSet = new function() {
this.add = add;
this.tile = tile;
this.remove = remove;
this.updateTimers = updateTimers;
var _progressWindows = [];
@ -87,19 +86,6 @@ Zotero.ProgressWindowSet = new function() {
}
function updateTimers() {
if (!_progressWindows.length) {
return;
}
for (var i=0; i<_progressWindows.length; i++) {
// Pass |requireMouseOver| so that the window only closes
// if the mouse was over it at some point
_progressWindows[i].instance.startCloseTimer(null, true);
}
}
this.closeAll = function () {
_progressWindows.forEach(pw => pw.instance.close());
}

View file

@ -1407,23 +1407,6 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
while (enumerator.hasMoreElements()) {
var win = enumerator.getNext();
if(!win.ZoteroPane) continue;
if (!win.ZoteroPane.isShowing() && !modalOnly) {
if (win != currentWindow) {
continue;
}
// If Zotero is closed in the top-most window, show a popup instead
_progressPopup = new Zotero.ProgressWindow();
_progressPopup.changeHeadline("Zotero");
if (icon) {
_progressPopup.addLines([msg], [icon]);
}
else {
_progressPopup.addDescription(msg);
}
_progressPopup.show();
continue;
}
var label = win.ZoteroPane.document.getElementById('zotero-pane-progress-label');
if (!label) {
@ -1847,10 +1830,6 @@ Zotero.Keys = new function() {
*/
function windowInit(document) {
var globalKeys = [
{
name: 'openZotero',
defaultKey: 'Z'
},
{
name: 'saveToZotero',
defaultKey: 'S'

View file

@ -40,7 +40,6 @@ var ZoteroPane = new function()
//Privileged methods
this.destroy = destroy;
this.isShowing = isShowing;
this.isFullScreen = isFullScreen;
this.handleKeyDown = handleKeyDown;
this.handleKeyUp = handleKeyUp;
@ -356,10 +355,7 @@ var ZoteroPane = new function()
return;
}
if(this.isShowing()) {
this.serializePersist();
}
this.serializePersist();
this.uninitContainers();
if(this.collectionsView) this.collectionsView.unregister();
@ -519,19 +515,6 @@ var ZoteroPane = new function()
return true;
});
/**
* Function to be called before ZoteroPane_Local is hidden. Does not actually hide the Zotero pane.
*/
this.makeHidden = function() {
this.serializePersist();
}
function isShowing() {
var zoteroPane = document.getElementById('zotero-pane-stack');
return zoteroPane
&& zoteroPane.getAttribute('hidden') != 'true'
&& zoteroPane.getAttribute('collapsed') != 'true';
}
function isFullScreen() {
return document.getElementById('zotero-pane-stack').getAttribute('fullscreenmode') == 'true';
@ -720,30 +703,6 @@ var ZoteroPane = new function()
// Errors don't seem to make it out otherwise
try {
switch (command) {
case 'openZotero':
try {
// Ignore Cmd-Shift-Z keystroke in text areas
if (Zotero.isMac && key == 'Z' &&
(event.originalTarget.localName == 'input'
|| event.originalTarget.localName == 'textarea')) {
try {
var isSearchBar = event.originalTarget.parentNode.parentNode.id == 'zotero-tb-search';
}
catch (e) {
Zotero.debug(e, 1);
Components.utils.reportError(e);
}
if (!isSearchBar) {
Zotero.debug('Ignoring keystroke in text field');
return;
}
}
}
catch (e) {
Zotero.debug(e);
}
if (window.ZoteroOverlay) window.ZoteroOverlay.toggleDisplay()
break;
case 'library':
document.getElementById('zotero-collections-tree').focus();
break;
@ -2257,9 +2216,6 @@ var ZoteroPane = new function()
if (found) {
document.getElementById('zotero-items-tree').focus();
}
// open Zotero pane
this.show();
};
@ -4916,18 +4872,8 @@ var ZoteroPane = new function()
this.updateToolbarPosition();
}
/**
* Shows the Zotero pane, making it visible if it is not and switching to the appropriate tab
* if necessary.
*/
this.show = function() {
if(window.ZoteroOverlay) {
if (!this.isShowing()) {
ZoteroOverlay.toggleDisplay();
}
}
}
/**
* Unserializes zotero-persist elements from preferences
*/

View file

@ -211,8 +211,6 @@
<label id="zotero-tb-sync-last-sync"/>
</tooltip>
</toolbarbutton>
<toolbarbutton id="zotero-close-button" class="tabs-closebutton close-icon standalone-no-display" oncommand="ZoteroOverlay.toggleDisplay()"/>
</hbox>
</toolbar>

View file

@ -126,7 +126,6 @@
<!ENTITY zotero.preferences.cite.styles.styleManager.csl "CSL">
<!ENTITY zotero.preferences.export.getAdditionalStyles "Get additional styles…">
<!ENTITY zotero.preferences.keys.openZotero "Open/Close Zotero Pane">
<!ENTITY zotero.preferences.keys.saveToZotero "Save to Zotero (address bar icon)">
<!ENTITY zotero.preferences.keys.toggleFullscreen "Toggle Fullscreen Mode">
<!ENTITY zotero.preferences.keys.focusLibrariesPane "Focus Libraries Pane">

View file

@ -703,15 +703,6 @@
width: 7px;
}
#zotero-splitter
{
border-top: none;
border-bottom: 1px solid #A3A3A3;
min-height: 4px;
max-height: 4px;
background-image: none;
}
#zotero-toolbar
{
visibility: visible !important;

View file

@ -1,7 +1,3 @@
.standalone-no-display {
display: none;
}
#main-window {
min-width: 670px;
min-height: 300px;

View file

@ -76,7 +76,6 @@ pref("extensions.zotero.tagSelector.showAutomatic", true);
pref("extensions.zotero.tagSelector.displayAllTags", false);
// Keyboard shortcuts
pref("extensions.zotero.keys.openZotero", "Z");
pref("extensions.zotero.keys.toggleFullscreen", "F");
pref("extensions.zotero.keys.saveToZotero", "S");
pref("extensions.zotero.keys.newItem", "N");

View file

@ -58,17 +58,24 @@ function loadBrowserWindow() {
*
* @param {Window} [win] - Existing window to use; if not specified, a new window is opened
*/
var loadZoteroPane = Zotero.Promise.coroutine(function* (win) {
var loadZoteroPane = async function (win) {
if (!win) {
var win = yield loadBrowserWindow();
var win = await loadBrowserWindow();
}
Zotero.Prefs.clear('lastViewedFolder');
win.ZoteroOverlay.toggleDisplay(true);
yield waitForItemsLoad(win, 0);
while (true) {
if (win.ZoteroPane && win.ZoteroPane.collectionsView) {
break;
}
Zotero.debug("Waiting for ZoteroPane initialization");
await Zotero.Promise.delay(50);
}
await waitForItemsLoad(win, 0);
return win;
});
};
var loadPrefPane = Zotero.Promise.coroutine(function* (paneName) {
var id = 'zotero-prefpane-' + paneName;