diff --git a/chrome.manifest b/chrome.manifest
index ded1a374b9b..7c64f1edba6 100644
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -58,17 +58,7 @@ skin zotero default chrome/skin/default/zotero/
overlay chrome://browser/content/browser.xul chrome://zotero/content/overlay.xul
-overlay chrome://zotero/content/preferences/preferences.xul chrome://zotero/content/preferences/preferences_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
-overlay chrome://zotero/content/preferences/preferences.xul#cite chrome://zotero/content/preferences/preferences_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
-overlay chrome://zotero/content/preferences/preferences_general.xul chrome://zotero/content/preferences/preferences_general_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
-overlay chrome://zotero/content/preferences/preferences_export.xul chrome://zotero/content/preferences/preferences_export_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
-overlay chrome://zotero/content/preferences/preferences_keys.xul chrome://zotero/content/preferences/preferences_keys_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
-overlay chrome://zotero/content/preferences/preferences_advanced.xul chrome://zotero/content/preferences/preferences_advanced_firefox.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
-
-overlay chrome://mozapps/content/downloads/unknownContentType.xul chrome://zotero/content/downloadOverlay.xul
-
style chrome://browser/content/browser.xul chrome://zotero/skin/zotero.css
-style chrome://global/content/customizeToolbar.xul chrome://zotero/skin/zotero.css
component {e4c61080-ec2d-11da-8ad9-0800200c9a66} components/zotero-service.js
component {531828f8-a16c-46be-b9aa-14845c3b010f} components/zotero-service.js
diff --git a/chrome/content/zotero-platform/mac/overlay.css b/chrome/content/zotero-platform/mac/overlay.css
index 40b88901622..e2bb79e24fd 100644
--- a/chrome/content/zotero-platform/mac/overlay.css
+++ b/chrome/content/zotero-platform/mac/overlay.css
@@ -1,94 +1,3 @@
-/*
- As of Fx36, the built-in Mac styles don't properly handle a menu-button within a combined
- button, so we need this ungodly mess.
-*/
-#zotero-toolbar-buttons[cui-areatype="toolbar"] > separator,
-#zotero-toolbar-save-button[cui-areatype="toolbar"]:not(:hover) > .toolbarbutton-menubutton-dropmarker::before,
-#zotero-toolbar-buttons[cui-areatype="toolbar"]:hover > #zotero-toolbar-save-button {
- box-shadow: none;
-}
-
-#zotero-toolbar-save-button[cui-areatype="toolbar"] {
- border: 0;
-}
-
-#zotero-toolbar-main-button[cui-areatype="toolbar"] {
- margin-right: 0;
- border-top-right-radius: 0;
- border-bottom-right-radius: 0;
- padding-right: 2px;
- padding-left: 2px;
-}
-
-#zotero-toolbar-save-button[cui-areatype="toolbar"] {
- margin-left: -1px;
- border-top-left-radius: 0;
- border-bottom-left-radius: 0;
- border-left: 0 solid transparent;
-}
-
-#zotero-toolbar-save-button[cui-areatype="toolbar"] > .toolbarbutton-menubutton-button {
- min-width: 27px;
- padding-left: 1px;
- padding-right: 1px;
-}
-
-/*
- * Recreate standard hover effect (except in overflow list)
- */
-#zotero-toolbar-buttons[cui-areatype="toolbar"]:not([overflowedItem=true]):hover > #zotero-toolbar-save-button > .toolbarbutton-menubutton-button,
-#zotero-toolbar-buttons[cui-areatype="toolbar"]:not([overflowedItem=true]):hover > #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker {
- border-width: 1px;
- border-style: solid;
- border-color: var(--toolbarbutton-hover-bordercolor) !important;
- box-shadow: var(--toolbarbutton-hover-boxshadow) !important;
- border-top-left-radius: 0;
- border-bottom-left-radius: 0;
-}
-
-#zotero-toolbar-buttons[cui-areatype="toolbar"]:not([overflowedItem=true]):hover > #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker::before {
- background: none;
-}
-
-#zotero-toolbar-buttons[cui-areatype="toolbar"]:not([overflowedItem=true]):hover > #zotero-toolbar-save-button > .toolbarbutton-menubutton-button {
- border-right: 1px solid transparent;
-}
-
-#zotero-toolbar-buttons[cui-areatype="toolbar"]:not([overflowedItem=true]):hover > #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker {
- border-left: 1px solid transparent;
-}
-
-#zotero-toolbar-buttons[cui-areatype="toolbar"]:not([overflowedItem=true]):hover > .toolbarbutton-menubutton-dropmarker {
- background: inherit;
-}
-
-#zotero-toolbar-save-button[cui-areatype="toolbar"]:not([overflowedItem=true]) > .toolbarbutton-menubutton-dropmarker:hover {
- background: var(--toolbarbutton-hover-background);
-}
-
-#zotero-toolbar-main-button[cui-areatype="toolbar"] {
- border-right: 1px solid transparent;
-}
-#zotero-toolbar-save-button[cui-areatype="toolbar"]:not([overflowedItem=true]):hover {
- border-left: 0 solid transparent;
-}
-#zotero-toolbar-buttons[cui-areatype="toolbar"]:not([overflowedItem=true]):hover > #zotero-toolbar-save-button > .toolbarbutton-menubutton-button {
- border-left: 1px solid transparent;
-}
-
-/*
- * Alterations for overflow menu
- */
-#zotero-toolbar-buttons[overflowedItem=true] {
- margin: 6px 4px 0;
-}
-
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-main-button {
- max-width: 16px;
-}
-
-/* End toolbar icons */
-
#zotero-splitter
{
border-top: none;
@@ -474,11 +383,6 @@ treechildren::-moz-tree-image {
list-style-image: url('chrome://zotero/skin/mac/toolbar-note-add.png');
}
-#zotero-tb-actions-menu
-{
- list-style-image: url('chrome://zotero/skin/mac/cog.png');
-}
-
#zotero-collectionmenu > .menuitem-iconic, #zotero-itemmenu > .menuitem-iconic, #zotero-collectionmenu > .menu-iconic, #zotero-itemmenu > .menu-iconic {
padding-top: 0px !important;
padding-bottom: 2px !important;
diff --git a/chrome/content/zotero-platform/unix/overlay.css b/chrome/content/zotero-platform/unix/overlay.css
index f4bff14f362..5fb28ea65ab 100644
--- a/chrome/content/zotero-platform/unix/overlay.css
+++ b/chrome/content/zotero-platform/unix/overlay.css
@@ -1,159 +1,3 @@
-/*
- As of Fx36, the built-in styles don't properly handle a menu-button within combined buttons.
-
- On Windows and Linux, the padding and hover effect (border and shading) are applied directly to
- the .toolbarbutton-icon (image) instead of the toolbarbutton, so proper sizing of the SVG depends
- on the total width including border and padding.
-*/
-
-/*
- * Nav bar
- */
-toolbar[id="nav-bar"] #zotero-toolbar-main-button .toolbarbutton-icon {
- width: 28px;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button .toolbarbutton-icon {
- width: 30px;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons #zotero-toolbar-main-button {
- margin-right: -1px;
- padding: 0; /* avoid shift on :active */
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-main-button .toolbarbutton-icon {
- margin-left: 2px;
- padding-left: 5px !important;
- padding-right: 5px !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button > .toolbarbutton-menubutton-button {
- padding-left: 0;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button > .toolbarbutton-menubutton-button .toolbarbutton-icon {
- padding-left: 6px !important;
- padding-right: 6px !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker {
- width: 18px !important;
- margin-top: 6px;
- margin-bottom: 6px;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker .dropmarker-icon {
- padding-left: 14px !important;
- padding-right: 3px !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button-single > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
- margin-top: 3px;
- margin-bottom: 3px;
- padding-left: 8px !important;
- padding-right: 8px !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button:hover > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-save-button[open] > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
- margin-top: 0;
- margin-bottom: 0;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button-single > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
- margin-top: 3px;
- margin-bottom: 3px;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > separator {
- /* Copied from .toolbarbutton-menubutton-dropmarker::before */
- display: -moz-box;
- width: 1px;
- height: 18px;
- -moz-margin-end: -1px;
- background-clip: padding-box;
- background-position: center;
- background-repeat: no-repeat;
- background-size: 1px 18px;
- box-shadow: var(--toolbarbutton-combined-boxshadow);
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-main-button .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-save-button .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-save-button .dropmarker-icon {
- border-color: var(--toolbarbutton-hover-bordercolor) !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > #zotero-toolbar-save-button:hover:not(:active) > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > #zotero-toolbar-save-button:hover > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
- background: inherit;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > #zotero-toolbar-save-button > .toolbarbutton-menubutton-button:hover:not(:active) > .toolbarbutton-icon,
-/* This selector doesn't work, so the dropmarker doesn't get a hover effect. :hover doesn't seem
- to have an effect on either part of the dropmarker */
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker:hover > .dropmarker-icon {
- background: var(--toolbarbutton-hover-background) !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > #zotero-toolbar-save-button:hover:active:not([open]):not([disabled]) .toolbarbutton-menubutton-button .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > #zotero-toolbar-save-button:hover[open]:not([disabled]) .toolbarbutton-menubutton-dropmarker .dropmarker-icon {
- background: var(--toolbarbutton-active-background);
- border-color: var(--toolbarbutton-active-bordercolor);
- box-shadow: var(--toolbarbutton-active-boxshadow);
- transition-duration: 10ms;
-}
-
-
-/*
- * Alterations for non-nav-bar toolbars
- */
-toolbar:not([id="nav-bar"]) #zotero-toolbar-main-button > .toolbarbutton-icon,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-main-button-single > .toolbarbutton-icon,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button-single > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
- height: 16px;
- width: 16px;
- padding: 0;
-}
-
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button-single > .toolbarbutton-menubutton-dropmarker {
- margin-left: -1px;
-}
-
-toolbar:not([id="nav-bar"]) #zotero-toolbar-buttons separator {
- display: none;
-}
-
-
-/* Alterations for overflow panel */
-#zotero-toolbar-main-button-single[overflowedItem=true] .toolbarbutton-icon,
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-main-button .toolbarbutton-icon,
-#zotero-toolbar-save-button-single[overflowedItem=true] .toolbarbutton-icon,
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-save-button .toolbarbutton-icon {
- width: 16px;
-}
-
-#zotero-toolbar-buttons[overflowedItem=true] {
- margin-left: 0 !important;
- margin-bottom: 0 !important;
- margin-right: 0 !important;
- padding: 0 !important;
-}
-
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-main-button {
- max-width: 28px !important;
- margin: 0 4px 0 0 !important;
-}
-
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-save-button .toolbarbutton-menubutton-button {
- margin-left: 8px;
-}
-/* End toolbar buttons */
-
-
/*
Override selected, unfocused tree row highlight color, which is too similar to the alternating
row color by default
diff --git a/chrome/content/zotero-platform/win/overlay.css b/chrome/content/zotero-platform/win/overlay.css
index 0aa17feb820..05b28fb4678 100644
--- a/chrome/content/zotero-platform/win/overlay.css
+++ b/chrome/content/zotero-platform/win/overlay.css
@@ -13,183 +13,6 @@
border-bottom-color: var(--theme-border-color);
}
-/*
- As of Fx36, the built-in styles don't properly handle a menu-button within combined buttons.
-
- On Windows and Linux, the padding and hover effect (border and shading) are applied directly to
- the .toolbarbutton-icon (image) instead of the toolbarbutton, so proper sizing of the SVG depends
- on the total width including border and padding.
-*/
-
-/*
- * Nav bar
- */
-toolbar[id="nav-bar"] #zotero-toolbar-main-button .toolbarbutton-icon {
- width: 30px; /* 16 + 1 + 1 + 6 + 6 */
- padding-left: 6px !important;
- padding-right: 6px !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button .toolbarbutton-icon {
- width: 29px; /* 16 + 6 + 6 + 1 */
- padding-left: 6px !important;
- padding-right: 6px !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-main-button-single .toolbarbutton-icon {
- width: 32px;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button-single .toolbarbutton-icon {
- width: 31px; /* Compensate for border on only one side */
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker .dropmarker-icon {
- padding-left: 4px;
- padding-right: 4px;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > separator {
- margin-top: 11px;
- margin-bottom: 11px;
- -moz-margin-start: -1px !important;
- -moz-margin-end: -3px !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > separator,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker::before {
- width: 1px;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons > #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker::before {
- -moz-margin-end: -1px;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > separator,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-save-button:not([disabled]) > .toolbarbutton-menubutton-dropmarker::before {
- background-image: none;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-main-button .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-save-button:not([disabled]) .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-save-button:not([disabled]) .dropmarker-icon {
- border-color: var(--toolbarbutton-hover-bordercolor) !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-main-button:not(:active) .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover:not([disabled]) > #zotero-toolbar-save-button:not(:active) .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover:not([disabled]) > #zotero-toolbar-save-button:not(:active) .dropmarker-icon {
- background: var(--toolbarbutton-hover-background);
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-save-button .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-save-button .dropmarker-icon {
- box-shadow: none;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-main-button .toolbarbutton-icon {
- border-top-right-radius: 0px !important;
- border-bottom-right-radius: 0px !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-buttons:hover > #zotero-toolbar-save-button .toolbarbutton-icon {
- border-top-left-radius: 0px !important;
- border-bottom-left-radius: 0px !important;
-}
-
-/*
- There are two hover effects: when the toolbaritem is hovered over, and when the button is hovered over.
- This applies the latter (and may not be right on different versions of Windows).
-*/
-toolbar[id="nav-bar"] #zotero-toolbar-main-button:hover:not(:active):not([disabled]) > .toolbarbutton-icon,
-/*
- The dropmarker doesn't honor :hover, so instead of showing the hover effect for each segment individually, do the
- menu-button parts together, which at least looks like a choice.
-*/
-toolbar[id="nav-bar"] #zotero-toolbar-save-button:hover .toolbarbutton-menubutton-button .toolbarbutton-icon,
-toolbar[id="nav-bar"] > #zotero-toolbar-save-button:hover:not(:active):not([disabled]) .toolbarbutton-menubutton-dropmarker .dropmarker-icon {
- background-color: hsla(210,48%,96%,.75) !important;
-}
-toolbar[id="nav-bar"] #zotero-toolbar-main-button:hover > .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-save-button:hover:not([disabled]) .toolbarbutton-menubutton-button .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-save-button:hover:not([disabled]) .toolbarbutton-menubutton-dropmarker .dropmarker-icon {
- border-color: hsla(210,54%,20%,.3) hsla(210,54%,20%,.35) hsla(210,54%,20%,.4) !important;
- box-shadow: 0 0 1px hsla(210,54%,20%,.03),
- 0 0 2px hsla(210,54%,20%,.1) !important;
-}
-
-toolbar[id="nav-bar"] #zotero-toolbar-save-button:hover:active:not([open]):not([disabled]) .toolbarbutton-menubutton-button .toolbarbutton-icon,
-toolbar[id="nav-bar"] #zotero-toolbar-save-button:hover[open]:not([disabled]) .toolbarbutton-menubutton-dropmarker .dropmarker-icon {
- background: var(--toolbarbutton-active-background) !important;
- border-color: var(--toolbarbutton-active-bordercolor) !important;
- box-shadow: var(--toolbarbutton-active-boxshadow) !important;
- transition-duration: 10ms;
-}
-
-#zotero-toolbar-save-button[cui-areatype="toolbar"] > menupopup,
-#zotero-toolbar-save-button-single[cui-areatype="toolbar"] > menupopup {
- margin-top: -7px;
-}
-
-
-/*
- * Alterations for non-nav-bar toolbars
- */
-toolbar:not([id="nav-bar"]) #zotero-toolbar-main-button > .toolbarbutton-icon,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-main-button-single > .toolbarbutton-icon,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button-single > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
- height: 16px;
- width: 16px;
- padding: 0;
-}
-
-toolbar:not([id="nav-bar"]) #zotero-toolbar-main-button-single,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button-single > .toolbarbutton-menubutton-button,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button > .toolbarbutton-menubutton-button {
- width: 24px;
-}
-
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button > .toolbarbutton-menubutton-dropmarker,
-toolbar:not([id="nav-bar"]) #zotero-toolbar-save-button-single > .toolbarbutton-menubutton-dropmarker {
- padding-left: 2px;
- padding-right: 3px;
-}
-
-toolbar:not([id="nav-bar"]) #zotero-toolbar-buttons separator {
- display: none;
-}
-
-
-/*
- * Alterations for overflow panel
- */
-#zotero-toolbar-main-button-single[overflowedItem=true] .toolbarbutton-icon,
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-main-button .toolbarbutton-icon,
-#zotero-toolbar-save-button-single[overflowedItem=true] .toolbarbutton-icon,
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-save-button .toolbarbutton-icon {
- height: 16px;
-}
-
-#zotero-toolbar-buttons[overflowedItem=true] {
- margin: 6px 0 0 0 !important;
-}
-
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-main-button {
- max-width: 18px;
-}
-
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-save-button toolbarbutton {
- margin-left: 0 !important;
-}
-
-#zotero-toolbar-buttons[overflowedItem=true] #zotero-toolbar-save-button .toolbarbutton-icon {
- margin-left: 8px;
- padding-right: 0 !important;
-}
-
-/* End toolbar buttons */
-
@media (min-resolution: 1.25dppx) {
#zotero-toolbar .toolbarbutton-icon {
diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js
deleted file mode 100644
index a2ac94f8a6b..00000000000
--- a/chrome/content/zotero/browser.js
+++ /dev/null
@@ -1,1036 +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 .
-
-
- Based on code from Greasemonkey and PiggyBank
-
- ***** END LICENSE BLOCK *****
-*/
-
-//
-// Zotero Ingester Browser Functions
-//
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Zotero_Browser
-//
-//////////////////////////////////////////////////////////////////////////////
-
-// Class to interface with the browser when ingesting data
-
-var Zotero_Browser = new function() {
- this.init = init;
- this.annotatePage = annotatePage;
- this.toggleMode = toggleMode;
- this.toggleCollapsed = toggleCollapsed;
- this.chromeLoad = chromeLoad;
- this.itemUpdated = itemUpdated;
- this.tabClose = tabClose;
- this.resize = resize;
-
- this.tabbrowser = null;
- this.appcontent = null;
- this.isScraping = false;
-
- var _browserData = new WeakMap();
- var _attachmentsMap = new WeakMap();
- var _detectCallbacks = [];
-
- var _blacklist = [
- "googlesyndication.com",
- "doubleclick.net",
- "questionmarket.com",
- "atdmt.com",
- "aggregateknowledge.com",
- "ad.yieldmanager.com"
- ];
-
- var _locationBlacklist = [
- "zotero://debug/"
- ];
-
- var tools = {
- 'zotero-annotate-tb-add':{
- cursor:"pointer",
- event:"click",
- callback:function(e) { _add("annotation", e) }
- },
- 'zotero-annotate-tb-highlight':{
- cursor:"text",
- event:"mouseup",
- callback:function(e) { _add("highlight", e) }
- },
- 'zotero-annotate-tb-unhighlight':{
- cursor:"text",
- event:"mouseup",
- callback:function(e) { _add("unhighlight", e) }
- }
- };
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // Public Zotero_Browser methods
- //
- //////////////////////////////////////////////////////////////////////////////
-
-
- /**
- * Initialize some variables and prepare event listeners for when chrome is done loading
- */
- function init() {
- // No gBrowser - running in standalone
- if (!window.hasOwnProperty("gBrowser")) {
- return;
- }
-
- var zoteroInitDone;
- if (!Zotero || Zotero.skipLoading) {
- // Zotero either failed to load or is reloading in Connector mode
- // In case of the latter, listen for the 'zotero-loaded' event (once) and retry
- var zoteroInitDone_deferred = Zotero.Promise.defer();
- var obs = Components.classes["@mozilla.org/observer-service;1"]
- .getService(Components.interfaces.nsIObserverService);
- var observer = {
- "observe":function() {
- obs.removeObserver(observer, 'zotero-loaded')
- zoteroInitDone_deferred.resolve();
- }
- };
- obs.addObserver(observer, 'zotero-loaded', false);
-
- zoteroInitDone = zoteroInitDone_deferred.promise;
- } else {
- zoteroInitDone = Zotero.Promise.resolve();
- }
-
- var chromeLoaded = Zotero.Promise.defer();
- window.addEventListener("load", function(e) { chromeLoaded.resolve() }, false);
-
- // Wait for Zotero to init and chrome to load before proceeding
- Zotero.Promise.all([
- zoteroInitDone.then(function() {
- ZoteroPane_Local.addReloadListener(reload);
- reload();
- }),
- chromeLoaded.promise
- ])
- .then(function() {
- Zotero_Browser.chromeLoad()
- });
- }
-
- /**
- * Called when Zotero is reloaded
- */
- function reload() {
- // Handles the display of a div showing progress in scraping
- Zotero_Browser.progress = new Zotero.ProgressWindow();
- }
-
- /**
- * Saves from current page using translator (called when the capture icon is clicked)
- *
- * @param {String} [translator]
- * @param {Event} [event]
- * @return {Promise}
- */
- this.scrapeThisPage = Zotero.Promise.coroutine(function* (translator, event) {
- // Perform translation
- var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser);
- var page = tab.getPageObject();
- if(page.translators && page.translators.length) {
- page.translate.setTranslator(translator || page.translators[0]);
- yield Zotero_Browser.performTranslation(page.translate);
- }
- else {
- yield this.saveAsWebPage(
- (event && event.shiftKey) ? !Zotero.Prefs.get('automaticSnapshots') : null
- );
- }
- });
-
- /**
- * Keep in sync with cmd_zotero_newItemFromCurrentPage
- *
- * @return {Promise}
- */
- this.saveAsWebPage = function (includeSnapshots) {
- // DEBUG: Possible to just trigger command directly with event? Assigning it to the
- // command property of the icon doesn't seem to work, and neither does goDoCommand()
- // from chrome://global/content/globalOverlay.js. Getting the command by id and
- // running doCommand() works but doesn't pass the event.
- return ZoteroPane.addItemFromPage('temporaryPDFHack', includeSnapshots);
- }
-
- /*
- * flags a page for annotation
- */
- function annotatePage(id, browser) {
- if (browser) {
- var tab = _getTabObject(browser);
- }
- else {
- var tab = _getTabObject(this.tabbrowser.selectedBrowser);
- }
- }
-
- /*
- * toggles a tool on/off
- */
- function toggleMode(toggleTool, ignoreOtherTools) {
- // make sure other tools are turned off
- if(!ignoreOtherTools) {
- for(var tool in tools) {
- if(tool != toggleTool && document.getElementById(tool).getAttribute("tool-active")) {
- toggleMode(tool, true);
- }
- }
- }
-
- // make sure annotation action is toggled
- var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser);
- var page = tab.getPageObject();
- if(page && page.annotations && page.annotations.clearAction) page.annotations.clearAction();
-
- if(!toggleTool) return;
-
- var body = Zotero_Browser.tabbrowser.selectedBrowser.contentDocument.getElementsByTagName("body")[0];
- var addElement = document.getElementById(toggleTool);
-
- if(addElement.getAttribute("tool-active")) {
- // turn off
- body.style.cursor = "auto";
- addElement.removeAttribute("tool-active");
- Zotero_Browser.tabbrowser.selectedBrowser.removeEventListener(tools[toggleTool].event, tools[toggleTool].callback, true);
- } else {
- body.style.cursor = tools[toggleTool].cursor;
- addElement.setAttribute("tool-active", "true");
- Zotero_Browser.tabbrowser.selectedBrowser.addEventListener(tools[toggleTool].event, tools[toggleTool].callback, true);
- }
- }
-
- /*
- * expands all annotations
- */
- function toggleCollapsed() {
- var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser);
- tab.getPageObject().annotations.toggleCollapsed();
- }
-
- /*
- * When chrome loads, register our event handlers with the appropriate interfaces
- */
- function chromeLoad() {
- this.tabbrowser = gBrowser;
- this.appcontent = document.getElementById("appcontent");
-
- // this gives us onLocationChange, for updating when tabs are switched/created
- gBrowser.tabContainer.addEventListener("TabClose",
- function(e) {
- //Zotero.debug("TabClose");
- Zotero_Browser.tabClose(e);
- }, false);
- gBrowser.tabContainer.addEventListener("TabSelect",
- function(e) {
- //Zotero.debug("TabSelect");
- // Note: async
- Zotero_Browser.updateStatus();
- }, false);
- // this is for pageshow, for updating the status of the book icon
- this.appcontent.addEventListener("pageshow", contentLoad, true);
- // this is for turning off the book icon when a user navigates away from a page
- this.appcontent.addEventListener("pagehide",
- function(e) {
- //Zotero.debug("pagehide");
- Zotero_Browser.contentHide(e);
- }, true);
-
- this.tabbrowser.addEventListener("resize",
- function(e) { Zotero_Browser.resize(e) }, false);
- // Resize on text zoom changes
-
- var reduce = document.getElementById('cmd_fullZoomReduce');
- var enlarge = document.getElementById('cmd_fullZoomEnlarge');
- var reset = document.getElementById('cmd_fullZoomReset');
-
- if(reduce) reduce.addEventListener("command",
- function(e) { Zotero_Browser.resize(e) }, false);
- if(enlarge) enlarge.addEventListener("command",
- function(e) { Zotero_Browser.resize(e) }, false);
- if(reset) reset.addEventListener("command",
- function(e) { Zotero_Browser.resize(e) }, false);
- }
-
-
- /*
- * An event handler called when a new document is loaded. Creates a new document
- * object, and updates the status of the capture icon
- */
- var contentLoad = function (event) {
- var doc = event.originalTarget;
- var isHTML = doc instanceof HTMLDocument;
- var rootDoc = (doc instanceof HTMLDocument ? doc.defaultView.top.document : doc);
- var browser = Zotero_Browser.tabbrowser.getBrowserForDocument(rootDoc);
- if(!browser) return;
-
- if(isHTML) {
- // ignore blacklisted domains
- try {
- if(doc.domain) {
- for (let i = 0; i < _blacklist.length; i++) {
- let blacklistedURL = _blacklist[i];
- if(doc.domain.substr(doc.domain.length-blacklistedURL.length) == blacklistedURL) {
- Zotero.debug("Ignoring blacklisted URL "+doc.location);
- return;
- }
- }
- }
- }
- catch (e) {}
- }
-
- try {
- if (_locationBlacklist.indexOf(doc.location.href) != -1) {
- return;
- }
-
- // Ignore TinyMCE popups
- if (!doc.location.host && doc.location.href.indexOf("tinymce/") != -1) {
- return;
- }
- }
- catch (e) {}
-
- // get data object
- var tab = _getTabObject(browser);
-
- if(isHTML && !Zotero.isConnector) {
- var annotationID = Zotero.Annotate.getAnnotationIDFromURL(browser.currentURI.spec);
- if(annotationID) {
- if(Zotero.Annotate.isAnnotated(annotationID)) {
- //window.alert(Zotero.getString("annotations.oneWindowWarning"));
- } else {
- var page = tab.getPageObject();
- if(!page.annotations) {
- // enable annotation
- page.annotations = new Zotero.Annotations(Zotero_Browser, browser, annotationID);
- var saveAnnotations = function() {
- page.annotations.save();
- page.annotations = undefined;
- };
- browser.contentWindow.addEventListener('beforeunload', saveAnnotations, false);
- browser.contentWindow.addEventListener('close', saveAnnotations, false);
- page.annotations.load();
- }
- }
- }
- }
-
- // detect translators
- tab.detectTranslators(rootDoc, doc);
-
- // register metadata updated event
- if(isHTML) {
- var contentWin = doc.defaultView;
- if(!contentWin.haveZoteroEventListener) {
- contentWin.addEventListener("ZoteroItemUpdated", function(event) { itemUpdated(event.originalTarget) }, false);
- contentWin.haveZoteroEventListener = true;
- }
- }
- };
-
- /*
- * called to unregister Zotero icon, etc.
- */
- this.contentHide = function (event) {
- var doc = event.originalTarget;
- if(!(doc instanceof HTMLDocument)) return;
-
- var rootDoc = (doc instanceof HTMLDocument ? doc.defaultView.top.document : doc);
- var browser = Zotero_Browser.tabbrowser.getBrowserForDocument(rootDoc);
- if(!browser) return;
-
- var tab = _getTabObject(browser);
- if(!tab) return;
-
- var page = tab.getPageObject();
- if(!page) return;
-
- if(doc == page.document || doc == rootDoc) {
- // clear translator only if the page on which the pagehide event was called is
- // either the page to which the translator corresponded, or the root document
- // (the second check is probably paranoid, but won't hurt)
- tab.clear();
- }
-
- // update status
- if(Zotero_Browser.tabbrowser.selectedBrowser == browser) {
- // Note: async
- this.updateStatus();
- }
- }
-
- /**
- * Called when item should be updated due to a DOM event
- */
- function itemUpdated(doc) {
- try {
- var rootDoc = (doc instanceof HTMLDocument ? doc.defaultView.top.document : doc);
- var browser = Zotero_Browser.tabbrowser.getBrowserForDocument(rootDoc);
- var tab = _getTabObject(browser);
- if(doc == tab.getPageObject().document || doc == rootDoc) tab.clear();
- tab.detectTranslators(rootDoc, doc);
- } catch(e) {
- Zotero.debug(e);
- }
- }
-
- /*
- * called when a tab is closed
- */
- function tabClose(event) {
- // Save annotations when closing a tab, since the browser is already
- // gone from tabbrowser by the time contentHide() gets called
- var tab = _getTabObject(event.target);
- var page = tab.getPageObject();
- if(page && page.annotations) page.annotations.save();
- tab.clear();
-
- // To execute if document object does not exist
- toggleMode();
- }
-
-
- /*
- * called when the window is resized
- */
- function resize(event) {
- var tab = _getTabObject(this.tabbrowser.selectedBrowser);
- var page = tab.getPageObject();
- if(!page.annotations) return;
-
- page.annotations.refresh();
- }
-
- /*
- * Updates the status of the capture icon to reflect the scrapability or lack
- * thereof of the current page
- */
- this.updateStatus = Zotero.Promise.coroutine(function* () {
- // Wait for translator initialization. This allows detection to still run on a page at startup
- // once translators have finished loading.
- if (Zotero.Schema && Zotero.Schema.schemaUpdatePromise.isPending()) {
- yield Zotero.Schema.schemaUpdatePromise;
- }
-
- if (!Zotero_Browser.tabbrowser) return;
- var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser);
-
- Components.utils.import("resource:///modules/CustomizableUI.jsm");
- var buttons = getSaveButtons();
- if (buttons.length) {
- let state = tab.getCaptureState();
- let tooltiptext = tab.getCaptureTooltip();
- for (let { button, placement } of buttons) {
- let inToolbar = placement.area == CustomizableUI.AREA_NAVBAR;
- button.image = tab.getCaptureIcon(Zotero.hiDPI || !inToolbar);
- button.tooltipText = tooltiptext;
- if (state == tab.CAPTURE_STATE_TRANSLATABLE) {
- button.classList.add('translate');
- }
- else {
- button.classList.remove('translate');
- }
- button.removeAttribute('disabled');
- }
- }
-
- // set annotation bar status
- var page = tab.getPageObject();
- if(page.annotations && page.annotations.annotations.length) {
- document.getElementById('zotero-annotate-tb').hidden = false;
- toggleMode();
- } else {
- document.getElementById('zotero-annotate-tb').hidden = true;
- }
- });
-
- this.addDetectCallback = function (func) {
- _detectCallbacks.push(func);
- };
-
- this.resolveDetectCallbacks = Zotero.Promise.coroutine(function* () {
- while (_detectCallbacks.length) {
- let cb = _detectCallbacks.shift();
- var res = cb();
- if (res && res.then) {
- yield res.then;
- }
- }
- });
-
- function getSaveButtons() {
- Components.utils.import("resource:///modules/CustomizableUI.jsm");
- var buttons = [];
-
- var placement = CustomizableUI.getPlacementOfWidget("zotero-toolbar-buttons");
- if (placement) {
- let button = document.getElementById("zotero-toolbar-save-button");
- if (button) {
- buttons.push({
- button: button,
- placement: placement
- });
- }
- }
-
- placement = CustomizableUI.getPlacementOfWidget("zotero-toolbar-save-button-single");
- if (placement) {
- let button = document.getElementById("zotero-toolbar-save-button-single");
- if (button) {
- buttons.push({
- button: button,
- placement: placement
- });
- }
- }
-
- return buttons;
- }
-
- /**
- * Called when status bar icon is right-clicked
- */
- this.onStatusPopupShowing = function(e) {
- var popup = e.target;
- while(popup.hasChildNodes()) popup.removeChild(popup.lastChild);
-
- var tab = _getTabObject(this.tabbrowser.selectedBrowser);
- var captureState = tab.getCaptureState();
- if (captureState == tab.CAPTURE_STATE_TRANSLATABLE) {
- let translators = tab.getPageObject().translators;
- for (var i=0, n = translators.length; i < n; i++) {
- let translator = translators[i];
-
- let menuitem = document.createElement("menuitem");
- menuitem.setAttribute("label",
- Zotero.getString("ingester.saveToZoteroUsing", translator.label));
- menuitem.setAttribute("image", (translator.itemType === "multiple"
- ? "chrome://zotero/skin/treesource-collection.png"
- : Zotero.ItemTypes.getImageSrc(translator.itemType)));
- menuitem.setAttribute("class", "menuitem-iconic");
- menuitem.addEventListener("command", function(e) {
- Zotero_Browser.scrapeThisPage(translator, e);
- e.stopPropagation();
- }, false);
- popup.appendChild(menuitem);
- }
- }
-
- let webPageIcon = tab.getWebPageCaptureIcon(Zotero.hiDPI);
- let menuitem = document.createElement("menuitem");
- menuitem.setAttribute("label", Zotero.getString('ingester.saveToZoteroAsWebPageWithSnapshot'));
- menuitem.setAttribute("image", webPageIcon);
- menuitem.setAttribute("class", "menuitem-iconic");
- menuitem.addEventListener("command", function (event) {
- Zotero_Browser.saveAsWebPage(true);
- event.stopPropagation();
- });
- popup.appendChild(menuitem);
-
- menuitem = document.createElement("menuitem");
- menuitem.setAttribute("label", Zotero.getString('ingester.saveToZoteroAsWebPageWithoutSnapshot'));
- menuitem.setAttribute("image", webPageIcon);
- menuitem.setAttribute("class", "menuitem-iconic");
- menuitem.addEventListener("command", function (event) {
- Zotero_Browser.saveAsWebPage(false);
- event.stopPropagation();
- });
- popup.appendChild(menuitem);
-
- if (captureState == tab.CAPTURE_STATE_TRANSLATABLE) {
- popup.appendChild(document.createElement("menuseparator"));
-
- let menuitem = document.createElement("menuitem");
- menuitem.setAttribute("label", Zotero.getString("locate.libraryLookup.label"));
- menuitem.setAttribute("tooltiptext", Zotero.getString("locate.libraryLookup.tooltip"));
- menuitem.setAttribute("image", "chrome://zotero/skin/locate-library-lookup.png");
- menuitem.setAttribute("class", "menuitem-iconic");
- menuitem.addEventListener("command", _constructLookupFunction(tab, function(event, obj) {
- var urls = [];
- for (let i = 0; i < obj.newItems.length; i++) {
- var url = Zotero.OpenURL.resolve(obj.newItems[i]);
- if(url) urls.push(url);
- }
- ZoteroPane.loadURI(urls, event);
- }), false);
- popup.appendChild(menuitem);
-
- var locateEngines = Zotero.LocateManager.getVisibleEngines();
- Zotero_LocateMenu.addLocateEngines(popup, locateEngines,
- _constructLookupFunction(tab, function(e, obj) {
- Zotero_LocateMenu.locateItem(e, obj.newItems);
- }), true);
- }
- }
-
- /**
- * Translates using the specified translation instance. setTranslator() must already
- * have been called
- * @param {Zotero.Translate} translate
- */
- this.performTranslation = Zotero.Promise.coroutine(function* (translate, libraryID, collection) {
- if (Zotero.locked) {
- Zotero_Browser.progress.Translation.operationInProgress();
- return;
- }
-
- if (!Zotero.isConnector && Zotero.DB.inTransaction()) {
- yield Zotero.DB.waitForTransaction();
- }
-
- Zotero_Browser.progress.show();
- Zotero_Browser.isScraping = true;
-
- // Get libraryID and collectionID
- if(libraryID === undefined && ZoteroPane && !Zotero.isConnector) {
- // Save to My Library by default if pane hasn't been opened
- if (!ZoteroPane.collectionsView || !ZoteroPane.collectionsView.selectedTreeRow) {
- libraryID = Zotero.Libraries.userLibraryID;
- }
- else if (!ZoteroPane.collectionsView.editable) {
- Zotero_Browser.progress.Translation.cannotEditCollection();
- return;
- }
- else {
- libraryID = ZoteroPane.getSelectedLibraryID();
- }
-
- collection = ZoteroPane.getSelectedCollection();
- }
-
- if (!Zotero.isConnector) {
- if (ZoteroPane.collectionsView
- && ZoteroPane.collectionsView
- && ZoteroPane.collectionsView.selectedTreeRow
- && ZoteroPane.collectionsView.selectedTreeRow.isPublications()) {
- Zotero_Browser.progress.Translation.cannotAddToPublications();
- return;
- }
-
- if (Zotero.Feeds.get(libraryID)) {
- Zotero_Browser.progress.Translation.cannotAddToFeed();
- return;
- }
- }
-
- Zotero_Browser.progress.Translation.scrapingTo(libraryID, collection);
-
- translate.clearHandlers("done");
- translate.clearHandlers("itemDone");
- translate.clearHandlers("attachmentProgress");
-
- var deferred = Zotero.Promise.defer();
-
- translate.setHandler("done", function() {
- Zotero_Browser.progress.Translation.doneHandler.apply(Zotero_Browser.progress.Translation, arguments);
- Zotero_Browser.isScraping = false;
- deferred.resolve();
- });
-
- translate.setHandler("itemDone", function() {
- let handler = Zotero_Browser.progress.Translation.itemDoneHandler(_attachmentsMap);
- handler.apply(Zotero_Browser.progress.Translation, arguments);
- });
-
- translate.setHandler("attachmentProgress", function() {
- let handler = Zotero_Browser.progress.Translation.attachmentProgressHandler(_attachmentsMap);
- handler.apply(Zotero_Browser.progress.Translation, arguments);
- });
-
- translate.translate({
- libraryID,
- collections: collection ? [collection.id] : false
- });
-
- return deferred.promise;
- });
-
-
- //////////////////////////////////////////////////////////////////////////////
- //
- // Private Zotero_Browser methods
- //
- //////////////////////////////////////////////////////////////////////////////
-
- function _constructLookupFunction(tab, success) {
- return function(e) {
- var page = tab.getPageObject();
- page.translate.setTranslator(page.translators[0]);
- page.translate.clearHandlers("done");
- page.translate.clearHandlers("itemDone");
- page.translate.setHandler("done", function(obj, status) {
- if(status) {
- success(e, obj);
- Zotero_Browser.progress.close();
- } else {
- Zotero_Browser.progress.changeHeadline(Zotero.getString("ingester.lookup.error"));
- Zotero_Browser.progress.startCloseTimer(8000);
- }
- });
-
- Zotero_Browser.progress.show();
- Zotero_Browser.progress.changeHeadline(Zotero.getString("ingester.lookup.performing"));
- page.translate.translate(false);
- e.stopPropagation();
- }
- }
-
- /*
- * Gets a data object given a browser window object
- */
- function _getTabObject(browser) {
- if(!browser) return false;
- var obj = _browserData.get(browser);
- if(!obj) {
- obj = new Zotero_Browser.Tab(browser);
- _browserData.set(browser, obj);
- }
- return obj;
- }
-
- /**
- * Adds an annotation
- */
- function _add(type, e) {
- var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser);
-
- if(type == "annotation") {
- // ignore click if it's on an existing annotation
- if(e.target.getAttribute("zotero-annotation")) return;
-
- var annotation = tab.getPageObject().annotations.createAnnotation();
- annotation.initWithEvent(e);
-
- // disable add mode, now that we've used it
- toggleMode();
- } else {
- try {
- var selection = Zotero_Browser.tabbrowser.selectedBrowser.contentWindow.getSelection();
- } catch(err) {
- return;
- }
- if(selection.isCollapsed) return;
-
- if(type == "highlight") {
- tab.getPageObject().annotations.highlight(selection.getRangeAt(0));
- } else if(type == "unhighlight") {
- tab.getPageObject().annotations.unhighlight(selection.getRangeAt(0));
- }
-
- selection.removeAllRanges();
- }
-
- // stop propagation
- e.stopPropagation();
- e.preventDefault();
- }
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Zotero_Browser.Tab
-//
-//////////////////////////////////////////////////////////////////////////////
-
-Zotero_Browser.Tab = function(browser) {
- this.browser = browser;
- this.wm = new WeakMap();
-}
-
-Zotero_Browser.Tab.prototype.CAPTURE_STATE_DISABLED = 0;
-Zotero_Browser.Tab.prototype.CAPTURE_STATE_GENERIC = 1;
-Zotero_Browser.Tab.prototype.CAPTURE_STATE_TRANSLATABLE = 2;
-
-/**
- * Gets page-specific information (stored in WeakMap to prevent holding
- * a reference to translate)
- */
-Zotero_Browser.Tab.prototype.getPageObject = function() {
- var doc = this.browser.contentWindow;
- if(!doc) return null;
- var obj = this.wm.get(doc);
- if(!obj) {
- obj = {};
- this.wm.set(doc, obj);
- }
- return obj;
-}
-
-/*
- * Removes page-specific information from WeakMap
- */
-Zotero_Browser.Tab.prototype.clear = function() {
- this.wm.delete(this.browser.contentWindow);
-}
-
-/*
- * detects translators for this browser object
- */
-Zotero_Browser.Tab.prototype.detectTranslators = Zotero.Promise.coroutine(function* (rootDoc, doc) {
- if (Zotero.Schema && Zotero.Schema.schemaUpdatePromise.isPending()) {
- yield Zotero.Schema.schemaUpdatePromise;
- }
-
- // If document no longer exists after waiting for schema updates (probably because another page has
- // been loaded), bail
- if (Components.utils.isDeadWrapper(doc)) {
- return;
- }
-
- if (doc instanceof HTMLDocument) {
- if (doc.documentURI.startsWith("about:")) {
- return;
- }
-
- // get translators
- var me = this;
-
- var translate = new Zotero.Translate.Web();
- translate.setDocument(doc);
- translate.setHandler("translators", function(obj, item) { me._translatorsAvailable(obj, item) });
- translate.setHandler("pageModified", function(translate, doc) { Zotero_Browser.itemUpdated(doc) });
- translate.getTranslators(true);
- } else if(doc.documentURI.substr(0, 7) == "file://") {
- this._attemptLocalFileImport(doc);
- }
-});
-
-
-/*
- * searches for a document in all of the frames of a given document
- */
-Zotero_Browser.Tab.prototype._searchFrames = function(rootDoc, searchDoc) {
- if(rootDoc == searchDoc) return true;
- var frames = rootDoc.getElementsByTagName("frame");
- for (let i = 0; i < frames.length; i++) {
- let frame = frames[i];
- if(frame.contentDocument &&
- (frame.contentDocument == searchDoc ||
- this._searchFrames(frame.contentDocument, searchDoc))) {
- return true;
- }
- }
-
- var frames = rootDoc.getElementsByTagName("iframe");
- for (let i = 0; i < frames.length; i++) {
- let frame = frames[i];
- if(frame.contentDocument &&
- (frame.contentDocument == searchDoc ||
- this._searchFrames(frame.contentDocument, searchDoc))) {
- return true;
- }
- }
-
- return false;
-}
-
-/*
- * Attempts import of a file; to be run on local files only
- */
-Zotero_Browser.Tab.prototype._attemptLocalFileImport = function(doc) {
- if(doc.documentURI.match(/\.csl(\.xml|\.txt)?$/i)) {
- // read CSL string
- var csl = Zotero.File.getContentsFromURL(doc.documentURI);
- if(csl.indexOf("http://purl.org/net/xbiblio/csl") != -1) {
- // looks like a CSL; try to import
- Zotero.Styles.install(csl, doc.documentURI);
- }
- } else {
- // see if we can import this file
- var file = Components.classes["@mozilla.org/network/protocol;1?name=file"]
- .getService(Components.interfaces.nsIFileProtocolHandler)
- .getFileFromURLSpec(doc.documentURI);
-
- var me = this;
- var translate = new Zotero.Translate.Import();
- translate.setLocation(file);
- translate.setHandler("translators", function(obj, item) { me._translatorsAvailable(obj, item) });
- translate.getTranslators();
- }
-}
-
-
-Zotero_Browser.Tab.prototype.getCaptureState = function () {
- var page = this.getPageObject();
- if (!page.saveEnabled) {
- return this.CAPTURE_STATE_DISABLED;
- }
- if (page.translators && page.translators.length) {
- return this.CAPTURE_STATE_TRANSLATABLE;
- }
- return this.CAPTURE_STATE_GENERIC;
-}
-
-/*
- * returns the URL of the image representing the translator to be called on the
- * current page, or false if the page cannot be scraped
- */
-Zotero_Browser.Tab.prototype.getCaptureIcon = function (hiDPI) {
- switch (this.getCaptureState()) {
- case this.CAPTURE_STATE_TRANSLATABLE:
- var itemType = this.getPageObject().translators[0].itemType;
- return (itemType === "multiple"
- ? "chrome://zotero/skin/treesource-collection" + Zotero.hiDPISuffix + ".png"
- : Zotero.ItemTypes.getImageSrc(itemType));
-
- default:
- return this.getWebPageCaptureIcon(hiDPI);
- }
-}
-
-// TODO: Show icons for images, PDFs, etc.?
-Zotero_Browser.Tab.prototype.getWebPageCaptureIcon = function (hiDPI) {
- return "chrome://zotero/skin/treeitem-webpage" + Zotero.hiDPISuffix + ".png";
-}
-
-Zotero_Browser.Tab.prototype.getCaptureTooltip = function() {
- switch (this.getCaptureState()) {
- case this.CAPTURE_STATE_DISABLED:
- var text = Zotero.getString('ingester.saveToZotero');
- break;
-
- case this.CAPTURE_STATE_TRANSLATABLE:
- var text = Zotero.getString('ingester.saveToZotero');
- var translator = this.getPageObject().translators[0];
- if (translator.itemType == 'multiple') {
- text += '…';
- }
- text += ' (' + translator.label + ')';
- break;
-
- // TODO: Different captions for images, PDFs, etc.?
- default:
- var text = Zotero.getString('ingester.saveToZotero')
- + " (" + Zotero.getString('itemTypes.webpage') + ")";
- }
-
- var key = Zotero.Keys.getKeyForCommand('saveToZotero');
- if (key) {
- // Add RLE mark in RTL mode to make shortcut render the right way
- text += (Zotero.rtl ? ' \u202B' : ' ') + '('
- + (Zotero.isMac ? '⇧⌘' : Zotero.getString('general.keys.ctrlShift'))
- + key
- + ')';
- }
-
- return text;
-}
-
-Zotero_Browser.Tab.prototype.getCaptureCommand = function () {
- switch (this.getCaptureState()) {
- case this.CAPTURE_STATE_DISABLED:
- return '';
- case this.CAPTURE_STATE_TRANSLATABLE:
- return '';
- default:
- return 'cmd_zotero_newItemFromCurrentPage';
- }
-}
-
-
-/**********CALLBACKS**********/
-
-/*
- * called when a user is supposed to select items
- */
-Zotero_Browser.Tab.prototype._selectItems = function(obj, itemList, callback) {
- // this is kinda ugly, mozillazine made me do it! honest!
- var io = { dataIn:itemList, dataOut:null }
- var newDialog = window.openDialog("chrome://zotero/content/ingester/selectitems.xul",
- "_blank","chrome,modal,centerscreen,resizable=yes", io);
-
- if(!io.dataOut) { // user selected no items, so close the progress indicatior
- Zotero_Browser.progress.close();
- }
-
- callback(io.dataOut);
-}
-
-/*
- * called when translators are available
- */
-Zotero_Browser.Tab.prototype._translatorsAvailable = Zotero.Promise.coroutine(function* (translate, translators) {
- var page = this.getPageObject();
- if (!page) return;
- page.saveEnabled = true;
-
- if(translators && translators.length) {
- //see if we should keep the previous set of translators
- if(//we already have a translator for part of this page
- page.translators && page.translators.length && page.document.location
- //and the page is still there
- && page.document.defaultView && !page.document.defaultView.closed
- //this set of translators is not targeting the same URL as a previous set of translators,
- // because otherwise we want to use the newer set,
- // but only if it's not in a subframe of the previous set
- && (page.document.location.href != translate.document.location.href ||
- Zotero.Utilities.Internal.isIframeOf(translate.document.defaultView, page.document.defaultView))
- //the best translator we had was of higher priority than the new set
- && (page.translators[0].priority < translators[0].priority
- //or the priority was the same, but...
- || (page.translators[0].priority == translators[0].priority
- //the previous set of translators targets the top frame or the current one does not either
- && (page.document.defaultView == page.document.defaultView.top
- || translate.document.defaultView !== page.document.defaultView.top)
- ))
- ) {
- Zotero.debug("Translate: a better translator was already found for this page");
- return; //keep what we had
- } else {
- this.clear(); //clear URL bar icon
- page = this.getPageObject();
- page.saveEnabled = true;
- }
-
- Zotero.debug("Translate: found translators for page\n"
- + "Best translator: " + translators[0].label + " with priority " + translators[0].priority);
- page.translate = translate;
- page.translators = translators;
- page.document = translate.document;
-
- translate.clearHandlers("select");
- translate.setHandler("select", this._selectItems);
- } else if(translate.type != "import" && translate.document.documentURI.length > 7
- && translate.document.documentURI.substr(0, 7) == "file://") {
- this._attemptLocalFileImport(translate.document);
- }
-
- if(!translators || !translators.length) Zotero.debug("Translate: No translators found");
-
- yield Zotero_Browser.updateStatus();
- yield Zotero_Browser.resolveDetectCallbacks();
-});
-
-Zotero_Browser.init();
\ No newline at end of file
diff --git a/chrome/content/zotero/downloadOverlay.js b/chrome/content/zotero/downloadOverlay.js
deleted file mode 100644
index 3ae485a0575..00000000000
--- a/chrome/content/zotero/downloadOverlay.js
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- ***** BEGIN LICENSE BLOCK *****
-
- Copyright © 2011 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 .
-
- ***** END LICENSE BLOCK *****
-*/
-var Zotero_DownloadOverlay = new function() {
- const PDF_MIME_TYPE = "application/pdf";
- const ALLOW_LIST = [
- "application/pdf",
- "application/postscript",
- "application/xhtml+xml",
- "text/html",
- "text/plain",
- /^audio\//,
- /^image\//,
- /^video\//,
- /^application\/vnd\.oasis\.opendocument\./,
- /^application\/vnd\.ms-/,
- /^application\/vnd\.openxmlformats-officedocument/,
- /^application\/vnd\.lotus-/,
- /^application\/vnd\.wolfram\./,
- "application/vnd.wordperfect",
- "application/wordperfect5.1",
- "application/msword",
- "application/x-latex"
- ];
-
- /**
- * Saves this item, if we are supposed to save it.
- *
- * @return {Boolean} True if an item was saved, false if we were not supposed to save
- */
- this.handleSave = Zotero.Promise.coroutine(function* () {
- if(!document.getElementById('zotero-radio').selected) return false;
-
- var retrieveMetadata = document.getElementById('zotero-recognizePDF').selected;
-
- var url = dialog.mLauncher.source.spec;
- Zotero.debug("Zotero_DownloadOverlay: Downloading from "+url);
-
- // set up progress window
- var win = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator)
- .getMostRecentWindow("navigator:browser");
- var libraryID, collection;
- try {
- let itemGroup = win.ZoteroPane.getCollectionTreeRow();
- if (itemGroup.filesEditable && !itemGroup.isPublications()) {
- libraryID = win.ZoteroPane.getSelectedLibraryID();
- collection = win.ZoteroPane.getSelectedCollection();
- }
- // TODO: Just show an error instead?
- else {
- Zotero.debug("Cannot save files to library " + itemGroup.ref.libraryID
- + " -- saving to My Library instead", 2);
- libraryID = Zotero.Libraries.userLibraryID;
- }
- } catch(e) {
- Zotero.debug(e, 1);
- };
-
- var recognizePDF = document.getElementById('zotero-recognizePDF').checked
- && !document.getElementById('zotero-recognizePDF').hidden
- && !document.getElementById('zotero-recognizePDF').disabled;
- var contentType = dialog.mLauncher.MIMEInfo.MIMEType;
-
- // mimic dialog cancellation
- dialog.onCancel();
-
- // show progress dialog
- var progressWin = new Zotero.ProgressWindow();
- progressWin.changeHeadline(Zotero.getString("save.link"));
- progressWin.show();
-
- // perform import
- try {
- var item = yield Zotero.Attachments.importFromURL({
- libraryID,
- url,
- collections: collection ? [collection.id] : [],
- contentType
- });
- }
- catch (e) {
- if (!win) return;
- progressWin.addDescription(Zotero.getString("save.link.error"));
- progressWin.startCloseTimer(8000);
- Zotero.logError(e);
- return false;
- }
-
- if(!win) return;
-
- progressWin.addLines([item.getDisplayTitle()], [item.getImageSrc()]);
- progressWin.startCloseTimer();
- if (collection) {
- yield collection.addItem(item.id);
- }
-
- yield win.ZoteroPane.selectItem(item.id);
-
- if(recognizePDF) {
- var timer = Components.classes["@mozilla.org/timer;1"]
- .createInstance(Components.interfaces.nsITimer);
- timer.init(function() {
- try {
- if (item && item.getFile()) {
- timer.cancel();
- Zotero.RecognizePDF.recognizeItems([item]);
- }
- } catch(e) { dump(e.toSource()) };
- }, 1000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
- }
-
- return true;
- });
-
- /**
- * Called when mode in dialog has been changed
- */
- this.modeChanged = function() {
- var zoteroSelected = document.getElementById('zotero-radio').selected;
-
- // don't allow user to remember Zotero option for file type; i'm not sure anyone wants this
- // to happen automatically
- if(zoteroSelected) document.getElementById('rememberChoice').selected = false;
- document.getElementById('rememberChoice').disabled = zoteroSelected;
- document.getElementById('zotero-recognizePDF').disabled = !zoteroSelected;
-
- Zotero_DownloadOverlay.updateLibraryNote();
- };
-
- /**
- * Determines whether the note stating that the item will be saved to "My Library" is shown
- */
- this.updateLibraryNote = function() {
- var zoteroSelected = document.getElementById('zotero-radio').selected;
- var zp = Zotero.getActiveZoteroPane(), canSave = true;
- try {
- canSave = zp.getCollectionTreeRow().filesEditable;
- } catch(e) {
- Zotero.logError(e);
- };
- document.getElementById('zotero-saveToLibrary-description').hidden = !zoteroSelected || canSave;
- window.sizeToContent();
- }
-
- /**
- * Called when the save dialog is opened
- */
- this.init = function() {
- if(Zotero.isConnector) return;
-
- // Disable for filetypes people probably don't want to save
- var show = false;
- var mimeType = dialog.mLauncher.MIMEInfo.MIMEType.toLowerCase();
- for (let elem of ALLOW_LIST) {
- if(typeof elem === "string") {
- if(elem === mimeType) {
- document.getElementById('zotero-container').hidden = false;
- document.getElementById('zotero-radio').disabled = false;
- break;
- }
- } else if(elem.test(mimeType)) {
- document.getElementById('zotero-container').hidden = false;
- document.getElementById('zotero-radio').disabled = false;
- break;
- }
- }
-
- // Hook in event listener to ondialogaccept
- document.documentElement.setAttribute('ondialogaccept',
- 'Zotero_DownloadOverlay.handleSave().then(function (saved) { if (!saved) {'
- + document.documentElement.getAttribute('ondialogaccept')
- +'}})');
-
- // Hook in event listener for mode change
- var radios = document.getElementById('mode').
- addEventListener("command", Zotero_DownloadOverlay.modeChanged, false);
-
- // Set label on retrieve PDF option
- if(mimeType === PDF_MIME_TYPE) {
- var recognizePDF = document.getElementById('zotero-recognizePDF');
- recognizePDF.label = Zotero.getString("pane.items.menu.recognizePDF");
- recognizePDF.hidden = false;
- recognizePDF.disabled = true;
- }
- };
-}
-
-window.addEventListener("load", Zotero_DownloadOverlay.init, false);
-window.addEventListener("activate", Zotero_DownloadOverlay.updateLibraryNote, false);
\ No newline at end of file
diff --git a/chrome/content/zotero/downloadOverlay.xul b/chrome/content/zotero/downloadOverlay.xul
deleted file mode 100644
index 0fe6a958749..00000000000
--- a/chrome/content/zotero/downloadOverlay.xul
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
- %zoteroDTD;
-]>
-
-
-
-
-
-
-
-
-
- &zotero.downloadManager.saveToLibrary.description;
-
-
-
-
-
-
diff --git a/chrome/content/zotero/icon.js b/chrome/content/zotero/icon.js
deleted file mode 100644
index 88caf73482d..00000000000
--- a/chrome/content/zotero/icon.js
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- ***** BEGIN LICENSE BLOCK *****
-
- Copyright © 2015 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 .
-
- ***** END LICENSE BLOCK *****
-*/
-
-"use strict";
-
-Components.utils.import("resource://zotero/config.js");
-Components.utils.import("resource:///modules/CustomizableUI.jsm");
-
-var Zotero = Components.classes["@zotero.org/Zotero;1"]
- .getService(Components.interfaces.nsISupports)
- .wrappedJSObject;
-var comboButtonsID = 'zotero-toolbar-buttons';
-addIcon();
-
-function addIcon() {
- // Don't try to add icons more than once, and avoid warnings in tests
- if (Zotero.toolbarIconAdded || CustomizableUI.getPlacementOfWidget(comboButtonsID)) {
- return;
- }
-
- CustomizableUI.addListener({
- onWidgetAdded: function (id, area, position) {
- if (id == comboButtonsID) {
- // When dropping combo button into panel, add two independent buttons instead
- if (area == CustomizableUI.AREA_PANEL) {
- let mainID = getSingleID('main');
- let saveID = getSingleID('save');
- CustomizableUI.removeWidgetFromArea(id);
- // Remove independent main and save buttons first if they're already in panel
- CustomizableUI.removeWidgetFromArea(mainID);
- CustomizableUI.removeWidgetFromArea(saveID);
- CustomizableUI.addWidgetToArea(mainID, area, position);
- let placement = CustomizableUI.getPlacementOfWidget(mainID)
- let mainPos = placement.position;
- CustomizableUI.addWidgetToArea(saveID, area, mainPos + 1);
- return;
- }
-
- var isUpgrade = false;
- try {
- isUpgrade = Zotero.Prefs.get("firstRunGuidanceShown.saveIcon");
- } catch(e) {}
- var property = "firstRunGuidance.toolbarButton." + (isUpgrade ? "upgrade" : "new");
- var shortcut = Zotero.getString(
- Zotero.isMac ? "general.keys.cmdShift" : "general.keys.ctrlShift"
- ) + Zotero.Prefs.get("keys.openZotero");
-
- let widget = CustomizableUI.getWidget(id);
- for (let instance of widget.instances) {
- let doc = instance.node.ownerDocument;
-
- updateItemForArea(instance.node, area);
-
- doc.getElementById("zotero-main-button-guidance").show({
- text: Zotero.getString(property, shortcut)
- });
- doc.getElementById("zotero-save-button-guidance").show();
- }
- }
- else if (id == getSingleID('save')) {
- let widget = CustomizableUI.getWidget(id);
- for (let instance of widget.instances) {
- instance.node.ownerDocument.defaultView.Zotero_Browser.updateStatus();
- }
- }
- },
-
- onWidgetOverflow: function (node, container) {
- if (node.id == comboButtonsID) {
- node.classList.add("toolbarbutton-1");
- }
- },
-
- onWidgetUnderflow: function (node, container) {
- if (node.id == comboButtonsID) {
- node.classList.remove("toolbarbutton-1");
- }
- },
-
- // Save icon in panel isn't in DOM until menu is shown once and therefore isn't updated
- // on page loads, so update the icon status when the panel is first shown so that it
- // doesn't remain disabled
- onAreaNodeRegistered: function (area, node) {
- if (area == CustomizableUI.AREA_PANEL) {
- var placement = CustomizableUI.getPlacementOfWidget(comboButtonsID)
- var update = false;
- let singleID = getSingleID('save');
- if (placement && placement.area == CustomizableUI.AREA_PANEL) {
- update = true;
- }
- else {
- placement = CustomizableUI.getPlacementOfWidget(singleID);
- if (placement && placement.area == CustomizableUI.AREA_PANEL) {
- update = true;
- }
- }
- if (update) {
- let widget = CustomizableUI.getWidget(singleID);
- for (let instance of widget.instances) {
- instance.node.ownerDocument.defaultView.Zotero_Browser.updateStatus();
- }
- }
- }
- }
- })
-
- // Create the combo buttons, which go in the toolbar by default
- CustomizableUI.createWidget({
- id: comboButtonsID,
- type: 'custom',
- label: ZOTERO_CONFIG.CLIENT_NAME,
- tooltiptext: ZOTERO_CONFIG.CLIENT_NAME,
- defaultArea: CustomizableUI.AREA_NAVBAR,
- onBuild: function (document) {
- const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-
- var item = document.createElementNS(kNSXUL, "toolbaritem");
- item.setAttribute("id", comboButtonsID);
- item.setAttribute("label", "Zotero (Combo)"); // TODO: localize
- // Set this as an attribute in addition to the property to make sure we can style correctly.
- item.setAttribute("removable", "true");
- item.classList.add("chromeclass-toolbar-additional");
-
- ['main', 'save'].map(button => {
- return {
- name: button,
- id: getID(button),
- tooltiptext: getTooltipText(button),
- oncommand: getCommand(button)
- };
- }).forEach(function(attribs, index) {
- if (index != 0) {
- item.appendChild(document.createElementNS(kNSXUL, "separator"));
- }
- let button = document.createElementNS(kNSXUL, "toolbarbutton");
- if (attribs.name == 'main') {
- button.setAttribute('label', Zotero.clientName);
- }
- else if (attribs.name == 'save') {
- button.setAttribute('label', Zotero.getString('ingester.saveToZotero'));
- button.setAttribute('disabled', 'true');
- button.setAttribute('type', 'menu-button');
- let menupopup = document.createElementNS(kNSXUL, "menupopup");
- menupopup.setAttribute('onpopupshowing', "Zotero_Browser.onStatusPopupShowing(event)");
- button.appendChild(menupopup);
- }
- delete attribs.name;
- setAttributes(button, attribs);
- item.appendChild(button);
- });
-
- updateItemForArea(item, this.currentArea)
-
- return item;
- }
- });
-
- // Create the independent Z button, which isn't shown by default
- CustomizableUI.createWidget({
- id: getSingleID('main'),
- label: Zotero.clientName,
- tooltiptext: getTooltipText('main'),
- defaultArea: false,
- onCommand: function (event) {
- event.target.ownerDocument.defaultView.ZoteroOverlay.toggleDisplay();
- }
- });
-
- // Create the independent save button, which isn't shown by default
- CustomizableUI.createWidget({
- id: getSingleID('save'),
- label: Zotero.getString('ingester.saveToZotero'),
- tooltiptext: getTooltipText('save'),
- defaultArea: false,
- onCommand: function (event) {
- event.target.ownerDocument.defaultView.Zotero_Browser.scrapeThisPage(null, event);
- },
- onCreated: function (button) {
- const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
- button.setAttribute('disabled', 'true');
- button.setAttribute('type', 'menu-button');
- let menupopup = button.ownerDocument.createElementNS(kNSXUL, "menupopup");
- menupopup.setAttribute('onpopupshowing', "Zotero_Browser.onStatusPopupShowing(event)");
- button.appendChild(menupopup);
- }
- });
-
- Zotero.toolbarIconAdded = true;
-}
-
-function getID(button) {
- switch (button) {
- case 'main':
- return "zotero-toolbar-main-button";
-
- case 'save':
- return "zotero-toolbar-save-button";
- }
-}
-
-function getSingleID(button) {
- return getID(button) + '-single';
-}
-
-function getCommand(button) {
- switch (button) {
- case 'main':
- return "ZoteroOverlay.toggleDisplay()";
-
- case 'save':
- return "Zotero_Browser.scrapeThisPage(null, event)";
- }
-}
-
-function getTooltipText(button) {
- var text;
- switch (button) {
- case 'main':
- if (Zotero && Zotero.initialized) {
- text = Zotero.clientName;
- let key = Zotero.Keys.getKeyForCommand('openZotero');
- if (key) {
- // Add RLE mark in RTL mode to make shortcut render the right way
- text += (Zotero.rtl ? ' \u202B' : ' ') + '('
- + (Zotero.isMac ? '⇧⌘' : Zotero.getString('general.keys.ctrlShift'))
- + key
- + ')';
- }
-
- }
- else {
- if (Zotero) {
- text = Zotero.startupError;
- }
-
- // Use defaults if necessary
- if (!text) {
- let src = 'chrome://zotero/locale/zotero.properties';
- let stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
- .getService(Components.interfaces.nsIStringBundleService);
- let stringBundle = stringBundleService.createBundle(src);
- text = stringBundle.GetStringFromName('startupError');
- }
- }
- break;
-
- case 'save':
- text = Zotero.getString('ingester.saveToZotero');
- break;
- }
- return text;
-}
-
-/**
- * Set various attributes that allow treeitem and subelements to be styled properly
- * in the different areas
- */
-function updateItemForArea(item, area) {
- if (area) {
- var areaType = CustomizableUI.getAreaType(area);
- var inPanel = area == CustomizableUI.AREA_PANEL;
- var classes = inPanel ? "panel-combined-button" : "toolbarbutton-1 toolbarbutton-combined";
- item.setAttribute("cui-areatype", areaType);
- item.classList.add("toolbaritem-combined-buttons");
- if (inPanel) {
- item.classList.add("panel-wide-item");
- }
- var buttons = item.getElementsByTagName('toolbarbutton');
- for (let i = 0; i < buttons.length; i++) {
- let button = buttons[i];
- button.setAttribute("class", classes);
- button.setAttribute("cui-areatype", areaType);
- }
- }
- // In customization palette pretend it's a single icon
- else {
- item.classList.remove("toolbaritem-combined-buttons");
- item.classList.remove("panel-wide-item");
- var buttons = item.getElementsByTagName('toolbarbutton');
- for (let i = 0; i < buttons.length; i++) {
- let button = buttons[i];
- button.setAttribute("class", "toolbarbutton-1");
- button.removeAttribute("cui-areatype");
- }
- }
-}
-
-function setAttributes(elem, attrs) {
- for (let i in attrs) {
- elem.setAttribute(i, attrs[i]);
- }
-}
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
index 03bdbabe7ed..f5b884eee8f 100644
--- a/chrome/content/zotero/overlay.js
+++ b/chrome/content/zotero/overlay.js
@@ -31,7 +31,6 @@ var ZoteroOverlay = new function()
const DEFAULT_ZPANE_HEIGHT = 300;
var toolbarCollapseState;
var zoteroPane, zoteroSplitter;
- var _stateBeforeReload = false;
this.isTab = false;
@@ -44,8 +43,6 @@ var ZoteroOverlay = new function()
zoteroPane = document.getElementById('zotero-pane-stack');
zoteroSplitter = document.getElementById('zotero-splitter');
- var iconLoaded = false;
-
if (!Zotero) {
throw new Error("No Zotero object");
}
@@ -55,30 +52,9 @@ var ZoteroOverlay = new function()
ZoteroPane_Overlay = ZoteroPane;
- // 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();
@@ -86,17 +62,6 @@ var ZoteroOverlay = new function()
}
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;
}
});
@@ -127,19 +92,10 @@ var ZoteroOverlay = new function()
.getBranch('extensions.zotero.');
prefBranch.clearUserPref('statusBarIcon');
- // Add toolbar icon
- try {
- iconLoaded = true;
- Services.scriptloader.loadSubScript("chrome://zotero/content/icon.js", {}, "UTF-8");
- }
- catch (e) {
- Zotero.logError(e);
- }
-
// Used for loading pages from upgrade wizard
if (Zotero.initialURL) {
setTimeout(function () {
- gBrowser.selectedTab = gBrowser.addTab(Zotero.initialURL);
+ Zotero.launchURL(ZOTERO_CONFIG.START_URL);
Zotero.initialURL = null;
}, 1);
}
@@ -151,11 +107,6 @@ var ZoteroOverlay = new function()
ZoteroPane.destroy();
}
- this.onBeforeUnload = function() {
- // close Zotero as a tab, so it won't be pinned
- var zoteroTab = ZoteroOverlay.findZoteroTab();
- if(zoteroTab) gBrowser.removeTab(zoteroTab);
- }
/**
* Hides/displays the Zotero interface
@@ -176,18 +127,6 @@ var ZoteroOverlay = new function()
return;
}
- if(makeVisible || makeVisible === undefined) {
- if(Zotero.isConnector) {
- // If in connector mode, bring Zotero Standalone to foreground
- Zotero.activateStandalone();
- return;
- } else if(this.isTab) {
- // If in separate tab mode, just open the tab
- this.loadZoteroTab();
- return;
- }
- }
-
if(makeVisible === undefined) makeVisible = zoteroPane.hidden || zoteroPane.collapsed;
/*
@@ -256,4 +195,3 @@ window.addEventListener("load", function(e) {
}
}, false);
window.addEventListener("unload", function(e) { ZoteroOverlay.onUnload(e); }, false);
-window.addEventListener("beforeunload", function(e) { ZoteroOverlay.onBeforeUnload(e); }, false);
diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul
index e2527960e97..2602bc2cd7e 100644
--- a/chrome/content/zotero/overlay.xul
+++ b/chrome/content/zotero/overlay.xul
@@ -38,8 +38,6 @@
-
-
@@ -48,44 +46,5 @@
onmouseup="ZoteroPane.updateTagSelectorSize()"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/chrome/content/zotero/preferences/preferences_advanced_firefox.xul b/chrome/content/zotero/preferences/preferences_advanced_firefox.xul
deleted file mode 100644
index 7890faf73df..00000000000
--- a/chrome/content/zotero/preferences/preferences_advanced_firefox.xul
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/chrome/content/zotero/preferences/preferences_general_firefox.xul b/chrome/content/zotero/preferences/preferences_general_firefox.xul
deleted file mode 100644
index 7eb55dd4ef4..00000000000
--- a/chrome/content/zotero/preferences/preferences_general_firefox.xul
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js
index 4b0202ef4de..1b34a3acd60 100644
--- a/chrome/content/zotero/standalone/standalone.js
+++ b/chrome/content/zotero/standalone/standalone.js
@@ -445,7 +445,6 @@ ZoteroStandalone.DebugOutput = {
};
-/** Taken from browser.js **/
function toJavaScriptConsole() {
toOpenWindowByType("global:console", "chrome://global/content/console.xul");
}
diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js
index 3af5782819e..626764538cb 100644
--- a/chrome/content/zotero/xpcom/mimeTypeHandler.js
+++ b/chrome/content/zotero/xpcom/mimeTypeHandler.js
@@ -54,14 +54,7 @@ Zotero.MIMETypeHandler = new function () {
_ignoreContentDispositionTypes = [];
_observers = [];
- if(Zotero.Prefs.get("parseEndNoteMIMETypes")) {
- this.registerMetadataHandlers();
- }
- Zotero.Prefs.registerObserver("parseEndNoteMIMETypes", function(val) {
- if (val) this.registerMetadataHandlers();
- else this.unregisterMetadataHandlers();
- }.bind(this));
-
+ // Install styles from the Cite preferences
this.addHandler("application/vnd.citationstyles.style+xml", Zotero.Promise.coroutine(function* (a1, a2) {
let win = Services.wm.getMostRecentWindow("zotero:basicViewer");
try {
@@ -77,40 +70,6 @@ Zotero.MIMETypeHandler = new function () {
win.close();
}
}));
- this.addHandler("text/x-csl", function(a1, a2) { Zotero.Styles.install(a1, a2) }); // deprecated
- this.addHandler("application/x-zotero-schema", Zotero.Schema.importSchema);
- this.addHandler("application/x-zotero-settings", Zotero.Prefs.importSettings);
- }
-
- // MIME types that Zotero should handle when parseEndNoteMIMETypes preference
- // is enabled
- var metadataMIMETypes = [
- "application/x-endnote-refer", "application/x-research-info-systems",
- "application/x-inst-for-scientific-info",
- "text/x-bibtex", "application/x-bibtex",
- // Non-standard
- "text/x-research-info-systems",
- "text/application/x-research-info-systems", // Nature serves this
- "text/ris", // Cell serves this
- "ris" // Not even trying
- ];
-
- /**
- * Registers MIME types for parseEndNoteMIMETypes preference
- */
- this.registerMetadataHandlers = function() {
- for (var i=0; i\s*/, ''));
- Zotero.debug(str);
-
- var confirm = ps.confirm(
- null,
- "",
- "Apply settings from zotero.org?"
- );
-
- if (!confirm) {
- return;
- }
-
- // TODO: parse settings XML
- }
-
// Handlers for some Zotero preferences
var _handlers = [
[ "automaticScraperUpdates", function(val) {
@@ -229,14 +203,6 @@ Zotero.Prefs = new function(){
Zotero.Prefs.set('note.fontSize', 11);
}
}],
- [ "zoteroDotOrgVersionHeader", function(val) {
- if (val) {
- Zotero.VersionHeader.register();
- }
- else {
- Zotero.VersionHeader.unregister();
- }
- }],
[ "sync.autoSync", function(val) {
if (val) {
Zotero.Sync.EventListeners.AutoSyncListener.register();
diff --git a/chrome/content/zotero/xpcom/sync/syncLocal.js b/chrome/content/zotero/xpcom/sync/syncLocal.js
index fc97b4b65dc..fab1727777a 100644
--- a/chrome/content/zotero/xpcom/sync/syncLocal.js
+++ b/chrome/content/zotero/xpcom/sync/syncLocal.js
@@ -392,15 +392,8 @@ Zotero.Sync.Data.Local = {
}
catch (e) {
Zotero.logError(e);
- if (Zotero.isStandalone) {
- var msg = Zotero.getString('sync.error.loginManagerCorrupted1', Zotero.appName) + "\n\n"
- + Zotero.getString('sync.error.loginManagerCorrupted2', [Zotero.appName, Zotero.appName]);
- }
- else {
- var msg = Zotero.getString('sync.error.loginManagerInaccessible') + "\n\n"
- + Zotero.getString('sync.error.checkMasterPassword', Zotero.appName) + "\n\n"
- + Zotero.getString('sync.error.corruptedLoginManager', Zotero.appName);
- }
+ var msg = Zotero.getString('sync.error.loginManagerCorrupted1', Zotero.appName) + "\n\n"
+ + Zotero.getString('sync.error.loginManagerCorrupted2', [Zotero.appName, Zotero.appName]);
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
ps.alert(null, Zotero.getString('general.error'), msg);
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
index 4b76d7eb4e6..0dead6bf455 100644
--- a/chrome/content/zotero/xpcom/zotero.js
+++ b/chrome/content/zotero/xpcom/zotero.js
@@ -231,8 +231,6 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
// Make sure that Zotero Standalone is not running as root
if(Zotero.isStandalone && !Zotero.isWin) _checkRoot();
- _addToolbarIcon();
-
try {
yield Zotero.DataDirectory.init();
if (this.restarting) {
@@ -333,27 +331,23 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
}
}
- if (!Zotero.isConnector) {
- if (!this.forceDataDir) {
- yield Zotero.DataDirectory.checkForMigration(
- dataDir, Zotero.DataDirectory.defaultDir
- );
- if (this.skipLoading) {
- return;
- }
-
- yield Zotero.DataDirectory.checkForLostLegacy();
- if (this.restarting) {
- return;
- }
+ if (!this.forceDataDir) {
+ yield Zotero.DataDirectory.checkForMigration(
+ dataDir, Zotero.DataDirectory.defaultDir
+ );
+ if (this.skipLoading) {
+ return;
}
- // Make sure data directory isn't in Dropbox, etc.
- if (Zotero.isStandalone) {
- yield Zotero.DataDirectory.checkForUnsafeLocation(dataDir);
+ yield Zotero.DataDirectory.checkForLostLegacy();
+ if (this.restarting) {
+ return;
}
}
+ // Make sure data directory isn't in Dropbox, etc.
+ yield Zotero.DataDirectory.checkForUnsafeLocation(dataDir);
+
// Register shutdown handler to call Zotero.shutdown()
var _shutdownObserver = {observe:function() { Zotero.shutdown().done() }};
Services.obs.addObserver(_shutdownObserver, "quit-application", false);
@@ -386,35 +380,15 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
Services.console.unregisterListener(ConsoleListener);
});
- // Load additional info for connector or not
- if(Zotero.isConnector) {
- Zotero.debug("Loading in connector mode");
- Zotero.Connector_Types.init();
-
- // Store a startupError until we get information from Zotero Standalone
- Zotero.startupError = Zotero.getString("connector.loadInProgress")
-
- if(!Zotero.isFirstLoadThisSession) {
- // We want to get a checkInitComplete message before initializing if we switched to
- // connector mode because Standalone was launched
- Zotero.IPC.broadcast("checkInitComplete");
- } else {
- Zotero.initComplete();
+ return _initFull()
+ .then(function (success) {
+ if (!success) {
+ return false;
}
- } else {
- Zotero.debug("Loading in full mode");
- return _initFull()
- .then(function (success) {
- if (!success) {
- return false;
- }
-
- if(Zotero.isStandalone) Zotero.Standalone.init();
- Zotero.initComplete();
- })
- }
-
- return true;
+
+ if (Zotero.isStandalone) Zotero.Standalone.init();
+ Zotero.initComplete();
+ })
});
/**
@@ -452,22 +426,6 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
};
- var _addToolbarIcon = function () {
- if (Zotero.isStandalone) return;
-
- // Add toolbar icon
- try {
- Services.scriptloader.loadSubScript("chrome://zotero/content/icon.js", {}, "UTF-8");
- }
- catch (e) {
- if (Zotero) {
- Zotero.debug(e, 1);
- }
- Components.utils.reportError(e);
- }
- };
-
-
/**
* Initialization function to be called only if Zotero is in full mode
*
@@ -1556,8 +1514,6 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
function _showWindowZoteroPaneOverlay(doc) {
doc.getElementById('zotero-collections-tree').disabled = true;
doc.getElementById('zotero-items-tree').disabled = true;
- doc.getElementById('zotero-pane-tab-catcher-top').hidden = false;
- doc.getElementById('zotero-pane-tab-catcher-bottom').hidden = false;
doc.getElementById('zotero-pane-overlay').hidden = false;
}
@@ -1565,8 +1521,6 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
function _hideWindowZoteroPaneOverlay(doc) {
doc.getElementById('zotero-collections-tree').disabled = false;
doc.getElementById('zotero-items-tree').disabled = false;
- doc.getElementById('zotero-pane-tab-catcher-top').hidden = true;
- doc.getElementById('zotero-pane-tab-catcher-bottom').hidden = true;
doc.getElementById('zotero-pane-overlay').hidden = true;
// See note in showZoteroPaneProgressMeter()
@@ -1900,13 +1854,10 @@ Zotero.Keys = new function() {
*/
Zotero.VersionHeader = {
init: function () {
- if (Zotero.Prefs.get("zoteroDotOrgVersionHeader")) {
- this.register();
- }
+ this.register();
Zotero.addShutdownListener(this.unregister);
},
- // Called from this.init() and Zotero.Prefs.observe()
register: function () {
Services.obs.addObserver(this, "http-on-modify-request", false);
},
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
index e62d963c977..14b58224ba9 100644
--- a/chrome/content/zotero/zoteroPane.js
+++ b/chrome/content/zotero/zoteroPane.js
@@ -52,7 +52,6 @@ var ZoteroPane = new function()
this.getSortDirection = getSortDirection;
this.setItemsPaneMessage = setItemsPaneMessage;
this.clearItemsPaneMessage = clearItemsPaneMessage;
- this.contextPopupShowing = contextPopupShowing;
this.viewSelectedAttachment = viewSelectedAttachment;
this.reportErrors = reportErrors;
this.displayErrorMessage = displayErrorMessage;
@@ -72,16 +71,6 @@ var ZoteroPane = new function()
this.init = function () {
Zotero.debug("Initializing Zotero pane");
- // For now, keep actions menu in the DOM and show it in Firefox for development
- if (!Zotero.isStandalone) {
- document.getElementById('zotero-tb-actions-menu-separator').hidden = false;
- document.getElementById('zotero-tb-actions-menu').hidden = false;
- }
-
- // Set "Report Errors..." label via property rather than DTD entity,
- // since we need to reference it in script elsewhere
- document.getElementById('zotero-tb-actions-reportErrors').setAttribute('label',
- Zotero.getString('errorReport.reportErrors'));
// Set key down handler
document.getElementById('appcontent').addEventListener('keydown', ZoteroPane_Local.handleKeyDown, true);
@@ -110,7 +99,6 @@ var ZoteroPane = new function()
Zotero.updateQuickSearchBox(document);
if (Zotero.isMac) {
- //document.getElementById('zotero-tb-actions-zeroconf-update').setAttribute('hidden', false);
document.getElementById('zotero-pane-stack').setAttribute('platform', 'mac');
} else if(Zotero.isWin) {
document.getElementById('zotero-pane-stack').setAttribute('platform', 'win');
@@ -122,22 +110,11 @@ var ZoteroPane = new function()
'sync.syncWith', ZOTERO_CONFIG.DOMAIN_NAME
);
- if (Zotero.isStandalone) {
- document.getElementById('zotero-tb-feed-add-fromPage').hidden = true;
- document.getElementById('zotero-tb-feed-add-fromPage-menu').hidden = true;
- }
-
// register an observer for Zotero reload
observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(_reloadObserver, "zotero-reloaded", false);
observerService.addObserver(_reloadObserver, "zotero-before-reload", false);
- this.addBeforeReloadListener(function(newMode) {
- if(newMode == "connector") {
- ZoteroPane_Local.setItemsPaneMessage(Zotero.getString('connector.standaloneOpen'));
- }
- return;
- });
this.addReloadListener(_loadPane);
// continue loading pane
@@ -149,7 +126,7 @@ var ZoteroPane = new function()
* mode
*/
function _loadPane() {
- if(!Zotero || !Zotero.initialized || Zotero.isConnector) return;
+ if (!Zotero || !Zotero.initialized) return;
// Set flags for hi-res displays
Zotero.hiDPI = window.devicePixelRatio > 1;
@@ -181,9 +158,6 @@ var ZoteroPane = new function()
itemsTree.addEventListener("mousedown", ZoteroPane_Local.onTreeMouseDown, true);
itemsTree.addEventListener("click", ZoteroPane_Local.onTreeClick, true);
- var menu = document.getElementById("contentAreaContextMenu");
- menu.addEventListener("popupshowing", ZoteroPane_Local.contextPopupShowing, false);
-
var tagSelector = document.getElementById('zotero-tag-selector');
tagSelector.onchange = function () {
return ZoteroPane_Local.updateTagFilter();
@@ -977,26 +951,6 @@ var ZoteroPane = new function()
}
});
- this.newFeedFromPage = Zotero.Promise.coroutine(function* (event) {
- let data = {unsaved: true};
- if (event) {
- data.url = event.target.getAttribute('feed');
- } else {
- data.url = gBrowser.selectedBrowser.feeds[0].href;
- }
- window.openDialog('chrome://zotero/content/feedSettings.xul',
- null, 'centerscreen, modal', data);
- if (!data.cancelled) {
- let feed = new Zotero.Feed();
- feed.url = data.url;
- feed.name = data.title;
- feed.refreshInterval = data.ttl;
- feed.cleanupReadAfter = data.cleanupReadAfter;
- feed.cleanupUnreadAfter = data.cleanupUnreadAfter;
- yield feed.saveTx();
- yield feed.updateFeed();
- }
- });
this.newFeedFromURL = Zotero.Promise.coroutine(function* () {
let data = {};
@@ -1411,7 +1365,6 @@ var ZoteroPane = new function()
"cmd_zotero_newCollection",
"cmd_zotero_newSavedSearch",
"zotero-tb-add",
- "cmd_zotero_newItemFromCurrentPage",
"zotero-tb-lookup",
"cmd_zotero_newStandaloneNote",
"zotero-tb-note-add",
@@ -1724,14 +1677,13 @@ var ZoteroPane = new function()
for (var i=0; i 1) {
- // if no gBrowser, find it
- if(!gBrowser) {
- let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
- var gBrowser = browserWindow.gBrowser;
- }
-
- // load in a new tab
- var tab = gBrowser.addTab(uri);
- var browser = gBrowser.getBrowserForTab(tab);
-
- if (event && event.shiftKey || !openInNewTab) {
- // if shift key is down, or we are opening in a new tab because there is no loadURI,
- // select new tab
- gBrowser.selectedTab = tab;
+ // Handle no-content zotero: URLs (e.g., zotero://select) without opening viewer
+ if (uri.startsWith('zotero:')) {
+ let nsIURI = Services.io.newURI(uri, null, null);
+ let handler = Components.classes["@mozilla.org/network/protocol;1?name=zotero"]
+ .getService();
+ let extension = handler.wrappedJSObject.getExtension(nsIURI);
+ if (extension.noContent) {
+ extension.doAction(nsIURI);
+ return;
}
}
- else {
- window.loadURI(uri);
- }
+
+ Zotero.openInViewer(uri);
}
}
@@ -3470,74 +3392,6 @@ var ZoteroPane = new function()
}
- // Updates browser context menu options
- function contextPopupShowing()
- {
- if (!Zotero.Prefs.get('browserContentContextMenu')) {
- return;
- }
-
- var menuitem = document.getElementById("zotero-context-add-to-current-note");
- if (menuitem){
- var items = ZoteroPane_Local.getSelectedItems();
- if (ZoteroPane_Local.itemsView.selection && ZoteroPane_Local.itemsView.selection.count==1
- && items[0] && items[0].isNote()
- && window.gContextMenu.isTextSelected)
- {
- menuitem.hidden = false;
- }
- else
- {
- menuitem.hidden = true;
- }
- }
-
- var menuitem = document.getElementById("zotero-context-add-to-new-note");
- if (menuitem){
- if (window.gContextMenu.isTextSelected)
- {
- menuitem.hidden = false;
- }
- else
- {
- menuitem.hidden = true;
- }
- }
-
- var menuitem = document.getElementById("zotero-context-save-link-as-item");
- if (menuitem) {
- if (window.gContextMenu.onLink) {
- menuitem.hidden = false;
- }
- else {
- menuitem.hidden = true;
- }
- }
-
- var menuitem = document.getElementById("zotero-context-save-image-as-item");
- if (menuitem) {
- // Not using window.gContextMenu.hasBGImage -- if the user wants it,
- // they can use the Firefox option to view and then import from there
- if (window.gContextMenu.onImage) {
- menuitem.hidden = false;
- }
- else {
- menuitem.hidden = true;
- }
- }
-
- // If Zotero is locked or library is read-only, disable menu items
- var menu = document.getElementById('zotero-content-area-context-menu');
- var disabled = Zotero.locked;
- if (!disabled && self.collectionsView.selection && self.collectionsView.selection.count) {
- var collectionTreeRow = self.collectionsView.selectedTreeRow;
- disabled = !collectionTreeRow.editable;
- }
- for (let menuitem of menu.firstChild.childNodes) {
- menuitem.disabled = disabled;
- }
- }
-
/**
* @return {Promise} - The id of the new note in non-popup mode, null in
* popup mode (where a note isn't created immediately), or false if library isn't editable
@@ -3603,6 +3457,7 @@ var ZoteroPane = new function()
}
+ // TODO: Move to server_connector
this.addSelectedTextToCurrentNote = Zotero.Promise.coroutine(function* () {
if (!this.canEdit()) {
this.displayCannotEditLibraryMessage();
@@ -3642,17 +3497,6 @@ var ZoteroPane = new function()
});
- this.createItemAndNoteFromSelectedText = Zotero.Promise.coroutine(function* (event) {
- var str = event.currentTarget.ownerDocument.popupNode.ownerDocument.defaultView.getSelection().toString();
- var uri = event.currentTarget.ownerDocument.popupNode.ownerDocument.location.href;
- var item = yield ZoteroPane.addItemFromPage();
- if (item) {
- return ZoteroPane.newNote(false, item.key, str, uri)
- }
- });
-
-
-
this.openNoteWindow = function (itemID, col, parentKey) {
if (!this.canEdit()) {
this.displayCannotEditLibraryMessage();
@@ -4153,42 +3997,6 @@ var ZoteroPane = new function()
});
- /*
- * Create an attachment from the current page
- *
- * |itemID| -- itemID of parent item
- * |link| -- create web link instead of snapshot
- */
- this.addAttachmentFromPage = Zotero.Promise.coroutine(function* (link, itemID) {
- if (Zotero.DB.inTransaction()) {
- yield Zotero.DB.waitForTransaction();
- }
-
- if (typeof itemID != 'number') {
- throw new Error("itemID must be an integer");
- }
-
- var progressWin = new Zotero.ProgressWindow();
- progressWin.changeHeadline(Zotero.getString('save.' + (link ? 'link' : 'attachment')));
- var type = link ? 'web-link' : 'snapshot';
- var icon = 'chrome://zotero/skin/treeitem-attachment-' + type + '.png';
- progressWin.addLines(window.content.document.title, icon)
- progressWin.show();
- progressWin.startCloseTimer();
-
- if (link) {
- return Zotero.Attachments.linkFromDocument({
- document: window.content.document,
- parentItemID: itemID
- });
- }
- return Zotero.Attachments.importFromDocument({
- document: window.content.document,
- parentItemID: itemID
- });
- });
-
-
this.viewItems = Zotero.Promise.coroutine(function* (items, event) {
if (items.length > 1) {
if (!event || (!event.metaKey && !event.shiftKey)) {
@@ -4290,8 +4098,8 @@ var ZoteroPane = new function()
// TODO: update DB with new info if changed?
var ext = Zotero.File.getExtension(file);
- var externalViewer = Zotero.isStandalone || (!Zotero.MIME.hasNativeHandler(mimeType, ext) &&
- (!Zotero.MIME.hasInternalHandler(mimeType, ext) || Zotero.Prefs.get('launchNonNativeFiles')));
+ var externalViewer = !Zotero.MIME.hasInternalHandler(mimeType, ext)
+ || Zotero.Prefs.get('launchNonNativeFiles');
}
if (!externalViewer) {
diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul
index 9b08daa9ea0..840c29059b5 100644
--- a/chrome/content/zotero/zoteroPane.xul
+++ b/chrome/content/zotero/zoteroPane.xul
@@ -43,7 +43,6 @@
-
@@ -66,38 +65,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -197,8 +141,6 @@
-
-
@@ -305,8 +247,6 @@