Remove tab mode

Closes #1135
This commit is contained in:
Dan Stillman 2016-12-21 05:01:50 -05:00
parent 405f41f4c2
commit 3b6b6aa36b
14 changed files with 4 additions and 367 deletions

View File

@ -219,11 +219,6 @@ toolbar:not([id="nav-bar"]) #zotero-toolbar-buttons separator {
padding-top: 4px;
}
#zotero-tb-fullscreen {
margin-left: 2px;
margin-right: 5px;
}
#zotero-view-tabbox tab {
padding-left: .7em;
padding-right: .7em;

View File

@ -29,7 +29,7 @@
var ZoteroOverlay = new function()
{
const DEFAULT_ZPANE_HEIGHT = 300;
var toolbarCollapseState, showInPref;
var toolbarCollapseState;
var zoteroPane, zoteroSplitter;
var _stateBeforeReload = false;
@ -119,31 +119,6 @@ var ZoteroOverlay = new function()
throw new Error("Skipping loading");
}
// Open Zotero app tab, if in Fx 4 and requested by pref
showInPref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch('extensions.zotero.').getIntPref('showIn');
this.isTab = showInPref !== 1;
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
var zoteroObserver = function(subject, topic, data) {
if(subject != window) return;
observerService.removeObserver(this, "browser-delayed-startup-finished");
if(showInPref === 3) {
var tabbar = document.getElementById("TabsToolbar");
if(tabbar && window.getComputedStyle(tabbar).display !== "none") {
// load Zotero as a tab, if it isn't loading by default
ZoteroOverlay.loadZoteroTab(true);
}
} else if(showInPref === 1) {
// close Zotero as a tab, in case it was pinned
var zoteroTab = ZoteroOverlay.findZoteroTab();
if(zoteroTab) gBrowser.removeTab(zoteroTab);
}
};
observerService.addObserver(zoteroObserver, "browser-delayed-startup-finished", false);
ZoteroPane.init();
// Clear old Zotero icon pref
@ -264,71 +239,6 @@ var ZoteroOverlay = new function()
}
}
}
/**
* Determines whether there is an open Zotero tab
*/
this.findZoteroTab = function() {
// Look for an existing tab
var tab = false;
var numTabs = gBrowser.browsers.length;
for(var index = 0; index < numTabs; index++) {
var currentBrowser = gBrowser.getBrowserAtIndex(index);
if(ZOTERO_TAB_URL == currentBrowser.currentURI.spec) {
tab = (gBrowser.tabs ? gBrowser.tabs : gBrowser.mTabs)[index];
break;
}
}
return tab;
}
/**
* Loads the Zotero tab, or adds a new tab if no tab yet exists
* @param {Boolean} background Whether the Zotero tab should be loaded in the background
*/
this.loadZoteroTab = function(background) {
var tab = this.findZoteroTab();
// If no existing tab, add a new tab
if(!tab) tab = gBrowser.addTab(ZOTERO_TAB_URL);
// Pin tab
if(showInPref == 3) gBrowser.pinTab(tab);
// If requested, activate tab
if(!background) gBrowser.selectedTab = tab;
}
/**
* Toggle between Zotero as a tab and Zotero as a pane
*/
this.toggleTab = function(setMode) {
var tab = this.findZoteroTab();
window.zoteroSavedCollectionSelection = ZoteroPane.collectionsView.selectedTreeRow.id;
window.zoteroSavedItemSelection = ZoteroPane.itemsView.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
if((gBrowser.tabs ? gBrowser.tabs : gBrowser.mTabs).length === 1) {
gBrowser.addTab(gBrowser.homePage);
}
// swap ZoteroPane object
ZoteroPane = ZoteroPane_Overlay;
// otherwise, close Zotero tab and open Zotero pane
gBrowser.removeTab(tab);
this.isTab = false;
this.toggleDisplay();
} else { // Zotero is running in the pane
if(setMode === false) return;
// close Zotero pane
this.toggleDisplay(false);
// open Zotero tab
this.isTab = true;
this.loadZoteroTab();
}
}
}
window.addEventListener("load", function(e) {

View File

@ -45,7 +45,6 @@
<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-toggleFullscreen" name="extensions.zotero.keys.toggleFullscreen" 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"/>
<preference id="pref-keys-toggleTagSelector" name="extensions.zotero.keys.toggleTagSelector" type="string"/>

View File

@ -55,12 +55,6 @@
<textbox id="textbox-openZotero" maxlength="1" size="1" preference="pref-keys-openZotero"/>
</row>
<row insertbefore="zotero-keys-new-item">
<label value="&zotero.preferences.keys.toggleFullscreen;" control="textbox-toggleFullscreen"/>
<label class="modifier"/>
<textbox id="textbox-toggleFullscreen" maxlength="1" size="1" preference="pref-keys-toggleFullscreen"/>
</row>
<row insertbefore="zotero-keys-new-item">
<label value="&zotero.preferences.keys.saveToZotero;" control="key-textbox-saveToZotero"/>
<label class="modifier"/>

View File

@ -28,28 +28,11 @@
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="zotero-prefpane-general">
<preferences id="zotero-prefpane-general-preferences">
<preference id="pref-showIn" name="extensions.zotero.showIn" type="int"/>
<preference id="pref-launchNonNativeFiles" name="extensions.zotero.launchNonNativeFiles" type="bool"/>
<preference id="pref-parseEndNoteMIMETypes"
name="extensions.zotero.parseEndNoteMIMETypes"
type="bool" onchange="Zotero.MIMETypeHandler.init()"/>
</preferences>
<groupbox id="zotero-prefpane-general-groupbox">
<grid id="zotero-prefpane-general-grid">
<rows id="zotero-prefpane-general-rows">
<row position="1">
<hbox align="center">
<label value="&zotero.preferences.showIn;" control="showAs"/>
</hbox>
<radiogroup id="showIn" orient="horizontal" preference="pref-showIn">
<radio id="zotero-prefpane-general-showIn-browserPane" label="&zotero.preferences.showIn.browserPane;" value="1"/>
<radio id="zotero-prefpane-general-showIn-separateTab" label="&zotero.preferences.showIn.separateTab;" value="2"/>
<radio id="zotero-prefpane-general-showIn-appTab" label="&zotero.preferences.showIn.appTab;" value="3"/>
</radiogroup>
</row>
</rows>
</grid>
</groupbox>
<groupbox id="zotero-prefpane-miscellaneous-groupbox">
<checkbox id="launchNonNativeFiles-checkbox"
preference="pref-launchNonNativeFiles"

View File

@ -1,139 +0,0 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2009 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
/*
* This object contains the various functions for the interface
*/
var ZoteroTab = new function()
{
this.onLoad = function() {
var me = this;
// find window this tab is loaded in
this.containerWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell)
.chromeEventHandler.ownerDocument.defaultView;
if(!this.containerWindow) return;
var tabs = (this.containerWindow.gBrowser.tabs
? this.containerWindow.gBrowser.tabs : this.containerWindow.gBrowser.mTabs);
// loop over all browsers in this window
for(var i=0; i<this.containerWindow.gBrowser.browsers.length; i++) {
var currentBrowser = this.containerWindow.gBrowser.browsers[i];
if(currentBrowser.contentWindow == window) {
// find containerBrowser and containerTab
this.containerBrowser = currentBrowser;
this.containerTab = tabs[i];
continue;
}
// if we somehow ended up with other Zotero tabs in the window, close them
if(currentBrowser && ZOTERO_TAB_URL == currentBrowser.currentURI.spec) {
this.containerWindow.gBrowser.removeTab(tabs[i]);
}
}
// stop drop events from propagating
this.containerBrowser.addEventListener("drop", _dropPropagationKiller, false);
// initialize ZoteroPane and swap out old window ZoteroPane object
if(this.containerWindow.ZoteroPane) {
this._swapZoteroPane();
} else {
this.containerWindow.addEventListener("load", function() { this._swapZoteroPane() }, false);
}
// get tab for browser
if(this.containerWindow.gBrowser.selectedTab === this.containerTab) {
// if tab is already selected, init now
ZoteroPane.init();
ZoteroPane.makeVisible();
} else {
// otherwise, add a handler to wait until this tab is selected
var listener = function(event) {
if(event.target !== me.containerTab) return;
me.containerWindow.gBrowser.tabContainer.removeEventListener("TabSelect", listener, false);
ZoteroPane.init();
ZoteroPane.makeVisible();
}
this.containerWindow.gBrowser.tabContainer.addEventListener("TabSelect", listener, false);
}
if(Zotero && Zotero.Prefs.get("showIn") != 2) {
// on Fx 4, add an event listener so the pinned tab isn't restored on close
var pinnedTabCloser = function() {
try {
me.containerWindow.gBrowser.removeTab(me.containerTab);
} catch(e) {}
}
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(pinnedTabCloser, "quit-application-requested", false);
this.containerWindow.addEventListener("close", pinnedTabCloser, false);
}
}
this._swapZoteroPane = function() {
if(!this.containerWindow.ZoteroOverlay.isTab) {
var tabs = (this.containerWindow.gBrowser.tabs
? this.containerWindow.gBrowser.tabs : this.containerWindow.gBrowser.mTabs);
if(tabs.length > 1) {
window.close();
} else {
if(tabs[0].pinned) this.containerWindow.gBrowser.unpinTab(tabs[0]);
document.location.replace(this.containerWindow.gHomeButton.getHomePage());
}
return;
}
this.containerWindow.ZoteroPane_Overlay = this.containerWindow.ZoteroPane;
this.containerWindow.ZoteroPane_Tab = ZoteroPane;
this.containerWindow.ZoteroPane = ZoteroPane;
}
this.onUnload = function() {
// remove drop propagation killer
this.containerBrowser.removeEventListener("drop", _dropPropagationKiller, false);
// replace window ZoteroPane
if(this.containerWindow.ZoteroPane === this.containerWindow.ZoteroPane_Tab) {
this.containerWindow.ZoteroPane = this.containerWindow.ZoteroPane_Overlay;
}
delete this.containerWindow.ZoteroPane_Tab;
// destroy pane
ZoteroPane.destroy();
}
function _dropPropagationKiller(event) {
event.stopPropagation();
event.preventDefault();
}
}
window.addEventListener("load", function(e) { ZoteroTab.onLoad(e); }, false);
window.addEventListener("unload", function(e) { ZoteroTab.onUnload(e); }, false);

View File

@ -1,66 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/tab.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/tab.css" type="text/css"?>
<?xul-overlay href="chrome://zotero/content/zoteroPane.xul"?>
<?xul-overlay href="chrome://zotero/content/itemPane.xul"?>
<!DOCTYPE window [
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
%textcontextDTD;
<!ENTITY % standaloneDTD SYSTEM "chrome://zotero/locale/standalone.dtd" >
%standaloneDTD;
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD;
]>
<page id="zotero-tab" title="Zotero" role="application"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xhtml="http://www.w3.org/1999/xhtml" disablefastfind="true"
flex="1">
<script type="application/javascript" src="tab.js"/>
<script type="application/javascript"
src="chrome://global/content/contentAreaUtils.js"/>
<xhtml:link rel="shortcut icon"
href="chrome://zotero/skin/zotero-new-z-16px.png" style="display:none"/>
<popup id="contentAreaContextMenu">
<menuitem id="context-undo"
label="&undoCmd.label;"
accesskey="&undoCmd.accesskey;"
command="cmd_undo"/>
<menuseparator id="context-sep-undo"/>
<menuitem id="context-cut"
label="&cutCmd.label;"
accesskey="&cutCmd.accesskey;"
command="cmd_cut"/>
<menuitem id="context-copy"
label="&copyCmd.label;"
accesskey="&copyCmd.accesskey;"
command="cmd_copy"/>
<menuitem id="context-paste"
label="&pasteCmd.label;"
accesskey="&pasteCmd.accesskey;"
command="cmd_paste"/>
<menuitem id="context-delete"
label="&deleteCmd.label;"
accesskey="&deleteCmd.accesskey;"
command="cmd_delete"/>
<menuseparator id="context-sep-paste"/>
<menuitem id="context-selectall"
label="&selectAllCmd.label;"
accesskey="&selectAllCmd.accesskey;"
command="cmd_selectAll"/>
</popup>
<commandset id="mainCommandSet"/>
<hbox flex="1" id="browser">
<vbox id="appcontent" flex="1">
<stack id="zotero-pane-stack" fullscreenmode="true" flex="1"/>
</vbox>
</hbox>
<keyset id="mainKeyset"/>
</page>

View File

@ -22,7 +22,6 @@
***** END LICENSE BLOCK *****
*/
const ZOTERO_TAB_URL = "chrome://zotero/content/tab.xul";
/*
* This object contains the various functions for the interface
@ -395,7 +394,8 @@ var ZoteroPane = new function()
this.updateTagSelectorSize();
// restore saved row selection (for tab switching)
var containerWindow = (window.ZoteroTab ? window.ZoteroTab.containerWindow : window);
// TODO: Remove now that no tab mode?
var containerWindow = window;
if(containerWindow.zoteroSavedCollectionSelection) {
this.collectionsView.addEventListener('load', Zotero.Promise.coroutine(function* () {
yield this.collectionsView.selectByID(containerWindow.zoteroSavedCollectionSelection);
@ -725,9 +725,6 @@ var ZoteroPane = new function()
case 'toggleTagSelector':
ZoteroPane_Local.toggleTagSelector();
break;
case 'toggleFullscreen':
ZoteroPane_Local.toggleTab();
break;
case 'copySelectedItemCitationsToClipboard':
ZoteroPane_Local.copySelectedItemsToClipboard(true)
break;
@ -4713,17 +4710,6 @@ var ZoteroPane = new function()
}
}
/**
* Toggles Zotero-as-a-tab by passing off the request to the ZoteroOverlay object associated
* with the present window
*/
this.toggleTab = function() {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var browserWindow = wm.getMostRecentWindow("navigator:browser");
if(browserWindow.ZoteroOverlay) browserWindow.ZoteroOverlay.toggleTab();
}
/**
* Sets the layout to either a three-vertical-pane layout and a layout where itemsPane is above itemPane
*/
@ -4747,9 +4733,7 @@ var ZoteroPane = new function()
*/
this.show = function() {
if(window.ZoteroOverlay) {
if(ZoteroOverlay.isTab) {
ZoteroOverlay.loadZoteroTab();
} else if(!this.isShowing()) {
if (!this.isShowing()) {
ZoteroOverlay.toggleDisplay();
}
}

View File

@ -248,9 +248,7 @@
<label id="zotero-tb-sync-last-sync"/>
</tooltip>
</toolbarbutton>
<toolbarseparator id="zotero-fullscreen-close-separator" class="standalone-no-display"/>
<toolbarbutton id="zotero-tb-fullscreen" tooltiptext="&zotero.toolbar.tab.tooltip;" oncommand="ZoteroPane_Local.toggleTab();" class="zotero-tb-button standalone-no-display"/>
<toolbarbutton id="zotero-close-button" class="tabs-closebutton close-icon standalone-no-display" oncommand="ZoteroOverlay.toggleDisplay()"/>
</hbox>
</toolbar>

View File

@ -8,10 +8,6 @@
<!ENTITY zotero.preferences.prefpane.general "General">
<!ENTITY zotero.preferences.userInterface "User Interface">
<!ENTITY zotero.preferences.showIn "Load Zotero in:">
<!ENTITY zotero.preferences.showIn.browserPane "Browser pane">
<!ENTITY zotero.preferences.showIn.separateTab "Separate tab">
<!ENTITY zotero.preferences.showIn.appTab "App tab">
<!ENTITY zotero.preferences.layout "Layout:">
<!ENTITY zotero.preferences.layout.standard "Standard">
<!ENTITY zotero.preferences.layout.stacked "Stacked">

View File

@ -123,7 +123,6 @@
<!ENTITY zotero.toolbar.supportAndDocumentation "Support and Documentation">
<!ENTITY zotero.toolbar.about.label "About Zotero">
<!ENTITY zotero.toolbar.advancedSearch "Advanced Search">
<!ENTITY zotero.toolbar.tab.tooltip "Toggle Tab Mode">
<!ENTITY zotero.toolbar.openURL.label "Locate">
<!ENTITY zotero.toolbar.openURL.tooltip "Find through your local library">

View File

@ -612,16 +612,6 @@
color: gray;
}
#zotero-tb-fullscreen
{
list-style-image: url('chrome://zotero/skin/toolbar-fullscreen-bottom.png');
}
#zotero-pane-stack[fullscreenmode="true"] #zotero-tb-fullscreen
{
list-style-image: url('chrome://zotero/skin/toolbar-fullscreen-top.png');
}
#zotero-tb-search
{
font-size: 11px !important;

View File

@ -73,11 +73,6 @@ grid row hbox:first-child
}
#showIn radio
{
width: 120px;
}
#fontSize radio
{
margin-right: 20px;

View File

@ -25,7 +25,6 @@ pref("extensions.zotero.triggerProxyAuthentication", true);
// Proxy auth URLs should respond successfully to HEAD requests over HTTP and HTTPS (in case of forced HTTPS requests)
pref("extensions.zotero.proxyAuthenticationURLs", 'http://www.acm.org,http://www.ebscohost.com,http://www.elsevier.com,http://www.ieee.org,http://www.jstor.org,http://www.ovid.com,http://www.springer.com,http://www.tandfonline.com');
pref("extensions.zotero.cacheTranslatorData",true);
pref("extensions.zotero.showIn", 1);
pref("extensions.zotero.browserContentContextMenu", true);
pref("extensions.zotero.openURL.resolver","http://worldcatlibraries.org/registry/gateway");
pref("extensions.zotero.openURL.version","1.0");