Add the export warning to the plugin interface export command

This commit is contained in:
Adomas Venčkauskas 2019-05-29 12:00:53 +03:00
parent 07c8269433
commit 96a0b77192
2 changed files with 30 additions and 20 deletions

View file

@ -243,27 +243,10 @@ var Zotero_File_Interface_Bibliography = new function() {
window.sizeToContent();
};
this.exportDocument = function() {
const documentationURL = "https://www.zotero.org/support/kb/word_processor_document_export";
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING);
var result = ps.confirmEx(null,
Zotero.getString('integration.exportDocument'),
Zotero.getString('integration.exportDocument.description1')
+ "\n\n"
+ Zotero.getString('integration.exportDocument.description2'),
buttonFlags,
Zotero.getString('general.export'),
null,
Zotero.getString('general.moreInformation'), null, {});
if (result == 0) {
this.exportDocument = function () {
if (Zotero.Integration.confirmExportDocument()) {
_io.exportDocument = true;
document.documentElement.acceptDialog();
} else if (result == 2) {
Zotero.launchURL(documentationURL);
}
}

View file

@ -540,6 +540,31 @@ Zotero.Integration = new function() {
}
Zotero.Integration.confirmExportDocument = function() {
const documentationURL = "https://www.zotero.org/support/kb/word_processor_document_export";
var ps = Services.prompt;
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL)
+ (ps.BUTTON_POS_2) * (ps.BUTTON_TITLE_IS_STRING);
var result = ps.confirmEx(null,
Zotero.getString('integration.exportDocument'),
Zotero.getString('integration.exportDocument.description1')
+ "\n\n"
+ Zotero.getString('integration.exportDocument.description2'),
buttonFlags,
Zotero.getString('general.export'),
null,
Zotero.getString('general.moreInformation'), null, {});
if (result == 0) {
return true;
}
else if (result == 2) {
Zotero.launchURL(documentationURL);
}
return false;
}
/**
* An exception thrown when a document contains an item that no longer exists in the current document.
*/
@ -813,7 +838,9 @@ Zotero.Integration.Interface.prototype.setDocPrefs = Zotero.Promise.coroutine(fu
*/
Zotero.Integration.Interface.prototype.exportDocument = async function () {
await this._session.init(true, false);
await this._session.exportDocument();
if (Zotero.Integration.confirmExportDocument()) {
await this._session.exportDocument();
}
}
/**