commit a417c9ef59071950bf371a2f72221bab3b771f98
parent 41e2f3008e50fd2803a3c22cb43ed8c9f00714a5
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 20 Mar 2013 04:47:52 -0400
Fix window height bug in Zotero preferences, and reorganize code
Prefpanes are now in separate overlays, which fixes the age-old resizing
bug when switching between panes (at least on OS X) that varied
depending on the initial pane. Code has also been moved into
pane-specific files and objects, with strict mode enabled. When calling
code from another pane (e.g., for a UI update in another pane), first
check whether the Zotero_Preferences.[Pane] object exists--if it doesn't
then nothing needs to be called.
This change breaks the word integration plugin pref overlays, which
hopefully can be rewritten to work with either overlay format.
There is a good chance that this breaks some other things in the
preferences too.
Fixes #243
Diffstat:
23 files changed, 3754 insertions(+), 3116 deletions(-)
diff --git a/chrome.manifest b/chrome.manifest
@@ -49,8 +49,13 @@ skin zotero default chrome/skin/default/zotero/
overlay chrome://browser/content/browser.xul chrome://zotero/content/statusBarOverlay.xul appversion<4.0
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 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_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
diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js
@@ -1,7 +1,7 @@
/*
***** BEGIN LICENSE BLOCK *****
- Copyright © 2009 Center for History and New Media
+ Copyright © 2006–2013 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
@@ -23,15 +23,40 @@
***** END LICENSE BLOCK *****
*/
-var openURLResolvers;
-var proxies;
-var charsets;
-var _io = {};
-
+"use strict";
var Zotero_Preferences = {
+ init: function () {
+ if(Zotero.isConnector) {
+ Zotero.activateStandalone();
+ window.close();
+ return;
+ }
+
+ observerService.addObserver(function() {
+ if(Zotero.isConnector) window.close();
+ }, "zotero-reloaded", false);
+
+ if(window.arguments) {
+ var io = window.arguments[0];
+
+ if(io.pane) {
+ var pane = document.getElementById(io.pane);
+ document.getElementById('zotero-prefs').showPane(pane);
+ // Quick hack to support install prompt from PDF recognize option
+ if (io.action && io.action == 'pdftools-install') {
+ this.Search.checkPDFToolsDownloadVersion();
+ }
+ }
+ } else if(document.location.hash == "#cite") {
+ document.getElementById('zotero-prefs').showPane(document.getElementById("zotero-prefpane-cite"));
+ }
+ },
+
onUnload: function () {
- Zotero_Preferences.Debug_Output.onUnload();
+ if (Zotero_Preferences.Debug_Output) {
+ Zotero_Preferences.Debug_Output.onUnload();
+ }
},
openHelpLink: function () {
@@ -69,2185 +94,39 @@ var Zotero_Preferences = {
);
}
}
- }
-}
-
-function init()
-{
- if(Zotero.isConnector) {
- Zotero.activateStandalone();
- window.close();
- return;
- }
-
- observerService.addObserver(function() {
- if(Zotero.isConnector) window.close();
- }, "zotero-reloaded", false);
-
- // Display the appropriate modifier keys for the platform
- var rows = document.getElementById('zotero-prefpane-keys').getElementsByTagName('row');
- for (var i=0; i<rows.length; i++) {
- rows[i].firstChild.nextSibling.value = Zotero.isMac ? 'Cmd+Shift+' : 'Ctrl+Alt+';
- }
-
- // JS-based strings
- var checkbox = document.getElementById('launchNonNativeFiles-checkbox');
- if (checkbox ) {
- checkbox.label = Zotero.getString(
- 'zotero.preferences.launchNonNativeFiles', Zotero.appName
- );
- }
-
- updateStorageSettings(null, null, true);
- updateWordProcessorInstructions();
- refreshStylesList();
- refreshProxyList();
- populateQuickCopyList();
- updateQuickCopyInstructions();
- initSearchPane();
- Zotero_Preferences.Debug_Output.init();
-
- var charsetMenu = document.getElementById("zotero-import-charsetMenu");
- var charsetMap = Zotero_Charset_Menu.populate(charsetMenu, false);
- charsetMenu.selectedItem =
- charsetMap[Zotero.Prefs.get("import.charset")] ?
- charsetMap[Zotero.Prefs.get("import.charset")] : charsetMap["auto"];
-
- if(window.arguments) {
- _io = window.arguments[0];
-
- if(_io.pane) {
- var pane = document.getElementById(_io.pane);
- document.getElementById('zotero-prefs').showPane(pane);
- // Quick hack to support install prompt from PDF recognize option
- if (_io.action && _io.action == 'pdftools-install') {
- checkPDFToolsDownloadVersion();
- }
- }
- } else if(document.location.hash == "#cite") {
- document.getElementById('zotero-prefs').showPane(document.getElementById("zotero-prefpane-cite"));
- }
-}
-
-
-function onDataDirLoad() {
- var path = document.getElementById('dataDirPath');
- var useDataDir = Zotero.Prefs.get('useDataDir');
- path.setAttribute('disabled', !useDataDir);
-}
-
-
-function onDataDirUpdate(event) {
- var radiogroup = document.getElementById('dataDir');
- var path = document.getElementById('dataDirPath');
- var useDataDir = Zotero.Prefs.get('useDataDir');
-
- // If triggered from the Choose button, don't show the dialog, since
- // Zotero.chooseZoteroDirectory() shows its own
- if (event.originalTarget && event.originalTarget.tagName == 'button') {
- return true;
- }
- // Fx3.6
- else if (event.explicitOriginalTarget && event.explicitOriginalTarget.tagName == 'button') {
- return true;
- }
-
- // If directory not set or invalid, prompt for location
- if (!getDataDirPath()) {
- event.stopPropagation();
- var file = Zotero.chooseZoteroDirectory(true);
- radiogroup.selectedIndex = file ? 1 : 0;
- return !!file;
- }
-
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
- var app = Zotero.isStandalone ? Zotero.getString('app.standalone') : Zotero.getString('app.firefox');
- var index = ps.confirmEx(window,
- Zotero.getString('general.restartRequired'),
- Zotero.getString('general.restartRequiredForChange', app),
- buttonFlags,
- Zotero.getString('general.restartNow'),
- null, null, null, {});
-
- if (index == 0) {
- useDataDir = !!radiogroup.selectedIndex;
- // quit() is asynchronous, but set this here just in case
- Zotero.Prefs.set('useDataDir', useDataDir);
- var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
- .getService(Components.interfaces.nsIAppStartup);
- appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit
- | Components.interfaces.nsIAppStartup.eRestart);
- }
-
- radiogroup.selectedIndex = useDataDir ? 1 : 0;
- return useDataDir;
-}
-
-
-function getDataDirPath() {
- var desc = Zotero.Prefs.get('dataDir');
- if (desc == '') {
- return '';
- }
-
- var file = Components.classes["@mozilla.org/file/local;1"].
- createInstance(Components.interfaces.nsILocalFile);
- try {
- file.persistentDescriptor = desc;
- }
- catch (e) {
- return '';
- }
- return file.path;
-}
-
-
-function populateOpenURLResolvers() {
- var openURLMenu = document.getElementById('openURLMenu');
-
- openURLResolvers = Zotero.OpenURL.discoverResolvers();
- var i = 0;
- for each(var r in openURLResolvers) {
- openURLMenu.insertItemAt(i, r.name);
- if (r.url == Zotero.Prefs.get('openURL.resolver') && r.version == Zotero.Prefs.get('openURL.version')) {
- openURLMenu.selectedIndex = i;
- }
- i++;
- }
-
- var button = document.getElementById('openURLSearchButton');
- switch (openURLResolvers.length) {
- case 0:
- var num = 'zero';
- break;
- case 1:
- var num = 'singular';
- break;
- default:
- var num = 'plural';
- }
-
- button.setAttribute('label', Zotero.getString('zotero.preferences.openurl.resolversFound.' + num, openURLResolvers.length));
-}
-
-
-//
-// Sync
-//
-function updateStorageSettings(enabled, protocol, skipWarnings) {
- if (enabled === null) {
- enabled = document.getElementById('pref-storage-enabled').value;
- }
-
- var oldProtocol = document.getElementById('pref-storage-protocol').value;
- if (protocol === null) {
- protocol = oldProtocol;
- }
-
- var storageSettings = document.getElementById('storage-settings');
- var protocolMenu = document.getElementById('storage-protocol');
- var settings = document.getElementById('storage-webdav-settings');
- var sep = document.getElementById('storage-separator');
-
- if (!enabled || protocol == 'zotero') {
- settings.hidden = true;
- sep.hidden = false;
- }
- else {
- settings.hidden = false;
- sep.hidden = true;
- }
-
- var menulists = storageSettings.getElementsByTagName('menulist');
- for each(var menulist in menulists) {
- if (menulist.className == 'storage-personal') {
- menulist.disabled = !enabled;
- }
- }
-
- if (!skipWarnings) {
- // WARN if going between
- }
-
- if (oldProtocol == 'zotero' && protocol == 'webdav') {
- var sql = "SELECT COUNT(*) FROM version WHERE schema='storage_zfs'";
- if (Zotero.DB.valueQuery(sql)) {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
- + ps.BUTTON_DELAY_ENABLE;
- var account = Zotero.Sync.Server.username;
- var index = ps.confirmEx(
- null,
- Zotero.getString('zotero.preferences.sync.purgeStorage.title'),
- Zotero.getString('zotero.preferences.sync.purgeStorage.desc'),
- buttonFlags,
- Zotero.getString('zotero.preferences.sync.purgeStorage.confirmButton'),
- Zotero.getString('zotero.preferences.sync.purgeStorage.cancelButton'), null, null, {}
- );
-
- if (index == 0) {
- var sql = "INSERT OR IGNORE INTO settings VALUES (?,?,?)";
- Zotero.DB.query(sql, ['storage', 'zfsPurge', 'user']);
-
- Zotero.Sync.Storage.ZFS.purgeDeletedStorageFiles(function (success) {
- if (success) {
- ps.alert(
- null,
- Zotero.getString("general.success"),
- "Attachment files from your personal library have been removed from the Zotero servers."
- );
- }
- else {
- ps.alert(
- null,
- Zotero.getString("general.error"),
- "An error occurred. Please try again later."
- );
- }
- });
- }
- }
- }
-
- setTimeout(function () {
- updateStorageTerms();
- }, 1)
-}
-
-
-function updateStorageSettingsGroups(enabled) {
- var storageSettings = document.getElementById('storage-settings');
- var menulists = storageSettings.getElementsByTagName('menulist');
- for each(var menulist in menulists) {
- if (menulist.className == 'storage-groups') {
- menulist.disabled = !enabled;
- }
- }
-
- setTimeout(function () {
- updateStorageTerms();
- }, 1)
-}
-
-
-function updateStorageTerms() {
- var terms = document.getElementById('storage-terms');
-
- var libraryEnabled = document.getElementById('pref-storage-enabled').value;
- var storageProtocol = document.getElementById('pref-storage-protocol').value;
- var groupsEnabled = document.getElementById('pref-group-storage-enabled').value;
-
- terms.hidden = !((libraryEnabled && storageProtocol == 'zotero') || groupsEnabled);
-}
-
-
-
-function unverifyStorageServer() {
- Zotero.Prefs.set('sync.storage.verified', false);
- Zotero.Sync.Storage.resetAllSyncStates(null, true, false);
-}
-
-function verifyStorageServer() {
- Zotero.debug("Verifying storage");
-
- var verifyButton = document.getElementById("storage-verify");
- var abortButton = document.getElementById("storage-abort");
- var progressMeter = document.getElementById("storage-progress");
- var urlField = document.getElementById("storage-url");
- var usernameField = document.getElementById("storage-username");
- var passwordField = document.getElementById("storage-password");
-
- verifyButton.hidden = true;
- abortButton.hidden = false;
- progressMeter.hidden = false;
-
- var request = null;
- var onDone = false;
-
- Zotero.Sync.Storage.WebDAV.checkServer()
- // Get the XMLHttpRequest for possible cancelling
- .progress(function (obj) {
- request = obj.xmlhttp;
- })
- .finally(function () {
- verifyButton.hidden = false;
- abortButton.hidden = true;
- progressMeter.hidden = true;
- })
- .spread(function (uri, status) {
- switch (status) {
- case Zotero.Sync.Storage.ERROR_NO_URL:
- onDone = function () {
- urlField.focus();
- };
- break;
-
- case Zotero.Sync.Storage.ERROR_NO_USERNAME:
- onDone = function () {
- usernameField.focus();
- };
- break;
-
- case Zotero.Sync.Storage.ERROR_NO_PASSWORD:
- case Zotero.Sync.Storage.ERROR_AUTH_FAILED:
- onDone = function () {
- passwordField.focus();
- };
- break;
- }
-
- return Zotero.Sync.Storage.WebDAV.checkServerCallback(uri, status, window);
- })
- .then(function (success) {
- if (success) {
- Zotero.debug("WebDAV verification succeeded");
-
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- promptService.alert(
- window,
- Zotero.getString('sync.storage.serverConfigurationVerified'),
- Zotero.getString('sync.storage.fileSyncSetUp')
- );
- Zotero.Prefs.set("sync.storage.verified", true);
- }
- else {
- Zotero.debug("WebDAV verification failed");
- if (onDone) {
- setTimeout(function () {
- onDone();
- }, 1);
- }
- }
- })
- .catch(function (e) {
- Zotero.debug("WebDAV verification failed");
- Zotero.debug(e, 1);
- Components.utils.reportError(e);
- Zotero.Utilities.Internal.errorPrompt(Zotero.getString('general.error'), e);
-
- if (onDone) {
- setTimeout(function () {
- onDone();
- }, 1);
- }
- })
- .done();
-
- abortButton.onclick = function () {
- if (request) {
- Zotero.debug("Cancelling verification request");
- request.onreadystatechange = undefined;
- request.abort();
- verifyButton.hidden = false;
- abortButton.hidden = true;
- progressMeter.hidden = true;
- }
- }
-}
-
-function handleSyncResetSelect(obj) {
- var index = obj.selectedIndex;
- var rows = obj.getElementsByTagName('row');
-
- for (var i=0; i<rows.length; i++) {
- if (i == index) {
- rows[i].setAttribute('selected', 'true');
- }
- else {
- rows[i].removeAttribute('selected');
- }
- }
-}
-
-function handleSyncReset(action) {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- if (!Zotero.Sync.Server.enabled) {
- ps.alert(
- null,
- Zotero.getString('general.error'),
- Zotero.getString('zotero.preferences.sync.reset.userInfoMissing',
- document.getElementById('zotero-prefpane-sync')
- .getElementsByTagName('tab')[0].label)
- );
- return;
- }
-
- var account = Zotero.Sync.Server.username;
-
- switch (action) {
- case 'restore-from-server':
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
- + ps.BUTTON_POS_1_DEFAULT;
- var index = ps.confirmEx(
- null,
- Zotero.getString('general.warning'),
- Zotero.getString('zotero.preferences.sync.reset.restoreFromServer', account),
- buttonFlags,
- Zotero.getString('zotero.preferences.sync.reset.replaceLocalData'),
- null, null, null, {}
- );
-
- switch (index) {
- case 0:
- // TODO: better error handling
-
- // Verify username and password
- var callback = function () {
- Zotero.Schema.stopRepositoryTimer();
- Zotero.Sync.Runner.clearSyncTimeout();
-
- Zotero.DB.skipBackup = true;
-
- var file = Zotero.getZoteroDirectory();
- file.append('restore-from-server');
- Zotero.File.putContents(file, '');
-
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
- var index = ps.confirmEx(
- null,
- Zotero.getString('general.restartRequired'),
- Zotero.getString('zotero.preferences.sync.reset.restartToComplete'),
- buttonFlags,
- Zotero.getString('general.restartNow'),
- null, null, null, {}
- );
-
- var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
- .getService(Components.interfaces.nsIAppStartup);
- appStartup.quit(Components.interfaces.nsIAppStartup.eRestart | Components.interfaces.nsIAppStartup.eAttemptQuit);
- };
-
- // TODO: better way of checking for an active session?
- if (Zotero.Sync.Server.sessionIDComponent == 'sessionid=') {
- Zotero.Sync.Server.login(callback);
- }
- else {
- callback();
- }
- break;
-
- // Cancel
- case 1:
- return;
- }
- break;
-
- case 'restore-to-server':
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
- + ps.BUTTON_POS_1_DEFAULT;
- var index = ps.confirmEx(
- null,
- Zotero.getString('general.warning'),
- Zotero.getString('zotero.preferences.sync.reset.restoreToServer', account),
- buttonFlags,
- Zotero.getString('zotero.preferences.sync.reset.replaceServerData'),
- null, null, null, {}
- );
-
- switch (index) {
- case 0:
- // TODO: better error handling
- Zotero.Sync.Server.clear(function () {
- Zotero.Sync.Server.sync(/*{
-
- // TODO: this doesn't work if the pref window is
- closed. fix, perhaps by making original callbacks
- available to the custom callbacks
-
- onSuccess: function () {
- Zotero.Sync.Runner.setSyncIcon();
- ps.alert(
- null,
- "Restore Completed",
- "Data on the Zotero server has been successfully restored."
- );
- },
- onError: function (msg) {
- // TODO: combine with error dialog for regular syncs
- ps.alert(
- null,
- "Restore Failed",
- "An error occurred uploading your data to the server.\n\n"
- + "Click the sync error icon in the Zotero toolbar "
- + "for further information."
- );
- Zotero.Sync.Runner.error(msg);
- }
- }*/);
- });
- break;
-
- // Cancel
- case 1:
- return;
- }
-
- break;
-
-
- case 'reset-storage-history':
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
- + ps.BUTTON_POS_1_DEFAULT;
- var index = ps.confirmEx(
- null,
- Zotero.getString('general.warning'),
- Zotero.getString('zotero.preferences.sync.reset.fileSyncHistory'),
- buttonFlags,
- Zotero.getString('general.reset'),
- null, null, null, {}
- );
-
- switch (index) {
- case 0:
- Zotero.Sync.Storage.resetAllSyncStates();
- ps.alert(
- null,
- "File Sync History Cleared",
- "The file sync history has been cleared."
- );
- break;
-
- // Cancel
- case 1:
- return;
- }
-
- break;
-
- default:
- throw ("Invalid action '" + action + "' in handleSyncReset()");
- }
-}
-
-
-/*
- * Builds the main Quick Copy drop-down from the current global pref
- */
-function populateQuickCopyList() {
- // Initialize default format drop-down
- var format = Zotero.Prefs.get("export.quickCopy.setting");
- var menulist = document.getElementById("zotero-quickCopy-menu");
- buildQuickCopyFormatDropDown(menulist, Zotero.QuickCopy.getContentType(format), format);
- menulist.setAttribute('preference', "pref-quickCopy-setting");
- updateQuickCopyHTMLCheckbox();
-
- if (!Zotero.isStandalone) {
- refreshQuickCopySiteList();
- }
-}
-
-
-/*
- * Builds a Quick Copy drop-down
- */
-function buildQuickCopyFormatDropDown(menulist, contentType, currentFormat) {
- if (!currentFormat) {
- currentFormat = menulist.value;
- }
- // Strip contentType from mode
- currentFormat = Zotero.QuickCopy.stripContentType(currentFormat);
-
- menulist.selectedItem = null;
- menulist.removeAllItems();
-
- // Prevent Cmd-w from setting "Wikipedia"
- menulist.onkeydown = function (event) {
- if ((Zotero.isMac && event.metaKey) || event.ctrlKey) {
- event.preventDefault();
- }
- }
-
- var popup = document.createElement('menupopup');
- menulist.appendChild(popup);
-
- var itemNode = document.createElement("menuitem");
- itemNode.setAttribute("label", Zotero.getString('zotero.preferences.export.quickCopy.bibStyles'));
- itemNode.setAttribute("disabled", true);
- popup.appendChild(itemNode);
-
- // add styles to list
- var styles = Zotero.Styles.getVisible();
- for each(var style in styles) {
- var baseVal = 'bibliography=' + style.styleID;
- var val = 'bibliography' + (contentType == 'html' ? '/html' : '') + '=' + style.styleID;
- var itemNode = document.createElement("menuitem");
- itemNode.setAttribute("value", val);
- itemNode.setAttribute("label", style.title);
- itemNode.setAttribute("oncommand", 'updateQuickCopyHTMLCheckbox()');
- popup.appendChild(itemNode);
-
- if (baseVal == currentFormat) {
- menulist.selectedItem = itemNode;
- }
- }
-
- var itemNode = document.createElement("menuitem");
- itemNode.setAttribute("label", Zotero.getString('zotero.preferences.export.quickCopy.exportFormats'));
- itemNode.setAttribute("disabled", true);
- popup.appendChild(itemNode);
-
- // add export formats to list
- var translation = new Zotero.Translate("export");
- var translators = translation.getTranslators();
-
- for (var i=0; i<translators.length; i++) {
- // Skip RDF formats
- switch (translators[i].translatorID) {
- case '6e372642-ed9d-4934-b5d1-c11ac758ebb7':
- case '14763d24-8ba0-45df-8f52-b8d1108e7ac9':
- continue;
- }
- var val = 'export=' + translators[i].translatorID;
- var itemNode = document.createElement("menuitem");
- itemNode.setAttribute("value", val);
- itemNode.setAttribute("label", translators[i].label);
- itemNode.setAttribute("oncommand", 'updateQuickCopyHTMLCheckbox()');
- popup.appendChild(itemNode);
-
- if (val == currentFormat) {
- menulist.selectedItem = itemNode;
- }
- }
-
- menulist.click();
-
- return popup;
-}
-
-function updateQuickCopyHTMLCheckbox() {
- var format = document.getElementById('zotero-quickCopy-menu').value;
- var mode, contentType;
-
- var checkbox = document.getElementById('zotero-quickCopy-copyAsHTML');
- [mode, format] = format.split('=');
- [mode, contentType] = mode.split('/');
-
- checkbox.checked = contentType == 'html';
- checkbox.disabled = mode != 'bibliography';
-}
-
-function showQuickCopySiteEditor(index) {
- var treechildren = document.getElementById('quickCopy-siteSettings-rows');
-
- if (index != undefined && index > -1 && index < treechildren.childNodes.length) {
- var treerow = treechildren.childNodes[index].firstChild;
- var domain = treerow.childNodes[0].getAttribute('label');
- var format = treerow.childNodes[1].getAttribute('label');
- var asHTML = treerow.childNodes[2].getAttribute('label') != '';
- }
-
- var format = Zotero.QuickCopy.getSettingFromFormattedName(format);
- if (asHTML) {
- format = format.replace('bibliography=', 'bibliography/html=');
- }
-
- var io = {domain: domain, format: format, ok: false};
- window.openDialog('chrome://zotero/content/preferences/quickCopySiteEditor.xul', "zotero-preferences-quickCopySiteEditor", "chrome, modal", io);
-
- if (!io.ok) {
- return;
- }
-
- if (domain && domain != io.domain) {
- Zotero.DB.query("DELETE FROM settings WHERE setting='quickCopySite' AND key=?", [domain]);
- }
-
- Zotero.DB.query("REPLACE INTO settings VALUES ('quickCopySite', ?, ?)", [io.domain, io.format]);
-
- refreshQuickCopySiteList();
-}
-
-function refreshQuickCopySiteList() {
- var treechildren = document.getElementById('quickCopy-siteSettings-rows');
- while (treechildren.hasChildNodes()) {
- treechildren.removeChild(treechildren.firstChild);
- }
-
- var sql = "SELECT key AS domainPath, value AS format FROM settings "
- + "WHERE setting='quickCopySite' ORDER BY domainPath COLLATE NOCASE";
- var siteData = Zotero.DB.query(sql);
-
- if (!siteData) {
- return;
- }
-
- for (var i=0; i<siteData.length; i++) {
- var treeitem = document.createElement('treeitem');
- var treerow = document.createElement('treerow');
- var domainCell = document.createElement('treecell');
- var formatCell = document.createElement('treecell');
- var HTMLCell = document.createElement('treecell');
-
- domainCell.setAttribute('label', siteData[i].domainPath);
-
- var formatted = Zotero.QuickCopy.getFormattedNameFromSetting(siteData[i].format);
- formatCell.setAttribute('label', formatted);
- var copyAsHTML = Zotero.QuickCopy.getContentType(siteData[i].format) == 'html';
- HTMLCell.setAttribute('label', copyAsHTML ? ' ✓ ' : '');
-
- treerow.appendChild(domainCell);
- treerow.appendChild(formatCell);
- treerow.appendChild(HTMLCell);
- treeitem.appendChild(treerow);
- treechildren.appendChild(treeitem);
- }
-}
-
-
-function deleteSelectedQuickCopySite() {
- var tree = document.getElementById('quickCopy-siteSettings');
- var treeitem = tree.lastChild.childNodes[tree.currentIndex];
- var domainPath = treeitem.firstChild.firstChild.getAttribute('label');
- Zotero.DB.query("DELETE FROM settings WHERE setting='quickCopySite' AND key=?", [domainPath]);
- refreshQuickCopySiteList();
-}
-
-
-function updateQuickCopyInstructions() {
- var prefix = Zotero.isMac ? 'Cmd+Shift+' : 'Ctrl+Alt+';
-
- var key = Zotero.Prefs.get('keys.copySelectedItemsToClipboard');
- var str = Zotero.getString('zotero.preferences.export.quickCopy.instructions', prefix + key);
- var instr = document.getElementById('quickCopy-instructions');
- while (instr.hasChildNodes()) {
- instr.removeChild(instr.firstChild);
- }
- instr.appendChild(document.createTextNode(str));
-
- var key = Zotero.Prefs.get('keys.copySelectedItemCitationsToClipboard');
- var str = Zotero.getString('zotero.preferences.export.quickCopy.citationInstructions', prefix + key);
- var instr = document.getElementById('quickCopy-citationInstructions');
- while (instr.hasChildNodes()) {
- instr.removeChild(instr.firstChild);
- }
- instr.appendChild(document.createTextNode(str));
-}
-
-
-function rebuildIndexPrompt() {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
- createInstance(Components.interfaces.nsIPromptService);
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_CANCEL);
-
- var index = ps.confirmEx(null,
- Zotero.getString('zotero.preferences.search.rebuildIndex'),
- Zotero.getString('zotero.preferences.search.rebuildWarning',
- Zotero.getString('zotero.preferences.search.indexUnindexed')),
- buttonFlags,
- Zotero.getString('zotero.preferences.search.rebuildIndex'),
- Zotero.getString('zotero.preferences.search.indexUnindexed'),
- null, null, {});
-
- if (index == 0) {
- Zotero.Fulltext.rebuildIndex();
- }
- else if (index == 1) {
- Zotero.Fulltext.rebuildIndex(true)
- }
-
- updateIndexStats();
-}
-
-
-function clearIndexPrompt() {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
- createInstance(Components.interfaces.nsIPromptService);
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_CANCEL);
-
- var index = ps.confirmEx(null,
- Zotero.getString('zotero.preferences.search.clearIndex'),
- Zotero.getString('zotero.preferences.search.clearWarning',
- Zotero.getString('zotero.preferences.search.clearNonLinkedURLs')),
- buttonFlags,
- Zotero.getString('zotero.preferences.search.clearIndex'),
- Zotero.getString('zotero.preferences.search.clearNonLinkedURLs'),
- null, null, {});
-
- if (index == 0) {
- Zotero.Fulltext.clearIndex();
- }
- else if (index == 1) {
- Zotero.Fulltext.clearIndex(true);
- }
-
- updateIndexStats();
-}
-
-
-function initSearchPane() {
- document.getElementById('fulltext-rebuildIndex').setAttribute('label',
- Zotero.getString('zotero.preferences.search.rebuildIndex'));
- document.getElementById('fulltext-clearIndex').setAttribute('label',
- Zotero.getString('zotero.preferences.search.clearIndex'));
- updatePDFToolsStatus();
-}
-
-
-/*
- * Update window according to installation status for PDF tools
- * (e.g. status line, install/update button, etc.)
- */
-function updatePDFToolsStatus() {
- var converterIsRegistered = Zotero.Fulltext.pdfConverterIsRegistered();
- var infoIsRegistered = Zotero.Fulltext.pdfInfoIsRegistered();
+ },
- var converterStatusLabel = document.getElementById('pdfconverter-status');
- var infoStatusLabel = document.getElementById('pdfinfo-status');
- var requiredLabel = document.getElementById('pdftools-required');
- var updateButton = document.getElementById('pdftools-update-button');
- var documentationLink = document.getElementById('pdftools-documentation-link');
- var settingsBox = document.getElementById('pdftools-settings');
- // If we haven't already generated the required and documentation messages
- if (!converterIsRegistered && !requiredLabel.hasChildNodes()) {
-
- // Xpdf link
- var str = Zotero.getString('zotero.preferences.search.pdf.toolsRequired',
- [Zotero.Fulltext.pdfConverterName, Zotero.Fulltext.pdfInfoName,
- '<a href="' + Zotero.Fulltext.pdfToolsURL + '">'
- + Zotero.Fulltext.pdfToolsName + '</a>']);
- var parts = Zotero.Utilities.parseMarkup(str);
- for (var i=0; i<parts.length; i++) {
- var part = parts[i];
- if (part.type == 'text') {
- var elem = document.createTextNode(part.text);
- }
- else if (part.type == 'link') {
- var elem = document.createElement('label');
- elem.setAttribute('value', part.text);
- elem.setAttribute('class', 'zotero-text-link');
- for (var key in part.attributes) {
- elem.setAttribute(key, part.attributes[key]);
-
- if (key == 'href') {
- elem.setAttribute('tooltiptext', part.attributes[key]);
- }
- }
- }
- requiredLabel.appendChild(elem);
- }
+ /**
+ * Opens a URI in the basic viewer in Standalone, or a new window in Firefox
+ */
+ openInViewer: function (uri, newTab) {
+ var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Components.interfaces.nsIWindowMediator);
+ const features = "menubar=yes,toolbar=no,location=no,scrollbars,centerscreen,resizable";
- requiredLabel.appendChild(document.createTextNode(' '
- + Zotero.getString('zotero.preferences.search.pdf.automaticInstall')));
-
- // Documentation link
- var link = '<a href="http://www.zotero.org/documentation/pdf_fulltext_indexing">'
- + Zotero.getString('zotero.preferences.search.pdf.documentationLink')
- + '</a>';
- var str = Zotero.getString('zotero.preferences.search.pdf.advancedUsers', link);
- var parts = Zotero.Utilities.parseMarkup(str);
-
- for (var i=0; i<parts.length; i++) {
- var part = parts[i];
- if (part.type == 'text') {
- var elem = document.createTextNode(part.text);
- }
- else if (part.type == 'link') {
- var elem = document.createElement('label');
- elem.setAttribute('value', part.text);
- elem.setAttribute('class', 'zotero-text-link');
- for (var key in part.attributes) {
- elem.setAttribute(key, part.attributes[key]);
-
- if (key == 'href') {
- elem.setAttribute('tooltiptext', part.attributes[key]);
- }
- }
+ if(Zotero.isStandalone) {
+ var win = wm.getMostRecentWindow("zotero:basicViewer");
+ if(win) {
+ win.loadURI(uri);
+ } else {
+ window.openDialog("chrome://zotero/content/standalone/basicViewer.xul",
+ "basicViewer", "chrome,resizable,centerscreen,menubar,scrollbars", uri);
}
- documentationLink.appendChild(elem);
- }
- }
-
- // converter status line
- var prefix = 'zotero.preferences.search.pdf.tool';
- if (converterIsRegistered) {
- var version = Zotero.Fulltext.pdfConverterVersion;
- str = Zotero.getString(prefix + 'Registered',
- Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform',
- [Zotero.Fulltext.pdfConverterName, version]));
- }
- else {
- str = Zotero.getString(prefix + 'NotRegistered',
- [Zotero.Fulltext.pdfConverterFileName]);
- }
- converterStatusLabel.setAttribute('value', str);
-
- // pdfinfo status line
- if (infoIsRegistered) {
- var version = Zotero.Fulltext.pdfInfoVersion;
- str = Zotero.getString(prefix + 'Registered',
- Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform',
- [Zotero.Fulltext.pdfInfoName, version]));
- }
- else {
- str = Zotero.getString(prefix + 'NotRegistered',
- [Zotero.Fulltext.pdfInfoFileName]);
- }
- infoStatusLabel.setAttribute('value', str);
-
- str = converterIsRegistered ?
- Zotero.getString('general.checkForUpdate') :
- Zotero.getString('zotero.preferences.search.pdf.checkForInstaller');
- updateButton.setAttribute('label', str);
-
- requiredLabel.setAttribute('hidden', converterIsRegistered);
- documentationLink.setAttribute('hidden', converterIsRegistered);
- settingsBox.setAttribute('hidden', !converterIsRegistered);
-}
-
-
-/*
- * Check available versions of PDF tools from server and prompt for installation
- * if a newer version is available
- */
-function checkPDFToolsDownloadVersion() {
- var url = Zotero.Fulltext.pdfToolsDownloadBaseURL
- + Zotero.platform.replace(' ', '-') + '.latest';
-
- // Find latest version for this platform
- var sent = Zotero.HTTP.doGet(url, function (xmlhttp) {
- try {
- if (xmlhttp.status == 200) {
- var converterIsRegistered = Zotero.Fulltext.pdfConverterIsRegistered();
- var infoIsRegistered = Zotero.Fulltext.pdfInfoIsRegistered();
- var bothRegistered = converterIsRegistered && infoIsRegistered;
-
- var converterVersion = xmlhttp.responseText.split(/\s/)[0];
- var infoVersion = xmlhttp.responseText.split(/\s/)[1];
-
- var converterVersionAvailable = converterVersion &&
- (!converterIsRegistered ||
- Zotero.Fulltext.pdfConverterVersion == 'UNKNOWN' ||
- converterVersion > Zotero.Fulltext.pdfConverterVersion);
- var infoVersionAvailable = infoVersion &&
- (!infoIsRegistered ||
- Zotero.Fulltext.pdfInfoVersion == 'UNKNOWN' ||
- infoVersion > Zotero.Fulltext.pdfInfoVersion);
- var bothAvailable = converterVersionAvailable && infoVersionAvailable;
-
- /*
- Zotero.debug(converterIsRegistered);
- Zotero.debug(infoIsRegistered);
- Zotero.debug(converterVersion);
- Zotero.debug(infoVersion);
- Zotero.debug(Zotero.Fulltext.pdfConverterVersion);
- Zotero.debug(Zotero.Fulltext.pdfInfoVersion);
- Zotero.debug(converterVersionAvailable);
- Zotero.debug(infoVersionAvailable);
- */
-
- // Up to date -- disable update button
- if (!converterVersionAvailable && !infoVersionAvailable) {
- var button = document.getElementById('pdftools-update-button');
- button.setAttribute('label', Zotero.getString('zotero.preferences.update.upToDate'));
- button.setAttribute('disabled', true);
- }
- // New version available -- display update prompt
- else {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
- createInstance(Components.interfaces.nsIPromptService);
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
-
- var msg = Zotero.getString('zotero.preferences.search.pdf.available'
- + ((converterIsRegistered || infoIsRegistered) ? 'Updates' : 'Downloads'),
- [Zotero.platform, 'zotero.org']) + '\n\n';
-
- if (converterVersionAvailable) {
- tvp = Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform',
- [Zotero.Fulltext.pdfConverterName, converterVersion]);
- msg += '- ' + tvp + '\n';
- }
- if (infoVersionAvailable) {
- tvp = Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform',
- [Zotero.Fulltext.pdfInfoName, infoVersion]);
- msg += '- ' + tvp + '\n';
- }
- msg += '\n';
- msg += Zotero.getString('zotero.preferences.search.pdf.zoteroCanInstallVersion'
- + (bothAvailable ? 's' : ''));
-
- var index = ps.confirmEx(null,
- converterIsRegistered ?
- Zotero.getString('general.updateAvailable') : '',
- msg,
- buttonFlags,
- converterIsRegistered ?
- Zotero.getString('general.upgrade') :
- Zotero.getString('general.install'),
- null, null, null, {});
-
- if (index == 0) {
- var installVersions = {
- converter: converterVersionAvailable ?
- converterVersion : null,
- info: infoVersionAvailable ?
- infoVersion : null
- };
- installPDFTools(installVersions);
- }
+ } else {
+ var win = wm.getMostRecentWindow("navigator:browser");
+ if(win) {
+ if(newTab) {
+ win.gBrowser.selectedTab = win.gBrowser.addTab(uri);
+ } else {
+ win.open(uri, null, features);
}
}
- // Version not found for platform
- else if (xmlhttp.status == 404) {
- onPDFToolsDownloadError(404);
+ else {
+ var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
+ .getService(Components.interfaces.nsIWindowWatcher);
+ var win = ww.openWindow(null, uri, null, features + ",width=775,height=575", null);
}
}
- catch (e) {
- onPDFToolsDownloadError(e);
- }
- });
-
- // Browser is offline
- if (!sent) {
- onPDFToolsDownloadError();
- }
-}
-
-
-/*
- * Begin installation of specified PDF tools from server -- does a HEAD call to
- * make sure file exists and then calls downloadPDFTool() if so
- */
-function installPDFTools(installVersions) {
- if (!installVersions) {
- installVersions = {
- converter: true,
- info: true
- };
- }
-
- // We install the converter first if it's available
- var url = Zotero.Fulltext.pdfToolsDownloadBaseURL;
- if (installVersions.converter) {
- var tool = 'converter';
- var version = installVersions.converter;
- url += Zotero.Fulltext.pdfConverterFileName + '-' + installVersions.converter;
- }
- else if (installVersions.info) {
- var tool = 'info';
- var version = installVersions.info;
- url += Zotero.Fulltext.pdfInfoFileName + '-' + installVersions.info;
- }
- else {
- return;
- }
-
- // Find latest version for this platform
- var sent = Zotero.HTTP.doHead(url, function (xmlhttp) {
- try {
- if (xmlhttp.status == 200) {
- // If doing both and on converter, chain pdfinfo
- if (installVersions.converter && installVersions.info) {
- downloadPDFTool(tool, version, function () {
- return installPDFTools({ info: installVersions.info });
- });
- }
- else {
- downloadPDFTool(tool, version);
- }
- }
- // Version not found for platform
- else if (xmlhttp.status == 404) {
- onPDFToolsDownloadError(404);
- }
- }
- catch (e) {
- onPDFToolsDownloadError(e);
- }
- });
-
- // Browser is offline
- if (!sent) {
- onPDFToolsDownloadError();
- }
-}
-
-
-/*
- * Download and install specified PDF tool
- */
-function downloadPDFTool(tool, version, callback) {
- var ioService = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService);
-
- if (tool == 'converter') {
- var fileName = Zotero.Fulltext.pdfConverterFileName;
- }
- else {
- var fileName = Zotero.Fulltext.pdfInfoFileName;
- }
-
-
- var url = Zotero.Fulltext.pdfToolsDownloadBaseURL + fileName + '-' + version;
- var uri = ioService.newURI(url, null, null);
-
- var file = Zotero.getZoteroDirectory();
- file.append(fileName);
- var fileURL = ioService.newFileURI(file);
-
- const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
- var wbp = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
- .createInstance(nsIWBP);
-
- var progressListener = new Zotero.WebProgressFinishListener(function () {
- // Set permissions to 755
- if (Zotero.isMac) {
- file.permissions = 33261;
- }
- else if (Zotero.isLinux) {
- file.permissions = 493;
- }
-
- // Write the version number to a file
- var versionFile = Zotero.getZoteroDirectory();
- versionFile.append(fileName + '.version');
- Zotero.File.putContents(versionFile, version + '');
-
- Zotero.Fulltext.registerPDFTool(tool);
-
- // Used to install info tool after converter
- if (callback) {
- callback();
- }
- // If done
- else {
- updatePDFToolsStatus();
- }
- });
-
- /*
- var tr = Components.classes["@mozilla.org/transfer;1"].
- createInstance(Components.interfaces.nsITransfer);
- tr.init(uri, fileURL, "", null, null, null, wbp);
- */
-
- document.getElementById('pdftools-update-button').disabled = true;
- var str = Zotero.getString('zotero.preferences.search.pdf.downloading');
- document.getElementById('pdftools-update-button').setAttribute('label', str);
-
- wbp.progressListener = progressListener;
- Zotero.debug("Saving " + uri.spec + " to " + fileURL.spec);
- try {
- wbp.saveURI(uri, null, null, null, null, fileURL);
- } catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
- // https://bugzilla.mozilla.org/show_bug.cgi?id=794602
- // XXX Always use when we no longer support Firefox < 18
- wbp.saveURI(uri, null, null, null, null, fileURL, null);
- }
-}
-
-
-function onPDFToolsDownloadError(e) {
- if (e == 404) {
- var str = Zotero.getString('zotero.preferences.search.pdf.toolDownloadsNotAvailable',
- Zotero.Fulltext.pdfToolsName) + ' '
- + Zotero.getString('zotero.preferences.search.pdf.viewManualInstructions');
- }
- else if (e) {
- Components.utils.reportError(e);
- var str = Zotero.getString('zotero.preferences.search.pdf.toolsDownloadError', Zotero.Fulltext.pdfToolsName)
- + ' ' + Zotero.getString('zotero.preferences.search.pdf.tryAgainOrViewManualInstructions');
- }
- else {
- var info = Components.classes["@mozilla.org/xre/app-info;1"]
- .getService(Components.interfaces.nsIXULAppInfo);
- var browser = info.name; // Returns "Firefox" for Firefox
- var str = Zotero.getString('general.browserIsOffline', browser);
- }
- alert(str);
-}
-
-
-function updateIndexStats() {
- var stats = Zotero.Fulltext.getIndexStats();
- document.getElementById('fulltext-stats-indexed').
- lastChild.setAttribute('value', stats.indexed);
- document.getElementById('fulltext-stats-partial').
- lastChild.setAttribute('value', stats.partial);
- document.getElementById('fulltext-stats-unindexed').
- lastChild.setAttribute('value', stats.unindexed);
- document.getElementById('fulltext-stats-words').
- lastChild.setAttribute('value', stats.words);
-}
-
-
-function revealDataDirectory() {
- var dataDir = Zotero.getZoteroDirectory();
- dataDir.QueryInterface(Components.interfaces.nsILocalFile);
- try {
- dataDir.reveal();
- }
- catch (e) {
- // On platforms that don't support nsILocalFile.reveal() (e.g. Linux),
- // launch the directory
- window.opener.ZoteroPane_Local.launchFile(dataDir);
- }
-}
-
-
-function runIntegrityCheck() {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- var ok = Zotero.DB.integrityCheck();
- if (ok) {
- ok = Zotero.Schema.integrityCheck();
- if (!ok) {
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
- var index = ps.confirmEx(window,
- Zotero.getString('general.failed'),
- Zotero.getString('db.integrityCheck.failed') + "\n\n" +
- Zotero.getString('db.integrityCheck.repairAttempt') + " " +
- Zotero.getString('db.integrityCheck.appRestartNeeded', Zotero.appName),
- buttonFlags,
- Zotero.getString('db.integrityCheck.fixAndRestart', Zotero.appName),
- null, null, null, {}
- );
-
- if (index == 0) {
- // Safety first
- Zotero.DB.backupDatabase();
-
- // Fix the errors
- Zotero.Schema.integrityCheck(true);
-
- // And run the check again
- ok = Zotero.Schema.integrityCheck();
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
- if (ok) {
- var str = 'success';
- var msg = Zotero.getString('db.integrityCheck.errorsFixed');
- }
- else {
- var str = 'failed';
- var msg = Zotero.getString('db.integrityCheck.errorsNotFixed')
- + "\n\n" + Zotero.getString('db.integrityCheck.reportInForums');
- }
-
- ps.confirmEx(window,
- Zotero.getString('general.' + str),
- msg,
- buttonFlags,
- Zotero.getString('general.restartApp', Zotero.appName),
- null, null, null, {}
- );
-
- var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
- .getService(Components.interfaces.nsIAppStartup);
- appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit
- | Components.interfaces.nsIAppStartup.eRestart);
- }
-
- return;
- }
- }
- var str = ok ? 'passed' : 'failed';
-
- ps.alert(window,
- Zotero.getString('general.' + str),
- Zotero.getString('db.integrityCheck.' + str)
- + (!ok ? "\n\n" + Zotero.getString('db.integrityCheck.dbRepairTool') : ''));
-}
-
-
-function updateTranslators() {
- Zotero.Schema.updateFromRepository(true, function (xmlhttp, updated) {
- var button = document.getElementById('updateButton');
- if (button) {
- if (updated===-1) {
- var label = Zotero.getString('zotero.preferences.update.upToDate');
- }
- else if (updated) {
- var label = Zotero.getString('zotero.preferences.update.updated');
- }
- else {
- var label = Zotero.getString('zotero.preferences.update.error');
- }
- button.setAttribute('label', label);
-
- if (updated) {
- refreshStylesList();
- }
- }
- });
-}
-
-
-function resetTranslatorsAndStyles() {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
-
- var index = ps.confirmEx(null,
- Zotero.getString('general.warning'),
- Zotero.getString('zotero.preferences.advanced.resetTranslatorsAndStyles.changesLost'),
- buttonFlags,
- Zotero.getString('zotero.preferences.advanced.resetTranslatorsAndStyles'),
- null, null, null, {});
-
- if (index == 0) {
- Zotero.Schema.resetTranslatorsAndStyles(function (xmlhttp, updated) {
- populateQuickCopyList();
- });
- }
-}
-
-
-function resetTranslators() {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
-
- var index = ps.confirmEx(null,
- Zotero.getString('general.warning'),
- Zotero.getString('zotero.preferences.advanced.resetTranslators.changesLost'),
- buttonFlags,
- Zotero.getString('zotero.preferences.advanced.resetTranslators'),
- null, null, null, {});
-
- if (index == 0) {
- Zotero.Schema.resetTranslators();
- }
-}
-
-
-function resetStyles() {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
-
- var index = ps.confirmEx(null,
- Zotero.getString('general.warning'),
- Zotero.getString('zotero.preferences.advanced.resetStyles.changesLost'),
- buttonFlags,
- Zotero.getString('zotero.preferences.advanced.resetStyles'),
- null, null, null, {});
-
- if (index == 0) {
- Zotero.Schema.resetStyles(function (xmlhttp, updated) {
- populateQuickCopyList();
- });
- }
-}
-
-
-Zotero_Preferences.Debug_Output = {
- _timer: null,
-
- init: function () {
- var storing = Zotero.Debug.storing;
- this._updateButton();
- this.updateLines();
- if (storing) {
- this._initTimer();
- }
- },
-
-
- toggleStore: function () {
- this.setStore(!Zotero.Debug.storing);
- },
-
-
- setStore: function (set) {
- Zotero.Debug.setStore(set);
- if (set) {
- this._initTimer();
- }
- else {
- if (this._timerID) {
- this._timer.cancel();
- this._timerID = null;
- }
- }
- this._updateButton();
- this.updateLines();
- },
-
-
- view: function () {
- openInViewer("zotero://debug/");
- },
-
-
- submit: function () {
- document.getElementById('debug-output-submit').disabled = true;
- document.getElementById('debug-output-submit-progress').hidden = false;
-
- var url = "https://repo.zotero.org/repo/report?debug=1";
- var output = Zotero.Debug.get(
- Zotero.Prefs.get('debug.store.submitSize'),
- Zotero.Prefs.get('debug.store.submitLineLength')
- );
- Zotero_Preferences.Debug_Output.setStore(false);
-
- var uploadCallback = function (xmlhttp) {
- document.getElementById('debug-output-submit').disabled = false;
- document.getElementById('debug-output-submit-progress').hidden = true;
-
- Zotero.debug(xmlhttp.responseText);
-
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- if (!xmlhttp.responseXML) {
- ps.alert(
- null,
- Zotero.getString('general.error'),
- Zotero.getString('general.invalidResponseServer')
- );
- return;
- }
- var reported = xmlhttp.responseXML.getElementsByTagName('reported');
- if (reported.length != 1) {
- ps.alert(
- null,
- Zotero.getString('general.error'),
- Zotero.getString('general.serverError')
- );
- return;
- }
-
- var reportID = reported[0].getAttribute('reportID');
- ps.alert(
- null,
- Zotero.getString('zotero.preferences.advanced.debug.title'),
- Zotero.getString('zotero.preferences.advanced.debug.sent', reportID)
- );
- }
-
- var bufferUploader = function (data) {
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- var oldLen = output.length;
- var newLen = data.length;
- var savings = Math.round(((oldLen - newLen) / oldLen) * 100)
- Zotero.debug("HTTP POST " + newLen + " bytes to " + url
- + " (gzipped from " + oldLen + " bytes; "
- + savings + "% savings)");
-
- if (Zotero.HTTP.browserIsOffline()) {
- ps.alert(
- null,
- Zotero.getString('general.error'),
- Zotero.getString('general.browserIsOffline', Zotero.appName)
- );
- return false;
- }
-
- var req =
- Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].
- createInstance();
- req.open('POST', url, true);
- req.setRequestHeader('Content-Type', "text/plain");
- req.setRequestHeader('Content-Encoding', 'gzip');
-
- req.channel.notificationCallbacks = {
- onProgress: function (request, context, progress, progressMax) {
- var pm = document.getElementById('debug-output-submit-progress');
- pm.mode = 'determined'
- pm.value = progress;
- pm.max = progressMax;
- },
-
- // nsIInterfaceRequestor
- getInterface: function (iid) {
- try {
- return this.QueryInterface(iid);
- }
- catch (e) {
- throw Components.results.NS_NOINTERFACE;
- }
- },
-
- QueryInterface: function(iid) {
- if (iid.equals(Components.interfaces.nsISupports) ||
- iid.equals(Components.interfaces.nsIInterfaceRequestor) ||
- iid.equals(Components.interfaces.nsIProgressEventSink)) {
- return this;
- }
- throw Components.results.NS_NOINTERFACE;
- },
-
- }
- req.onreadystatechange = function () {
- if (req.readyState == 4) {
- uploadCallback(req);
- }
- };
- try {
- req.sendAsBinary(data);
- }
- catch (e) {
- ps.alert(
- null,
- Zotero.getString('general.error'),
- Zotero.getString('zotero.preferences.advanced.debug.error')
- );
- }
- }
-
- // Get input stream from debug output data
- var unicodeConverter =
- Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
- .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
- unicodeConverter.charset = "UTF-8";
- var bodyStream = unicodeConverter.convertToInputStream(output);
-
- // Get listener for when compression is done
- var listener = new Zotero.BufferedInputListener(bufferUploader);
-
- // Initialize stream converter
- var converter =
- Components.classes["@mozilla.org/streamconv;1?from=uncompressed&to=gzip"]
- .createInstance(Components.interfaces.nsIStreamConverter);
- converter.asyncConvertData("uncompressed", "gzip", listener, null);
-
- // Send input stream to stream converter
- var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].
- createInstance(Components.interfaces.nsIInputStreamPump);
- pump.init(bodyStream, -1, -1, 0, 0, true);
- pump.asyncRead(converter, null);
- },
-
-
- clear: function () {
- Zotero.Debug.clear();
- this.updateLines();
- },
-
-
- updateLines: function () {
- var enabled = Zotero.Debug.storing;
- var lines = Zotero.Debug.count();
- document.getElementById('debug-output-lines').value = lines;
- var empty = lines == 0;
- document.getElementById('debug-output-view').disabled = !enabled && empty;
- document.getElementById('debug-output-clear').disabled = empty;
- document.getElementById('debug-output-submit').disabled = empty;
- },
-
-
- _initTimer: function () {
- this._timer = Components.classes["@mozilla.org/timer;1"].
- createInstance(Components.interfaces.nsITimer);
- this._timer.initWithCallback({
- notify: function() {
- Zotero_Preferences.Debug_Output.updateLines();
- }
- }, 10000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
- },
-
-
- _updateButton: function () {
- var storing = Zotero.Debug.storing
-
- var button = document.getElementById('debug-output-enable');
- if (storing) {
- button.label = Zotero.getString('general.disable');
- }
- else {
- button.label = Zotero.getString('general.enable');
- }
- },
-
-
- onUnload: function () {
- if (this._timer) {
- this._timer.cancel();
- }
- }
-}
-
-function onOpenURLSelected()
-{
- var openURLServerField = document.getElementById('openURLServerField');
- var openURLVersionMenu = document.getElementById('openURLVersionMenu');
- var openURLMenu = document.getElementById('openURLMenu');
-
- if(openURLMenu.value == "custom")
- {
- openURLServerField.focus();
- }
- else
- {
- openURLServerField.value = openURLResolvers[openURLMenu.selectedIndex]['url'];
- openURLVersionMenu.value = openURLResolvers[openURLMenu.selectedIndex]['version'];
- Zotero.Prefs.set("openURL.resolver", openURLResolvers[openURLMenu.selectedIndex]['url']);
- Zotero.Prefs.set("openURL.version", openURLResolvers[openURLMenu.selectedIndex]['version']);
- }
-}
-
-function onOpenURLCustomized()
-{
- document.getElementById('openURLMenu').value = "custom";
-}
-
-/** STYLES **/
-
-/**
- * Refreshes the list of styles in the styles pane
- * @param {String} cslID Style to select
- */
-function refreshStylesList(cslID) {
- var treechildren = document.getElementById('styleManager-rows');
- while (treechildren.hasChildNodes()) {
- treechildren.removeChild(treechildren.firstChild);
- }
-
- var styles = Zotero.Styles.getVisible();
-
- var selectIndex = false;
- var i = 0;
- for each(var style in styles) {
- var treeitem = document.createElement('treeitem');
- var treerow = document.createElement('treerow');
- var titleCell = document.createElement('treecell');
- var updatedCell = document.createElement('treecell');
- var cslCell = document.createElement('treecell');
-
- if (style.updated) {
- var updatedDate = Zotero.Date.formatDate(Zotero.Date.strToDate(style.updated), true);
- }
- else {
- var updatedDate = '';
- }
-
- treeitem.setAttribute('id', 'zotero-csl-' + style.styleID);
- titleCell.setAttribute('label', style.title);
- updatedCell.setAttribute('label', updatedDate);
- // if not EN
- if(style.type == "csl") {
- cslCell.setAttribute('src', 'chrome://zotero/skin/tick.png');
- }
-
- treerow.appendChild(titleCell);
- treerow.appendChild(updatedCell);
- treerow.appendChild(cslCell);
- treeitem.appendChild(treerow);
- treechildren.appendChild(treeitem);
-
- if (cslID == style.styleID) {
- document.getElementById('styleManager').view.selection.select(i);
- }
- i++;
- }
-}
-
-/**
- * Adds a new style to the style pane
- **/
-function addStyle() {
- const nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"]
- .createInstance(nsIFilePicker);
- fp.init(window, Zotero.getString("zotero.preferences.styles.addStyle"), nsIFilePicker.modeOpen);
-
- fp.appendFilter("CSL Style", "*.csl");
- fp.appendFilter("ENS Style", "*.ens");
-
- var rv = fp.show();
- if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
- Zotero.Styles.install(fp.file);
- }
-}
-
-/**
- * Deletes selected styles from the styles pane
- **/
-function deleteStyle() {
- // get selected cslIDs
- var tree = document.getElementById('styleManager');
- var treeItems = tree.lastChild.childNodes;
- var cslIDs = [];
- var start = {};
- var end = {};
- var nRanges = tree.view.selection.getRangeCount();
- for(var i=0; i<nRanges; i++) {
- tree.view.selection.getRangeAt(i, start, end);
- for(var j=start.value; j<=end.value; j++) {
- cslIDs.push(treeItems[j].getAttribute('id').substr(11));
- }
- }
-
- if(cslIDs.length == 0) {
- return;
- } else if(cslIDs.length == 1) {
- var selectedStyle = Zotero.Styles.get(cslIDs[0])
- var text = Zotero.getString('styles.deleteStyle', selectedStyle.title);
- } else {
- var text = Zotero.getString('styles.deleteStyles');
- }
-
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- if(ps.confirm(null, '', text)) {
- // delete if requested
- if(cslIDs.length == 1) {
- selectedStyle.remove();
- } else {
- for(var i=0; i<cslIDs.length; i++) {
- Zotero.Styles.get(cslIDs[i]).remove();
- }
- }
-
- this.refreshStylesList();
- document.getElementById('styleManager-delete').disabled = true;
- }
-}
-
-/**
- * Shows an error if import fails
- **/
-function styleImportError() {
- alert(Zotero.getString('styles.installError', "This"));
-}
-
-/**PROXIES**/
-
-/**
- * Adds a proxy to the proxy pane
- */
-function showProxyEditor(index) {
- if(index == -1) return;
- window.openDialog('chrome://zotero/content/preferences/proxyEditor.xul',
- "zotero-preferences-proxyEditor", "chrome, modal", index !== undefined ? proxies[index] : null);
- refreshProxyList();
-}
-
-/**
- * Deletes the currently selected proxy
- */
-function deleteProxy() {
- if(document.getElementById('proxyTree').currentIndex == -1) return;
- proxies[document.getElementById('proxyTree').currentIndex].erase();
- refreshProxyList();
- document.getElementById('proxyTree-delete').disabled = true;
-}
-
-/**
- * Refreshes the proxy pane
- */
-function refreshProxyList() {
- if(!document.getElementById("zotero-prefpane-proxies")) return;
-
- // get and sort proxies
- proxies = Zotero.Proxies.proxies.slice();
- for(var i=0; i<proxies.length; i++) {
- if(!proxies[i].proxyID) {
- proxies.splice(i, 1);
- i--;
- }
- }
- proxies = proxies.sort(function(a, b) {
- if(a.multiHost) {
- if(b.multiHost) {
- if(a.hosts[0] < b.hosts[0]) {
- return -1;
- } else {
- return 1;
- }
- } else {
- return -1;
- }
- } else if(b.multiHost) {
- return 1;
- }
-
- if(a.scheme < b.scheme) {
- return -1;
- } else if(b.scheme > a.scheme) {
- return 1;
- }
-
- return 0;
- });
-
- // erase old children
- var treechildren = document.getElementById('proxyTree-rows');
- while (treechildren.hasChildNodes()) {
- treechildren.removeChild(treechildren.firstChild);
- }
-
- // add proxies to list
- for (var i=0; i<proxies.length; i++) {
- var treeitem = document.createElement('treeitem');
- var treerow = document.createElement('treerow');
- var hostnameCell = document.createElement('treecell');
- var schemeCell = document.createElement('treecell');
-
- hostnameCell.setAttribute('label', proxies[i].multiHost ? Zotero.getString("proxies.multiSite") : proxies[i].hosts[0]);
- schemeCell.setAttribute('label', proxies[i].scheme);
-
- treerow.appendChild(hostnameCell);
- treerow.appendChild(schemeCell);
- treeitem.appendChild(treerow);
- treechildren.appendChild(treeitem);
- }
-
- document.getElementById('proxyTree').currentIndex = -1;
- document.getElementById('proxyTree-delete').disabled = true;
- document.getElementById('zotero-proxies-transparent').checked = Zotero.Prefs.get("proxies.transparent");
- document.getElementById('zotero-proxies-autoRecognize').checked = Zotero.Prefs.get("proxies.autoRecognize");
- document.getElementById('zotero-proxies-disableByDomain-checkbox').checked = Zotero.Prefs.get("proxies.disableByDomain");
- document.getElementById('zotero-proxies-disableByDomain-textbox').value = Zotero.Prefs.get("proxies.disableByDomainString");
-}
-
-/**
- * Updates proxy autoRecognize and transparent settings based on checkboxes
- */
-function updateProxyPrefs() {
- var transparent = document.getElementById('zotero-proxies-transparent').checked;
- Zotero.Prefs.set("proxies.transparent", transparent);
- Zotero.Prefs.set("proxies.autoRecognize", document.getElementById('zotero-proxies-autoRecognize').checked);
- Zotero.Prefs.set("proxies.disableByDomainString", document.getElementById('zotero-proxies-disableByDomain-textbox').value);
- Zotero.Prefs.set("proxies.disableByDomain", document.getElementById('zotero-proxies-disableByDomain-checkbox').checked &&
- document.getElementById('zotero-proxies-disableByDomain-textbox').value != "");
-
- Zotero.Proxies.init();
-
- document.getElementById('proxyTree-add').disabled =
- document.getElementById('proxyTree-delete').disabled =
- document.getElementById('proxyTree').disabled =
- document.getElementById('zotero-proxies-autoRecognize').disabled =
- document.getElementById('zotero-proxies-disableByDomain-checkbox').disabled =
- document.getElementById('zotero-proxies-disableByDomain-textbox').disabled = !transparent;
-
-}
-
-/**
- * Determines if there are word processors, and if not, enables no word processor message
- */
-function updateWordProcessorInstructions() {
- if(document.getElementById("wordProcessors").childNodes.length == 2) {
- document.getElementById("wordProcessors-noWordProcessorPluginsInstalled").hidden = undefined;
- }
- if(Zotero.isStandalone) {
- document.getElementById("wordProcessors-getWordProcessorPlugins").hidden = true;
- }
-}
-
-/**
- * Sets "Status bar icon" to "None" if Zotero is set to load in separate tab
- */
-function handleShowInPreferenceChange() {
- var showInSeparateTab = document.getElementById("zotero-prefpane-general-showIn-separateTab");
- var showInAppTab = document.getElementById("zotero-prefpane-general-showIn-appTab");
- if(showInAppTab.selected) {
- document.getElementById('statusBarIcon').selectedItem = document.getElementById('statusBarIcon-none');
- Zotero.Prefs.set("statusBarIcon", 0);
- } else {
- document.getElementById('statusBarIcon').selectedItem = document.getElementById('statusBarIcon-full');
- Zotero.Prefs.set("statusBarIcon", 2);
- }
-}
-
-/**
- * Opens a URI in the basic viewer in Standalone, or a new window in Firefox
- */
-function openInViewer(uri, newTab) {
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- const features = "menubar=yes,toolbar=no,location=no,scrollbars,centerscreen,resizable";
-
- if(Zotero.isStandalone) {
- var win = wm.getMostRecentWindow("zotero:basicViewer");
- if(win) {
- win.loadURI(uri);
- } else {
- window.openDialog("chrome://zotero/content/standalone/basicViewer.xul",
- "basicViewer", "chrome,resizable,centerscreen,menubar,scrollbars", uri);
- }
- } else {
- var win = wm.getMostRecentWindow("navigator:browser");
- if(win) {
- if(newTab) {
- win.gBrowser.selectedTab = win.gBrowser.addTab(uri);
- } else {
- win.open(uri, null, features);
- }
- }
- else {
- var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
- .getService(Components.interfaces.nsIWindowWatcher);
- var win = ww.openWindow(null, uri, null, features + ",width=775,height=575", null);
- }
- }
-}
-
-
-Zotero_Preferences.Attachment_Base_Directory = {
- choosePath: function () {
- // Get existing base directory
- var oldBasePath = Zotero.Prefs.get('baseAttachmentPath');
- if (oldBasePath) {
- var oldBasePathFile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- try {
- oldBasePathFile.persistentDescriptor = oldBasePath;
- }
- catch (e) {
- Zotero.debug(e, 1);
- Components.utils.reportError(e);
- oldBasePathFile = null;
- }
- }
-
- //Prompt user to choose new base path
- var nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"]
- .createInstance(nsIFilePicker);
- if (oldBasePathFile) {
- fp.displayDirectory = oldBasePathFile;
- }
- fp.init(window, Zotero.getString('attachmentBasePath.selectDir'), nsIFilePicker.modeGetFolder);
- fp.appendFilters(nsIFilePicker.filterAll);
- if (fp.show() != nsIFilePicker.returnOK) {
- return false;
- }
- var newBasePathFile = fp.file;
-
- if (oldBasePathFile && oldBasePathFile.equals(newBasePathFile)) {
- Zotero.debug("Base directory hasn't changed");
- return false;
- }
-
- // Find all current attachments with relative attachment paths
- var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=? AND path LIKE '"
- + Zotero.Attachments.BASE_PATH_PLACEHOLDER + "%'";
- var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE];
- var oldRelativeAttachmentIDs = Zotero.DB.columnQuery(sql, params) || [];
-
- //Find all attachments on the new base path
- var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=?";
- var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE];
- var allAttachments = Zotero.DB.columnQuery(sql,params);
- var newAttachmentPaths = {};
- var numNewAttachments = 0;
- var numOldAttachments = 0;
- var attachmentFile = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- for (let i=0; i<allAttachments.length; i++) {
- let attachmentID = allAttachments[i];
-
- try {
- let attachment = Zotero.Items.get(attachmentID);
- attachmentFile.persistentDescriptor = attachment.attachmentPath;
- }
- catch (e) {
- // Don't deal with bad attachment paths. Just skip them.
- continue;
- }
-
- // If a file with the same relative path exists within the new base directory,
- // don't touch the attachment, since it will continue to work
- let isExistingRelativeAttachment = oldRelativeAttachmentIDs.indexOf(attachmentID) != -1;
- if (isExistingRelativeAttachment && oldBasePathFile) {
- let relFile = attachmentFile.clone();
- let relPath = attachmentFile.getRelativeDescriptor(oldBasePathFile);
- relFile.setRelativeDescriptor(newBasePathFile, relPath);
- if (relFile.exists()) {
- numNewAttachments++;
- continue;
- }
- }
-
- // Files within the new base directory need to be updated to use
- // relative paths (or, if the new base directory is an ancestor or
- // descendant of the old one, new relative paths)
- if (Zotero.File.directoryContains(newBasePathFile, attachmentFile)) {
- newAttachmentPaths[attachmentID] = isExistingRelativeAttachment
- ? attachmentFile.persistentDescriptor : null;
- numNewAttachments++;
- }
- // Existing relative attachments not within the new base directory
- // will be converted to absolute paths
- else if (isExistingRelativeAttachment && oldBasePathFile) {
- newAttachmentPaths[attachmentID] = attachmentFile.persistentDescriptor;
- numOldAttachments++;
- }
- }
-
- //Confirm change of the base path
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- var chooseStrPrefix = 'attachmentBasePath.chooseNewPath.';
- var clearStrPrefix = 'attachmentBasePath.clearBasePath.';
- var title = Zotero.getString(chooseStrPrefix + 'title');
- var msg1 = Zotero.getString(chooseStrPrefix + 'message') + "\n\n", msg2 = msg3 = "";
- switch (numNewAttachments) {
- case 0:
- break;
-
- case 1:
- msg2 += Zotero.getString(chooseStrPrefix + 'existingAttachments.singular') + " ";
- break;
-
- default:
- msg2 += Zotero.getString(chooseStrPrefix + 'existingAttachments.plural', numNewAttachments) + " ";
- }
-
- switch (numOldAttachments) {
- case 0:
- break;
-
- case 1:
- msg3 += Zotero.getString(clearStrPrefix + 'existingAttachments.singular');
- break;
-
- default:
- msg3 += Zotero.getString(clearStrPrefix + 'existingAttachments.plural', numOldAttachments);
- }
-
-
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
- var index = ps.confirmEx(
- null,
- title,
- (msg1 + msg2 + msg3).trim(),
- buttonFlags,
- Zotero.getString(chooseStrPrefix + 'button'),
- null,
- null,
- null,
- {}
- );
-
- if (index == 1) {
- return false;
- }
-
- // Set new data directory
- Zotero.debug("Setting new base directory");
- Zotero.Prefs.set('baseAttachmentPath', newBasePathFile.persistentDescriptor);
- Zotero.Prefs.set('saveRelativeAttachmentPath', true);
- // Resave all attachments on base path (so that their paths become relative)
- // and all other relative attachments (so that their paths become absolute)
- for (let id in newAttachmentPaths) {
- let attachment = Zotero.Items.get(id);
- if (newAttachmentPaths[id]) {
- attachment.attachmentPath = newAttachmentPaths[id];
- attachment.save();
- }
- else {
- attachment.updateAttachmentPath();
- }
- }
- return newBasePathFile.persistentDescriptor;
- },
-
-
- getPath: function (asFile) {
- var desc = Zotero.Prefs.get('baseAttachmentPath');
- if (desc == '') {
- return asFile ? null : '';
- }
-
- var file = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- try {
- file.persistentDescriptor = desc;
- }
- catch (e) {
- return asFile ? null : '';
- }
- return asFile ? file : file.path;
- },
-
-
- clearPath: function () {
- // Find all current attachments with relative paths
- var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=? AND path LIKE '"
- + Zotero.Attachments.BASE_PATH_PLACEHOLDER + "%'";
- var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE];
- var relativeAttachmentIDs = Zotero.DB.columnQuery(sql, params) || [];
-
- // Prompt for confirmation
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- var strPrefix = 'attachmentBasePath.clearBasePath.';
- var title = Zotero.getString(strPrefix + 'title');
- var msg = Zotero.getString(strPrefix + 'message');
- switch (relativeAttachmentIDs.length) {
- case 0:
- break;
-
- case 1:
- msg += "\n\n" + Zotero.getString(strPrefix + 'existingAttachments.singular');
- break;
-
- default:
- msg += "\n\n" + Zotero.getString(strPrefix + 'existingAttachments.plural',
- relativeAttachmentIDs.length);
- }
-
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
- var index = ps.confirmEx(
- window,
- title,
- msg,
- buttonFlags,
- Zotero.getString(strPrefix + 'button'),
- null,
- null,
- null,
- {}
- );
-
- if (index == 1) {
- return false;
- }
-
- // Disable relative path saving and then resave all relative
- // attachments so that their absolute paths are stored
- Zotero.debug('Clearing base directory');
- Zotero.Prefs.set('saveRelativeAttachmentPath', false);
- for (var i=0; i<relativeAttachmentIDs.length; i++) {
- Zotero.Items.get(relativeAttachmentIDs[i]).updateAttachmentPath();
- }
- Zotero.Prefs.set('baseAttachmentPath', '');
- },
-
-
- updateUI: function () {
- var filefield = document.getElementById('baseAttachmentPath');
- var file = this.getPath(true);
- filefield.file = file;
- if (file) {
- filefield.label = file.path;
- }
- else {
- filefield.label = '';
- }
-
- document.getElementById('resetBasePath').disabled = !Zotero.Prefs.get('baseAttachmentPath');
}
-}
-\ No newline at end of file
+};
+\ No newline at end of file
diff --git a/chrome/content/zotero/preferences/preferences.xul b/chrome/content/zotero/preferences/preferences.xul
@@ -2,7 +2,7 @@
<!--
***** BEGIN LICENSE BLOCK *****
- Copyright © 2009 Center for History and New Media
+ Copyright © 2006–2013 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
@@ -31,834 +31,52 @@
<?xml-stylesheet href="chrome://zotero/skin/zotero.css"?>
<!--
-
-To add a new preference:
- 1) Add a new <preference> to <preferences>
- 2) Add a XUL control with a 'preference' attribute
- 3) (Optional) Add additional setup/change logic to preferences.js
- 4) (Optional) To add an observer for a preference change,
- add an appropriate case in the switch statement
- in Zotero.Prefs.observe()
-
+ To add an observer for a preference change, add an appropriate case in
+ the switch statement in Zotero.Prefs.observe().
-->
-<prefwindow id="zotero-prefs" title="&zotero.preferences.title;" onload="init()" onunload="Zotero_Preferences.onUnload()"
- windowtype="zotero:pref" ondialoghelp="Zotero_Preferences.openHelpLink()"
+<prefwindow id="zotero-prefs"
+ title="&zotero.preferences.title;"
+ onload="Zotero_Preferences.init()"
+ onunload="Zotero_Preferences.onUnload()"
+ ondialoghelp="Zotero_Preferences.openHelpLink()"
+ windowtype="zotero:pref"
+ width="620"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="zotero-prefpane-general"
- label="&zotero.preferences.prefpane.general;"
- image="chrome://zotero/skin/prefs-general.png"
- helpTopic="general">
- <preferences id="zotero-prefpane-general-preferences">
- <preference id="pref-fontSize" name="extensions.zotero.fontSize" type="string"/>
- <preference id="pref-noteFontSize" name="extensions.zotero.note.fontSize" type="string"/>
- <preference id="pref-automaticScraperUpdates" name="extensions.zotero.automaticScraperUpdates" type="bool"/>
- <preference id="pref-reportTranslationFailure" name="extensions.zotero.reportTranslationFailure" type="bool"/>
- <preference id="pref-automaticSnapshots" name="extensions.zotero.automaticSnapshots" type="bool"/>
- <preference id="pref-downloadAssociatedFiles" name="extensions.zotero.downloadAssociatedFiles" type="bool"/>
- <preference id="pref-automaticTags" name="extensions.zotero.automaticTags" type="bool"/>
- <preference id="pref-trashAutoEmptyDays" name="extensions.zotero.trashAutoEmptyDays" type="int"/>
-
- <preference id="pref-groups-copyChildNotes" name="extensions.zotero.groups.copyChildNotes" type="bool"/>
- <preference id="pref-groups-copyChildFileAttachments" name="extensions.zotero.groups.copyChildFileAttachments" type="bool"/>
- <preference id="pref-groups-copyChildLinks" name="extensions.zotero.groups.copyChildLinks" type="bool"/>
- <preference id="pref-groups-copyTags" name="extensions.zotero.groups.copyTags" type="bool"/>
- </preferences>
-
- <groupbox id="zotero-prefpane-general-groupbox">
- <caption label="&zotero.preferences.userInterface;"/>
-
- <grid id="zotero-prefpane-general-grid">
- <columns>
- <column/>
- <column flex="1"/>
- </columns>
-
- <rows id="zotero-prefpane-general-rows">
- <row>
- <hbox align="center">
- <label value="&zotero.preferences.fontSize;" control="fontSize"/>
- </hbox>
- <radiogroup id="fontSize" orient="horizontal" align="center" preference="pref-fontSize">
- <radio id="fontSize1" label="&zotero.preferences.fontSize.small;" value="1.0"/>
- <radio id="fontSize2" label="&zotero.preferences.fontSize.medium;" value="1.15"/>
- <radio id="fontSize3" label="&zotero.preferences.fontSize.large;" value="1.3"/>
- <radio id="fontSize4" label="&zotero.preferences.fontSize.xlarge;" value="1.5"/>
- </radiogroup>
- </row>
-
- <row>
- <hbox align="center">
- <label value="&zotero.preferences.fontSize.notes;" control="noteFontSize"/>
- </hbox>
- <hbox>
- <menulist id="noteFontSize" preference="pref-noteFontSize" editable="true">
- <menupopup>
- <menuitem label="11"/>
- <menuitem label="12"/>
- <menuitem label="13"/>
- <menuitem label="14"/>
- <menuitem label="18"/>
- <menuitem label="24"/>
- <menuitem label="36"/>
- <menuitem label="48"/>
- <menuitem label="64"/>
- <menuitem label="72"/>
- <menuitem label="96"/>
- </menupopup>
- </menulist>
- </hbox>
- </row>
- </rows>
- </grid>
-
- <label class="statusLine" value="&zotero.preferences.keys.changesTakeEffect;"/>
- </groupbox>
-
- <groupbox id="zotero-prefpane-miscellaneous-groupbox">
- <caption label="&zotero.preferences.miscellaneous;"/>
-
- <hbox align="center">
- <checkbox label="&zotero.preferences.autoUpdate;" preference="pref-automaticScraperUpdates"/>
- <button id="updateButton" style="margin-top:0" label="&zotero.preferences.updateNow;" oncommand="updateTranslators()"/>
- </hbox>
-
- <checkbox label="&zotero.preferences.reportTranslationFailure;" preference="pref-reportTranslationFailure"/>
- <checkbox id="automaticSnapshots-checkbox"
- label="&zotero.preferences.automaticSnapshots;"
- preference="pref-automaticSnapshots"/>
- <checkbox label="&zotero.preferences.downloadAssociatedFiles;" preference="pref-downloadAssociatedFiles"/>
- <checkbox label="&zotero.preferences.automaticTags;" preference="pref-automaticTags"/>
- <hbox align="center">
- <label value="&zotero.preferences.trashAutoEmptyDaysPre;"/>
- <textbox size="2" preference="pref-trashAutoEmptyDays"/>
- <label value="&zotero.preferences.trashAutoEmptyDaysPost;"/>
- </hbox>
- </groupbox>
-
- <groupbox>
- <caption label="&zotero.preferences.groups;"/>
-
- <label value="&zotero.preferences.groups.whenCopyingInclude;"/>
- <vbox style="margin-left: 2em">
- <checkbox label="&zotero.preferences.groups.childNotes;" preference="pref-groups-copyChildNotes"/>
- <checkbox label="&zotero.preferences.groups.childFiles;" preference="pref-groups-copyChildFileAttachments"/>
- <checkbox label="&zotero.preferences.groups.childLinks;" preference="pref-groups-copyChildLinks"/>
- <checkbox label="&zotero.preferences.groups.tags;" preference="pref-groups-copyTags"/>
- </vbox>
- </groupbox>
-
- <separator/>
- </prefpane>
-
+ label="&zotero.preferences.prefpane.general;"
+ image="chrome://zotero/skin/prefs-general.png"
+ src="chrome://zotero/content/preferences/preferences_general.xul"/>
<prefpane id="zotero-prefpane-sync"
- label="&zotero.preferences.prefpane.sync;"
- onpaneload="document.getElementById('sync-password').value = Zotero.Sync.Server.password; var pass = Zotero.Sync.Storage.WebDAV.password; if (pass) { document.getElementById('storage-password').value = pass; }"
- image="chrome://zotero/skin/prefs-sync.png"
- helpTopic="sync">
- <preferences>
- <preference id="pref-sync-autosync" name="extensions.zotero.sync.autoSync" type="bool"/>
- <preference id="pref-sync-username" name="extensions.zotero.sync.server.username" type="string" instantApply="true"/>
- <preference id="pref-storage-enabled" name="extensions.zotero.sync.storage.enabled" type="bool"/>
- <preference id="pref-storage-protocol" name="extensions.zotero.sync.storage.protocol" type="string" onchange="unverifyStorageServer()"/>
- <preference id="pref-storage-scheme" name="extensions.zotero.sync.storage.scheme" type="string" instantApply="true"/>
- <preference id="pref-storage-url" name="extensions.zotero.sync.storage.url" type="string"/>
- <preference id="pref-storage-username" name="extensions.zotero.sync.storage.username" type="string"/>
- <preference id="pref-storage-downloadMode-personal" name="extensions.zotero.sync.storage.downloadMode.personal" type="string"/>
- <preference id="pref-storage-downloadMode-groups" name="extensions.zotero.sync.storage.downloadMode.groups" type="string"/>
- <preference id="pref-group-storage-enabled" name="extensions.zotero.sync.storage.groups.enabled" type="bool"/>
- </preferences>
-
- <tabbox>
- <tabs>
- <tab label="&zotero.preferences.settings;"/>
- <tab label="&zotero.preferences.sync.reset;"/>
- </tabs>
-
- <tabpanels>
- <tabpanel orient="vertical">
- <groupbox>
- <caption label="&zotero.preferences.sync.syncServer;"/>
-
- <hbox>
- <grid>
- <columns>
- <column/>
- <column/>
- </columns>
-
- <rows>
- <row>
- <label value="&zotero.preferences.sync.username;"/>
- <textbox preference="pref-sync-username"
- onchange="this.value = this.value.trim(); Zotero.Prefs.set('sync.server.username', this.value); var pass = document.getElementById('sync-password'); if (pass.value) { Zotero.Sync.Server.password = pass.value; }"/>
- </row>
- <row>
- <label value="&zotero.preferences.sync.password;"/>
- <textbox id="sync-password" type="password"
- onchange="Zotero.Sync.Server.password = this.value"/>
- </row>
- <row>
- <box/>
- <checkbox label="&zotero.preferences.sync.syncAutomatically;" preference="pref-sync-autosync"/>
- </row>
- <!--
- <row>
- <box/>
- <hbox>
- <button label="Verify login"
- oncommand="alert('Unimplemented')"/>
- </hbox>
- </row>
- -->
- </rows>
- </grid>
-
- <hbox style="width:2em"/>
-
- <vbox>
- <label class="zotero-text-link" value="&zotero.preferences.sync.about;" href="http://www.zotero.org/support/sync"/>
- <separator class="thin"/>
- <label class="zotero-text-link" value="&zotero.preferences.sync.createAccount;" href="http://zotero.org/user/register"/>
- <separator class="thin"/>
- <label class="zotero-text-link" value="&zotero.preferences.sync.lostPassword;" href="http://zotero.org/user/lostpassword"/>
- </vbox>
- </hbox>
- </groupbox>
-
-
- <groupbox id="storage-settings">
- <caption label="&zotero.preferences.sync.fileSyncing;"/>
-
- <!-- My Library -->
- <hbox>
- <checkbox label="&zotero.preferences.sync.fileSyncing.myLibrary;" preference="pref-storage-enabled" oncommand="updateStorageSettings(this.checked, null)"/>
- <menulist id="storage-protocol" class="storage-personal" style="margin-left: .5em" preference="pref-storage-protocol" oncommand="updateStorageSettings(null, this.value)">
- <menupopup>
- <menuitem label="Zotero" value="zotero"/>
- <menuitem label="WebDAV" value="webdav"/>
- </menupopup>
- </menulist>
- </hbox>
-
- <stack id="storage-webdav-settings" style="margin-top: .5em; margin-bottom: .8em; border: 1px gray solid; border-radius: 3px">
- <!-- Background shading -->
- <box style="background: black; opacity:.03"/>
-
- <grid style="padding: .7em .4em .7em 0">
- <columns>
- <column/>
- <column flex="1"/>
- </columns>
-
- <rows>
- <row>
- <label value="&zotero.preferences.sync.fileSyncing.url;"/>
- <hbox>
- <menulist id="storage-url-prefix"
- preference="pref-storage-scheme"
- onsynctopreference="unverifyStorageServer()" style="padding: 0; width: 7em">
- <menupopup>
- <menuitem label="http" value="http" style="padding: 0"/>
- <menuitem label="https" value="https" style="padding: 0"/>
- </menupopup>
- </menulist>
- <label value="://"/>
- <textbox id="storage-url" flex="1"
- preference="pref-storage-url"
- onkeypress="if (Zotero.isMac && event.keyCode == 13) { this.blur(); setTimeout(verifyStorageServer, 1); }"
- onchange="unverifyStorageServer(); this.value = this.value.replace(/(^https?:\/\/|\/zotero\/?$|\/$)/g, ''); Zotero.Prefs.set('sync.storage.url', this.value)"/>
- <label value="/zotero/"/>
- </hbox>
- </row>
- <row>
- <label value="&zotero.preferences.sync.username;"/>
- <hbox>
- <textbox id="storage-username"
- preference="pref-storage-username"
- onkeypress="if (Zotero.isMac && event.keyCode == 13) { this.blur(); setTimeout(verifyStorageServer, 1); }"
- onchange="unverifyStorageServer(); Zotero.Prefs.set('sync.storage.username', this.value); var pass = document.getElementById('storage-password'); if (pass.value) { Zotero.Sync.Storage.WebDAV.password = pass.value; }"/>
- </hbox>
- </row>
- <row>
- <label value="&zotero.preferences.sync.password;"/>
- <hbox>
- <textbox id="storage-password" flex="0" type="password"
- onkeypress="if (Zotero.isMac && event.keyCode == 13) { this.blur(); setTimeout(verifyStorageServer, 1); }"
- onchange="unverifyStorageServer(); Zotero.Sync.Storage.WebDAV.password = this.value;"/>
- </hbox>
- </row>
- <row>
- <box/>
- <hbox>
- <button id="storage-verify" label="Verify Server"
- oncommand="verifyStorageServer()"/>
- <button id="storage-abort" label="Stop" hidden="true"/>
- <progressmeter id="storage-progress" hidden="true"
- mode="undetermined"/>
- </hbox>
- </row>
- </rows>
- </grid>
-
- </stack>
-
- <hbox class="storage-settings-download-options" align="center">
- <label value="&zotero.preferences.sync.fileSyncing.download;"/>
- <menulist class="storage-personal" preference="pref-storage-downloadMode-personal" style="margin-left: 0">
- <menupopup>
- <menuitem label="&zotero.preferences.sync.fileSyncing.download.onDemand;" value="on-demand"/>
- <menuitem label="&zotero.preferences.sync.fileSyncing.download.atSyncTime;" value="on-sync"/>
- </menupopup>
- </menulist>
- </hbox>
-
- <separator id="storage-separator" class="thin"/>
-
- <!-- Group Libraries -->
- <checkbox label="&zotero.preferences.sync.fileSyncing.groups;"
- preference="pref-group-storage-enabled" oncommand="updateStorageSettingsGroups(this.checked)"/>
-
- <hbox class="storage-settings-download-options" align="center">
- <label value="&zotero.preferences.sync.fileSyncing.download;"/>
- <menulist class="storage-groups" preference="pref-storage-downloadMode-groups" style="margin-left: 0">
- <menupopup>
- <menuitem label="&zotero.preferences.sync.fileSyncing.download.onDemand;" value="on-demand"/>
- <menuitem label="&zotero.preferences.sync.fileSyncing.download.atSyncTime;" value="on-sync"/>
- </menupopup>
- </menulist>
- </hbox>
-
- <separator class="thin"/>
-
- <vbox>
- <hbox id="storage-terms" style="margin-top: .4em" align="center">
- <label>&zotero.preferences.sync.fileSyncing.tos1;</label>
- <label class="zotero-text-link" href="http://www.digitalscholar.org/z_terms" value="&zotero.preferences.sync.fileSyncing.tos2;"/>
- <label>&zotero.preferences.period;</label>
- </hbox>
- </vbox>
- </groupbox>
- </tabpanel>
-
- <tabpanel id="zotero-reset" orient="vertical">
- <!-- This doesn't wrap without an explicit width, for some reason -->
- <description width="45em">&zotero.preferences.sync.reset.warning1;<label style="margin-left: 0; margin-right: 0" class="zotero-text-link" href="http://zotero.org/support/kb/sync_reset_options">&zotero.preferences.sync.reset.warning2;</label>&zotero.preferences.sync.reset.warning3;</description>
-
- <radiogroup id="zotero-reset-sync-group" oncommand="handleSyncResetSelect(this)">
- <groupbox>
- <caption label="&zotero.preferences.sync.syncServer;"/>
-
- <grid>
- <columns>
- <column/>
- <column align="start" pack="start" flex="1"/>
- </columns>
-
- <rows>
- <row id="zotero-restore-from-server" selected="true">
- <radio/>
- <vbox onclick="this.previousSibling.click()">
- <label value="&zotero.preferences.sync.reset.restoreFromServer;"/>
- <description>&zotero.preferences.sync.reset.restoreFromServer.desc;</description>
- </vbox>
- </row>
-
- <row id="zotero-restore-to-server">
- <radio/>
- <vbox onclick="this.previousSibling.click()">
- <label value="&zotero.preferences.sync.reset.restoreToServer;"/>
- <description>&zotero.preferences.sync.reset.restoreToServer.desc;</description>
- </vbox>
- </row>
- </rows>
- </grid>
-
- <hbox>
- <button label="&zotero.preferences.sync.reset.button;" oncommand="handleSyncReset(document.getElementById('zotero-reset-sync-group').selectedItem.parentNode.id.substr(7))"/>
- </hbox>
- </groupbox>
-
- <groupbox>
- <caption label="&zotero.preferences.sync.fileSyncing;"/>
-
- <grid>
- <columns>
- <column/>
- <column align="start" pack="start" flex="1"/>
- </columns>
-
- <rows>
- <row id="zotero-reset-storage-history">
- <radio/>
- <vbox onclick="this.previousSibling.click()">
- <label value="&zotero.preferences.sync.reset.resetFileSyncHistory;"/>
- <description>&zotero.preferences.sync.reset.resetFileSyncHistory.desc;</description>
- </vbox>
- </row>
- </rows>
- </grid>
-
- <hbox>
- <button label="&zotero.preferences.sync.reset.button;" oncommand="handleSyncReset(document.getElementById('zotero-reset-sync-group').selectedItem.parentNode.id.substr(7))"/>
- </hbox>
- </groupbox>
- </radiogroup>
- </tabpanel>
- </tabpanels>
- </tabbox>
-
- <separator/>
- </prefpane>
-
+ label="&zotero.preferences.prefpane.sync;"
+ image="chrome://zotero/skin/prefs-sync.png"
+ src="chrome://zotero/content/preferences/preferences_sync.xul"/>
<prefpane id="zotero-prefpane-search"
- label="&zotero.preferences.prefpane.search;"
- onpaneload="updateIndexStats()"
- image="chrome://zotero/skin/prefs-search.png"
- helpTopic="search">
- <preferences>
- <preference id="pref-fulltext-textMaxLength" name="extensions.zotero.fulltext.textMaxLength" type="int"/>
- <preference id="pref-fulltext-pdfmaxpages" name="extensions.zotero.fulltext.pdfMaxPages" type="int"/>
- </preferences>
-
- <groupbox>
- <caption label="&zotero.preferences.search.fulltextCache;"/>
-
- <hbox>
- <button id="fulltext-rebuildIndex" flex="1" oncommand="rebuildIndexPrompt()"/>
- <button id="fulltext-clearIndex" flex="1" oncommand="clearIndexPrompt()"/>
- </hbox>
-
- <separator/>
-
- <hbox align="center">
- <label value="&zotero.preferences.fulltext.textMaxLength;"/>
- <textbox size="10" preference="pref-fulltext-textMaxLength"/>
- <label value="(&zotero.preferences.default; 500000)"/>
- </hbox>
- </groupbox>
-
- <groupbox id="pdftools-box">
- <caption label="&zotero.preferences.search.pdfIndexing;"/>
-
- <label id="pdfconverter-status"/>
- <separator class="thin"/>
- <label id="pdfinfo-status"/>
-
- <separator class="thin"/>
-
- <label id="pdftools-required" hidden="true"/>
-
- <separator class="thin"/>
-
- <hbox>
- <button id="pdftools-update-button" flex="1" oncommand="checkPDFToolsDownloadVersion()"/>
- </hbox>
-
- <separator class="thin"/>
-
- <label id="pdftools-documentation-link" hidden="true"/>
-
- <separator class="thin"/>
-
- <hbox id="pdftools-settings" align="center" hidden="true">
- <label value="&zotero.preferences.fulltext.pdfMaxPages;"/>
- <textbox size="5" preference="pref-fulltext-pdfmaxpages"/>
- <label value="(&zotero.preferences.default; 100)"/>
- </hbox>
- </groupbox>
-
- <groupbox id="fulltext-stats">
- <caption label="&zotero.preferences.search.indexStats;"/>
-
- <grid>
- <columns>
- <column/>
- <column/>
- </columns>
-
- <rows>
- <row id="fulltext-stats-indexed">
- <label value="&zotero.preferences.search.indexStats.indexed;"/>
- <label/>
- </row>
- <row id="fulltext-stats-partial">
- <label value="&zotero.preferences.search.indexStats.partial;"/>
- <label/>
- </row>
- <row id="fulltext-stats-unindexed">
- <label value="&zotero.preferences.search.indexStats.unindexed;"/>
- <label/>
- </row>
- <row id="fulltext-stats-words">
- <label value="&zotero.preferences.search.indexStats.words;"/>
- <label/>
- </row>
- </rows>
- </grid>
- </groupbox>
-
- <separator/>
- </prefpane>
-
+ label="&zotero.preferences.prefpane.search;"
+ image="chrome://zotero/skin/prefs-search.png"
+ src="chrome://zotero/content/preferences/preferences_search.xul"/>
<prefpane id="zotero-prefpane-export"
- label="&zotero.preferences.prefpane.export;"
- image="chrome://zotero/skin/prefs-export.png"
- helpTopic="export">
- <preferences>
- <preference id="pref-quickCopy-setting" name="extensions.zotero.export.quickCopy.setting" type="string"/>
- <preference id="pref-quickCopy-dragLimit" name="extensions.zotero.export.quickCopy.dragLimit" type="int"/>
- </preferences>
-
- <groupbox id="zotero-prefpane-export-groupbox">
- <caption label="&zotero.preferences.quickCopy.caption;"/>
-
- <label id="quickCopy-instructions"/>
- <separator class="thin"/>
- <label id="quickCopy-citationInstructions"/>
-
- <separator/>
-
- <label value="&zotero.preferences.quickCopy.defaultOutputFormat;" control="quickCopy-menu"/>
- <menulist id="zotero-quickCopy-menu"/>
-
- <separator class="thin"/>
-
- <checkbox id="zotero-quickCopy-copyAsHTML" label="&zotero.preferences.quickCopy.copyAsHTML;"
- oncommand="buildQuickCopyFormatDropDown(document.getElementById('zotero-quickCopy-menu'), this.checked ? 'html' : '');"/>
-
- <vbox id="zotero-prefpane-export-siteSettings"/>
-
- <hbox align="center">
- <label value="&zotero.preferences.quickCopy.dragLimit;"/>
- <textbox preference="pref-quickCopy-dragLimit" size="3"/>
- <label value="&zotero.preferences.items;" flex="1"/>
- </hbox>
- </groupbox>
-
- <groupbox>
- <caption label="&zotero.preferences.charset;"/>
-
- <checkbox id="zotero-export-displayCharsetOption" label="&zotero.preferences.charset.displayExportOption;"
- preference="pref-export-displayCharsetOption"/>
-
- <hbox align="center">
- <label value="&zotero.preferences.charset.importCharset;:" control="zotero-import-charsetMenu"/>
- <menulist id="zotero-import-charsetMenu" preference="pref-import-charset"/>
- </hbox>
- </groupbox>
-
- <separator/>
- </prefpane>
-
+ label="&zotero.preferences.prefpane.export;"
+ image="chrome://zotero/skin/prefs-export.png"
+ src="chrome://zotero/content/preferences/preferences_export.xul"/>
<prefpane id="zotero-prefpane-cite"
- label="&zotero.preferences.prefpane.cite;"
- image="chrome://zotero/skin/prefs-styles.png"
- helpTopic="cite">
-
- <preferences id="zotero-preferences-cite">
- <preference id="pref-cite-useClassicAddCitationDialog" name="extensions.zotero.integration.useClassicAddCitationDialog" type="bool"/>
- <preference id="pref-cite-citePaperJournalArticleURL" name="extensions.zotero.export.citePaperJournalArticleURL" type="bool"/>
- <preference id="pref-cite-automaticTitleAbbreviation" name="extensions.zotero.cite.automaticTitleAbbreviation" type="bool"/>
- </preferences>
-
- <tabbox>
- <tabs>
- <tab label="&zotero.preferences.cite.wordProcessors;"/>
- <tab label="&zotero.preferences.cite.styles;"/>
- </tabs>
- <tabpanels>
- <tabpanel orient="vertical" id="wordProcessors">
- <label id="wordProcessors-noWordProcessorPluginsInstalled" width="45em" hidden="true">
- &zotero.preferences.cite.wordProcessors.noWordProcessorPluginsInstalled;
- </label>
- <checkbox label="&zotero.preferences.cite.wordProcessors.useClassicAddCitationDialog;" preference="pref-cite-useClassicAddCitationDialog"/>
- <label id="wordProcessors-getWordProcessorPlugins" class="zotero-text-link" href="&zotero.preferences.cite.wordProcessors.getPlugins.url;" value="&zotero.preferences.cite.wordProcessors.getPlugins;"/>
- </tabpanel>
- <tabpanel orient="vertical" id="styles">
- <groupbox flex="1">
- <caption label="&zotero.preferences.cite.styles.styleManager;"/>
-
- <tree flex="1" id="styleManager" hidecolumnpicker="true" rows="6"
- onselect="document.getElementById('styleManager-delete').disabled = undefined"
- onkeypress="if (event.keyCode == event.DOM_VK_DELETE) { deleteSelectedStyle(); }">
- <treecols>
- <treecol id="styleManager-title" label="&zotero.preferences.cite.styles.styleManager.title;" flex="3"/>
- <treecol id="styleManager-updated" label="&zotero.preferences.cite.styles.styleManager.updated;" flex="1"/>
- <treecol id="styleManager-csl" label="&zotero.preferences.cite.styles.styleManager.csl;"/>
- </treecols>
- <treechildren id="styleManager-rows"/>
- </tree>
- <separator class="thin"/>
- <hbox align="center" flex="1" height="40">
- <label class="zotero-text-link" href="http://www.zotero.org/styles/" value="&zotero.preferences.export.getAdditionalStyles;" flex="1"/>
- <button disabled="true" id="styleManager-delete" label="-" onclick="deleteStyle()"/>
- <button label="+" onclick="addStyle()"/>
- </hbox>
- </groupbox>
-
- <groupbox>
- <caption label="&zotero.preferences.citationOptions.caption;"/>
-
- <checkbox label="&zotero.preferences.export.citePaperJournalArticleURL;" preference="pref-cite-citePaperJournalArticleURL"/>
- <!-- This doesn't wrap without an explicit width, for some reason -->
- <label id="export-citePaperJournalArticleURL" width="45em">
- &zotero.preferences.export.citePaperJournalArticleURL.description;
- </label>
-
- <checkbox label="&zotero.preferences.cite.styles.automaticTitleAbbreviation;" preference="pref-cite-automaticTitleAbbreviation"/>
- </groupbox>
- </tabpanel>
- </tabpanels>
- </tabbox>
- </prefpane>
-
+ label="&zotero.preferences.prefpane.cite;"
+ image="chrome://zotero/skin/prefs-styles.png"
+ src="chrome://zotero/content/preferences/preferences_cite.xul"/>
<prefpane id="zotero-prefpane-keys"
- label="&zotero.preferences.prefpane.keys;"
- image="chrome://zotero/skin/prefs-keys.png"
- helpTopic="shortcut_keys">
- <preferences>
- <preference id="pref-keys-openZotero" name="extensions.zotero.keys.openZotero" type="string"/>
- <preference id="pref-keys-toggleFullscreen" name="extensions.zotero.keys.toggleFullscreen" type="string"/>
- <preference id="pref-keys-library" name="extensions.zotero.keys.library" type="string"/>
- <preference id="pref-keys-quicksearch" name="extensions.zotero.keys.quicksearch" type="string"/>
- <preference id="pref-keys-newItem" name="extensions.zotero.keys.newItem" type="string"/>
- <preference id="pref-keys-newNote" name="extensions.zotero.keys.newNote" type="string"/>
- <preference id="pref-keys-toggleTagSelector" name="extensions.zotero.keys.toggleTagSelector" type="string"/>
- <preference id="pref-keys-copySelectedItemCitationsToClipboard" name="extensions.zotero.keys.copySelectedItemCitationsToClipboard" type="string"/>
- <preference id="pref-keys-copySelectedItemsToClipboard" name="extensions.zotero.keys.copySelectedItemsToClipboard" type="string"/>
- <preference id="pref-keys-importFromClipboard" name="extensions.zotero.keys.importFromClipboard" type="string"/>
- </preferences>
-
- <grid>
- <columns>
- <column flex="1"/>
- <column/>
- <column/>
- </columns>
-
- <rows>
- <row>
- <label value="&zotero.preferences.keys.openZotero;" control="key-textbox-openZotero"/>
- <label/>
- <textbox id="textbox-openZotero" maxlength="1" size="1" preference="pref-keys-openZotero"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.toggleFullscreen;" control="textbox-toggleFullscreen"/>
- <label/>
- <textbox id="textbox-toggleFullscreen" maxlength="1" size="1" preference="pref-keys-toggleFullscreen"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.focusLibrariesPane;" control="textbox-library"/>
- <label/>
- <textbox id="textbox-library" maxlength="1" size="1" preference="pref-keys-library"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.quicksearch;" control="textbox-quicksearch"/>
- <label/>
- <textbox id="textbox-quicksearch" maxlength="1" size="1" preference="pref-keys-quicksearch"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.newItem;" control="textbox-newItem"/>
- <label/>
- <textbox id="textbox-newItem" maxlength="1" size="1" preference="pref-keys-newItem"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.newNote;" control="textbox-newNote"/>
- <label/>
- <textbox id="textbox-newNote" maxlength="1" size="1" preference="pref-keys-newNote"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.toggleTagSelector;" control="textbox-toggleTagSelector"/>
- <label/>
- <textbox id="textbox-toggleTagSelector" maxlength="1" size="1" preference="pref-keys-toggleTagSelector"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.copySelectedItemCitationsToClipboard;" control="textbox-copySelectedItemCitationsToClipboard"/>
- <label/>
- <textbox id="textbox-copySelectedItemCitationsToClipboard" maxlength="1" size="1" preference="pref-keys-copySelectedItemCitationsToClipboard"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.copySelectedItemsToClipboard;" control="textbox-copySelectedItemsToClipboard"/>
- <label/>
- <textbox id="textbox-copySelectedItemsToClipboard" maxlength="1" size="1" preference="pref-keys-copySelectedItemsToClipboard" onchange="updateQuickCopyInstructions()"/>
- </row>
-
- <row>
- <label value="&zotero.preferences.keys.importFromClipboard;" control="textbox-importFromClipboard"/>
- <label/>
- <textbox id="textbox-importFromClipboard" maxlength="1" size="1" preference="pref-keys-importFromClipboard"/>
- </row>
- </rows>
- </grid>
-
- <label class="statusLine" value="&zotero.preferences.keys.changesTakeEffect;"/>
-
- <separator/>
- </prefpane>
-
+ label="&zotero.preferences.prefpane.keys;"
+ image="chrome://zotero/skin/prefs-keys.png"
+ src="chrome://zotero/content/preferences/preferences_keys.xul"/>
<prefpane id="zotero-prefpane-advanced"
- label="&zotero.preferences.prefpane.advanced;"
- image="chrome://zotero/skin/prefs-advanced.png"
- helpTopic="advanced">
- <preferences>
- <preference id="pref-baseAttachmentPath" name="extensions.zotero.baseAttachmentPath" type="string"/>
- <preference id="pref-useDataDir" name="extensions.zotero.useDataDir" type="bool"/>
- <preference id="pref-dataDir" name="extensions.zotero.dataDir" type="string"/>
- <preference id="pref-export-displayCharsetOption" name="extensions.zotero.export.displayCharsetOption" type="bool"/>
- <preference id="pref-debug-output-enableAfterRestart" name="extensions.zotero.debug.store" type="bool"/>
- <preference id="pref-import-charset" name="extensions.zotero.import.charset" type="string"/>
- <preference id="pref-openURL-resolver" name="extensions.zotero.openURL.resolver" type="string"/>
- <preference id="pref-openURL-version" name="extensions.zotero.openURL.version" type="string"/>
- </preferences>
-
- <tabbox id="zotero-prefpane-advanced-tabs">
- <tabs>
- <tab label="&zotero.preferences.prefpane.general;"/>
- <tab label="&zotero.preferences.advanced.filesAndFolders;"/>
- </tabs>
-
- <tabpanels id="zotero-prefpane-advanced-tabpanels">
- <tabpanel id="zotero-prefpane-advanced-general-tab" orient="vertical">
- <groupbox>
- <caption label="&zotero.preferences.debugOutputLogging;"/>
-
- <!-- This doesn't wrap without an explicit width -->
- <vbox>
- <description width="45em">&zotero.preferences.debugOutputLogging.message;</description>
- </vbox>
-
- <hbox align="center">
- <button id="debug-output-enable" oncommand="Zotero_Preferences.Debug_Output.toggleStore()"/>
- <label id="debug-output-lines" style="margin-right: 0"/>
- <label value="&zotero.preferences.debugOutputLogging.linesLogged;"/>
- <checkbox preference="pref-debug-output-enableAfterRestart" label="&zotero.preferences.debugOutputLogging.enableAfterRestart;" style="margin-left: 1.5em"/>
- </hbox>
-
- <hbox align="center">
- <button id="debug-output-view" label="&zotero.preferences.debugOutputLogging.viewOutput;" oncommand="Zotero_Preferences.Debug_Output.view()"/>
- <button id="debug-output-clear" label="&zotero.preferences.debugOutputLogging.clearOutput;" oncommand="Zotero_Preferences.Debug_Output.clear()"/>
- <button id="debug-output-submit" label="&zotero.preferences.debugOutputLogging.submitToServer;" oncommand="Zotero_Preferences.Debug_Output.submit()"/>
- <progressmeter id="debug-output-submit-progress" mode="undetermined" hidden="true"/>
- </hbox>
- </groupbox>
-
- <groupbox>
- <caption label="&zotero.preferences.openurl.caption;"/>
-
- <hbox align="center">
- <!-- vbox prevents some weird vertical stretching of the menulist -->
- <vbox flex="1">
- <menulist id="openURLMenu" oncommand="onOpenURLSelected();">
- <menupopup>
- <menuseparator/>
- <menuitem label="&zotero.preferences.openurl.custom;" value="custom" selected="true"/>
- </menupopup>
- </menulist>
- </vbox>
- <button id="openURLSearchButton" label="&zotero.preferences.openurl.search;" oncommand="populateOpenURLResolvers()"/>
- </hbox>
-
- <hbox align="center">
- <label value="&zotero.preferences.openurl.server;"/>
- <textbox id="openURLServerField" flex="1" oninput="onOpenURLCustomized();" preference="pref-openURL-resolver"/>
- </hbox>
-
- <hbox align="center">
- <label value="&zotero.preferences.openurl.version;" control="openURLVersionMenu"/>
- <menulist id="openURLVersionMenu" oncommand="onOpenURLCustomized();" preference="pref-openURL-version">
- <menupopup>
- <menuitem label="0.1" value="0.1"/>
- <menuitem label="1.0" value="1.0"/>
- </menupopup>
- </menulist>
- </hbox>
- </groupbox>
-
- <groupbox id="zotero-prefpane-advanced-miscellaneous">
- <caption label="&zotero.preferences.miscellaneous;"/>
- <hbox id="zotero-prefpane-advanced-openbuttons" align="center">
- <button id="openAboutConfig" label="&zotero.preferences.openAboutConfig;" oncommand="openInViewer('about:config')"/>
- <button id="openCSLEdit" label="&zotero.preferences.openCSLEdit;" oncommand="openInViewer('chrome://zotero/content/tools/csledit.xul', true)"/>
- <button id="openCSLPreview" label="&zotero.preferences.openCSLPreview;" oncommand="openInViewer('chrome://zotero/content/tools/cslpreview.xul', true)"/>
- </hbox>
- </groupbox>
- </tabpanel>
-
- <tabpanel orient="vertical">
- <groupbox>
- <caption label="&zotero.preferences.attachmentBaseDir.caption;"/>
-
- <!-- This doesn't wrap without an explicit width -->
- <vbox>
- <description width="45em">&zotero.preferences.attachmentBaseDir.message;</description>
- </vbox>
-
- <hbox align="center">
- <label value="&zotero.preferences.attachmentBaseDir.basePath;"/>
- <filefield id="baseAttachmentPath"
- preference="pref-baseAttachmentPath"
- onsyncfrompreference="Zotero_Preferences.Attachment_Base_Directory.updateUI()"
- preference-editable="true"
- readonly="true"
- flex="1"
- tabindex="-1"/>
- <button label="&zotero.preferences.attachmentBaseDir.selectBasePath;"
- oncommand="Zotero_Preferences.Attachment_Base_Directory.choosePath()"/>
- </hbox>
-
- <hbox>
- <button id="resetBasePath"
- label="&zotero.preferences.attachmentBaseDir.resetBasePath;"
- oncommand="Zotero_Preferences.Attachment_Base_Directory.clearPath()"/>
- </hbox>
-
- </groupbox>
-
- <groupbox>
- <caption label="&zotero.preferences.dataDir;"/>
-
- <radiogroup id="dataDir" preference="pref-useDataDir" onsyncfrompreference="onDataDirLoad();" onsynctopreference="return onDataDirUpdate(event);">
- <radio label="&zotero.preferences.dataDir.useProfile;" value="false"/>
- <hbox>
- <radio label="&zotero.preferences.dataDir.custom;" value="true"/>
- <textbox id="dataDirPath" preference="pref-dataDir" onsyncfrompreference="return getDataDirPath();" readonly="true" flex="1"/>
- <button label="&zotero.preferences.dataDir.choose;" oncommand="var file = Zotero.chooseZoteroDirectory(true); if (!file) { event.stopPropagation(); }"/>
- </hbox>
- </radiogroup>
-
- <hbox>
- <button label="&zotero.preferences.dataDir.reveal;" oncommand="revealDataDirectory()"/>
- </hbox>
- </groupbox>
-
- <groupbox>
- <caption label="&zotero.preferences.dbMaintenance;"/>
-
- <hbox>
- <button label="&zotero.preferences.dbMaintenance.integrityCheck;" oncommand="runIntegrityCheck()"/>
- <button label="&zotero.preferences.dbMaintenance.resetTranslators;" oncommand="resetTranslators()"/>
- <button label="&zotero.preferences.dbMaintenance.resetStyles;" oncommand="resetStyles()"/>
- </hbox>
- </groupbox>
- </tabpanel>
- </tabpanels>
- </tabbox>
- </prefpane>
+ label="&zotero.preferences.prefpane.advanced;"
+ image="chrome://zotero/skin/prefs-advanced.png"
+ src="chrome://zotero/content/preferences/preferences_advanced.xul"/>
<!-- These mess up the prefwindow (more) if they come before the prefpanes
https://bugzilla.mozilla.org/show_bug.cgi?id=296418 -->
diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js
@@ -0,0 +1,789 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+*/
+
+"use strict";
+
+Zotero_Preferences.Advanced = {
+ _openURLResolvers: null,
+
+
+ init: function () {
+ Zotero_Preferences.Debug_Output.init();
+ },
+
+ revealDataDirectory: function () {
+ var dataDir = Zotero.getZoteroDirectory();
+ dataDir.QueryInterface(Components.interfaces.nsILocalFile);
+ try {
+ dataDir.reveal();
+ }
+ catch (e) {
+ // On platforms that don't support nsILocalFile.reveal() (e.g. Linux),
+ // launch the directory
+ window.opener.ZoteroPane_Local.launchFile(dataDir);
+ }
+ },
+
+
+ runIntegrityCheck: function () {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ var ok = Zotero.DB.integrityCheck();
+ if (ok) {
+ ok = Zotero.Schema.integrityCheck();
+ if (!ok) {
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
+ var index = ps.confirmEx(window,
+ Zotero.getString('general.failed'),
+ Zotero.getString('db.integrityCheck.failed') + "\n\n" +
+ Zotero.getString('db.integrityCheck.repairAttempt') + " " +
+ Zotero.getString('db.integrityCheck.appRestartNeeded', Zotero.appName),
+ buttonFlags,
+ Zotero.getString('db.integrityCheck.fixAndRestart', Zotero.appName),
+ null, null, null, {}
+ );
+
+ if (index == 0) {
+ // Safety first
+ Zotero.DB.backupDatabase();
+
+ // Fix the errors
+ Zotero.Schema.integrityCheck(true);
+
+ // And run the check again
+ ok = Zotero.Schema.integrityCheck();
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
+ if (ok) {
+ var str = 'success';
+ var msg = Zotero.getString('db.integrityCheck.errorsFixed');
+ }
+ else {
+ var str = 'failed';
+ var msg = Zotero.getString('db.integrityCheck.errorsNotFixed')
+ + "\n\n" + Zotero.getString('db.integrityCheck.reportInForums');
+ }
+
+ ps.confirmEx(window,
+ Zotero.getString('general.' + str),
+ msg,
+ buttonFlags,
+ Zotero.getString('general.restartApp', Zotero.appName),
+ null, null, null, {}
+ );
+
+ var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
+ .getService(Components.interfaces.nsIAppStartup);
+ appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit
+ | Components.interfaces.nsIAppStartup.eRestart);
+ }
+
+ return;
+ }
+ }
+ var str = ok ? 'passed' : 'failed';
+
+ ps.alert(window,
+ Zotero.getString('general.' + str),
+ Zotero.getString('db.integrityCheck.' + str)
+ + (!ok ? "\n\n" + Zotero.getString('db.integrityCheck.dbRepairTool') : ''));
+ },
+
+
+ resetTranslatorsAndStyles: function () {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
+
+ var index = ps.confirmEx(null,
+ Zotero.getString('general.warning'),
+ Zotero.getString('zotero.preferences.advanced.resetTranslatorsAndStyles.changesLost'),
+ buttonFlags,
+ Zotero.getString('zotero.preferences.advanced.resetTranslatorsAndStyles'),
+ null, null, null, {});
+
+ if (index == 0) {
+ Zotero.Schema.resetTranslatorsAndStyles(function (xmlhttp, updated) {
+ this.populateQuickCopyList();
+ });
+ }
+ },
+
+
+ resetTranslators: function () {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
+
+ var index = ps.confirmEx(null,
+ Zotero.getString('general.warning'),
+ Zotero.getString('zotero.preferences.advanced.resetTranslators.changesLost'),
+ buttonFlags,
+ Zotero.getString('zotero.preferences.advanced.resetTranslators'),
+ null, null, null, {});
+
+ if (index == 0) {
+ Zotero.Schema.resetTranslators();
+ }
+ },
+
+
+ resetStyles: function () {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
+
+ var index = ps.confirmEx(null,
+ Zotero.getString('general.warning'),
+ Zotero.getString('zotero.preferences.advanced.resetStyles.changesLost'),
+ buttonFlags,
+ Zotero.getString('zotero.preferences.advanced.resetStyles'),
+ null, null, null, {});
+
+ if (index == 0) {
+ var self = this;
+ Zotero.Schema.resetStyles(function (xmlhttp, updated) {
+ self.populateQuickCopyList();
+ });
+ }
+ },
+
+
+ onDataDirLoad: function () {
+ var path = document.getElementById('dataDirPath');
+ var useDataDir = Zotero.Prefs.get('useDataDir');
+ path.setAttribute('disabled', !useDataDir);
+ },
+
+
+ onDataDirUpdate: function (event) {
+ var radiogroup = document.getElementById('dataDir');
+ var path = document.getElementById('dataDirPath');
+ var useDataDir = Zotero.Prefs.get('useDataDir');
+
+ // If triggered from the Choose button, don't show the dialog, since
+ // Zotero.chooseZoteroDirectory() shows its own
+ if (event.originalTarget && event.originalTarget.tagName == 'button') {
+ return true;
+ }
+ // Fx3.6
+ else if (event.explicitOriginalTarget && event.explicitOriginalTarget.tagName == 'button') {
+ return true;
+ }
+
+ // If directory not set or invalid, prompt for location
+ if (!this.getDataDirPath()) {
+ event.stopPropagation();
+ var file = Zotero.chooseZoteroDirectory(true);
+ radiogroup.selectedIndex = file ? 1 : 0;
+ return !!file;
+ }
+
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
+ var app = Zotero.isStandalone ? Zotero.getString('app.standalone') : Zotero.getString('app.firefox');
+ var index = ps.confirmEx(window,
+ Zotero.getString('general.restartRequired'),
+ Zotero.getString('general.restartRequiredForChange', app),
+ buttonFlags,
+ Zotero.getString('general.restartNow'),
+ null, null, null, {});
+
+ if (index == 0) {
+ useDataDir = !!radiogroup.selectedIndex;
+ // quit() is asynchronous, but set this here just in case
+ Zotero.Prefs.set('useDataDir', useDataDir);
+ var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
+ .getService(Components.interfaces.nsIAppStartup);
+ appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit
+ | Components.interfaces.nsIAppStartup.eRestart);
+ }
+
+ radiogroup.selectedIndex = useDataDir ? 1 : 0;
+ return useDataDir;
+ },
+
+
+ getDataDirPath: function () {
+ var desc = Zotero.Prefs.get('dataDir');
+ if (desc == '') {
+ return '';
+ }
+
+ var file = Components.classes["@mozilla.org/file/local;1"].
+ createInstance(Components.interfaces.nsILocalFile);
+ try {
+ file.persistentDescriptor = desc;
+ }
+ catch (e) {
+ return '';
+ }
+ return file.path;
+ },
+
+
+ populateOpenURLResolvers: function () {
+ var openURLMenu = document.getElementById('openURLMenu');
+
+ this._openURLResolvers = Zotero.OpenURL.discoverResolvers();
+ var i = 0;
+ for each(var r in this._openURLResolvers) {
+ openURLMenu.insertItemAt(i, r.name);
+ if (r.url == Zotero.Prefs.get('openURL.resolver') && r.version == Zotero.Prefs.get('openURL.version')) {
+ openURLMenu.selectedIndex = i;
+ }
+ i++;
+ }
+
+ var button = document.getElementById('openURLSearchButton');
+ switch (this._openURLResolvers.length) {
+ case 0:
+ var num = 'zero';
+ break;
+ case 1:
+ var num = 'singular';
+ break;
+ default:
+ var num = 'plural';
+ }
+
+ button.setAttribute('label', Zotero.getString('zotero.preferences.openurl.resolversFound.' + num, this._openURLResolvers.length));
+ },
+
+
+ onOpenURLSelected: function () {
+ var openURLServerField = document.getElementById('openURLServerField');
+ var openURLVersionMenu = document.getElementById('openURLVersionMenu');
+ var openURLMenu = document.getElementById('openURLMenu');
+
+ if(openURLMenu.value == "custom")
+ {
+ openURLServerField.focus();
+ }
+ else
+ {
+ openURLServerField.value = this._openURLResolvers[openURLMenu.selectedIndex]['url'];
+ openURLVersionMenu.value = this._openURLResolvers[openURLMenu.selectedIndex]['version'];
+ Zotero.Prefs.set("openURL.resolver", this._openURLResolvers[openURLMenu.selectedIndex]['url']);
+ Zotero.Prefs.set("openURL.version", this._openURLResolvers[openURLMenu.selectedIndex]['version']);
+ }
+ },
+
+ onOpenURLCustomized: function () {
+ document.getElementById('openURLMenu').value = "custom";
+ }
+};
+
+
+Zotero_Preferences.Attachment_Base_Directory = {
+ choosePath: function () {
+ // Get existing base directory
+ var oldBasePath = Zotero.Prefs.get('baseAttachmentPath');
+ if (oldBasePath) {
+ var oldBasePathFile = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+ try {
+ oldBasePathFile.persistentDescriptor = oldBasePath;
+ }
+ catch (e) {
+ Zotero.debug(e, 1);
+ Components.utils.reportError(e);
+ oldBasePathFile = null;
+ }
+ }
+
+ //Prompt user to choose new base path
+ var nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"]
+ .createInstance(nsIFilePicker);
+ if (oldBasePathFile) {
+ fp.displayDirectory = oldBasePathFile;
+ }
+ fp.init(window, Zotero.getString('attachmentBasePath.selectDir'), nsIFilePicker.modeGetFolder);
+ fp.appendFilters(nsIFilePicker.filterAll);
+ if (fp.show() != nsIFilePicker.returnOK) {
+ return false;
+ }
+ var newBasePathFile = fp.file;
+
+ if (oldBasePathFile && oldBasePathFile.equals(newBasePathFile)) {
+ Zotero.debug("Base directory hasn't changed");
+ return false;
+ }
+
+ // Find all current attachments with relative attachment paths
+ var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=? AND path LIKE '"
+ + Zotero.Attachments.BASE_PATH_PLACEHOLDER + "%'";
+ var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE];
+ var oldRelativeAttachmentIDs = Zotero.DB.columnQuery(sql, params) || [];
+
+ //Find all attachments on the new base path
+ var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=?";
+ var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE];
+ var allAttachments = Zotero.DB.columnQuery(sql,params);
+ var newAttachmentPaths = {};
+ var numNewAttachments = 0;
+ var numOldAttachments = 0;
+ var attachmentFile = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+ for (let i=0; i<allAttachments.length; i++) {
+ let attachmentID = allAttachments[i];
+
+ try {
+ let attachment = Zotero.Items.get(attachmentID);
+ attachmentFile.persistentDescriptor = attachment.attachmentPath;
+ }
+ catch (e) {
+ // Don't deal with bad attachment paths. Just skip them.
+ continue;
+ }
+
+ // If a file with the same relative path exists within the new base directory,
+ // don't touch the attachment, since it will continue to work
+ let isExistingRelativeAttachment = oldRelativeAttachmentIDs.indexOf(attachmentID) != -1;
+ if (isExistingRelativeAttachment && oldBasePathFile) {
+ let relFile = attachmentFile.clone();
+ let relPath = attachmentFile.getRelativeDescriptor(oldBasePathFile);
+ relFile.setRelativeDescriptor(newBasePathFile, relPath);
+ if (relFile.exists()) {
+ numNewAttachments++;
+ continue;
+ }
+ }
+
+ // Files within the new base directory need to be updated to use
+ // relative paths (or, if the new base directory is an ancestor or
+ // descendant of the old one, new relative paths)
+ if (Zotero.File.directoryContains(newBasePathFile, attachmentFile)) {
+ newAttachmentPaths[attachmentID] = isExistingRelativeAttachment
+ ? attachmentFile.persistentDescriptor : null;
+ numNewAttachments++;
+ }
+ // Existing relative attachments not within the new base directory
+ // will be converted to absolute paths
+ else if (isExistingRelativeAttachment && oldBasePathFile) {
+ newAttachmentPaths[attachmentID] = attachmentFile.persistentDescriptor;
+ numOldAttachments++;
+ }
+ }
+
+ //Confirm change of the base path
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ var chooseStrPrefix = 'attachmentBasePath.chooseNewPath.';
+ var clearStrPrefix = 'attachmentBasePath.clearBasePath.';
+ var title = Zotero.getString(chooseStrPrefix + 'title');
+ var msg1 = Zotero.getString(chooseStrPrefix + 'message') + "\n\n", msg2 = msg3 = "";
+ switch (numNewAttachments) {
+ case 0:
+ break;
+
+ case 1:
+ msg2 += Zotero.getString(chooseStrPrefix + 'existingAttachments.singular') + " ";
+ break;
+
+ default:
+ msg2 += Zotero.getString(chooseStrPrefix + 'existingAttachments.plural', numNewAttachments) + " ";
+ }
+
+ switch (numOldAttachments) {
+ case 0:
+ break;
+
+ case 1:
+ msg3 += Zotero.getString(clearStrPrefix + 'existingAttachments.singular');
+ break;
+
+ default:
+ msg3 += Zotero.getString(clearStrPrefix + 'existingAttachments.plural', numOldAttachments);
+ }
+
+
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
+ var index = ps.confirmEx(
+ null,
+ title,
+ (msg1 + msg2 + msg3).trim(),
+ buttonFlags,
+ Zotero.getString(chooseStrPrefix + 'button'),
+ null,
+ null,
+ null,
+ {}
+ );
+
+ if (index == 1) {
+ return false;
+ }
+
+ // Set new data directory
+ Zotero.debug("Setting new base directory");
+ Zotero.Prefs.set('baseAttachmentPath', newBasePathFile.persistentDescriptor);
+ Zotero.Prefs.set('saveRelativeAttachmentPath', true);
+ // Resave all attachments on base path (so that their paths become relative)
+ // and all other relative attachments (so that their paths become absolute)
+ for (let id in newAttachmentPaths) {
+ let attachment = Zotero.Items.get(id);
+ if (newAttachmentPaths[id]) {
+ attachment.attachmentPath = newAttachmentPaths[id];
+ attachment.save();
+ }
+ else {
+ attachment.updateAttachmentPath();
+ }
+ }
+ return newBasePathFile.persistentDescriptor;
+ },
+
+
+ getPath: function (asFile) {
+ var desc = Zotero.Prefs.get('baseAttachmentPath');
+ if (desc == '') {
+ return asFile ? null : '';
+ }
+
+ var file = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+ try {
+ file.persistentDescriptor = desc;
+ }
+ catch (e) {
+ return asFile ? null : '';
+ }
+ return asFile ? file : file.path;
+ },
+
+
+ clearPath: function () {
+ // Find all current attachments with relative paths
+ var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=? AND path LIKE '"
+ + Zotero.Attachments.BASE_PATH_PLACEHOLDER + "%'";
+ var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE];
+ var relativeAttachmentIDs = Zotero.DB.columnQuery(sql, params) || [];
+
+ // Prompt for confirmation
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ var strPrefix = 'attachmentBasePath.clearBasePath.';
+ var title = Zotero.getString(strPrefix + 'title');
+ var msg = Zotero.getString(strPrefix + 'message');
+ switch (relativeAttachmentIDs.length) {
+ case 0:
+ break;
+
+ case 1:
+ msg += "\n\n" + Zotero.getString(strPrefix + 'existingAttachments.singular');
+ break;
+
+ default:
+ msg += "\n\n" + Zotero.getString(strPrefix + 'existingAttachments.plural',
+ relativeAttachmentIDs.length);
+ }
+
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
+ var index = ps.confirmEx(
+ window,
+ title,
+ msg,
+ buttonFlags,
+ Zotero.getString(strPrefix + 'button'),
+ null,
+ null,
+ null,
+ {}
+ );
+
+ if (index == 1) {
+ return false;
+ }
+
+ // Disable relative path saving and then resave all relative
+ // attachments so that their absolute paths are stored
+ Zotero.debug('Clearing base directory');
+ Zotero.Prefs.set('saveRelativeAttachmentPath', false);
+ for (var i=0; i<relativeAttachmentIDs.length; i++) {
+ Zotero.Items.get(relativeAttachmentIDs[i]).updateAttachmentPath();
+ }
+ Zotero.Prefs.set('baseAttachmentPath', '');
+ },
+
+
+ updateUI: function () {
+ var filefield = document.getElementById('baseAttachmentPath');
+ var file = this.getPath(true);
+ filefield.file = file;
+ if (file) {
+ filefield.label = file.path;
+ }
+ else {
+ filefield.label = '';
+ }
+
+ document.getElementById('resetBasePath').disabled = !Zotero.Prefs.get('baseAttachmentPath');
+ }
+};
+
+
+Zotero_Preferences.Debug_Output = {
+ _timer: null,
+
+ init: function () {
+ var storing = Zotero.Debug.storing;
+ this._updateButton();
+ this.updateLines();
+ if (storing) {
+ this._initTimer();
+ }
+ },
+
+
+ toggleStore: function () {
+ this.setStore(!Zotero.Debug.storing);
+ },
+
+
+ setStore: function (set) {
+ Zotero.Debug.setStore(set);
+ if (set) {
+ this._initTimer();
+ }
+ else {
+ if (this._timerID) {
+ this._timer.cancel();
+ this._timerID = null;
+ }
+ }
+ this._updateButton();
+ this.updateLines();
+ },
+
+
+ view: function () {
+ Zotero_Preferences.openInViewer("zotero://debug/");
+ },
+
+
+ submit: function () {
+ document.getElementById('debug-output-submit').disabled = true;
+ document.getElementById('debug-output-submit-progress').hidden = false;
+
+ var url = "https://repo.zotero.org/repo/report?debug=1";
+ var output = Zotero.Debug.get(
+ Zotero.Prefs.get('debug.store.submitSize'),
+ Zotero.Prefs.get('debug.store.submitLineLength')
+ );
+ Zotero_Preferences.Debug_Output.setStore(false);
+
+ var uploadCallback = function (xmlhttp) {
+ document.getElementById('debug-output-submit').disabled = false;
+ document.getElementById('debug-output-submit-progress').hidden = true;
+
+ Zotero.debug(xmlhttp.responseText);
+
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ if (!xmlhttp.responseXML) {
+ ps.alert(
+ null,
+ Zotero.getString('general.error'),
+ Zotero.getString('general.invalidResponseServer')
+ );
+ return;
+ }
+ var reported = xmlhttp.responseXML.getElementsByTagName('reported');
+ if (reported.length != 1) {
+ ps.alert(
+ null,
+ Zotero.getString('general.error'),
+ Zotero.getString('general.serverError')
+ );
+ return;
+ }
+
+ var reportID = reported[0].getAttribute('reportID');
+ ps.alert(
+ null,
+ Zotero.getString('zotero.preferences.advanced.debug.title'),
+ Zotero.getString('zotero.preferences.advanced.debug.sent', reportID)
+ );
+ }
+
+ var bufferUploader = function (data) {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ var oldLen = output.length;
+ var newLen = data.length;
+ var savings = Math.round(((oldLen - newLen) / oldLen) * 100)
+ Zotero.debug("HTTP POST " + newLen + " bytes to " + url
+ + " (gzipped from " + oldLen + " bytes; "
+ + savings + "% savings)");
+
+ if (Zotero.HTTP.browserIsOffline()) {
+ ps.alert(
+ null,
+ Zotero.getString('general.error'),
+ Zotero.getString('general.browserIsOffline', Zotero.appName)
+ );
+ return false;
+ }
+
+ var req =
+ Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].
+ createInstance();
+ req.open('POST', url, true);
+ req.setRequestHeader('Content-Type', "text/plain");
+ req.setRequestHeader('Content-Encoding', 'gzip');
+
+ req.channel.notificationCallbacks = {
+ onProgress: function (request, context, progress, progressMax) {
+ var pm = document.getElementById('debug-output-submit-progress');
+ pm.mode = 'determined'
+ pm.value = progress;
+ pm.max = progressMax;
+ },
+
+ // nsIInterfaceRequestor
+ getInterface: function (iid) {
+ try {
+ return this.QueryInterface(iid);
+ }
+ catch (e) {
+ throw Components.results.NS_NOINTERFACE;
+ }
+ },
+
+ QueryInterface: function(iid) {
+ if (iid.equals(Components.interfaces.nsISupports) ||
+ iid.equals(Components.interfaces.nsIInterfaceRequestor) ||
+ iid.equals(Components.interfaces.nsIProgressEventSink)) {
+ return this;
+ }
+ throw Components.results.NS_NOINTERFACE;
+ },
+
+ }
+ req.onreadystatechange = function () {
+ if (req.readyState == 4) {
+ uploadCallback(req);
+ }
+ };
+ try {
+ req.sendAsBinary(data);
+ }
+ catch (e) {
+ ps.alert(
+ null,
+ Zotero.getString('general.error'),
+ Zotero.getString('zotero.preferences.advanced.debug.error')
+ );
+ }
+ }
+
+ // Get input stream from debug output data
+ var unicodeConverter =
+ Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
+ .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+ unicodeConverter.charset = "UTF-8";
+ var bodyStream = unicodeConverter.convertToInputStream(output);
+
+ // Get listener for when compression is done
+ var listener = new Zotero.BufferedInputListener(bufferUploader);
+
+ // Initialize stream converter
+ var converter =
+ Components.classes["@mozilla.org/streamconv;1?from=uncompressed&to=gzip"]
+ .createInstance(Components.interfaces.nsIStreamConverter);
+ converter.asyncConvertData("uncompressed", "gzip", listener, null);
+
+ // Send input stream to stream converter
+ var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].
+ createInstance(Components.interfaces.nsIInputStreamPump);
+ pump.init(bodyStream, -1, -1, 0, 0, true);
+ pump.asyncRead(converter, null);
+ },
+
+
+ clear: function () {
+ Zotero.Debug.clear();
+ this.updateLines();
+ },
+
+
+ updateLines: function () {
+ var enabled = Zotero.Debug.storing;
+ var lines = Zotero.Debug.count();
+ document.getElementById('debug-output-lines').value = lines;
+ var empty = lines == 0;
+ document.getElementById('debug-output-view').disabled = !enabled && empty;
+ document.getElementById('debug-output-clear').disabled = empty;
+ document.getElementById('debug-output-submit').disabled = empty;
+ },
+
+
+ _initTimer: function () {
+ this._timer = Components.classes["@mozilla.org/timer;1"].
+ createInstance(Components.interfaces.nsITimer);
+ this._timer.initWithCallback({
+ notify: function() {
+ Zotero_Preferences.Debug_Output.updateLines();
+ }
+ }, 10000, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
+ },
+
+
+ _updateButton: function () {
+ var storing = Zotero.Debug.storing
+
+ var button = document.getElementById('debug-output-enable');
+ if (storing) {
+ button.label = Zotero.getString('general.disable');
+ }
+ else {
+ button.label = Zotero.getString('general.enable');
+ }
+ },
+
+
+ onUnload: function () {
+ if (this._timer) {
+ this._timer.cancel();
+ }
+ }
+};
diff --git a/chrome/content/zotero/preferences/preferences_advanced.xul b/chrome/content/zotero/preferences/preferences_advanced.xul
@@ -0,0 +1,204 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay id="zotero-prefpane-advanced-overlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <prefpane id="zotero-prefpane-advanced"
+ onpaneload="Zotero_Preferences.Advanced.init()"
+ helpTopic="advanced">
+ <preferences>
+ <preference id="pref-baseAttachmentPath" name="extensions.zotero.baseAttachmentPath" type="string"/>
+ <preference id="pref-useDataDir" name="extensions.zotero.useDataDir" type="bool"/>
+ <preference id="pref-dataDir" name="extensions.zotero.dataDir" type="string"/>
+ <preference id="pref-export-displayCharsetOption" name="extensions.zotero.export.displayCharsetOption" type="bool"/>
+ <preference id="pref-debug-output-enableAfterRestart" name="extensions.zotero.debug.store" type="bool"/>
+ <preference id="pref-import-charset" name="extensions.zotero.import.charset" type="string"/>
+ <preference id="pref-openURL-resolver" name="extensions.zotero.openURL.resolver" type="string"/>
+ <preference id="pref-openURL-version" name="extensions.zotero.openURL.version" type="string"/>
+ </preferences>
+
+ <tabbox id="zotero-prefpane-advanced-tabs">
+ <tabs>
+ <tab label="&zotero.preferences.prefpane.general;"/>
+ <tab label="&zotero.preferences.advanced.filesAndFolders;"/>
+ </tabs>
+
+ <tabpanels id="zotero-prefpane-advanced-tabpanels">
+ <tabpanel id="zotero-prefpane-advanced-general-tab" orient="vertical">
+ <groupbox>
+ <caption label="&zotero.preferences.debugOutputLogging;"/>
+
+ <!-- This doesn't wrap without an explicit width -->
+ <vbox>
+ <description width="45em">&zotero.preferences.debugOutputLogging.message;</description>
+ </vbox>
+
+ <hbox align="center">
+ <button id="debug-output-enable" oncommand="Zotero_Preferences.Debug_Output.toggleStore()"/>
+ <label id="debug-output-lines" style="margin-right: 0"/>
+ <label value="&zotero.preferences.debugOutputLogging.linesLogged;"/>
+ <checkbox preference="pref-debug-output-enableAfterRestart" label="&zotero.preferences.debugOutputLogging.enableAfterRestart;" style="margin-left: 1.5em"/>
+ </hbox>
+
+ <hbox align="center">
+ <button id="debug-output-view" label="&zotero.preferences.debugOutputLogging.viewOutput;" oncommand="Zotero_Preferences.Debug_Output.view()"/>
+ <button id="debug-output-clear" label="&zotero.preferences.debugOutputLogging.clearOutput;" oncommand="Zotero_Preferences.Debug_Output.clear()"/>
+ <button id="debug-output-submit" label="&zotero.preferences.debugOutputLogging.submitToServer;" oncommand="Zotero_Preferences.Debug_Output.submit()"/>
+ <progressmeter id="debug-output-submit-progress" mode="undetermined" hidden="true"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox>
+ <caption label="&zotero.preferences.openurl.caption;"/>
+
+ <hbox align="center">
+ <!-- vbox prevents some weird vertical stretching of the menulist -->
+ <vbox flex="1">
+ <menulist id="openURLMenu" oncommand="Zotero_Preferences.Advanced.onOpenURLSelected();">
+ <menupopup>
+ <menuseparator/>
+ <menuitem label="&zotero.preferences.openurl.custom;" value="custom" selected="true"/>
+ </menupopup>
+ </menulist>
+ </vbox>
+ <button id="openURLSearchButton" label="&zotero.preferences.openurl.search;"
+ oncommand="Zotero_Preferences.Advanced.populateOpenURLResolvers()"/>
+ </hbox>
+
+ <hbox align="center">
+ <label value="&zotero.preferences.openurl.server;"/>
+ <textbox id="openURLServerField" flex="1"
+ oninput="Zotero_Preferences.Advanced.onOpenURLCustomized();"
+ preference="pref-openURL-resolver"/>
+ </hbox>
+
+ <hbox align="center">
+ <label value="&zotero.preferences.openurl.version;" control="openURLVersionMenu"/>
+ <menulist id="openURLVersionMenu"
+ oncommand="Zotero_Preferences.Advanced.onOpenURLCustomized();"
+ preference="pref-openURL-version">
+ <menupopup>
+ <menuitem label="0.1" value="0.1"/>
+ <menuitem label="1.0" value="1.0"/>
+ </menupopup>
+ </menulist>
+ </hbox>
+ </groupbox>
+
+ <groupbox id="zotero-prefpane-advanced-miscellaneous">
+ <caption label="&zotero.preferences.miscellaneous;"/>
+ <hbox id="zotero-prefpane-advanced-openbuttons" align="center">
+ <button id="openAboutConfig"
+ label="&zotero.preferences.openAboutConfig;"
+ oncommand="Zotero_Preferences.openInViewer('about:config')"/>
+ <button id="openCSLEdit"
+ label="&zotero.preferences.openCSLEdit;"
+ oncommand="Zotero_Preferences.openInViewer('chrome://zotero/content/tools/csledit.xul', true)"/>
+ <button id="openCSLPreview"
+ label="&zotero.preferences.openCSLPreview;"
+ oncommand="Zotero_Preferences.openInViewer('chrome://zotero/content/tools/cslpreview.xul', true)"/>
+ </hbox>
+ </groupbox>
+ </tabpanel>
+
+ <tabpanel orient="vertical">
+ <groupbox>
+ <caption label="&zotero.preferences.attachmentBaseDir.caption;"/>
+
+ <!-- This doesn't wrap without an explicit width -->
+ <vbox>
+ <description width="45em">&zotero.preferences.attachmentBaseDir.message;</description>
+ </vbox>
+
+ <hbox align="center">
+ <label value="&zotero.preferences.attachmentBaseDir.basePath;"/>
+ <filefield id="baseAttachmentPath"
+ preference="pref-baseAttachmentPath"
+ onsyncfrompreference="Zotero_Preferences.Attachment_Base_Directory.updateUI()"
+ preference-editable="true"
+ readonly="true"
+ flex="1"
+ tabindex="-1"/>
+ <button label="&zotero.preferences.attachmentBaseDir.selectBasePath;"
+ oncommand="Zotero_Preferences.Attachment_Base_Directory.choosePath()"/>
+ </hbox>
+
+ <hbox>
+ <button id="resetBasePath"
+ label="&zotero.preferences.attachmentBaseDir.resetBasePath;"
+ oncommand="Zotero_Preferences.Attachment_Base_Directory.clearPath()"/>
+ </hbox>
+
+ </groupbox>
+
+ <groupbox>
+ <caption label="&zotero.preferences.dataDir;"/>
+
+ <radiogroup id="dataDir"
+ preference="pref-useDataDir"
+ onsyncfrompreference="Zotero_Preferences.Advanced.onDataDirLoad();"
+ onsynctopreference="return Zotero_Preferences.Advanced.onDataDirUpdate(event);">
+ <radio label="&zotero.preferences.dataDir.useProfile;" value="false"/>
+ <hbox>
+ <radio label="&zotero.preferences.dataDir.custom;" value="true"/>
+ <textbox id="dataDirPath" preference="pref-dataDir"
+ onsyncfrompreference="return Zotero_Preferences.Advanced.getDataDirPath();"
+ readonly="true" flex="1"/>
+ <button label="&zotero.preferences.dataDir.choose;"
+ oncommand="var file = Zotero.chooseZoteroDirectory(true);
+ if (!file) {
+ event.stopPropagation();
+ }"/>
+ </hbox>
+ </radiogroup>
+
+ <hbox>
+ <button label="&zotero.preferences.dataDir.reveal;"
+ oncommand="Zotero_Preferences.Advanced.revealDataDirectory()"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox>
+ <caption label="&zotero.preferences.dbMaintenance;"/>
+
+ <hbox>
+ <button label="&zotero.preferences.dbMaintenance.integrityCheck;"
+ oncommand="Zotero_Preferences.Advanced.runIntegrityCheck()"/>
+ <button label="&zotero.preferences.dbMaintenance.resetTranslators;"
+ oncommand="Zotero_Preferences.Advanced.resetTranslators()"/>
+ <button label="&zotero.preferences.dbMaintenance.resetStyles;"
+ oncommand="Zotero_Preferences.Advanced.resetStyles()"/>
+ </hbox>
+ </groupbox>
+ </tabpanel>
+ </tabpanels>
+ </tabbox>
+ </prefpane>
+
+ <script src="preferences_advanced.js" type="application/javascript;version=1.8"/>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_advanced_firefox.xul b/chrome/content/zotero/preferences/preferences_advanced_firefox.xul
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <prefpane id="zotero-prefpane-advanced">
+ <preferences id="zotero-prefpane-general-preferences">
+ <preference id="pref-zoteroDotOrgVersionHeader"
+ name="extensions.zotero.zoteroDotOrgVersionHeader"
+ type="bool"/>
+ </preferences>
+
+ <tabbox id="zotero-prefpane-advanced-tabs">
+ <tabpanels id="zotero-prefpane-advanced-tabpanels">
+ <tabpanel id="zotero-prefpane-advanced-general-tab">
+ <groupbox id="zotero-prefpane-advanced-miscellaneous">
+ <checkbox label="&zotero.preferences.zoteroDotOrgVersionHeader;"
+ tooltiptext="&zotero.preferences.zoteroDotOrgVersionHeader.tooltip;"
+ preference="pref-zoteroDotOrgVersionHeader"
+ insertbefore="zotero-prefpane-advanced-openbuttons"/>
+ <separator class="thin"
+ insertbefore="zotero-prefpane-advanced-openbuttons"/>
+ </groupbox>
+ </tabpanel>
+ </tabpanels>
+ </tabbox>
+ </prefpane>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_cite.js b/chrome/content/zotero/preferences/preferences_cite.js
@@ -0,0 +1,170 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+*/
+
+"use strict";
+
+Zotero_Preferences.Cite = {
+ init: function () {
+ this.updateWordProcessorInstructions();
+ this.refreshStylesList();
+ },
+
+
+ /**
+ * Determines if there are word processors, and if not, enables no word processor message
+ */
+ updateWordProcessorInstructions: function () {
+ if(document.getElementById("wordProcessors").childNodes.length == 2) {
+ document.getElementById("wordProcessors-noWordProcessorPluginsInstalled").hidden = undefined;
+ }
+ if(Zotero.isStandalone) {
+ document.getElementById("wordProcessors-getWordProcessorPlugins").hidden = true;
+ }
+ },
+
+
+ /**
+ * Refreshes the list of styles in the styles pane
+ * @param {String} cslID Style to select
+ */
+ refreshStylesList: function (cslID) {
+ Zotero.debug("Refreshing styles list");
+
+ var treechildren = document.getElementById('styleManager-rows');
+ while (treechildren.hasChildNodes()) {
+ treechildren.removeChild(treechildren.firstChild);
+ }
+
+ var styles = Zotero.Styles.getVisible();
+
+ var selectIndex = false;
+ var i = 0;
+ for each(var style in styles) {
+ var treeitem = document.createElement('treeitem');
+ var treerow = document.createElement('treerow');
+ var titleCell = document.createElement('treecell');
+ var updatedCell = document.createElement('treecell');
+ var cslCell = document.createElement('treecell');
+
+ if (style.updated) {
+ var updatedDate = Zotero.Date.formatDate(Zotero.Date.strToDate(style.updated), true);
+ }
+ else {
+ var updatedDate = '';
+ }
+
+ treeitem.setAttribute('id', 'zotero-csl-' + style.styleID);
+ titleCell.setAttribute('label', style.title);
+ updatedCell.setAttribute('label', updatedDate);
+ // if not EN
+ if(style.type == "csl") {
+ cslCell.setAttribute('src', 'chrome://zotero/skin/tick.png');
+ }
+
+ treerow.appendChild(titleCell);
+ treerow.appendChild(updatedCell);
+ treerow.appendChild(cslCell);
+ treeitem.appendChild(treerow);
+ treechildren.appendChild(treeitem);
+
+ if (cslID == style.styleID) {
+ document.getElementById('styleManager').view.selection.select(i);
+ }
+ i++;
+ }
+ },
+
+
+ /**
+ * Adds a new style to the style pane
+ **/
+ addStyle: function () {
+ const nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"]
+ .createInstance(nsIFilePicker);
+ fp.init(window, Zotero.getString("zotero.preferences.styles.addStyle"), nsIFilePicker.modeOpen);
+
+ fp.appendFilter("CSL Style", "*.csl");
+ fp.appendFilter("ENS Style", "*.ens");
+
+ var rv = fp.show();
+ if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
+ Zotero.Styles.install(fp.file);
+ }
+ },
+
+
+ /**
+ * Deletes selected styles from the styles pane
+ **/
+ deleteStyle: function () {
+ // get selected cslIDs
+ var tree = document.getElementById('styleManager');
+ var treeItems = tree.lastChild.childNodes;
+ var cslIDs = [];
+ var start = {};
+ var end = {};
+ var nRanges = tree.view.selection.getRangeCount();
+ for(var i=0; i<nRanges; i++) {
+ tree.view.selection.getRangeAt(i, start, end);
+ for(var j=start.value; j<=end.value; j++) {
+ cslIDs.push(treeItems[j].getAttribute('id').substr(11));
+ }
+ }
+
+ if(cslIDs.length == 0) {
+ return;
+ } else if(cslIDs.length == 1) {
+ var selectedStyle = Zotero.Styles.get(cslIDs[0])
+ var text = Zotero.getString('styles.deleteStyle', selectedStyle.title);
+ } else {
+ var text = Zotero.getString('styles.deleteStyles');
+ }
+
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+ if(ps.confirm(null, '', text)) {
+ // delete if requested
+ if(cslIDs.length == 1) {
+ selectedStyle.remove();
+ } else {
+ for(var i=0; i<cslIDs.length; i++) {
+ Zotero.Styles.get(cslIDs[i]).remove();
+ }
+ }
+
+ this.refreshStylesList();
+ document.getElementById('styleManager-delete').disabled = true;
+ }
+ },
+
+
+ /**
+ * Shows an error if import fails
+ **/
+ styleImportError: function () {
+ alert(Zotero.getString('styles.installError', "This"));
+ }
+}
diff --git a/chrome/content/zotero/preferences/preferences_cite.xul b/chrome/content/zotero/preferences/preferences_cite.xul
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay id="zotero-prefpane-cite-overlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <prefpane id="zotero-prefpane-cite"
+ onpaneload="Zotero_Preferences.Cite.init()"
+ helpTopic="cite">
+
+ <preferences id="zotero-preferences-cite">
+ <preference id="pref-cite-useClassicAddCitationDialog" name="extensions.zotero.integration.useClassicAddCitationDialog" type="bool"/>
+ <preference id="pref-cite-citePaperJournalArticleURL" name="extensions.zotero.export.citePaperJournalArticleURL" type="bool"/>
+ <preference id="pref-cite-automaticTitleAbbreviation" name="extensions.zotero.cite.automaticTitleAbbreviation" type="bool"/>
+ </preferences>
+
+ <tabbox>
+ <tabs>
+ <tab label="&zotero.preferences.cite.wordProcessors;"/>
+ <tab label="&zotero.preferences.cite.styles;"/>
+ </tabs>
+ <tabpanels>
+ <tabpanel orient="vertical" id="wordProcessors">
+ <label id="wordProcessors-noWordProcessorPluginsInstalled" width="45em" hidden="true">
+ &zotero.preferences.cite.wordProcessors.noWordProcessorPluginsInstalled;
+ </label>
+ <checkbox label="&zotero.preferences.cite.wordProcessors.useClassicAddCitationDialog;" preference="pref-cite-useClassicAddCitationDialog"/>
+ <label id="wordProcessors-getWordProcessorPlugins" class="zotero-text-link" href="&zotero.preferences.cite.wordProcessors.getPlugins.url;" value="&zotero.preferences.cite.wordProcessors.getPlugins;"/>
+ </tabpanel>
+ <tabpanel orient="vertical" id="styles">
+ <groupbox flex="1">
+ <caption label="&zotero.preferences.cite.styles.styleManager;"/>
+
+ <tree flex="1" id="styleManager" hidecolumnpicker="true" rows="6"
+ onselect="document.getElementById('styleManager-delete').disabled = undefined"
+ onkeypress="if (event.keyCode == event.DOM_VK_DELETE) { Zotero_Preferences.Cite.deleteSelectedStyle(); }">
+ <treecols>
+ <treecol id="styleManager-title" label="&zotero.preferences.cite.styles.styleManager.title;" flex="3"/>
+ <treecol id="styleManager-updated" label="&zotero.preferences.cite.styles.styleManager.updated;" flex="1"/>
+ <treecol id="styleManager-csl" label="&zotero.preferences.cite.styles.styleManager.csl;"/>
+ </treecols>
+ <treechildren id="styleManager-rows"/>
+ </tree>
+ <separator class="thin"/>
+ <hbox align="center" flex="1" height="40">
+ <label class="zotero-text-link" href="http://www.zotero.org/styles/" value="&zotero.preferences.export.getAdditionalStyles;" flex="1"/>
+ <button disabled="true" id="styleManager-delete" label="-" onclick="Zotero_Preferences.Cite.deleteStyle()"/>
+ <button label="+" onclick="Zotero_Preferences.Cite.addStyle()"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox>
+ <caption label="&zotero.preferences.citationOptions.caption;"/>
+
+ <checkbox label="&zotero.preferences.export.citePaperJournalArticleURL;" preference="pref-cite-citePaperJournalArticleURL"/>
+ <!-- This doesn't wrap without an explicit width, for some reason -->
+ <label id="export-citePaperJournalArticleURL" width="45em">
+ &zotero.preferences.export.citePaperJournalArticleURL.description;
+ </label>
+
+ <checkbox label="&zotero.preferences.cite.styles.automaticTitleAbbreviation;" preference="pref-cite-automaticTitleAbbreviation"/>
+ </groupbox>
+ </tabpanel>
+ </tabpanels>
+ </tabbox>
+ </prefpane>
+
+ <script src="preferences_cite.js" type="application/javascript;version=1.8"/>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_export.js b/chrome/content/zotero/preferences/preferences_export.js
@@ -0,0 +1,246 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+*/
+
+"use strict";
+
+Zotero_Preferences.Export = {
+ init: function () {
+ this.populateQuickCopyList();
+ this.updateQuickCopyInstructions();
+
+ var charsetMenu = document.getElementById("zotero-import-charsetMenu");
+ var charsetMap = Zotero_Charset_Menu.populate(charsetMenu, false);
+ charsetMenu.selectedItem =
+ charsetMap[Zotero.Prefs.get("import.charset")] ?
+ charsetMap[Zotero.Prefs.get("import.charset")] : charsetMap["auto"];
+ },
+
+
+ /*
+ * Builds the main Quick Copy drop-down from the current global pref
+ */
+ populateQuickCopyList: function () {
+ // Initialize default format drop-down
+ var format = Zotero.Prefs.get("export.quickCopy.setting");
+ var menulist = document.getElementById("zotero-quickCopy-menu");
+ this.buildQuickCopyFormatDropDown(menulist, Zotero.QuickCopy.getContentType(format), format);
+ menulist.setAttribute('preference', "pref-quickCopy-setting");
+ this.updateQuickCopyHTMLCheckbox();
+
+ if (!Zotero.isStandalone) {
+ this.refreshQuickCopySiteList();
+ }
+ },
+
+
+ /*
+ * Builds a Quick Copy drop-down
+ */
+ buildQuickCopyFormatDropDown: function (menulist, contentType, currentFormat) {
+ if (!currentFormat) {
+ currentFormat = menulist.value;
+ }
+ // Strip contentType from mode
+ currentFormat = Zotero.QuickCopy.stripContentType(currentFormat);
+
+ menulist.selectedItem = null;
+ menulist.removeAllItems();
+
+ // Prevent Cmd-w from setting "Wikipedia"
+ menulist.onkeydown = function (event) {
+ if ((Zotero.isMac && event.metaKey) || event.ctrlKey) {
+ event.preventDefault();
+ }
+ }
+
+ var popup = document.createElement('menupopup');
+ menulist.appendChild(popup);
+
+ var itemNode = document.createElement("menuitem");
+ itemNode.setAttribute("label", Zotero.getString('zotero.preferences.export.quickCopy.bibStyles'));
+ itemNode.setAttribute("disabled", true);
+ popup.appendChild(itemNode);
+
+ // add styles to list
+ var styles = Zotero.Styles.getVisible();
+ for each(var style in styles) {
+ var baseVal = 'bibliography=' + style.styleID;
+ var val = 'bibliography' + (contentType == 'html' ? '/html' : '') + '=' + style.styleID;
+ var itemNode = document.createElement("menuitem");
+ itemNode.setAttribute("value", val);
+ itemNode.setAttribute("label", style.title);
+ itemNode.setAttribute("oncommand", 'Zotero_Preferences.Export.updateQuickCopyHTMLCheckbox()');
+ popup.appendChild(itemNode);
+
+ if (baseVal == currentFormat) {
+ menulist.selectedItem = itemNode;
+ }
+ }
+
+ var itemNode = document.createElement("menuitem");
+ itemNode.setAttribute("label", Zotero.getString('zotero.preferences.export.quickCopy.exportFormats'));
+ itemNode.setAttribute("disabled", true);
+ popup.appendChild(itemNode);
+
+ // add export formats to list
+ var translation = new Zotero.Translate("export");
+ var translators = translation.getTranslators();
+
+ for (var i=0; i<translators.length; i++) {
+ // Skip RDF formats
+ switch (translators[i].translatorID) {
+ case '6e372642-ed9d-4934-b5d1-c11ac758ebb7':
+ case '14763d24-8ba0-45df-8f52-b8d1108e7ac9':
+ continue;
+ }
+ var val = 'export=' + translators[i].translatorID;
+ var itemNode = document.createElement("menuitem");
+ itemNode.setAttribute("value", val);
+ itemNode.setAttribute("label", translators[i].label);
+ itemNode.setAttribute("oncommand", 'Zotero_Preferences.Export.updateQuickCopyHTMLCheckbox()');
+ popup.appendChild(itemNode);
+
+ if (val == currentFormat) {
+ menulist.selectedItem = itemNode;
+ }
+ }
+
+ menulist.click();
+
+ return popup;
+ },
+
+
+ updateQuickCopyHTMLCheckbox: function () {
+ var format = document.getElementById('zotero-quickCopy-menu').value;
+ var mode, contentType;
+
+ var checkbox = document.getElementById('zotero-quickCopy-copyAsHTML');
+ [mode, format] = format.split('=');
+ [mode, contentType] = mode.split('/');
+
+ checkbox.checked = contentType == 'html';
+ checkbox.disabled = mode != 'bibliography';
+ },
+
+
+ showQuickCopySiteEditor: function (index) {
+ var treechildren = document.getElementById('quickCopy-siteSettings-rows');
+
+ if (index != undefined && index > -1 && index < treechildren.childNodes.length) {
+ var treerow = treechildren.childNodes[index].firstChild;
+ var domain = treerow.childNodes[0].getAttribute('label');
+ var format = treerow.childNodes[1].getAttribute('label');
+ var asHTML = treerow.childNodes[2].getAttribute('label') != '';
+ }
+
+ var format = Zotero.QuickCopy.getSettingFromFormattedName(format);
+ if (asHTML) {
+ format = format.replace('bibliography=', 'bibliography/html=');
+ }
+
+ var io = {domain: domain, format: format, ok: false};
+ window.openDialog('chrome://zotero/content/preferences/quickCopySiteEditor.xul', "zotero-preferences-quickCopySiteEditor", "chrome, modal", io);
+
+ if (!io.ok) {
+ return;
+ }
+
+ if (domain && domain != io.domain) {
+ Zotero.DB.query("DELETE FROM settings WHERE setting='quickCopySite' AND key=?", [domain]);
+ }
+
+ Zotero.DB.query("REPLACE INTO settings VALUES ('quickCopySite', ?, ?)", [io.domain, io.format]);
+
+ this.refreshQuickCopySiteList();
+ },
+
+
+ refreshQuickCopySiteList: function () {
+ var treechildren = document.getElementById('quickCopy-siteSettings-rows');
+ while (treechildren.hasChildNodes()) {
+ treechildren.removeChild(treechildren.firstChild);
+ }
+
+ var sql = "SELECT key AS domainPath, value AS format FROM settings "
+ + "WHERE setting='quickCopySite' ORDER BY domainPath COLLATE NOCASE";
+ var siteData = Zotero.DB.query(sql);
+
+ if (!siteData) {
+ return;
+ }
+
+ for (var i=0; i<siteData.length; i++) {
+ var treeitem = document.createElement('treeitem');
+ var treerow = document.createElement('treerow');
+ var domainCell = document.createElement('treecell');
+ var formatCell = document.createElement('treecell');
+ var HTMLCell = document.createElement('treecell');
+
+ domainCell.setAttribute('label', siteData[i].domainPath);
+
+ var formatted = Zotero.QuickCopy.getFormattedNameFromSetting(siteData[i].format);
+ formatCell.setAttribute('label', formatted);
+ var copyAsHTML = Zotero.QuickCopy.getContentType(siteData[i].format) == 'html';
+ HTMLCell.setAttribute('label', copyAsHTML ? ' ✓ ' : '');
+
+ treerow.appendChild(domainCell);
+ treerow.appendChild(formatCell);
+ treerow.appendChild(HTMLCell);
+ treeitem.appendChild(treerow);
+ treechildren.appendChild(treeitem);
+ }
+ },
+
+
+ deleteSelectedQuickCopySite: function () {
+ var tree = document.getElementById('quickCopy-siteSettings');
+ var treeitem = tree.lastChild.childNodes[tree.currentIndex];
+ var domainPath = treeitem.firstChild.firstChild.getAttribute('label');
+ Zotero.DB.query("DELETE FROM settings WHERE setting='quickCopySite' AND key=?", [domainPath]);
+ this.refreshQuickCopySiteList();
+ },
+
+
+ updateQuickCopyInstructions: function () {
+ var prefix = Zotero.isMac ? 'Cmd+Shift+' : 'Ctrl+Alt+';
+
+ var key = Zotero.Prefs.get('keys.copySelectedItemsToClipboard');
+ var str = Zotero.getString('zotero.preferences.export.quickCopy.instructions', prefix + key);
+ var instr = document.getElementById('quickCopy-instructions');
+ while (instr.hasChildNodes()) {
+ instr.removeChild(instr.firstChild);
+ }
+ instr.appendChild(document.createTextNode(str));
+
+ var key = Zotero.Prefs.get('keys.copySelectedItemCitationsToClipboard');
+ var str = Zotero.getString('zotero.preferences.export.quickCopy.citationInstructions', prefix + key);
+ var instr = document.getElementById('quickCopy-citationInstructions');
+ while (instr.hasChildNodes()) {
+ instr.removeChild(instr.firstChild);
+ }
+ instr.appendChild(document.createTextNode(str));
+ }
+};
diff --git a/chrome/content/zotero/preferences/preferences_export.xul b/chrome/content/zotero/preferences/preferences_export.xul
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <prefpane id="zotero-prefpane-export"
+ onpaneload="Zotero_Preferences.Export.init()"
+ helpTopic="export">
+
+ <preferences>
+ <preference id="pref-quickCopy-setting" name="extensions.zotero.export.quickCopy.setting" type="string"/>
+ <preference id="pref-quickCopy-dragLimit" name="extensions.zotero.export.quickCopy.dragLimit" type="int"/>
+ </preferences>
+
+ <groupbox id="zotero-prefpane-export-groupbox">
+ <caption label="&zotero.preferences.quickCopy.caption;"/>
+
+ <label id="quickCopy-instructions"/>
+ <separator class="thin"/>
+ <label id="quickCopy-citationInstructions"/>
+
+ <separator/>
+
+ <label value="&zotero.preferences.quickCopy.defaultOutputFormat;" control="quickCopy-menu"/>
+ <menulist id="zotero-quickCopy-menu"/>
+
+ <separator class="thin"/>
+
+ <checkbox id="zotero-quickCopy-copyAsHTML" label="&zotero.preferences.quickCopy.copyAsHTML;"
+ oncommand="Zotero_Preferences.Export.buildQuickCopyFormatDropDown(document.getElementById('zotero-quickCopy-menu'), this.checked ? 'html' : '');"/>
+
+ <vbox id="zotero-prefpane-export-siteSettings"/>
+
+ <hbox align="center">
+ <label value="&zotero.preferences.quickCopy.dragLimit;"/>
+ <textbox preference="pref-quickCopy-dragLimit" size="3"/>
+ <label value="&zotero.preferences.items;" flex="1"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox>
+ <caption label="&zotero.preferences.charset;"/>
+
+ <checkbox id="zotero-export-displayCharsetOption" label="&zotero.preferences.charset.displayExportOption;"
+ preference="pref-export-displayCharsetOption"/>
+
+ <hbox align="center">
+ <label value="&zotero.preferences.charset.importCharset;:" control="zotero-import-charsetMenu"/>
+ <menulist id="zotero-import-charsetMenu" preference="pref-import-charset"/>
+ </hbox>
+ </groupbox>
+
+ <!-- Unclear why this is necessary to prevent the menulist from getting cut off -->
+ <separator/>
+ <separator/>
+
+ <script src="preferences_export.js" type="application/javascript;version=1.8"/>
+ </prefpane>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_export_firefox.xul b/chrome/content/zotero/preferences/preferences_export_firefox.xul
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <prefpane id="zotero-prefpane-export">
+ <groupbox id="zotero-prefpane-export-groupbox">
+ <vbox id="zotero-prefpane-export-siteSettings">
+ <separator/>
+
+ <label value="&zotero.preferences.quickCopy.siteEditor.setings;" control="quickCopy-siteSettings"/>
+ <tree flex="1" id="quickCopy-siteSettings" hidecolumnpicker="true" rows="6" seltype="single"
+ ondblclick="Zotero_Preferences.Export.showQuickCopySiteEditor(this.currentIndex)"
+ onkeypress="if (event.keyCode == event.DOM_VK_DELETE) { Zotero_Preferences.Export.deleteSelectedQuickCopySite(); }">
+ <treecols>
+ <treecol id="quickCopy-urlColumn" label="&zotero.preferences.quickCopy.siteEditor.domainPath;" flex="1"/>
+ <treecol id="quickCopy-formatColumn" label="&zotero.preferences.quickCopy.siteEditor.outputFormat;" flex="2"/>
+ <treecol id="quickCopy-copyAsHTML" label="HTML"/>
+ </treecols>
+ <treechildren id="quickCopy-siteSettings-rows"/>
+ </tree>
+ <separator class="thin"/>
+ <hbox pack="end">
+ <button label="-" onclick="Zotero_Preferences.Export.deleteSelectedQuickCopySite()"/>
+ <button label="+" onclick="Zotero_Preferences.Export.showQuickCopySiteEditor()"/>
+ </hbox>
+ </vbox>
+ </groupbox>
+ </prefpane>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_firefox.xul b/chrome/content/zotero/preferences/preferences_firefox.xul
@@ -2,7 +2,7 @@
<!--
***** BEGIN LICENSE BLOCK *****
- Copyright © 2009 Center for History and New Media
+ Copyright © 2006–2013 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
@@ -29,96 +29,8 @@
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
<?xml-stylesheet href="chrome://zotero/skin/preferences.css"?>
-<!--
-
-To add a new preference:
- 1) Add a new <preference> to <preferences>
- 2) Add a XUL control with a 'preference' attribute
- 3) (Optional) Add additional setup/change logic to preferences.js
- 4) (Optional) To add an observer for a preference change,
- add an appropriate case in the switch statement
- in Zotero.Prefs.observe()
-
--->
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefwindow id="zotero-prefs">
- <prefpane id="zotero-prefpane-general"
- label="&zotero.preferences.prefpane.general;"
- image="chrome://zotero/skin/prefs-general.png">
- <preferences id="zotero-prefpane-general-preferences">
- <preference id="pref-showIn" name="extensions.zotero.showIn" type="int"/>
- <preference id="pref-statusBarIcon" name="extensions.zotero.statusBarIcon" type="int"/>
- <preference id="pref-launchNonNativeFiles" name="extensions.zotero.launchNonNativeFiles" type="bool"/>
- <preference id="pref-parseEndNoteMIMETypes"
- name="extensions.zotero.parseEndNoteMIMETypes"
- type="bool" onchange="Zotero.MIMETypeHandler.init()"/>
- </preferences>
- <groupbox id="zotero-prefpane-general-groupbox">
- <grid id="zotero-prefpane-general-grid">
- <rows id="zotero-prefpane-general-rows">
- <row position="1">
- <hbox align="center">
- <label value="&zotero.preferences.showIn;" control="showAs"/>
- </hbox>
- <radiogroup id="showIn" orient="horizontal" preference="pref-showIn" oncommand="handleShowInPreferenceChange()">
- <radio id="zotero-prefpane-general-showIn-browserPane" label="&zotero.preferences.showIn.browserPane;" value="1"/>
- <radio id="zotero-prefpane-general-showIn-separateTab" label="&zotero.preferences.showIn.separateTab;" value="2"/>
- <radio id="zotero-prefpane-general-showIn-appTab" label="&zotero.preferences.showIn.appTab;" value="3"/>
- </radiogroup>
- </row>
- <row position="2" id="zotero-prefpane-general-statusBarIcon-row">
- <hbox align="center">
- <label id="statusBarIcon-label" value="&zotero.preferences.statusBarIcon;" control="statusBarIcon"/>
- </hbox>
- <radiogroup id="statusBarIcon" orient="horizontal" preference="pref-statusBarIcon">
- <radio id="statusBarIcon-full" src="chrome://zotero/skin/zotero_status_bar.png" value="2"/>
- <radio id="statusBarIcon-compact" src="chrome://zotero/skin/zotero_status_bar_compact.png" value="1"/>
- <radio id="statusBarIcon-none" label="&zotero.preferences.statusBarIcon.none;" value="0"/>
- </radiogroup>
- </row>
- </rows>
- </grid>
- </groupbox>
- <groupbox id="zotero-prefpane-miscellaneous-groupbox">
- <checkbox id="launchNonNativeFiles-checkbox"
- preference="pref-launchNonNativeFiles"
- onsyncfrompreference="return !document.getElementById(this.getAttribute('preference')).value"
- onsynctopreference="return !this.checked"
- insertbefore="automaticSnapshots-checkbox"/>
- <checkbox label="&zotero.preferences.parseRISRefer;"
- preference="pref-parseEndNoteMIMETypes"
- insertbefore="automaticSnapshots-checkbox"/>
- </groupbox>
- </prefpane>
-
- <prefpane id="zotero-prefpane-export"
- label="&zotero.preferences.prefpane.export;"
- image="chrome://zotero/skin/prefs-export.png"
- helpTopic="export">
- <groupbox id="zotero-prefpane-export-groupbox">
- <vbox id="zotero-prefpane-export-siteSettings">
- <separator/>
-
- <label value="&zotero.preferences.quickCopy.siteEditor.setings;" control="quickCopy-siteSettings"/>
- <tree flex="1" id="quickCopy-siteSettings" hidecolumnpicker="true" rows="6" seltype="single"
- ondblclick="showQuickCopySiteEditor(this.currentIndex)"
- onkeypress="if (event.keyCode == event.DOM_VK_DELETE) { deleteSelectedQuickCopySite(); }">
- <treecols>
- <treecol id="quickCopy-urlColumn" label="&zotero.preferences.quickCopy.siteEditor.domainPath;" flex="1"/>
- <treecol id="quickCopy-formatColumn" label="&zotero.preferences.quickCopy.siteEditor.outputFormat;" flex="2"/>
- <treecol id="quickCopy-copyAsHTML" label="HTML"/>
- </treecols>
- <treechildren id="quickCopy-siteSettings-rows"/>
- </tree>
- <separator class="thin"/>
- <hbox pack="end">
- <button label="-" onclick="deleteSelectedQuickCopySite()"/>
- <button label="+" onclick="showQuickCopySiteEditor()"/>
- </hbox>
- </vbox>
- </groupbox>
- </prefpane>
-
<prefpane id="zotero-prefpane-proxies"
label="&zotero.preferences.prefpane.proxies;"
image="chrome://zotero/skin/prefs-proxies.png" position="6"
@@ -130,7 +42,7 @@ To add a new preference:
&zotero.preferences.proxies.desc_after_link;
</description>
- <command id="zotero-proxies-update" oncommand="updateProxyPrefs()"/>
+ <command id="zotero-proxies-update" oncommand="Zotero_Preferences.Proxies.updateProxyPrefs()"/>
<checkbox id="zotero-proxies-transparent" label="&zotero.preferences.proxies.transparent;"
command="zotero-proxies-update"/>
<vbox style="margin-left: 1em">
@@ -139,7 +51,7 @@ To add a new preference:
<hbox>
<checkbox id="zotero-proxies-disableByDomain-checkbox" label="&zotero.preferences.proxies.disableByDomain;"
command="zotero-proxies-update"/>
- <textbox id="zotero-proxies-disableByDomain-textbox" onchange="updateProxyPrefs()"/>
+ <textbox id="zotero-proxies-disableByDomain-textbox" onchange="Zotero_Preferences.Proxies.updateProxyPrefs()"/>
</hbox>
</vbox>
@@ -147,8 +59,8 @@ To add a new preference:
<caption label="&zotero.preferences.proxies.configured;"/>
<tree id="proxyTree" hidecolumnpicker="true" rows="6" seltype="single"
- ondblclick="showProxyEditor(this.currentIndex)" onselect="document.getElementById('proxyTree-delete').disabled = undefined"
- onkeypress="if (event.keyCode == event.DOM_VK_DELETE) { deleteProxy(); }">
+ ondblclick="Zotero_Preferences.Proxies.showProxyEditor(this.currentIndex)" onselect="document.getElementById('proxyTree-delete').disabled = undefined"
+ onkeypress="if (event.keyCode == event.DOM_VK_DELETE) { Zotero_Preferences.Proxies.deleteProxy(); }">
<treecols>
<treecol id="proxyTree-hostname" label="&zotero.preferences.proxies.hostname;" flex="1"/>
<treecol id="proxyTree-scheme" label="&zotero.preferences.proxies.scheme;" flex="3"/>
@@ -157,35 +69,14 @@ To add a new preference:
</tree>
<separator class="thin"/>
<hbox pack="end">
- <button disabled="true" id="proxyTree-delete" label="-" onclick="deleteProxy()"/>
- <button label="+" id="proxyTree-add" onclick="showProxyEditor()"/>
+ <button disabled="true" id="proxyTree-delete" label="-" onclick="Zotero_Preferences.Proxies.deleteProxy()"/>
+ <button label="+" id="proxyTree-add" onclick="Zotero_Preferences.Proxies.showProxyEditor()"/>
</hbox>
</groupbox>
<separator/>
</prefpane>
- <prefpane id="zotero-prefpane-advanced">
- <preferences id="zotero-prefpane-general-preferences">
- <preference id="pref-zoteroDotOrgVersionHeader"
- name="extensions.zotero.zoteroDotOrgVersionHeader"
- type="bool"/>
- </preferences>
-
- <tabbox id="zotero-prefpane-advanced-tabs">
- <tabpanels id="zotero-prefpane-advanced-tabpanels">
- <tabpanel id="zotero-prefpane-advanced-general-tab">
- <groupbox id="zotero-prefpane-advanced-miscellaneous">
- <checkbox label="&zotero.preferences.zoteroDotOrgVersionHeader;"
- tooltiptext="&zotero.preferences.zoteroDotOrgVersionHeader.tooltip;"
- preference="pref-zoteroDotOrgVersionHeader"
- insertbefore="zotero-prefpane-advanced-openbuttons"/>
- <separator class="thin"
- insertbefore="zotero-prefpane-advanced-openbuttons"/>
- </groupbox>
- </tabpanel>
- </tabpanels>
- </tabbox>
- </prefpane>
+ <script src="preferences_proxies.js" type="application/javascript;version=1.8"/>
</prefwindow>
</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_general.js b/chrome/content/zotero/preferences/preferences_general.js
@@ -0,0 +1,76 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+*/
+
+"use strict";
+
+Zotero_Preferences.General = {
+ init: function () {
+ // JS-based strings
+ var checkbox = document.getElementById('launchNonNativeFiles-checkbox');
+ if (checkbox) {
+ checkbox.label = Zotero.getString(
+ 'zotero.preferences.launchNonNativeFiles', Zotero.appName
+ );
+ }
+ },
+
+ /**
+ * Sets "Status bar icon" to "None" if Zotero is set to load in separate tab
+ */
+ handleShowInPreferenceChange: function () {
+ var showInSeparateTab = document.getElementById("zotero-prefpane-general-showIn-separateTab");
+ var showInAppTab = document.getElementById("zotero-prefpane-general-showIn-appTab");
+ if(showInAppTab.selected) {
+ document.getElementById('statusBarIcon').selectedItem = document.getElementById('statusBarIcon-none');
+ Zotero.Prefs.set("statusBarIcon", 0);
+ } else {
+ document.getElementById('statusBarIcon').selectedItem = document.getElementById('statusBarIcon-full');
+ Zotero.Prefs.set("statusBarIcon", 2);
+ }
+ },
+
+
+ updateTranslators: function () {
+ Zotero.Schema.updateFromRepository(true, function (xmlhttp, updated) {
+ var button = document.getElementById('updateButton');
+ if (button) {
+ if (updated===-1) {
+ var label = Zotero.getString('zotero.preferences.update.upToDate');
+ }
+ else if (updated) {
+ var label = Zotero.getString('zotero.preferences.update.updated');
+ }
+ else {
+ var label = Zotero.getString('zotero.preferences.update.error');
+ }
+ button.setAttribute('label', label);
+
+ if (updated && Zotero_Preferences.Cite) {
+ Zotero_Preferences.Cite.refreshStylesList();
+ }
+ }
+ });
+ }
+}
diff --git a/chrome/content/zotero/preferences/preferences_general.xul b/chrome/content/zotero/preferences/preferences_general.xul
@@ -0,0 +1,137 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <prefpane id="zotero-prefpane-general"
+ onpaneload="Zotero_Preferences.General.init()"
+ helpTopic="general">
+
+ <preferences id="zotero-prefpane-general-preferences">
+ <preference id="pref-fontSize" name="extensions.zotero.fontSize" type="string"/>
+ <preference id="pref-noteFontSize" name="extensions.zotero.note.fontSize" type="string"/>
+ <preference id="pref-automaticScraperUpdates" name="extensions.zotero.automaticScraperUpdates" type="bool"/>
+ <preference id="pref-reportTranslationFailure" name="extensions.zotero.reportTranslationFailure" type="bool"/>
+ <preference id="pref-automaticSnapshots" name="extensions.zotero.automaticSnapshots" type="bool"/>
+ <preference id="pref-downloadAssociatedFiles" name="extensions.zotero.downloadAssociatedFiles" type="bool"/>
+ <preference id="pref-automaticTags" name="extensions.zotero.automaticTags" type="bool"/>
+ <preference id="pref-trashAutoEmptyDays" name="extensions.zotero.trashAutoEmptyDays" type="int"/>
+
+ <preference id="pref-groups-copyChildNotes" name="extensions.zotero.groups.copyChildNotes" type="bool"/>
+ <preference id="pref-groups-copyChildFileAttachments" name="extensions.zotero.groups.copyChildFileAttachments" type="bool"/>
+ <preference id="pref-groups-copyChildLinks" name="extensions.zotero.groups.copyChildLinks" type="bool"/>
+ <preference id="pref-groups-copyTags" name="extensions.zotero.groups.copyTags" type="bool"/>
+ </preferences>
+
+ <groupbox id="zotero-prefpane-general-groupbox">
+ <caption label="&zotero.preferences.userInterface;"/>
+
+ <grid id="zotero-prefpane-general-grid">
+ <columns>
+ <column/>
+ <column flex="1"/>
+ </columns>
+
+ <rows id="zotero-prefpane-general-rows">
+ <row>
+ <hbox align="center">
+ <label value="&zotero.preferences.fontSize;" control="fontSize"/>
+ </hbox>
+ <radiogroup id="fontSize" orient="horizontal" align="center" preference="pref-fontSize">
+ <radio id="fontSize1" label="&zotero.preferences.fontSize.small;" value="1.0"/>
+ <radio id="fontSize2" label="&zotero.preferences.fontSize.medium;" value="1.15"/>
+ <radio id="fontSize3" label="&zotero.preferences.fontSize.large;" value="1.3"/>
+ <radio id="fontSize4" label="&zotero.preferences.fontSize.xlarge;" value="1.5"/>
+ </radiogroup>
+ </row>
+
+ <row>
+ <hbox align="center">
+ <label value="&zotero.preferences.fontSize.notes;" control="noteFontSize"/>
+ </hbox>
+ <hbox>
+ <menulist id="noteFontSize" preference="pref-noteFontSize" editable="true">
+ <menupopup>
+ <menuitem label="11"/>
+ <menuitem label="12"/>
+ <menuitem label="13"/>
+ <menuitem label="14"/>
+ <menuitem label="18"/>
+ <menuitem label="24"/>
+ <menuitem label="36"/>
+ <menuitem label="48"/>
+ <menuitem label="64"/>
+ <menuitem label="72"/>
+ <menuitem label="96"/>
+ </menupopup>
+ </menulist>
+ </hbox>
+ </row>
+ </rows>
+ </grid>
+
+ <label class="statusLine" value="&zotero.preferences.keys.changesTakeEffect;"/>
+ </groupbox>
+
+ <groupbox id="zotero-prefpane-miscellaneous-groupbox">
+ <caption label="&zotero.preferences.miscellaneous;"/>
+
+ <hbox align="center">
+ <checkbox label="&zotero.preferences.autoUpdate;" preference="pref-automaticScraperUpdates"/>
+ <button id="updateButton" style="margin-top:0" label="&zotero.preferences.updateNow;"
+ oncommand="Zotero_Preferences.General.updateTranslators()"/>
+ </hbox>
+
+ <checkbox label="&zotero.preferences.reportTranslationFailure;" preference="pref-reportTranslationFailure"/>
+ <checkbox id="automaticSnapshots-checkbox"
+ label="&zotero.preferences.automaticSnapshots;"
+ preference="pref-automaticSnapshots"/>
+ <checkbox label="&zotero.preferences.downloadAssociatedFiles;" preference="pref-downloadAssociatedFiles"/>
+ <checkbox label="&zotero.preferences.automaticTags;" preference="pref-automaticTags"/>
+ <hbox align="center">
+ <label value="&zotero.preferences.trashAutoEmptyDaysPre;"/>
+ <textbox size="2" preference="pref-trashAutoEmptyDays"/>
+ <label value="&zotero.preferences.trashAutoEmptyDaysPost;"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox>
+ <caption label="&zotero.preferences.groups;"/>
+
+ <label value="&zotero.preferences.groups.whenCopyingInclude;"/>
+ <vbox style="margin-left: 2em">
+ <checkbox label="&zotero.preferences.groups.childNotes;" preference="pref-groups-copyChildNotes"/>
+ <checkbox label="&zotero.preferences.groups.childFiles;" preference="pref-groups-copyChildFileAttachments"/>
+ <checkbox label="&zotero.preferences.groups.childLinks;" preference="pref-groups-copyChildLinks"/>
+ <checkbox label="&zotero.preferences.groups.tags;" preference="pref-groups-copyTags"/>
+ </vbox>
+ </groupbox>
+
+ <separator/>
+ </prefpane>
+
+ <script src="preferences_general.js" type="application/javascript;version=1.8"/>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_general_firefox.xul b/chrome/content/zotero/preferences/preferences_general_firefox.xul
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <prefpane id="zotero-prefpane-general">
+ <preferences id="zotero-prefpane-general-preferences">
+ <preference id="pref-showIn" name="extensions.zotero.showIn" type="int"/>
+ <preference id="pref-statusBarIcon" name="extensions.zotero.statusBarIcon" type="int"/>
+ <preference id="pref-launchNonNativeFiles" name="extensions.zotero.launchNonNativeFiles" type="bool"/>
+ <preference id="pref-parseEndNoteMIMETypes"
+ name="extensions.zotero.parseEndNoteMIMETypes"
+ type="bool" onchange="Zotero.MIMETypeHandler.init()"/>
+ </preferences>
+ <groupbox id="zotero-prefpane-general-groupbox">
+ <grid id="zotero-prefpane-general-grid">
+ <rows id="zotero-prefpane-general-rows">
+ <row position="1">
+ <hbox align="center">
+ <label value="&zotero.preferences.showIn;" control="showAs"/>
+ </hbox>
+ <radiogroup id="showIn" orient="horizontal" preference="pref-showIn" oncommand="Zotero_Preferences.General.handleShowInPreferenceChange()">
+ <radio id="zotero-prefpane-general-showIn-browserPane" label="&zotero.preferences.showIn.browserPane;" value="1"/>
+ <radio id="zotero-prefpane-general-showIn-separateTab" label="&zotero.preferences.showIn.separateTab;" value="2"/>
+ <radio id="zotero-prefpane-general-showIn-appTab" label="&zotero.preferences.showIn.appTab;" value="3"/>
+ </radiogroup>
+ </row>
+ <row position="2" id="zotero-prefpane-general-statusBarIcon-row">
+ <hbox align="center">
+ <label id="statusBarIcon-label" value="&zotero.preferences.statusBarIcon;" control="statusBarIcon"/>
+ </hbox>
+ <radiogroup id="statusBarIcon" orient="horizontal" preference="pref-statusBarIcon">
+ <radio id="statusBarIcon-full" src="chrome://zotero/skin/zotero_status_bar.png" value="2"/>
+ <radio id="statusBarIcon-compact" src="chrome://zotero/skin/zotero_status_bar_compact.png" value="1"/>
+ <radio id="statusBarIcon-none" label="&zotero.preferences.statusBarIcon.none;" value="0"/>
+ </radiogroup>
+ </row>
+ </rows>
+ </grid>
+ </groupbox>
+ <groupbox id="zotero-prefpane-miscellaneous-groupbox">
+ <checkbox id="launchNonNativeFiles-checkbox"
+ preference="pref-launchNonNativeFiles"
+ onsyncfrompreference="return !document.getElementById(this.getAttribute('preference')).value"
+ onsynctopreference="return !this.checked"
+ insertbefore="automaticSnapshots-checkbox"/>
+ <checkbox label="&zotero.preferences.parseRISRefer;"
+ preference="pref-parseEndNoteMIMETypes"
+ insertbefore="automaticSnapshots-checkbox"/>
+ </groupbox>
+ </prefpane>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_keys.js b/chrome/content/zotero/preferences/preferences_keys.js
@@ -0,0 +1,36 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+*/
+
+"use strict";
+
+Zotero_Preferences.Keys = {
+ init: function () {
+ // Display the appropriate modifier keys for the platform
+ var rows = document.getElementById('zotero-prefpane-keys').getElementsByTagName('row');
+ for (var i=0; i<rows.length; i++) {
+ rows[i].firstChild.nextSibling.value = Zotero.isMac ? 'Cmd+Shift+' : 'Ctrl+Alt+';
+ }
+ }
+};
diff --git a/chrome/content/zotero/preferences/preferences_keys.xul b/chrome/content/zotero/preferences/preferences_keys.xul
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <prefpane id="zotero-prefpane-keys"
+ onpaneload="Zotero_Preferences.Keys.init()"
+ helpTopic="shortcut_keys">
+ <preferences>
+ <preference id="pref-keys-openZotero" name="extensions.zotero.keys.openZotero" type="string"/>
+ <preference id="pref-keys-toggleFullscreen" name="extensions.zotero.keys.toggleFullscreen" type="string"/>
+ <preference id="pref-keys-library" name="extensions.zotero.keys.library" type="string"/>
+ <preference id="pref-keys-quicksearch" name="extensions.zotero.keys.quicksearch" type="string"/>
+ <preference id="pref-keys-newItem" name="extensions.zotero.keys.newItem" type="string"/>
+ <preference id="pref-keys-newNote" name="extensions.zotero.keys.newNote" type="string"/>
+ <preference id="pref-keys-toggleTagSelector" name="extensions.zotero.keys.toggleTagSelector" type="string"/>
+ <preference id="pref-keys-copySelectedItemCitationsToClipboard" name="extensions.zotero.keys.copySelectedItemCitationsToClipboard" type="string"/>
+ <preference id="pref-keys-copySelectedItemsToClipboard" name="extensions.zotero.keys.copySelectedItemsToClipboard" type="string"/>
+ <preference id="pref-keys-importFromClipboard" name="extensions.zotero.keys.importFromClipboard" type="string"/>
+ </preferences>
+
+ <grid>
+ <columns>
+ <column flex="1"/>
+ <column/>
+ <column/>
+ </columns>
+
+ <rows>
+ <row>
+ <label value="&zotero.preferences.keys.openZotero;" control="key-textbox-openZotero"/>
+ <label/>
+ <textbox id="textbox-openZotero" maxlength="1" size="1" preference="pref-keys-openZotero"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.toggleFullscreen;" control="textbox-toggleFullscreen"/>
+ <label/>
+ <textbox id="textbox-toggleFullscreen" maxlength="1" size="1" preference="pref-keys-toggleFullscreen"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.focusLibrariesPane;" control="textbox-library"/>
+ <label/>
+ <textbox id="textbox-library" maxlength="1" size="1" preference="pref-keys-library"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.quicksearch;" control="textbox-quicksearch"/>
+ <label/>
+ <textbox id="textbox-quicksearch" maxlength="1" size="1" preference="pref-keys-quicksearch"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.newItem;" control="textbox-newItem"/>
+ <label/>
+ <textbox id="textbox-newItem" maxlength="1" size="1" preference="pref-keys-newItem"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.newNote;" control="textbox-newNote"/>
+ <label/>
+ <textbox id="textbox-newNote" maxlength="1" size="1" preference="pref-keys-newNote"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.toggleTagSelector;" control="textbox-toggleTagSelector"/>
+ <label/>
+ <textbox id="textbox-toggleTagSelector" maxlength="1" size="1" preference="pref-keys-toggleTagSelector"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.copySelectedItemCitationsToClipboard;" control="textbox-copySelectedItemCitationsToClipboard"/>
+ <label/>
+ <textbox id="textbox-copySelectedItemCitationsToClipboard" maxlength="1" size="1"
+ preference="pref-keys-copySelectedItemCitationsToClipboard"
+ onchange="if (Zotero_Preferences.Export) { Zotero_Preferences.Export.updateQuickCopyInstructions(); }"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.copySelectedItemsToClipboard;" control="textbox-copySelectedItemsToClipboard"/>
+ <label/>
+ <textbox id="textbox-copySelectedItemsToClipboard" maxlength="1" size="1"
+ preference="pref-keys-copySelectedItemsToClipboard"
+ onchange="if (Zotero_Preferences.Export) { Zotero_Preferences.Export.updateQuickCopyInstructions(); }"/>
+ </row>
+
+ <row>
+ <label value="&zotero.preferences.keys.importFromClipboard;" control="textbox-importFromClipboard"/>
+ <label/>
+ <textbox id="textbox-importFromClipboard" maxlength="1" size="1" preference="pref-keys-importFromClipboard"/>
+ </row>
+ </rows>
+ </grid>
+
+ <label class="statusLine" value="&zotero.preferences.keys.changesTakeEffect;"/>
+
+ <separator/>
+ </prefpane>
+
+ <script src="preferences_keys.js" type="application/javascript;version=1.8"/>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_proxies.js b/chrome/content/zotero/preferences/preferences_proxies.js
@@ -0,0 +1,147 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+*/
+
+"use strict";
+
+Zotero_Preferences.Proxies = {
+ _proxies: null,
+
+
+ init: function () {
+ this.refreshProxyList();
+ },
+
+ /**
+ * Updates proxy autoRecognize and transparent settings based on checkboxes
+ */
+ updateProxyPrefs: function () {
+ var transparent = document.getElementById('zotero-proxies-transparent').checked;
+ Zotero.Prefs.set("proxies.transparent", transparent);
+ Zotero.Prefs.set("proxies.autoRecognize", document.getElementById('zotero-proxies-autoRecognize').checked);
+ Zotero.Prefs.set("proxies.disableByDomainString", document.getElementById('zotero-proxies-disableByDomain-textbox').value);
+ Zotero.Prefs.set("proxies.disableByDomain", document.getElementById('zotero-proxies-disableByDomain-checkbox').checked &&
+ document.getElementById('zotero-proxies-disableByDomain-textbox').value != "");
+
+ Zotero.Proxies.init();
+
+ document.getElementById('proxyTree-add').disabled =
+ document.getElementById('proxyTree-delete').disabled =
+ document.getElementById('proxyTree').disabled =
+ document.getElementById('zotero-proxies-autoRecognize').disabled =
+ document.getElementById('zotero-proxies-disableByDomain-checkbox').disabled =
+ document.getElementById('zotero-proxies-disableByDomain-textbox').disabled = !transparent;
+ },
+
+
+ /**
+ * Adds a proxy to the proxy pane
+ */
+ showProxyEditor: function (index) {
+ if(index == -1) return;
+ window.openDialog('chrome://zotero/content/preferences/proxyEditor.xul',
+ "zotero-preferences-proxyEditor", "chrome, modal", index !== undefined ? this._proxies[index] : null);
+ this.refreshProxyList();
+ },
+
+
+ /**
+ * Deletes the currently selected proxy
+ */
+ deleteProxy: function () {
+ if(document.getElementById('proxyTree').currentIndex == -1) return;
+ this._proxies[document.getElementById('proxyTree').currentIndex].erase();
+ this.refreshProxyList();
+ document.getElementById('proxyTree-delete').disabled = true;
+ },
+
+
+ /**
+ * Refreshes the proxy pane
+ */
+ refreshProxyList: function () {
+ if(!document.getElementById("zotero-prefpane-proxies")) return;
+
+ // get and sort proxies
+ this._proxies = Zotero.Proxies.proxies.slice();
+ for(var i=0; i<this._proxies.length; i++) {
+ if(!this._proxies[i].proxyID) {
+ this._proxies.splice(i, 1);
+ i--;
+ }
+ }
+ this._proxies = this._proxies.sort(function(a, b) {
+ if(a.multiHost) {
+ if(b.multiHost) {
+ if(a.hosts[0] < b.hosts[0]) {
+ return -1;
+ } else {
+ return 1;
+ }
+ } else {
+ return -1;
+ }
+ } else if(b.multiHost) {
+ return 1;
+ }
+
+ if(a.scheme < b.scheme) {
+ return -1;
+ } else if(b.scheme > a.scheme) {
+ return 1;
+ }
+
+ return 0;
+ });
+
+ // erase old children
+ var treechildren = document.getElementById('proxyTree-rows');
+ while (treechildren.hasChildNodes()) {
+ treechildren.removeChild(treechildren.firstChild);
+ }
+
+ // add proxies to list
+ for (var i=0; i<this._proxies.length; i++) {
+ var treeitem = document.createElement('treeitem');
+ var treerow = document.createElement('treerow');
+ var hostnameCell = document.createElement('treecell');
+ var schemeCell = document.createElement('treecell');
+
+ hostnameCell.setAttribute('label', this._proxies[i].multiHost ? Zotero.getString("proxies.multiSite") : this._proxies[i].hosts[0]);
+ schemeCell.setAttribute('label', this._proxies[i].scheme);
+
+ treerow.appendChild(hostnameCell);
+ treerow.appendChild(schemeCell);
+ treeitem.appendChild(treerow);
+ treechildren.appendChild(treeitem);
+ }
+
+ document.getElementById('proxyTree').currentIndex = -1;
+ document.getElementById('proxyTree-delete').disabled = true;
+ document.getElementById('zotero-proxies-transparent').checked = Zotero.Prefs.get("proxies.transparent");
+ document.getElementById('zotero-proxies-autoRecognize').checked = Zotero.Prefs.get("proxies.autoRecognize");
+ document.getElementById('zotero-proxies-disableByDomain-checkbox').checked = Zotero.Prefs.get("proxies.disableByDomain");
+ document.getElementById('zotero-proxies-disableByDomain-textbox').value = Zotero.Prefs.get("proxies.disableByDomainString");
+ }
+};
diff --git a/chrome/content/zotero/preferences/preferences_search.js b/chrome/content/zotero/preferences/preferences_search.js
@@ -0,0 +1,483 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+*/
+
+"use strict";
+
+Zotero_Preferences.Search = {
+ init: function () {
+ document.getElementById('fulltext-rebuildIndex').setAttribute('label',
+ Zotero.getString('zotero.preferences.search.rebuildIndex'));
+ document.getElementById('fulltext-clearIndex').setAttribute('label',
+ Zotero.getString('zotero.preferences.search.clearIndex'));
+ this.updatePDFToolsStatus();
+
+ this.updateIndexStats();
+ },
+
+ /*
+ * Update window according to installation status for PDF tools
+ * (e.g. status line, install/update button, etc.)
+ */
+ updatePDFToolsStatus: function () {
+ var converterIsRegistered = Zotero.Fulltext.pdfConverterIsRegistered();
+ var infoIsRegistered = Zotero.Fulltext.pdfInfoIsRegistered();
+
+ var converterStatusLabel = document.getElementById('pdfconverter-status');
+ var infoStatusLabel = document.getElementById('pdfinfo-status');
+ var requiredLabel = document.getElementById('pdftools-required');
+ var updateButton = document.getElementById('pdftools-update-button');
+ var documentationLink = document.getElementById('pdftools-documentation-link');
+ var settingsBox = document.getElementById('pdftools-settings');
+
+ // If we haven't already generated the required and documentation messages
+ if (!converterIsRegistered && !requiredLabel.hasChildNodes()) {
+
+ // Xpdf link
+ var str = Zotero.getString('zotero.preferences.search.pdf.toolsRequired',
+ [Zotero.Fulltext.pdfConverterName, Zotero.Fulltext.pdfInfoName,
+ '<a href="' + Zotero.Fulltext.pdfToolsURL + '">'
+ + Zotero.Fulltext.pdfToolsName + '</a>']);
+ var parts = Zotero.Utilities.parseMarkup(str);
+ for (var i=0; i<parts.length; i++) {
+ var part = parts[i];
+ if (part.type == 'text') {
+ var elem = document.createTextNode(part.text);
+ }
+ else if (part.type == 'link') {
+ var elem = document.createElement('label');
+ elem.setAttribute('value', part.text);
+ elem.setAttribute('class', 'zotero-text-link');
+ for (var key in part.attributes) {
+ elem.setAttribute(key, part.attributes[key]);
+
+ if (key == 'href') {
+ elem.setAttribute('tooltiptext', part.attributes[key]);
+ }
+ }
+ }
+ requiredLabel.appendChild(elem);
+ }
+
+ requiredLabel.appendChild(document.createTextNode(' '
+ + Zotero.getString('zotero.preferences.search.pdf.automaticInstall')));
+
+ // Documentation link
+ var link = '<a href="http://www.zotero.org/documentation/pdf_fulltext_indexing">'
+ + Zotero.getString('zotero.preferences.search.pdf.documentationLink')
+ + '</a>';
+ var str = Zotero.getString('zotero.preferences.search.pdf.advancedUsers', link);
+ var parts = Zotero.Utilities.parseMarkup(str);
+
+ for (var i=0; i<parts.length; i++) {
+ var part = parts[i];
+ if (part.type == 'text') {
+ var elem = document.createTextNode(part.text);
+ }
+ else if (part.type == 'link') {
+ var elem = document.createElement('label');
+ elem.setAttribute('value', part.text);
+ elem.setAttribute('class', 'zotero-text-link');
+ for (var key in part.attributes) {
+ elem.setAttribute(key, part.attributes[key]);
+
+ if (key == 'href') {
+ elem.setAttribute('tooltiptext', part.attributes[key]);
+ }
+ }
+ }
+ documentationLink.appendChild(elem);
+ }
+ }
+
+ // converter status line
+ var prefix = 'zotero.preferences.search.pdf.tool';
+ if (converterIsRegistered) {
+ var version = Zotero.Fulltext.pdfConverterVersion;
+ str = Zotero.getString(prefix + 'Registered',
+ Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform',
+ [Zotero.Fulltext.pdfConverterName, version]));
+ }
+ else {
+ str = Zotero.getString(prefix + 'NotRegistered',
+ [Zotero.Fulltext.pdfConverterFileName]);
+ }
+ converterStatusLabel.setAttribute('value', str);
+
+ // pdfinfo status line
+ if (infoIsRegistered) {
+ var version = Zotero.Fulltext.pdfInfoVersion;
+ str = Zotero.getString(prefix + 'Registered',
+ Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform',
+ [Zotero.Fulltext.pdfInfoName, version]));
+ }
+ else {
+ str = Zotero.getString(prefix + 'NotRegistered',
+ [Zotero.Fulltext.pdfInfoFileName]);
+ }
+ infoStatusLabel.setAttribute('value', str);
+
+ str = converterIsRegistered ?
+ Zotero.getString('general.checkForUpdate') :
+ Zotero.getString('zotero.preferences.search.pdf.checkForInstaller');
+ updateButton.setAttribute('label', str);
+
+ requiredLabel.setAttribute('hidden', converterIsRegistered);
+ documentationLink.setAttribute('hidden', converterIsRegistered);
+ settingsBox.setAttribute('hidden', !converterIsRegistered);
+ },
+
+
+ /*
+ * Check available versions of PDF tools from server and prompt for installation
+ * if a newer version is available
+ */
+ checkPDFToolsDownloadVersion: function () {
+ var url = Zotero.Fulltext.pdfToolsDownloadBaseURL
+ + Zotero.platform.replace(' ', '-') + '.latest';
+
+ // Find latest version for this platform
+ var self = this;
+ var sent = Zotero.HTTP.doGet(url, function (xmlhttp) {
+ try {
+ if (xmlhttp.status == 200) {
+ var converterIsRegistered = Zotero.Fulltext.pdfConverterIsRegistered();
+ var infoIsRegistered = Zotero.Fulltext.pdfInfoIsRegistered();
+ var bothRegistered = converterIsRegistered && infoIsRegistered;
+
+ var converterVersion = xmlhttp.responseText.split(/\s/)[0];
+ var infoVersion = xmlhttp.responseText.split(/\s/)[1];
+
+ var converterVersionAvailable = converterVersion &&
+ (!converterIsRegistered ||
+ Zotero.Fulltext.pdfConverterVersion == 'UNKNOWN' ||
+ converterVersion > Zotero.Fulltext.pdfConverterVersion);
+ var infoVersionAvailable = infoVersion &&
+ (!infoIsRegistered ||
+ Zotero.Fulltext.pdfInfoVersion == 'UNKNOWN' ||
+ infoVersion > Zotero.Fulltext.pdfInfoVersion);
+ var bothAvailable = converterVersionAvailable && infoVersionAvailable;
+
+ /*
+ Zotero.debug(converterIsRegistered);
+ Zotero.debug(infoIsRegistered);
+ Zotero.debug(converterVersion);
+ Zotero.debug(infoVersion);
+ Zotero.debug(Zotero.Fulltext.pdfConverterVersion);
+ Zotero.debug(Zotero.Fulltext.pdfInfoVersion);
+ Zotero.debug(converterVersionAvailable);
+ Zotero.debug(infoVersionAvailable);
+ */
+
+ // Up to date -- disable update button
+ if (!converterVersionAvailable && !infoVersionAvailable) {
+ var button = document.getElementById('pdftools-update-button');
+ button.setAttribute('label', Zotero.getString('zotero.preferences.update.upToDate'));
+ button.setAttribute('disabled', true);
+ }
+ // New version available -- display update prompt
+ else {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
+ createInstance(Components.interfaces.nsIPromptService);
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
+
+ var msg = Zotero.getString('zotero.preferences.search.pdf.available'
+ + ((converterIsRegistered || infoIsRegistered) ? 'Updates' : 'Downloads'),
+ [Zotero.platform, 'zotero.org']) + '\n\n';
+
+ if (converterVersionAvailable) {
+ tvp = Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform',
+ [Zotero.Fulltext.pdfConverterName, converterVersion]);
+ msg += '- ' + tvp + '\n';
+ }
+ if (infoVersionAvailable) {
+ tvp = Zotero.getString('zotero.preferences.search.pdf.toolVersionPlatform',
+ [Zotero.Fulltext.pdfInfoName, infoVersion]);
+ msg += '- ' + tvp + '\n';
+ }
+ msg += '\n';
+ msg += Zotero.getString('zotero.preferences.search.pdf.zoteroCanInstallVersion'
+ + (bothAvailable ? 's' : ''));
+
+ var index = ps.confirmEx(null,
+ converterIsRegistered ?
+ Zotero.getString('general.updateAvailable') : '',
+ msg,
+ buttonFlags,
+ converterIsRegistered ?
+ Zotero.getString('general.upgrade') :
+ Zotero.getString('general.install'),
+ null, null, null, {});
+
+ if (index == 0) {
+ var installVersions = {
+ converter: converterVersionAvailable ?
+ converterVersion : null,
+ info: infoVersionAvailable ?
+ infoVersion : null
+ };
+ self.installPDFTools(installVersions);
+ }
+ }
+ }
+ // Version not found for platform
+ else if (xmlhttp.status == 404) {
+ self.onPDFToolsDownloadError(404);
+ }
+ }
+ catch (e) {
+ self.onPDFToolsDownloadError(e);
+ }
+ });
+
+ // Browser is offline
+ if (!sent) {
+ this.onPDFToolsDownloadError();
+ }
+ },
+
+
+ /*
+ * Begin installation of specified PDF tools from server -- does a HEAD call to
+ * make sure file exists and then calls downloadPDFTool() if so
+ */
+ installPDFTools: function (installVersions) {
+ if (!installVersions) {
+ installVersions = {
+ converter: true,
+ info: true
+ };
+ }
+
+ // We install the converter first if it's available
+ var url = Zotero.Fulltext.pdfToolsDownloadBaseURL;
+ if (installVersions.converter) {
+ var tool = 'converter';
+ var version = installVersions.converter;
+ url += Zotero.Fulltext.pdfConverterFileName + '-' + installVersions.converter;
+ }
+ else if (installVersions.info) {
+ var tool = 'info';
+ var version = installVersions.info;
+ url += Zotero.Fulltext.pdfInfoFileName + '-' + installVersions.info;
+ }
+ else {
+ return;
+ }
+
+ // Find latest version for this platform
+ var self = this;
+ var sent = Zotero.HTTP.doHead(url, function (xmlhttp) {
+ try {
+ if (xmlhttp.status == 200) {
+ // If doing both and on converter, chain pdfinfo
+ if (installVersions.converter && installVersions.info) {
+ self.downloadPDFTool(tool, version, function () {
+ return self.installPDFTools({ info: installVersions.info });
+ });
+ }
+ else {
+ self.downloadPDFTool(tool, version);
+ }
+ }
+ // Version not found for platform
+ else if (xmlhttp.status == 404) {
+ self.onPDFToolsDownloadError(404);
+ }
+ }
+ catch (e) {
+ self.onPDFToolsDownloadError(e);
+ }
+ });
+
+ // Browser is offline
+ if (!sent) {
+ self.onPDFToolsDownloadError();
+ }
+ },
+
+
+ /*
+ * Download and install specified PDF tool
+ */
+ downloadPDFTool: function (tool, version, callback) {
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
+
+ if (tool == 'converter') {
+ var fileName = Zotero.Fulltext.pdfConverterFileName;
+ }
+ else {
+ var fileName = Zotero.Fulltext.pdfInfoFileName;
+ }
+
+
+ var url = Zotero.Fulltext.pdfToolsDownloadBaseURL + fileName + '-' + version;
+ var uri = ioService.newURI(url, null, null);
+
+ var file = Zotero.getZoteroDirectory();
+ file.append(fileName);
+ var fileURL = ioService.newFileURI(file);
+
+ const nsIWBP = Components.interfaces.nsIWebBrowserPersist;
+ var wbp = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(nsIWBP);
+
+ var self = this;
+ var progressListener = new Zotero.WebProgressFinishListener(function () {
+ // Set permissions to 755
+ if (Zotero.isMac) {
+ file.permissions = 33261;
+ }
+ else if (Zotero.isLinux) {
+ file.permissions = 493;
+ }
+
+ // Write the version number to a file
+ var versionFile = Zotero.getZoteroDirectory();
+ versionFile.append(fileName + '.version');
+ Zotero.File.putContents(versionFile, version + '');
+
+ Zotero.Fulltext.registerPDFTool(tool);
+
+ // Used to install info tool after converter
+ if (callback) {
+ callback();
+ }
+ // If done
+ else {
+ self.updatePDFToolsStatus();
+ }
+ });
+
+ /*
+ var tr = Components.classes["@mozilla.org/transfer;1"].
+ createInstance(Components.interfaces.nsITransfer);
+ tr.init(uri, fileURL, "", null, null, null, wbp);
+ */
+
+ document.getElementById('pdftools-update-button').disabled = true;
+ var str = Zotero.getString('zotero.preferences.search.pdf.downloading');
+ document.getElementById('pdftools-update-button').setAttribute('label', str);
+
+ wbp.progressListener = progressListener;
+ Zotero.debug("Saving " + uri.spec + " to " + fileURL.spec);
+ try {
+ wbp.saveURI(uri, null, null, null, null, fileURL);
+ } catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=794602
+ // XXX Always use when we no longer support Firefox < 18
+ wbp.saveURI(uri, null, null, null, null, fileURL, null);
+ }
+ },
+
+
+ onPDFToolsDownloadError: function (e) {
+ if (e == 404) {
+ var str = Zotero.getString('zotero.preferences.search.pdf.toolDownloadsNotAvailable',
+ Zotero.Fulltext.pdfToolsName) + ' '
+ + Zotero.getString('zotero.preferences.search.pdf.viewManualInstructions');
+ }
+ else if (e) {
+ Components.utils.reportError(e);
+ var str = Zotero.getString('zotero.preferences.search.pdf.toolsDownloadError', Zotero.Fulltext.pdfToolsName)
+ + ' ' + Zotero.getString('zotero.preferences.search.pdf.tryAgainOrViewManualInstructions');
+ }
+ else {
+ var info = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULAppInfo);
+ var browser = info.name; // Returns "Firefox" for Firefox
+ var str = Zotero.getString('general.browserIsOffline', browser);
+ }
+ alert(str);
+ },
+
+
+ updateIndexStats: function () {
+ var stats = Zotero.Fulltext.getIndexStats();
+ document.getElementById('fulltext-stats-indexed').
+ lastChild.setAttribute('value', stats.indexed);
+ document.getElementById('fulltext-stats-partial').
+ lastChild.setAttribute('value', stats.partial);
+ document.getElementById('fulltext-stats-unindexed').
+ lastChild.setAttribute('value', stats.unindexed);
+ document.getElementById('fulltext-stats-words').
+ lastChild.setAttribute('value', stats.words);
+ },
+
+
+ rebuildIndexPrompt: function () {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
+ createInstance(Components.interfaces.nsIPromptService);
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_CANCEL);
+
+ var index = ps.confirmEx(null,
+ Zotero.getString('zotero.preferences.search.rebuildIndex'),
+ Zotero.getString('zotero.preferences.search.rebuildWarning',
+ Zotero.getString('zotero.preferences.search.indexUnindexed')),
+ buttonFlags,
+ Zotero.getString('zotero.preferences.search.rebuildIndex'),
+ Zotero.getString('zotero.preferences.search.indexUnindexed'),
+ null, null, {});
+
+ if (index == 0) {
+ Zotero.Fulltext.rebuildIndex();
+ }
+ else if (index == 1) {
+ Zotero.Fulltext.rebuildIndex(true)
+ }
+
+ this.updateIndexStats();
+ },
+
+
+ clearIndexPrompt: function () {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
+ createInstance(Components.interfaces.nsIPromptService);
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_CANCEL);
+
+ var index = ps.confirmEx(null,
+ Zotero.getString('zotero.preferences.search.clearIndex'),
+ Zotero.getString('zotero.preferences.search.clearWarning',
+ Zotero.getString('zotero.preferences.search.clearNonLinkedURLs')),
+ buttonFlags,
+ Zotero.getString('zotero.preferences.search.clearIndex'),
+ Zotero.getString('zotero.preferences.search.clearNonLinkedURLs'),
+ null, null, {});
+
+ if (index == 0) {
+ Zotero.Fulltext.clearIndex();
+ }
+ else if (index == 1) {
+ Zotero.Fulltext.clearIndex(true);
+ }
+
+ this.updateIndexStats();
+ }
+};
diff --git a/chrome/content/zotero/preferences/preferences_search.xul b/chrome/content/zotero/preferences/preferences_search.xul
@@ -0,0 +1,118 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2006–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <prefpane id="zotero-prefpane-search"
+ onpaneload="Zotero_Preferences.Search.init()"
+ helpTopic="search">
+ <preferences>
+ <preference id="pref-fulltext-textMaxLength" name="extensions.zotero.fulltext.textMaxLength" type="int"/>
+ <preference id="pref-fulltext-pdfmaxpages" name="extensions.zotero.fulltext.pdfMaxPages" type="int"/>
+ </preferences>
+
+ <groupbox>
+ <caption label="&zotero.preferences.search.fulltextCache;"/>
+
+ <hbox>
+ <button id="fulltext-rebuildIndex" flex="1" oncommand="Zotero_Preferences.Search.rebuildIndexPrompt()"/>
+ <button id="fulltext-clearIndex" flex="1" oncommand="Zotero_Preferences.Search.clearIndexPrompt()"/>
+ </hbox>
+
+ <separator/>
+
+ <hbox align="center">
+ <label value="&zotero.preferences.fulltext.textMaxLength;"/>
+ <textbox size="10" preference="pref-fulltext-textMaxLength"/>
+ <label value="(&zotero.preferences.default; 500000)"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox id="pdftools-box">
+ <caption label="&zotero.preferences.search.pdfIndexing;"/>
+
+ <label id="pdfconverter-status"/>
+ <separator class="thin"/>
+ <label id="pdfinfo-status"/>
+
+ <separator class="thin"/>
+
+ <label id="pdftools-required" hidden="true"/>
+
+ <separator class="thin"/>
+
+ <hbox>
+ <button id="pdftools-update-button" flex="1" oncommand="Zotero_Preferences.Search.checkPDFToolsDownloadVersion()"/>
+ </hbox>
+
+ <separator class="thin"/>
+
+ <label id="pdftools-documentation-link" hidden="true"/>
+
+ <separator class="thin"/>
+
+ <hbox id="pdftools-settings" align="center" hidden="true">
+ <label value="&zotero.preferences.fulltext.pdfMaxPages;"/>
+ <textbox size="5" preference="pref-fulltext-pdfmaxpages"/>
+ <label value="(&zotero.preferences.default; 100)"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox id="fulltext-stats">
+ <caption label="&zotero.preferences.search.indexStats;"/>
+
+ <grid>
+ <columns>
+ <column/>
+ <column/>
+ </columns>
+
+ <rows>
+ <row id="fulltext-stats-indexed">
+ <label value="&zotero.preferences.search.indexStats.indexed;"/>
+ <label/>
+ </row>
+ <row id="fulltext-stats-partial">
+ <label value="&zotero.preferences.search.indexStats.partial;"/>
+ <label/>
+ </row>
+ <row id="fulltext-stats-unindexed">
+ <label value="&zotero.preferences.search.indexStats.unindexed;"/>
+ <label/>
+ </row>
+ <row id="fulltext-stats-words">
+ <label value="&zotero.preferences.search.indexStats.words;"/>
+ <label/>
+ </row>
+ </rows>
+ </grid>
+ </groupbox>
+
+ <separator/>
+ </prefpane>
+
+ <script src="preferences_search.js" type="application/javascript;version=1.8"/>
+</overlay>
diff --git a/chrome/content/zotero/preferences/preferences_sync.js b/chrome/content/zotero/preferences/preferences_sync.js
@@ -0,0 +1,435 @@
+/*
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2008–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+*/
+
+"use strict";
+
+Zotero_Preferences.Sync = {
+ init: function () {
+ this.updateStorageSettings(null, null, true);
+
+ document.getElementById('sync-password').value = Zotero.Sync.Server.password;
+ var pass = Zotero.Sync.Storage.WebDAV.password;
+ if (pass) {
+ document.getElementById('storage-password').value = pass;
+ }
+ },
+
+ updateStorageSettings: function (enabled, protocol, skipWarnings) {
+ if (enabled === null) {
+ enabled = document.getElementById('pref-storage-enabled').value;
+ }
+
+ var oldProtocol = document.getElementById('pref-storage-protocol').value;
+ if (protocol === null) {
+ protocol = oldProtocol;
+ }
+
+ var storageSettings = document.getElementById('storage-settings');
+ var protocolMenu = document.getElementById('storage-protocol');
+ var settings = document.getElementById('storage-webdav-settings');
+ var sep = document.getElementById('storage-separator');
+
+ if (!enabled || protocol == 'zotero') {
+ settings.hidden = true;
+ sep.hidden = false;
+ }
+ else {
+ settings.hidden = false;
+ sep.hidden = true;
+ }
+
+ var menulists = storageSettings.getElementsByTagName('menulist');
+ for each(var menulist in menulists) {
+ if (menulist.className == 'storage-personal') {
+ menulist.disabled = !enabled;
+ }
+ }
+
+ if (!skipWarnings) {
+ // WARN if going between
+ }
+
+ if (oldProtocol == 'zotero' && protocol == 'webdav') {
+ var sql = "SELECT COUNT(*) FROM version WHERE schema='storage_zfs'";
+ if (Zotero.DB.valueQuery(sql)) {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING)
+ + ps.BUTTON_DELAY_ENABLE;
+ var account = Zotero.Sync.Server.username;
+ var index = ps.confirmEx(
+ null,
+ Zotero.getString('zotero.preferences.sync.purgeStorage.title'),
+ Zotero.getString('zotero.preferences.sync.purgeStorage.desc'),
+ buttonFlags,
+ Zotero.getString('zotero.preferences.sync.purgeStorage.confirmButton'),
+ Zotero.getString('zotero.preferences.sync.purgeStorage.cancelButton'), null, null, {}
+ );
+
+ if (index == 0) {
+ var sql = "INSERT OR IGNORE INTO settings VALUES (?,?,?)";
+ Zotero.DB.query(sql, ['storage', 'zfsPurge', 'user']);
+
+ Zotero.Sync.Storage.ZFS.purgeDeletedStorageFiles(function (success) {
+ if (success) {
+ ps.alert(
+ null,
+ Zotero.getString("general.success"),
+ "Attachment files from your personal library have been removed from the Zotero servers."
+ );
+ }
+ else {
+ ps.alert(
+ null,
+ Zotero.getString("general.error"),
+ "An error occurred. Please try again later."
+ );
+ }
+ });
+ }
+ }
+ }
+
+ var self = this;
+ setTimeout(function () {
+ self.updateStorageTerms();
+ }, 1)
+ },
+
+
+ updateStorageSettingsGroups: function (enabled) {
+ var storageSettings = document.getElementById('storage-settings');
+ var menulists = storageSettings.getElementsByTagName('menulist');
+ for each(var menulist in menulists) {
+ if (menulist.className == 'storage-groups') {
+ menulist.disabled = !enabled;
+ }
+ }
+
+ var self = this;
+ setTimeout(function () {
+ self.updateStorageTerms();
+ }, 1)
+ },
+
+
+ updateStorageTerms: function () {
+ var terms = document.getElementById('storage-terms');
+
+ var libraryEnabled = document.getElementById('pref-storage-enabled').value;
+ var storageProtocol = document.getElementById('pref-storage-protocol').value;
+ var groupsEnabled = document.getElementById('pref-group-storage-enabled').value;
+
+ terms.hidden = !((libraryEnabled && storageProtocol == 'zotero') || groupsEnabled);
+ },
+
+
+ unverifyStorageServer: function () {
+ Zotero.Prefs.set('sync.storage.verified', false);
+ Zotero.Sync.Storage.resetAllSyncStates(null, true, false);
+ },
+
+
+ verifyStorageServer: function () {
+ Zotero.debug("Verifying storage");
+
+ var verifyButton = document.getElementById("storage-verify");
+ var abortButton = document.getElementById("storage-abort");
+ var progressMeter = document.getElementById("storage-progress");
+ var urlField = document.getElementById("storage-url");
+ var usernameField = document.getElementById("storage-username");
+ var passwordField = document.getElementById("storage-password");
+
+ verifyButton.hidden = true;
+ abortButton.hidden = false;
+ progressMeter.hidden = false;
+
+ var request = null;
+ var onDone = false;
+
+ Zotero.Sync.Storage.WebDAV.checkServer()
+ // Get the XMLHttpRequest for possible cancelling
+ .progress(function (obj) {
+ request = obj.xmlhttp;
+ })
+ .finally(function () {
+ verifyButton.hidden = false;
+ abortButton.hidden = true;
+ progressMeter.hidden = true;
+ })
+ .spread(function (uri, status) {
+ switch (status) {
+ case Zotero.Sync.Storage.ERROR_NO_URL:
+ onDone = function () {
+ urlField.focus();
+ };
+ break;
+
+ case Zotero.Sync.Storage.ERROR_NO_USERNAME:
+ onDone = function () {
+ usernameField.focus();
+ };
+ break;
+
+ case Zotero.Sync.Storage.ERROR_NO_PASSWORD:
+ case Zotero.Sync.Storage.ERROR_AUTH_FAILED:
+ onDone = function () {
+ passwordField.focus();
+ };
+ break;
+ }
+
+ return Zotero.Sync.Storage.WebDAV.checkServerCallback(uri, status, window);
+ })
+ .then(function (success) {
+ if (success) {
+ Zotero.debug("WebDAV verification succeeded");
+
+ var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+ promptService.alert(
+ window,
+ Zotero.getString('sync.storage.serverConfigurationVerified'),
+ Zotero.getString('sync.storage.fileSyncSetUp')
+ );
+ Zotero.Prefs.set("sync.storage.verified", true);
+ }
+ else {
+ Zotero.debug("WebDAV verification failed");
+ if (onDone) {
+ setTimeout(function () {
+ onDone();
+ }, 1);
+ }
+ }
+ })
+ .catch(function (e) {
+ Zotero.debug("WebDAV verification failed");
+ Zotero.debug(e, 1);
+ Components.utils.reportError(e);
+ Zotero.Utilities.Internal.errorPrompt(Zotero.getString('general.error'), e);
+
+ if (onDone) {
+ setTimeout(function () {
+ onDone();
+ }, 1);
+ }
+ })
+ .done();
+
+ abortButton.onclick = function () {
+ if (request) {
+ Zotero.debug("Cancelling verification request");
+ request.onreadystatechange = undefined;
+ request.abort();
+ verifyButton.hidden = false;
+ abortButton.hidden = true;
+ progressMeter.hidden = true;
+ }
+ }
+ },
+
+
+ handleSyncResetSelect: function (obj) {
+ var index = obj.selectedIndex;
+ var rows = obj.getElementsByTagName('row');
+
+ for (var i=0; i<rows.length; i++) {
+ if (i == index) {
+ rows[i].setAttribute('selected', 'true');
+ }
+ else {
+ rows[i].removeAttribute('selected');
+ }
+ }
+ },
+
+
+ handleSyncReset: function (action) {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ if (!Zotero.Sync.Server.enabled) {
+ ps.alert(
+ null,
+ Zotero.getString('general.error'),
+ Zotero.getString('zotero.preferences.sync.reset.userInfoMissing',
+ document.getElementById('zotero-prefpane-sync')
+ .getElementsByTagName('tab')[0].label)
+ );
+ return;
+ }
+
+ var account = Zotero.Sync.Server.username;
+
+ switch (action) {
+ case 'restore-from-server':
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ + ps.BUTTON_POS_1_DEFAULT;
+ var index = ps.confirmEx(
+ null,
+ Zotero.getString('general.warning'),
+ Zotero.getString('zotero.preferences.sync.reset.restoreFromServer', account),
+ buttonFlags,
+ Zotero.getString('zotero.preferences.sync.reset.replaceLocalData'),
+ null, null, null, {}
+ );
+
+ switch (index) {
+ case 0:
+ // TODO: better error handling
+
+ // Verify username and password
+ var callback = function () {
+ Zotero.Schema.stopRepositoryTimer();
+ Zotero.Sync.Runner.clearSyncTimeout();
+
+ Zotero.DB.skipBackup = true;
+
+ var file = Zotero.getZoteroDirectory();
+ file.append('restore-from-server');
+ Zotero.File.putContents(file, '');
+
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
+ var index = ps.confirmEx(
+ null,
+ Zotero.getString('general.restartRequired'),
+ Zotero.getString('zotero.preferences.sync.reset.restartToComplete'),
+ buttonFlags,
+ Zotero.getString('general.restartNow'),
+ null, null, null, {}
+ );
+
+ var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
+ .getService(Components.interfaces.nsIAppStartup);
+ appStartup.quit(Components.interfaces.nsIAppStartup.eRestart | Components.interfaces.nsIAppStartup.eAttemptQuit);
+ };
+
+ // TODO: better way of checking for an active session?
+ if (Zotero.Sync.Server.sessionIDComponent == 'sessionid=') {
+ Zotero.Sync.Server.login(callback);
+ }
+ else {
+ callback();
+ }
+ break;
+
+ // Cancel
+ case 1:
+ return;
+ }
+ break;
+
+ case 'restore-to-server':
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ + ps.BUTTON_POS_1_DEFAULT;
+ var index = ps.confirmEx(
+ null,
+ Zotero.getString('general.warning'),
+ Zotero.getString('zotero.preferences.sync.reset.restoreToServer', account),
+ buttonFlags,
+ Zotero.getString('zotero.preferences.sync.reset.replaceServerData'),
+ null, null, null, {}
+ );
+
+ switch (index) {
+ case 0:
+ // TODO: better error handling
+ Zotero.Sync.Server.clear(function () {
+ Zotero.Sync.Server.sync(/*{
+
+ // TODO: this doesn't work if the pref window is
+ closed. fix, perhaps by making original callbacks
+ available to the custom callbacks
+
+ onSuccess: function () {
+ Zotero.Sync.Runner.setSyncIcon();
+ ps.alert(
+ null,
+ "Restore Completed",
+ "Data on the Zotero server has been successfully restored."
+ );
+ },
+ onError: function (msg) {
+ // TODO: combine with error dialog for regular syncs
+ ps.alert(
+ null,
+ "Restore Failed",
+ "An error occurred uploading your data to the server.\n\n"
+ + "Click the sync error icon in the Zotero toolbar "
+ + "for further information."
+ );
+ Zotero.Sync.Runner.error(msg);
+ }
+ }*/);
+ });
+ break;
+
+ // Cancel
+ case 1:
+ return;
+ }
+
+ break;
+
+
+ case 'reset-storage-history':
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ + ps.BUTTON_POS_1_DEFAULT;
+ var index = ps.confirmEx(
+ null,
+ Zotero.getString('general.warning'),
+ Zotero.getString('zotero.preferences.sync.reset.fileSyncHistory'),
+ buttonFlags,
+ Zotero.getString('general.reset'),
+ null, null, null, {}
+ );
+
+ switch (index) {
+ case 0:
+ Zotero.Sync.Storage.resetAllSyncStates();
+ ps.alert(
+ null,
+ "File Sync History Cleared",
+ "The file sync history has been cleared."
+ );
+ break;
+
+ // Cancel
+ case 1:
+ return;
+ }
+
+ break;
+
+ default:
+ throw ("Invalid action '" + action + "' in handleSyncReset()");
+ }
+ }
+};
diff --git a/chrome/content/zotero/preferences/preferences_sync.xul b/chrome/content/zotero/preferences/preferences_sync.xul
@@ -0,0 +1,319 @@
+<?xml version="1.0"?>
+<!--
+ ***** BEGIN LICENSE BLOCK *****
+
+ Copyright © 2008–2013 Center for History and New Media
+ George Mason University, Fairfax, Virginia, USA
+ http://zotero.org
+
+ This file is part of Zotero.
+
+ Zotero is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Zotero is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Zotero. If not, see <http://www.gnu.org/licenses/>.
+
+ ***** END LICENSE BLOCK *****
+-->
+<!DOCTYPE prefwindow SYSTEM "chrome://zotero/locale/preferences.dtd">
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <prefpane id="zotero-prefpane-sync"
+ onpaneload="Zotero_Preferences.Sync.init()"
+ helpTopic="sync">
+ <preferences>
+ <preference id="pref-sync-autosync" name="extensions.zotero.sync.autoSync" type="bool"/>
+ <preference id="pref-sync-username" name="extensions.zotero.sync.server.username" type="string" instantApply="true"/>
+ <preference id="pref-storage-enabled" name="extensions.zotero.sync.storage.enabled" type="bool"/>
+ <preference id="pref-storage-protocol" name="extensions.zotero.sync.storage.protocol" type="string"
+ onchange="Zotero_Preferences.Sync.unverifyStorageServer()"/>
+ <preference id="pref-storage-scheme" name="extensions.zotero.sync.storage.scheme" type="string" instantApply="true"/>
+ <preference id="pref-storage-url" name="extensions.zotero.sync.storage.url" type="string"/>
+ <preference id="pref-storage-username" name="extensions.zotero.sync.storage.username" type="string"/>
+ <preference id="pref-storage-downloadMode-personal" name="extensions.zotero.sync.storage.downloadMode.personal" type="string"/>
+ <preference id="pref-storage-downloadMode-groups" name="extensions.zotero.sync.storage.downloadMode.groups" type="string"/>
+ <preference id="pref-group-storage-enabled" name="extensions.zotero.sync.storage.groups.enabled" type="bool"/>
+ </preferences>
+
+ <tabbox>
+ <tabs>
+ <tab label="&zotero.preferences.settings;"/>
+ <tab label="&zotero.preferences.sync.reset;"/>
+ </tabs>
+
+ <tabpanels>
+ <tabpanel orient="vertical">
+ <groupbox>
+ <caption label="&zotero.preferences.sync.syncServer;"/>
+
+ <hbox>
+ <grid>
+ <columns>
+ <column/>
+ <column/>
+ </columns>
+
+ <rows>
+ <row>
+ <label value="&zotero.preferences.sync.username;"/>
+ <textbox preference="pref-sync-username"
+ onchange="this.value = this.value.trim(); Zotero.Prefs.set('sync.server.username', this.value); var pass = document.getElementById('sync-password'); if (pass.value) { Zotero.Sync.Server.password = pass.value; }"/>
+ </row>
+ <row>
+ <label value="&zotero.preferences.sync.password;"/>
+ <textbox id="sync-password" type="password"
+ onchange="Zotero.Sync.Server.password = this.value"/>
+ </row>
+ <row>
+ <box/>
+ <checkbox label="&zotero.preferences.sync.syncAutomatically;" preference="pref-sync-autosync"/>
+ </row>
+ <!--
+ <row>
+ <box/>
+ <hbox>
+ <button label="Verify login"
+ oncommand="alert('Unimplemented')"/>
+ </hbox>
+ </row>
+ -->
+ </rows>
+ </grid>
+
+ <hbox style="width:2em"/>
+
+ <vbox>
+ <label class="zotero-text-link" value="&zotero.preferences.sync.about;" href="http://www.zotero.org/support/sync"/>
+ <separator class="thin"/>
+ <label class="zotero-text-link" value="&zotero.preferences.sync.createAccount;" href="http://zotero.org/user/register"/>
+ <separator class="thin"/>
+ <label class="zotero-text-link" value="&zotero.preferences.sync.lostPassword;" href="http://zotero.org/user/lostpassword"/>
+ </vbox>
+ </hbox>
+ </groupbox>
+
+
+ <groupbox id="storage-settings">
+ <caption label="&zotero.preferences.sync.fileSyncing;"/>
+
+ <!-- My Library -->
+ <hbox>
+ <checkbox label="&zotero.preferences.sync.fileSyncing.myLibrary;"
+ preference="pref-storage-enabled"
+ oncommand="Zotero_Preferences.Sync.updateStorageSettings(this.checked, null)"/>
+ <menulist id="storage-protocol" class="storage-personal"
+ style="margin-left: .5em"
+ preference="pref-storage-protocol"
+ oncommand="Zotero_Preferences.Sync.updateStorageSettings(null, this.value)">
+ <menupopup>
+ <menuitem label="Zotero" value="zotero"/>
+ <menuitem label="WebDAV" value="webdav"/>
+ </menupopup>
+ </menulist>
+ </hbox>
+
+ <stack id="storage-webdav-settings" style="margin-top: .5em; margin-bottom: .8em; border: 1px gray solid; border-radius: 3px">
+ <!-- Background shading -->
+ <box style="background: black; opacity:.03"/>
+
+ <grid style="padding: .7em .4em .7em 0">
+ <columns>
+ <column/>
+ <column flex="1"/>
+ </columns>
+
+ <rows>
+ <row>
+ <label value="&zotero.preferences.sync.fileSyncing.url;"/>
+ <hbox>
+ <menulist id="storage-url-prefix"
+ preference="pref-storage-scheme"
+ onsynctopreference="Zotero_Preferences.Sync.unverifyStorageServer()"
+ style="padding: 0; width: 7em">
+ <menupopup>
+ <menuitem label="http" value="http" style="padding: 0"/>
+ <menuitem label="https" value="https" style="padding: 0"/>
+ </menupopup>
+ </menulist>
+ <label value="://"/>
+ <textbox id="storage-url" flex="1"
+ preference="pref-storage-url"
+ onkeypress="if (Zotero.isMac && event.keyCode == 13) {
+ this.blur();
+ setTimeout(Zotero_Preferences.Sync.verifyStorageServer, 1);
+ }"
+ onchange="Zotero_Preferences.Sync.unverifyStorageServer();
+ this.value = this.value.replace(/(^https?:\/\/|\/zotero\/?$|\/$)/g, '');
+ Zotero.Prefs.set('sync.storage.url', this.value)"/>
+ <label value="/zotero/"/>
+ </hbox>
+ </row>
+ <row>
+ <label value="&zotero.preferences.sync.username;"/>
+ <hbox>
+ <textbox id="storage-username"
+ preference="pref-storage-username"
+ onkeypress="if (Zotero.isMac && event.keyCode == 13) {
+ this.blur();
+ setTimeout(Zotero_Preferences.Sync.verifyStorageServer, 1); }"
+ onchange="Zotero_Preferences.Sync.unverifyStorageServer();
+ Zotero.Prefs.set('sync.storage.username', this.value);
+ var pass = document.getElementById('storage-password');
+ if (pass.value) {
+ Zotero.Sync.Storage.WebDAV.password = pass.value;
+ }"/>
+ </hbox>
+ </row>
+ <row>
+ <label value="&zotero.preferences.sync.password;"/>
+ <hbox>
+ <textbox id="storage-password" flex="0" type="password"
+ onkeypress="if (Zotero.isMac && event.keyCode == 13) {
+ this.blur();
+ setTimeout(Zotero_Preferences.Sync.verifyStorageServer, 1);
+ }"
+ onchange="Zotero_Preferences.Sync.unverifyStorageServer();
+ Zotero.Sync.Storage.WebDAV.password = this.value;"/>
+ </hbox>
+ </row>
+ <row>
+ <box/>
+ <hbox>
+ <button id="storage-verify" label="Verify Server"
+ oncommand="Zotero_Preferences.Sync.verifyStorageServer()"/>
+ <button id="storage-abort" label="Stop" hidden="true"/>
+ <progressmeter id="storage-progress" hidden="true"
+ mode="undetermined"/>
+ </hbox>
+ </row>
+ </rows>
+ </grid>
+
+ </stack>
+
+ <hbox class="storage-settings-download-options" align="center">
+ <label value="&zotero.preferences.sync.fileSyncing.download;"/>
+ <menulist class="storage-personal" preference="pref-storage-downloadMode-personal" style="margin-left: 0">
+ <menupopup>
+ <menuitem label="&zotero.preferences.sync.fileSyncing.download.onDemand;" value="on-demand"/>
+ <menuitem label="&zotero.preferences.sync.fileSyncing.download.atSyncTime;" value="on-sync"/>
+ </menupopup>
+ </menulist>
+ </hbox>
+
+ <separator id="storage-separator" class="thin"/>
+
+ <!-- Group Libraries -->
+ <checkbox label="&zotero.preferences.sync.fileSyncing.groups;"
+ preference="pref-group-storage-enabled"
+ oncommand="Zotero_Preferences.Sync.updateStorageSettingsGroups(this.checked)"/>
+
+ <hbox class="storage-settings-download-options" align="center">
+ <label value="&zotero.preferences.sync.fileSyncing.download;"/>
+ <menulist class="storage-groups" preference="pref-storage-downloadMode-groups" style="margin-left: 0">
+ <menupopup>
+ <menuitem label="&zotero.preferences.sync.fileSyncing.download.onDemand;" value="on-demand"/>
+ <menuitem label="&zotero.preferences.sync.fileSyncing.download.atSyncTime;" value="on-sync"/>
+ </menupopup>
+ </menulist>
+ </hbox>
+
+ <separator class="thin"/>
+
+ <vbox>
+ <hbox id="storage-terms" style="margin-top: .4em" align="center">
+ <label>&zotero.preferences.sync.fileSyncing.tos1;</label>
+ <label class="zotero-text-link" href="http://www.digitalscholar.org/z_terms" value="&zotero.preferences.sync.fileSyncing.tos2;"/>
+ <label>&zotero.preferences.period;</label>
+ </hbox>
+ </vbox>
+ </groupbox>
+ </tabpanel>
+
+ <tabpanel id="zotero-reset" orient="vertical">
+ <!-- This doesn't wrap without an explicit width, for some reason -->
+ <description width="45em">&zotero.preferences.sync.reset.warning1;<label style="margin-left: 0; margin-right: 0" class="zotero-text-link" href="http://zotero.org/support/kb/sync_reset_options">&zotero.preferences.sync.reset.warning2;</label>&zotero.preferences.sync.reset.warning3;</description>
+
+ <radiogroup id="zotero-reset-sync-group"
+ oncommand="Zotero_Preferences.Sync.handleSyncResetSelect(this)">
+ <groupbox>
+ <caption label="&zotero.preferences.sync.syncServer;"/>
+
+ <grid>
+ <columns>
+ <column/>
+ <column align="start" pack="start" flex="1"/>
+ </columns>
+
+ <rows>
+ <row id="zotero-restore-from-server" selected="true">
+ <radio/>
+ <vbox onclick="this.previousSibling.click()">
+ <label value="&zotero.preferences.sync.reset.restoreFromServer;"/>
+ <description>&zotero.preferences.sync.reset.restoreFromServer.desc;</description>
+ </vbox>
+ </row>
+
+ <row id="zotero-restore-to-server">
+ <radio/>
+ <vbox onclick="this.previousSibling.click()">
+ <label value="&zotero.preferences.sync.reset.restoreToServer;"/>
+ <description>&zotero.preferences.sync.reset.restoreToServer.desc;</description>
+ </vbox>
+ </row>
+ </rows>
+ </grid>
+
+ <hbox>
+ <button label="&zotero.preferences.sync.reset.button;"
+ oncommand="Zotero_Preferences.Sync.handleSyncReset(
+ document.getElementById('zotero-reset-sync-group').selectedItem.parentNode.id.substr(7)
+ )"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox>
+ <caption label="&zotero.preferences.sync.fileSyncing;"/>
+
+ <grid>
+ <columns>
+ <column/>
+ <column align="start" pack="start" flex="1"/>
+ </columns>
+
+ <rows>
+ <row id="zotero-reset-storage-history">
+ <radio/>
+ <vbox onclick="this.previousSibling.click()">
+ <label value="&zotero.preferences.sync.reset.resetFileSyncHistory;"/>
+ <description>&zotero.preferences.sync.reset.resetFileSyncHistory.desc;</description>
+ </vbox>
+ </row>
+ </rows>
+ </grid>
+
+ <hbox>
+ <button label="&zotero.preferences.sync.reset.button;"
+ oncommand="Zotero_Preferences.Sync.handleSyncReset(
+ document.getElementById('zotero-reset-sync-group').selectedItem.parentNode.id.substr(7)
+ )"/>
+ </hbox>
+ </groupbox>
+ </radiogroup>
+ </tabpanel>
+ </tabpanels>
+ </tabbox>
+
+ <separator/>
+ </prefpane>
+
+ <script src="preferences_sync.js" type="application/javascript;version=1.8"/>
+</overlay>
diff --git a/chrome/content/zotero/preferences/quickCopySiteEditor.xul b/chrome/content/zotero/preferences/quickCopySiteEditor.xul
@@ -2,7 +2,7 @@
<!--
***** BEGIN LICENSE BLOCK *****
- Copyright © 2009 Center for History and New Media
+ Copyright © 2007 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://zotero.org
@@ -60,15 +60,21 @@
<menulist id="zotero-quickCopy-menu"/>
<separator class="thin"/>
<checkbox id="zotero-quickCopy-copyAsHTML" label="&zotero.preferences.quickCopy.copyAsHTML;"
- oncommand="buildQuickCopyFormatDropDown(document.getElementById('zotero-quickCopy-menu'), this.checked ? 'html' : '')"/>
+ oncommand="Zotero_Preferences.Export.buildQuickCopyFormatDropDown(
+ document.getElementById('zotero-quickCopy-menu'), this.checked ? 'html' : ''
+ )"/>
</vbox>
<script>
<![CDATA[
var io = window.arguments[0];
document.getElementById('zotero-quickCopy-domain').value = io.domain ? io.domain : '';
- buildQuickCopyFormatDropDown(document.getElementById('zotero-quickCopy-menu'), Zotero.QuickCopy.getContentType(io.format), io.format);
- updateQuickCopyHTMLCheckbox();
+ Zotero_Preferences.Export.buildQuickCopyFormatDropDown(
+ document.getElementById('zotero-quickCopy-menu'),
+ Zotero.QuickCopy.getContentType(io.format),
+ io.format
+ );
+ Zotero_Preferences.Export.updateQuickCopyHTMLCheckbox();
]]>
</script>
</dialog>