From 89c4a7dd04b72a1e664316a1801c99d862337782 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 13 Nov 2007 06:56:04 +0000 Subject: [PATCH] CSL-related updates: - Add a content listener to install CSLs served with text/x-csl - Delete styles with old URIs when new versions come from repo - Change default style prefs to use new URI for Chicago Note - Clear CSL table and quick copy drop-down when resetting translators (so it works correctly for styles too) - Change button text from "Rebuild Translators Table" to more accurate and forward-looking "Reset Translators and Styles..." - Allow passed callbacks in Schema.updateScrapersRemote() and Schema.rebuild(Translators|Styles|TranslatorsAndStyles)Table[s] --- chrome/content/zotero/browser.js | 1 + .../content/zotero/preferences/preferences.js | 72 +++++++- .../zotero/preferences/preferences.xul | 4 +- chrome/content/zotero/xpcom/cite.js | 158 ++++++++++++++++++ chrome/content/zotero/xpcom/schema.js | 109 ++++++++---- chrome/locale/af-ZA/zotero/preferences.dtd | 1 - chrome/locale/af-ZA/zotero/zotero.properties | 2 - chrome/locale/ar/zotero/preferences.dtd | 1 - chrome/locale/ar/zotero/zotero.properties | 2 - chrome/locale/bg-BG/zotero/preferences.dtd | 1 - chrome/locale/bg-BG/zotero/zotero.properties | 2 - chrome/locale/ca-AD/zotero/preferences.dtd | 1 - chrome/locale/ca-AD/zotero/zotero.properties | 2 - chrome/locale/cs-CZ/zotero/preferences.dtd | 1 - chrome/locale/cs-CZ/zotero/zotero.properties | 2 - chrome/locale/da-DK/zotero/preferences.dtd | 1 - chrome/locale/da-DK/zotero/zotero.properties | 2 - chrome/locale/de-AT/zotero/preferences.dtd | 1 - chrome/locale/de-AT/zotero/zotero.properties | 2 - chrome/locale/de-CH/zotero/preferences.dtd | 1 - chrome/locale/de-CH/zotero/zotero.properties | 2 - chrome/locale/de/zotero/preferences.dtd | 1 - chrome/locale/de/zotero/zotero.properties | 2 - chrome/locale/el-GR/zotero/preferences.dtd | 1 - chrome/locale/el-GR/zotero/zotero.properties | 2 - chrome/locale/en-US/zotero/preferences.dtd | 4 +- chrome/locale/en-US/zotero/zotero.properties | 14 +- chrome/locale/es-ES/zotero/preferences.dtd | 1 - chrome/locale/es-ES/zotero/zotero.properties | 2 - chrome/locale/et-EE/zotero/preferences.dtd | 1 - chrome/locale/et-EE/zotero/zotero.properties | 2 - chrome/locale/fr-FR/zotero/preferences.dtd | 1 - chrome/locale/fr-FR/zotero/zotero.properties | 2 - chrome/locale/he-IL/zotero/preferences.dtd | 1 - chrome/locale/he-IL/zotero/zotero.properties | 2 - chrome/locale/hu-HU/zotero/preferences.dtd | 1 - chrome/locale/hu-HU/zotero/zotero.properties | 2 - chrome/locale/is-IS/zotero/preferences.dtd | 1 - chrome/locale/is-IS/zotero/zotero.properties | 2 - chrome/locale/it-IT/zotero/preferences.dtd | 1 - chrome/locale/it-IT/zotero/zotero.properties | 2 - chrome/locale/ja-JP/zotero/preferences.dtd | 1 - chrome/locale/ja-JP/zotero/zotero.properties | 2 - chrome/locale/ko-KR/zotero/preferences.dtd | 1 - chrome/locale/ko-KR/zotero/zotero.properties | 2 - chrome/locale/mn-MN/zotero/preferences.dtd | 1 - chrome/locale/mn-MN/zotero/zotero.properties | 2 - chrome/locale/nb-NO/zotero/preferences.dtd | 1 - chrome/locale/nb-NO/zotero/zotero.properties | 2 - chrome/locale/nl-NL/zotero/preferences.dtd | 1 - chrome/locale/nl-NL/zotero/zotero.properties | 2 - chrome/locale/pl-PL/zotero/preferences.dtd | 1 - chrome/locale/pl-PL/zotero/zotero.properties | 2 - chrome/locale/pt-BR/zotero/preferences.dtd | 1 - chrome/locale/pt-BR/zotero/zotero.properties | 2 - chrome/locale/pt-PT/zotero/preferences.dtd | 1 - chrome/locale/pt-PT/zotero/zotero.properties | 2 - chrome/locale/ro-RO/zotero/preferences.dtd | 1 - chrome/locale/ro-RO/zotero/zotero.properties | 2 - chrome/locale/ru-RU/zotero/preferences.dtd | 1 - chrome/locale/ru-RU/zotero/zotero.properties | 2 - chrome/locale/sr-YU/zotero/preferences.dtd | 1 - chrome/locale/sr-YU/zotero/zotero.properties | 2 - chrome/locale/sv-SE/zotero/preferences.dtd | 1 - chrome/locale/sv-SE/zotero/zotero.properties | 2 - chrome/locale/tr-TR/zotero/preferences.dtd | 1 - chrome/locale/tr-TR/zotero/zotero.properties | 2 - chrome/locale/vi-VN/zotero/preferences.dtd | 1 - chrome/locale/vi-VN/zotero/zotero.properties | 2 - chrome/locale/zh-CN/zotero/preferences.dtd | 1 - chrome/locale/zh-CN/zotero/zotero.properties | 2 - chrome/locale/zh-TW/zotero/preferences.dtd | 1 - chrome/locale/zh-TW/zotero/zotero.properties | 2 - defaults/preferences/zotero.js | 4 +- 74 files changed, 318 insertions(+), 147 deletions(-) diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index d2f9bb478..0cff06bee 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -105,6 +105,7 @@ var Zotero_Browser = new function() { Zotero_Browser._scrapePopupShowing = false; Zotero.Ingester.ProxyMonitor.init(); Zotero.Ingester.MIMEHandler.init(); + Zotero.Cite.MIMEHandler.init(); Zotero.Translate.init(); window.addEventListener("load", diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index 54c0a8f93..42a09f8ab 100644 --- a/chrome/content/zotero/preferences/preferences.js +++ b/chrome/content/zotero/preferences/preferences.js @@ -146,6 +146,9 @@ function populateQuickCopyList() { function buildQuickCopyFormatDropDown(menulist, currentFormat) { + menulist.selectedItem = null; + menulist.removeAllItems(); + // Prevent Cmd-w from setting "Wikipedia" menulist.onkeydown = function (event) { if ((Zotero.isMac && event.metaKey) || event.ctrlKey) { @@ -769,7 +772,26 @@ function runIntegrityCheck() { } -function rebuildTranslators() { +function updateTranslators() { + Zotero.Schema.updateScrapersRemote(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); + } + }); +} + + +function resetTranslatorsAndStyles() { var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); @@ -778,9 +800,31 @@ function rebuildTranslators() { var index = ps.confirmEx(null, Zotero.getString('general.warning'), - Zotero.getString('zotero.preferences.advanced.rebuildTranslators.changesLost'), + Zotero.getString('zotero.preferences.advanced.resetTranslatorsAndStyles.changesLost'), buttonFlags, - Zotero.getString('zotero.preferences.advanced.rebuildTranslators.rebuildTable'), + Zotero.getString('zotero.preferences.advanced.resetTranslatorsAndStyles'), + null, null, null, {}); + + if (index == 0) { + Zotero.Schema.rebuildTranslatorsAndStylesTables(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) { @@ -789,6 +833,28 @@ function rebuildTranslators() { } +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.rebuildStylesTable(function (xmlhttp, updated) { + populateQuickCopyList(); + }); + } +} + + function onOpenURLSelected() { var openURLMenu = document.getElementById('openURLMenu'); diff --git a/chrome/content/zotero/preferences/preferences.xul b/chrome/content/zotero/preferences/preferences.xul index 6550d5d9b..042b2d109 100644 --- a/chrome/content/zotero/preferences/preferences.xul +++ b/chrome/content/zotero/preferences/preferences.xul @@ -114,7 +114,7 @@ To add a new preference: -