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

This commit is contained in:
Adomas Venčkauskas 2018-02-16 11:37:53 +02:00
parent 00e52ae62b
commit 628bc536a0
3 changed files with 45 additions and 14 deletions

View file

@ -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

View file

@ -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>

View file

@ -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">