diff --git a/chrome.manifest b/chrome.manifest index d4c5700ca0..70743e7294 100644 --- a/chrome.manifest +++ b/chrome.manifest @@ -7,7 +7,6 @@ content zotero-platform chrome/content/zotero-platform/unix/ os=FreeBSD content zotero-platform chrome/content/zotero-platform/unix/ os=OpenBSD content zotero-platform-version chrome/content/zotero-platform/default-version/ -content zotero-platform-version chrome/content/zotero-platform/mac-big-sur/ os=Darwin osversion>=11 resource zotero resource/ diff --git a/chrome/content/zotero-platform/mac-big-sur/style.css b/chrome/content/zotero-platform/mac-big-sur/style.css deleted file mode 100644 index b7562719d9..0000000000 --- a/chrome/content/zotero-platform/mac-big-sur/style.css +++ /dev/null @@ -1,4 +0,0 @@ -/* Quick Format dialog, which is based on window corners, which are different on Big Sur */ -#quick-format-iframe { - margin-top: 2px; -} diff --git a/chrome/content/zotero/integration/addCitationDialog.js b/chrome/content/zotero/integration/addCitationDialog.js deleted file mode 100644 index 79fa186ab0..0000000000 --- a/chrome/content/zotero/integration/addCitationDialog.js +++ /dev/null @@ -1,876 +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 . - - ***** END LICENSE BLOCK ***** -*/ - -import { getCSSItemTypeIcon } from 'components/icons'; - - -window.isPristine = true; - -var Zotero_Citation_Dialog = new function () { - // Array value [0] is property name. - // Array value [1] is default value of property. - var _preserveData = { - "prefix":["value", ""], - "suffix":["value", ""], - "label":["selectedIndex", 0], - "locator":["value", ""], - "suppress-author":["checked", false] - }; - - var _accepted = false; - var _itemData = new Object(); - var _multipleSourcesOn = false; - var _lastSelected = null; - var _previewShown = false; - var _suppressNextTreeSelect = false; - var _suppressNextListSelect = false; - var _customHTML = false; - var _locatorIndexArray = {}; - var _locatorNameArray = {}; - var _autoRegeneratePref; - var _acceptButton; - var _multipleSourceButton; - var _sortCheckbox; - var _citationList; - var _originalHTML; - var _editor; - var serial_number; - var io; - - this.toggleMultipleSources = toggleMultipleSources; - this.toggleEditor = toggleEditor; - this.treeItemSelected = treeItemSelected; - this.listItemSelected = listItemSelected; - this.up = up; - this.down = down; - this.remove = remove; - this.setSortToggle = setSortToggle; - this.confirmRegenerate = confirmRegenerate; - this.accept = accept; - this.cancel = cancel; - - /* - * initialize add citation dialog - */ - this.load = Zotero.Promise.coroutine(function* () { - // make sure we are visible - window.setTimeout(async function () { - let screenX = window.screenX, screenY = window.screenY, i = 5; - while (!screenX && i--) { - await new Promise(resolve => window.requestAnimationFrame(resolve)); - screenX = window.screenX; - screenY = window.screenY; - } - var xRange = [window.screen.availLeft, window.screen.left + window.screen.width - window.outerWidth]; - var yRange = [window.screen.availTop, window.screen.top + window.screen.height - window.outerHeight]; - if(screenX < xRange[0] || screenX > xRange[1] || screenY < yRange[0] || screenY > yRange[1]) { - var targetX = Math.max(Math.min(screenX, xRange[1]), xRange[0]); - var targetY = Math.max(Math.min(screenY, yRange[1]), yRange[0]); - Zotero.debug(`Moving window to ${targetX}, ${targetY}`); - window.moveTo(targetX, targetY); - } - }, 0); - - - io = window.arguments[0].wrappedJSObject; - - // find accept button - _acceptButton = document.querySelector('dialog').getButton("accept"); - _multipleSourceButton = document.querySelector('dialog').getButton("extra1"); - _multipleSourceButton.label = Zotero.getString("citation.multipleSources") - document.querySelector('dialog').getButton("extra2").label = Zotero.getString("citation.showEditor"); - _autoRegeneratePref = Zotero.Prefs.get("integration.autoRegenerate"); - _citationList = document.getElementById("item-list"); - - window.addEventListener('dialogaccept', () => Zotero_Citation_Dialog.accept()); - window.addEventListener('dialogcancel', () => Zotero_Citation_Dialog.cancel()); - window.addEventListener('dialogextra1', () => Zotero_Citation_Dialog.toggleMultipleSources()); - window.addEventListener('dialogextra2', () => Zotero_Citation_Dialog.toggleEditor()); - - // Manipulated by _addItem(). Discriminates between cite instances - // based on the same item in the same citation. Internal throwaway variable, - // reset each time _multipleSourcesOn is set to true. - serial_number = 0; - - // if a style with sortable citations, present checkbox - if(io.sortable) { - _sortCheckbox = document.getElementById("keepSorted"); - _sortCheckbox.hidden = false; - _sortCheckbox.checked = !io.citation.properties.unsorted; - } - - // load locators - var locators = Zotero.Cite.labels; - var menu = document.getElementById("label"); - var label_list = document.getElementById("locator-type-popup"); - var i = 0; - var pageLocatorIndex; - for(var value in locators) { - var locator = locators[value]; - let locatorLabel = Zotero.Cite.getLocatorString(locator); - // add to list of labels - var child = document.createXULElement("menuitem"); - child.setAttribute("value", value); - child.setAttribute("label", locatorLabel); - label_list.appendChild(child); - // add to array - _locatorIndexArray[locator] = i; - _locatorNameArray[i] = locator; - if (locator == 'page') { - pageLocatorIndex = i; - _preserveData.label[1] = i; - } - i++; - } - menu.selectedIndex = pageLocatorIndex; - - if (!io.itemTreeID) { - io.itemTreeID = "add-citation-select-item-dialog"; - } - - // load (from selectItemsDialog.js) - yield doLoad(); - - // if we already have a citation, load data from it - _editor = document.querySelector('#editor').contentWindow.editor; - if(io.citation.citationItems.length) { - if(io.citation.citationItems.length === 1) { - // single citation - toggleMultipleSources(false); - _suppressNextTreeSelect = true; - - // DEBUG: When editing a citation before the library data has been loaded (i.e., in - // Firefox before the pane has been opened), this is the citation id, not the item id, - // and this fails. It works on subsequent attempts. Since this won't happen in - // Standalone, we can ignore. - var id = io.citation.citationItems[0].id; - let selected = yield collectionsView.selectItem(id); - - for(var box in _preserveData) { - var property = _preserveData[box][0]; - if(io.citation.citationItems[0][box]) { - if(box === "label") { - document.getElementById(box)[property] = _locatorIndexArray[io.citation.citationItems[0][box]]; - } else { - document.getElementById(box)[property] = io.citation.citationItems[0][box]; - } - } - } - } else { - // multiple citations - toggleMultipleSources(true); - var _itemData = {}; - // There is a little thrashing here, with repeated writes and - // overwrites of node content. But sticking to the same - // workflow for all updates (node -> array -> io.citation) makes - // debugging a little less painful. - for(var i=0; i -1) { - var itemDataID = _citationList.getSelectedItem(0).getAttribute("value"); - itemID = itemDataID.slice(0, itemDataID.indexOf(":")); - } - - // delete item list - _itemData = new Object(); - - // delete all items - _clearCitationList(); - - // refresh - if (itemID) { - collectionsView.selectItem(itemID); - } - _updateAccept(); - _updatePreview(); - } - } - - /* - * called when an item in the item selection tree is clicked - */ - function treeItemSelected() { - if(_suppressNextTreeSelect) { - _suppressNextTreeSelect = false; - _updateAccept(); - return; - } - var items = itemsView.getSelectedItems(true); // treeview from xpcom/itemTreeView.js - var itemID = (items.length ? items[0] : false); - - if(_multipleSourcesOn) { - // We can safely use itemID here, because none of these operations - // affect selected items; this is all about the tree and navigation. - - // turn off highlight in selected item list - _suppressNextListSelect = true; - document.getElementById("item-list").selectedIndex = -1; - - // disable all fields - - for(var box in _preserveData) { - document.getElementById(box).disabled = true; - } - - // disable adding nothing - document.getElementById("add").disabled = !itemID; - document.getElementById("remove").disabled = true; - document.getElementById("up").disabled = true; - document.getElementById("down").disabled = true; - } else { - for(var box in _preserveData) { - document.getElementById(box).disabled = !itemID; - } - _updateAccept(); - _updatePreview(); - window.isPristine = false; - } - } - - /* - * called when an item in the selected items list is clicked - */ - function listItemSelected() { - if(_suppressNextListSelect) { - _suppressNextListSelect = false; - _updateAccept(); - return; - } - var selectedListItem = _citationList.getSelectedItem(0); - var selectedListIndex = _citationList.selectedIndex; - var itemDataID = (selectedListItem ? selectedListItem.getAttribute("value") : false); - _itemSelected(itemDataID); - // turn off highlight in item tree - _suppressNextTreeSelect = true; - itemsView.selection.clearSelection(); - document.getElementById("remove").disabled = !itemDataID; - document.getElementById("add").disabled = true; - _configListPosition(!itemDataID, selectedListIndex); - } - - function _configListPosition(flag, selectedListIndex) { - if (selectedListIndex > 0) { - document.getElementById("up").disabled = flag; - } else { - document.getElementById("up").disabled = true; - } - if (-1 < selectedListIndex && selectedListIndex < (_citationList.getRowCount() - 1)) { - document.getElementById("down").disabled = flag; - } else { - document.getElementById("down").disabled = true; - } - } - - function _move(direction) { - // automatically uncheck sorted checkbox if user is rearranging citation - if(_sortCheckbox && _sortCheckbox.checked) { - _sortCheckbox.checked = false; - setSortToggle(); - } - - var insertBeforeItem; - var selectedListItem = _citationList.getSelectedItem(0); - var selectedListIndex = _citationList.selectedIndex; - var itemDataID = selectedListItem.getAttribute("value"); - if (direction === -1) { - insertBeforeItem = selectedListItem.previousSibling; - } else { - insertBeforeItem = selectedListItem.nextSibling.nextSibling; - } - var listItem = _citationList.removeChild(selectedListItem); - _citationList.insertBefore(listItem, insertBeforeItem); - _citationList.selectedIndex = (selectedListIndex + direction); - _itemSelected(itemDataID); - _updatePreview(); - _configListPosition(false, (selectedListIndex + direction)); - window.isPristine = false; - } - - function up() { - _move(-1); - } - - function down() { - _move(1); - } - - /* - * Adds an item to the multipleSources list - */ - this.add = Zotero.Promise.coroutine(function* (first_item) { - var pos, len; - var items = itemsView.getSelectedItems(); // treeview from xpcom/itemTreeView.js - window.isPristine = false; - - if (!items.length) { - yield sortCitation(); - _updateAccept(); - _updatePreview(); - return; - } - - // Add to selection list and generate a new itemDataID for this cite. - for (let item of items) { - var selectionNode = _addItem(item); - var itemDataID = selectionNode.getAttribute("value"); - document.getElementById("add").disabled = !itemDataID; - } - - // Save existing locator and affix field content, if any. - if (first_item) { - _itemSelected(itemDataID, true); - } else { - _itemSelected(); - // set to defaults - for(var box in _preserveData) { - var property = _preserveData[box][0]; - var default_value = _preserveData[box][1]; - document.getElementById(box)[property] = default_value; - } - // Save default locator and affix element values to this multi-item. - _itemSelected(itemDataID, true); - } - - for(var box in _preserveData) { - document.getElementById(box).disabled = true; - } - - _citationList.ensureElementIsVisible(selectionNode); - - // allow user to press OK - selectionNode = yield sortCitation(selectionNode); - _citationList.selectItem(selectionNode); - _updateAccept(); - _updatePreview(); - }); - - /* - * Deletes a citation from the multipleSources list - */ - function remove() { - var selectedListItem = _citationList.getSelectedItem(0); - var selectedListIndex = _citationList.selectedIndex; - var itemDataID = selectedListItem.getAttribute("value"); - - // remove from _itemData - delete _itemData[itemDataID]; - _itemData[itemDataID] = undefined; - _lastSelected = null; - - // remove from list - _citationList.removeChild(selectedListItem); - - if (selectedListIndex >= _citationList.getRowCount()) { - selectedListIndex = _citationList.getRowCount() - 1; - } - _citationList.selectedIndex = selectedListIndex; - - _updateAccept(); - _updatePreview(); - window.isPristine = false; - } - - /* - * Sorts preview citations, if preview is open. - */ - this.citationSortUnsort = Zotero.Promise.coroutine(function* () { - setSortToggle(); - yield sortCitation(); - _updatePreview(); - }); - - /* - * Sets the current sort toggle state persistently on the citation. - */ - function setSortToggle() { - if(!_sortCheckbox) return; - if(!_sortCheckbox.checked) { - io.citation.properties.unsorted = true; - } else { - io.citation.properties.unsorted = false; - } - return; - } - - /* - * Sorts the list of citations - */ - var sortCitation = Zotero.Promise.coroutine(function* (scrollToItem) { - if(!_sortCheckbox) return scrollToItem; - if(!_sortCheckbox.checked) { - io.citation.properties.unsorted = true; - return scrollToItem; - } - var scrollToItemID = false; - if (scrollToItem) { - scrollToItemID = scrollToItem.getAttribute("value"); - } - _getCitation(); - - // delete all existing items from list - _clearCitationList(); - - // run preview function to re-sort, if it hasn't already been - // run - yield io.sort(); - - // add items back to list - scrollToItem = null; - for(var i=0; i 0) { - if (result == 2) { - _showItemInLibrary(parseInt(item.id)); - } - return false; - } - if (checkbox.value) { - Zotero.Retractions.disableCitationWarningsForItem({ id: parseInt(item.id) }); - } - } - item.ignoreRetraction = true; - } - } - } - - io.accept(); - _accepted = true; - return true; - } - - /* - * called when cancel button is clicked - */ - function cancel() { - if(_accepted) return true; - io.cancel(); - _accepted = true; - return true; - } - - /* - * Updates the contents of the preview pane - */ - function _updatePreview() { - if(_previewShown) { - _getCitation(); - - _editor.setEnabled(io.citation.citationItems.length); - if (io.citation.citationItems.length) { - io.preview().then((preview) => { - _editor.setContent(preview, true); - - _originalHTML = _editor.getContent(true); - }); - } else { - _editor.setContent(""); - _originalHTML = ""; - } - } - } - - /* - * Controls whether the accept (OK) button should be enabled - */ - function _updateAccept() { - if(_multipleSourcesOn) { - _acceptButton.disabled = !_citationList.getRowCount(); - // To prevent accidental data loss, do not allow change to - // single citation mode if multiple items are in selection - // list. - if (_citationList.getRowCount() > 1) { - _multipleSourceButton.disabled = true; - } else { - _multipleSourceButton.disabled = false; - } - } else { - collectionsView.onLoad.addListener(Zotero.Promise.coroutine(function* () { - if (itemsView) { - yield itemsView.waitForLoad(); - _acceptButton.disabled = !itemsView.getSelectedItems().length; - } - })); - } - } - - /* - * called when an item is selected; if itemDataID is false, disables fields; if - * itemDataID is undefined, only updates _itemData array - * - * Note: This function no longer disables fields. That operation is - * now performed separately by explicit code. - */ - function _itemSelected(itemDataID, forceSave) { - - if (forceSave) { - _lastSelected = itemDataID; - } - - if(_lastSelected && !_itemData[_lastSelected]) { - _itemData[_lastSelected] = new Object(); - } - - for(var box in _preserveData) { - var domBox = document.getElementById(box); - var property = _preserveData[box][0]; - - // save property - if(_lastSelected) { - if(property == "label") { - _itemData[_lastSelected][box] = _locatorNameArray[domBox.selectedIndex]; - } else { - _itemData[_lastSelected][box] = domBox[property]; - } - } - // restore previous property - if(itemDataID) { - domBox.disabled = false; - if(_itemData[itemDataID] && _itemData[itemDataID][box] !== undefined) { - if(property == "label") { - domBox[property] = _locatorIndexArray[_itemData[itemDataID][box]]; - } else { - domBox[property] = _itemData[itemDataID][box]; - } - } - } - } - - if(itemDataID !== undefined) _lastSelected = itemDataID; - } - - /* - * updates io.citation to reflect selected items - */ - function _getCitation() { - var key; - io.citation.citationItems = new Array(); - - // use to map selectedIndexes back to page/paragraph/line - var locatorTypeElements = document.getElementById("label").getElementsByTagName("menuitem"); - if(_multipleSourcesOn) { - _itemSelected(); // store locator info - var listLength = _citationList.getRowCount(); - if(listLength) { - // generate citationItems - for(var i=0; i { - let onOpen = function () { - win.removeEventListener('load', onOpen); - resolve(); - }; - win.addEventListener('load', onOpen); - }); - pane = win.ZoteroPane; - } - pane.selectItem(id); - - // Pull window to foreground - Zotero.Utilities.Internal.activate(pane.document.defaultView); - } -} - -window.cancel = Zotero_Citation_Dialog.cancel; diff --git a/chrome/content/zotero/integration/addCitationDialog.xhtml b/chrome/content/zotero/integration/addCitationDialog.xhtml deleted file mode 100644 index b53b992746..0000000000 --- a/chrome/content/zotero/integration/addCitationDialog.xhtml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -