diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js
index 1491ac0bb..3bf9e9a3a 100644
--- a/chrome/content/zotero/integration/quickFormat.js
+++ b/chrome/content/zotero/integration/quickFormat.js
@@ -29,7 +29,7 @@ var Zotero_QuickFormat = new function () {
showEditor, referencePanel, referenceBox, referenceHeight = 0, separatorHeight = 0,
currentLocator, currentLocatorLabel, currentSearchTime, dragging, panel,
panelPrefix, panelSuffix, panelSuppressAuthor, panelLocatorLabel, panelLocator, panelInfo,
- panelRefersToBubble, panelFrameHeight = 0;
+ panelRefersToBubble, panelFrameHeight = 0, accepted = false;
// A variable that contains the timeout object for the latest onKeyPress event
var eventTimeout = null;
@@ -918,9 +918,25 @@ var Zotero_QuickFormat = new function () {
* Accepts current selection and adds citation
*/
function _accept() {
- _updateCitationObject();
- document.getElementById("quick-format-deck").selectedIndex = 1;
- io.accept(_onProgress);
+ if(accepted) return;
+ accepted = true;
+ try {
+ _updateCitationObject();
+ document.getElementById("quick-format-deck").selectedIndex = 1;
+ io.accept(_onProgress);
+ } catch(e) {
+ Zotero.debug(e);
+ }
+ }
+
+ /**
+ * Handles windows closed with the close box
+ */
+ this.onUnload = function() {
+ if(accepted) return;
+ accepted = true;
+ io.citation.citationItems = [];
+ io.accept();
}
/**
@@ -928,7 +944,8 @@ var Zotero_QuickFormat = new function () {
*/
this.onKeyPress = function(event) {
var keyCode = event.keyCode;
- if(keyCode === event.DOM_VK_ESCAPE) {
+ if(keyCode === event.DOM_VK_ESCAPE && !accepted) {
+ accepted = true;
io.citation.citationItems = [];
io.accept();
}
diff --git a/chrome/content/zotero/integration/quickFormat.xul b/chrome/content/zotero/integration/quickFormat.xul
index b82478f9d..f0452c3b4 100644
--- a/chrome/content/zotero/integration/quickFormat.xul
+++ b/chrome/content/zotero/integration/quickFormat.xul
@@ -37,7 +37,8 @@
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
persist="screenX screenY"
- onkeypress="Zotero_QuickFormat.onKeyPress(event)">
+ onkeypress="Zotero_QuickFormat.onKeyPress(event)"
+ onunload="Zotero_QuickFormat.onUnload()">
diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
index c180649d4..80091adac 100644
--- a/chrome/content/zotero/xpcom/integration.js
+++ b/chrome/content/zotero/xpcom/integration.js
@@ -1387,7 +1387,7 @@ Zotero.Integration.Fields.prototype.addEditCitation = function(field, callback)
var field = this.addField(true);
field.setCode("TEMP");
- citation = {"citationItems":{}, "properties":{}};
+ citation = {"citationItems":[], "properties":{}};
}
var io = new Zotero.Integration.CitationEditInterface(citation, field, this, session, newField, callback);