diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 307d18249e..0f88362721 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1249,33 +1249,39 @@ Zotero.Integration.Fields.prototype._retrieveFields = function() { * @param {Field} field The Zotero field object * @param {Integer} i The field index */ -Zotero.Integration.Fields.prototype._showCorruptFieldError = function(e, field, i) { +Zotero.Integration.Fields.prototype._showCorruptFieldError = function(e, field, callback, errorCallback, i) { + Zotero.logError(e); + var msg = Zotero.getString("integration.corruptField")+'\n\n'+ Zotero.getString('integration.corruptField.description'); field.select(); + this._doc.activate(); var result = this._doc.displayAlert(msg, Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_CAUTION, Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_YES_NO_CANCEL); if(result == 0) { - throw e; + throw new Zotero.Integration.UserCancelledException; } else if(result == 1) { // No this._removeCodeFields.push(i); + return true; } else { // Display reselect edit citation dialog - var added = this.addEditCitation(field); - if(added) { - this._doc.activate(); - } else { - throw new Zotero.Integration.UserCancelledException(); - } + var me = this; + var oldWindow = Zotero.Integration.currentWindow; + this.addEditCitation(field, function() { + Zotero.Integration.currentWindow.close(); + Zotero.Integration.currentWindow = oldWindow; + me.updateSession(callback, errorCallback); + }); + return false; } } /** * Updates Zotero.Integration.Session attached to Zotero.Integration.Fields in line with document */ -Zotero.Integration.Fields.prototype.updateSession = function(callback) { +Zotero.Integration.Fields.prototype.updateSession = function(callback, errorCallback) { var me = this; this.get(function(fields) { me._session.resetRequest(me._doc); @@ -1300,7 +1306,9 @@ Zotero.Integration.Fields.prototype.updateSession = function(callback) { try { me._session.loadBibliographyData(me._bibliographyData); } catch(e) { - if(e instanceof Zotero.Integration.CorruptFieldException) { + if(errorCallback) { + errorCallback(e); + } else if(e instanceof Zotero.Integration.CorruptFieldException) { var msg = Zotero.getString("integration.corruptBibliography")+'\n\n'+ Zotero.getString('integration.corruptBibliography.description'); var result = me._doc.displayAlert(msg, @@ -1333,16 +1341,16 @@ Zotero.Integration.Fields.prototype.updateSession = function(callback) { if(callback) callback(me._session); })); } else { - if(callback) callback(this._session); + if(callback) callback(me._session); } - }); + }, errorCallback); }); } /** * Keep processing fields until all have been processed */ -Zotero.Integration.Fields.prototype._processFields = function(fields, callback, i) { +Zotero.Integration.Fields.prototype._processFields = function(fields, callback, errorCallback, i) { if(!i) i = 0; for(var n = fields.length; i