From 628bc536a0fc47a429b300a35f6b0fbb3638b3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Fri, 16 Feb 2018 11:37:53 +0200 Subject: [PATCH] Add a button in preferences to enable word plugins if some are disabled --- .../zotero/preferences/preferences_cite.js | 40 +++++++++++++++---- .../zotero/preferences/preferences_cite.xul | 14 +++++-- chrome/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 index 5e8bd44e9a..8a032b69f3 100644 --- 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 index e30e6f1def..57e43a1484 100644 --- a/chrome/content/zotero/preferences/preferences_cite.xul +++ b/chrome/content/zotero/preferences/preferences_cite.xul @@ -96,11 +96,17 @@ - +