www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 628bc536a0fc47a429b300a35f6b0fbb3638b3cd
parent 00e52ae62b2e84d7fa770ca2f61d1b3b36f156bf
Author: Adomas Venčkauskas <adomas.ven@gmail.com>
Date:   Fri, 16 Feb 2018 11:37:53 +0200

Add a button in preferences to enable word plugins if some are disabled

Diffstat:
Mchrome/content/zotero/preferences/preferences_cite.js | 40+++++++++++++++++++++++++++++++++-------
Mchrome/content/zotero/preferences/preferences_cite.xul | 14++++++++++----
Mchrome/locale/en-US/zotero/preferences.dtd | 5++---
3 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/chrome/content/zotero/preferences/preferences_cite.js b/chrome/content/zotero/preferences/preferences_cite.js @@ -26,24 +26,50 @@ "use strict"; Zotero_Preferences.Cite = { + wordPluginIDs: new Set([ + 'zoteroOpenOfficeIntegration@zotero.org', + 'zoteroMacWordIntegration@zotero.org', + 'zoteroWinWordIntegration@zotero.org' + ]), + init: Zotero.Promise.coroutine(function* () { + Components.utils.import("resource://gre/modules/AddonManager.jsm"); this.updateWordProcessorInstructions(); yield this.refreshStylesList(); }), /** - * Determines if there are word processors, and if not, enables no word processor message + * Determines if any word processors are disabled and if so, shows a message in the pref pane */ - updateWordProcessorInstructions: function () { - if(document.getElementById("wordProcessors").childNodes.length == 2) { - document.getElementById("wordProcessors-noWordProcessorPluginsInstalled").hidden = undefined; - } - if(Zotero.isStandalone) { - document.getElementById("wordProcessors-getWordProcessorPlugins").hidden = true; + updateWordProcessorInstructions: async function () { + var someDisabled = false; + await new Promise(function(resolve) { + AddonManager.getAllAddons(function(addons) { + for (let addon of addons) { + if (Zotero_Preferences.Cite.wordPluginIDs.has(addon.id) && addon.userDisabled) { + someDisabled = true; + } + } + resolve(); + }); + }); + if (someDisabled) { + document.getElementById("wordProcessors-somePluginsDisabled").hidden = undefined; } }, + enableWordPlugins: function () { + AddonManager.getAllAddons(function(addons) { + for (let addon of addons) { + if (Zotero_Preferences.Cite.wordPluginIDs.has(addon.id) && addon.userDisabled) { + addon.userDisabled = false; + } + } + return Zotero.Utilities.Internal.quit(true); + }); + }, + /** * Refreshes the list of styles in the styles pane diff --git a/chrome/content/zotero/preferences/preferences_cite.xul b/chrome/content/zotero/preferences/preferences_cite.xul @@ -96,11 +96,17 @@ </groupbox> </tabpanel> <tabpanel orient="vertical" id="wordProcessors"> - <label id="wordProcessors-noWordProcessorPluginsInstalled" width="45em" hidden="true"> - &zotero.preferences.cite.wordProcessors.noWordProcessorPluginsInstalled; - </label> + <vbox id="wordProcessors-somePluginsDisabled" hidden="true"> + <label> + &zotero.preferences.cite.wordProcessors.somePluginsDisabled; + </label> + <hbox pack="center"> + <button id="wordProcessors-enablePlugins" + label="&zotero.preferences.cite.wordProcessors.enablePlugins;" + oncommand="Zotero_Preferences.Cite.enableWordPlugins()"/> + </hbox> + </vbox> <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> </tabpanels> </tabbox> diff --git a/chrome/locale/en-US/zotero/preferences.dtd b/chrome/locale/en-US/zotero/preferences.dtd @@ -121,9 +121,8 @@ <!ENTITY zotero.preferences.prefpane.cite "Cite"> <!ENTITY zotero.preferences.cite.styles "Styles"> <!ENTITY zotero.preferences.cite.wordProcessors "Word Processors"> -<!ENTITY zotero.preferences.cite.wordProcessors.noWordProcessorPluginsInstalled "No word processor plug-ins are currently installed."> -<!ENTITY zotero.preferences.cite.wordProcessors.getPlugins "Get word processor plug-ins…"> -<!ENTITY zotero.preferences.cite.wordProcessors.getPlugins.url "http://www.zotero.org/support/word_processor_plugin_installation_for_zotero_2.1"> +<!ENTITY zotero.preferences.cite.wordProcessors.somePluginsDisabled "Some word processor plugins are disabled."> +<!ENTITY zotero.preferences.cite.wordProcessors.enablePlugins "Enable Plugins and Restart Zotero"> <!ENTITY zotero.preferences.cite.wordProcessors.useClassicAddCitationDialog "Use classic Add Citation dialog"> <!ENTITY zotero.preferences.styleEditor "Style Editor"> <!ENTITY zotero.preferences.stylePreview "Style Preview">