Modify integration.js to use Zotero.Exception.UserCancelled
This commit is contained in:
parent
53bcccd9e7
commit
de6a776e88
|
@ -622,7 +622,7 @@ Zotero.Integration = new function() {
|
||||||
* Show appropriate dialogs for an integration error
|
* Show appropriate dialogs for an integration error
|
||||||
*/
|
*/
|
||||||
this.handleError = function(e, document) {
|
this.handleError = function(e, document) {
|
||||||
if(!(e instanceof Zotero.Integration.UserCancelledException)) {
|
if(!(e instanceof Zotero.Exception.UserCancelled)) {
|
||||||
try {
|
try {
|
||||||
var displayError = null;
|
var displayError = null;
|
||||||
if(e instanceof Zotero.Integration.DisplayException) {
|
if(e instanceof Zotero.Integration.DisplayException) {
|
||||||
|
@ -803,11 +803,6 @@ Zotero.Integration.MissingItemException.prototype.name = "MissingItemException";
|
||||||
Zotero.Integration.MissingItemException.prototype.message = "An item in this document is missing from your Zotero library.";
|
Zotero.Integration.MissingItemException.prototype.message = "An item in this document is missing from your Zotero library.";
|
||||||
Zotero.Integration.MissingItemException.prototype.toString = function() { return this.message; };
|
Zotero.Integration.MissingItemException.prototype.toString = function() { return this.message; };
|
||||||
|
|
||||||
Zotero.Integration.UserCancelledException = function() {};
|
|
||||||
Zotero.Integration.UserCancelledException.prototype.name = "UserCancelledException";
|
|
||||||
Zotero.Integration.UserCancelledException.prototype.message = "User cancelled document update.";
|
|
||||||
Zotero.Integration.UserCancelledException.prototype.toString = function() { return this.message; };
|
|
||||||
|
|
||||||
Zotero.Integration.DisplayException = function(name, params) {
|
Zotero.Integration.DisplayException = function(name, params) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.params = params ? params : [];
|
this.params = params ? params : [];
|
||||||
|
@ -898,7 +893,7 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet
|
||||||
|
|
||||||
this._session.setDocPrefs(this._doc, this._app.primaryFieldType, this._app.secondaryFieldType, function(status) {
|
this._session.setDocPrefs(this._doc, this._app.primaryFieldType, this._app.secondaryFieldType, function(status) {
|
||||||
if(status === false) {
|
if(status === false) {
|
||||||
throw new Zotero.Integration.UserCancelledException();
|
throw new Zotero.Exception.UserCancelled("document preferences update");
|
||||||
}
|
}
|
||||||
|
|
||||||
// save doc prefs in doc
|
// save doc prefs in doc
|
||||||
|
@ -921,7 +916,7 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet
|
||||||
var warning = this._doc.displayAlert(Zotero.getString("integration.upgradeWarning"),
|
var warning = this._doc.displayAlert(Zotero.getString("integration.upgradeWarning"),
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_WARNING,
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_WARNING,
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK_CANCEL);
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK_CANCEL);
|
||||||
if(!warning) throw new Zotero.Integration.UserCancelledException();
|
if(!warning) throw new Zotero.Exception.UserCancelled("document upgrade");
|
||||||
} else if(data.dataVersion > DATA_VERSION) {
|
} else if(data.dataVersion > DATA_VERSION) {
|
||||||
throw new Zotero.Integration.DisplayException("newerDocumentVersion", [data.zoteroVersion, Zotero.version]);
|
throw new Zotero.Integration.DisplayException("newerDocumentVersion", [data.zoteroVersion, Zotero.version]);
|
||||||
}
|
}
|
||||||
|
@ -943,7 +938,7 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet
|
||||||
this._session.setDocPrefs(this._doc, this._app.primaryFieldType,
|
this._session.setDocPrefs(this._doc, this._app.primaryFieldType,
|
||||||
this._app.secondaryFieldType, function(status) {
|
this._app.secondaryFieldType, function(status) {
|
||||||
if(status === false) {
|
if(status === false) {
|
||||||
throw new Zotero.Integration.UserCancelledException();
|
throw new Zotero.Exception.UserCancelled("document preferences update");
|
||||||
}
|
}
|
||||||
|
|
||||||
me._doc.setDocumentData(me._session.data.serializeXML());
|
me._doc.setDocumentData(me._session.data.serializeXML());
|
||||||
|
@ -1206,7 +1201,7 @@ Zotero.Integration.Fields.prototype.addField = function(note) {
|
||||||
if(!this._doc.displayAlert(Zotero.getString("integration.replace"),
|
if(!this._doc.displayAlert(Zotero.getString("integration.replace"),
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_STOP,
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_STOP,
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK_CANCEL)) {
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK_CANCEL)) {
|
||||||
throw new Zotero.Integration.UserCancelledException;
|
throw new Zotero.Exception.UserCancelled("inserting citation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1324,7 +1319,7 @@ Zotero.Integration.Fields.prototype._showCorruptFieldError = function(e, field,
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_YES_NO_CANCEL);
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_YES_NO_CANCEL);
|
||||||
|
|
||||||
if(result == 0) {
|
if(result == 0) {
|
||||||
throw new Zotero.Integration.UserCancelledException;
|
throw new Zotero.Exception.UserCancelled("document update");
|
||||||
} else if(result == 1) { // No
|
} else if(result == 1) { // No
|
||||||
this._removeCodeFields.push(i);
|
this._removeCodeFields.push(i);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1376,7 +1371,7 @@ Zotero.Integration.Fields.prototype._showMissingItemError = function(e, field, c
|
||||||
this._doc.activate();
|
this._doc.activate();
|
||||||
var result = this._doc.displayAlert(msg, 1, 3);
|
var result = this._doc.displayAlert(msg, 1, 3);
|
||||||
if(result == 0) { // Cancel
|
if(result == 0) { // Cancel
|
||||||
throw new Zotero.Integration.UserCancelledException();
|
throw new Zotero.Exception.UserCancelled("document update");
|
||||||
} else if(result == 1) { // No
|
} else if(result == 1) { // No
|
||||||
for each(var reselectKey in e.reselectKeys) {
|
for each(var reselectKey in e.reselectKeys) {
|
||||||
this._deleteKeys[reselectKey] = true;
|
this._deleteKeys[reselectKey] = true;
|
||||||
|
@ -1755,7 +1750,7 @@ Zotero.Integration.Fields.prototype.addEditCitation = function(field, callback)
|
||||||
if(!this._doc.displayAlert(Zotero.getString("integration.citationChanged.edit"),
|
if(!this._doc.displayAlert(Zotero.getString("integration.citationChanged.edit"),
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_WARNING,
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_WARNING,
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK_CANCEL)) {
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK_CANCEL)) {
|
||||||
throw new Zotero.Integration.UserCancelledException;
|
throw new Zotero.Exception.UserCancelled("editing citation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1834,7 +1829,7 @@ Zotero.Integration.CitationEditInterface.prototype = {
|
||||||
try {
|
try {
|
||||||
return defaultHandler();
|
return defaultHandler();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
if(e instanceof Zotero.Integration.UserCancelledException) {
|
if(e instanceof Zotero.Exception.UserCancelled) {
|
||||||
this._field.delete();
|
this._field.delete();
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user