Don't break when add citation box is closed directly instead of cancelled

This commit is contained in:
Simon Kornblith 2013-03-31 21:54:04 -04:00
parent c7c0c4c5dc
commit e2a68c747c
4 changed files with 15 additions and 4 deletions

View file

@ -34,6 +34,7 @@ var Zotero_Citation_Dialog = new function () {
"suppress-author":["checked", false]
};
var _accepted = false;
var _itemData = new Object();
var _multipleSourcesOn = false;
var _lastSelected = null;
@ -581,6 +582,8 @@ var Zotero_Citation_Dialog = new function () {
* called when accept button is clicked
*/
function accept() {
if(_accepted) return true;
_getCitation();
var isCustom = _previewShown && io.citation.citationItems.length // if a citation is selected
&& _originalHTML
@ -600,6 +603,7 @@ var Zotero_Citation_Dialog = new function () {
}
io.accept();
_accepted = true;
return true;
}
@ -607,8 +611,12 @@ var Zotero_Citation_Dialog = new function () {
* called when cancel button is clicked
*/
function cancel() {
if(_accepted) return true;
io.citation.citationItems = new Array();
io.accept();
_accepted = true;
return true;
}
/*

View file

@ -41,7 +41,7 @@
onunload="doUnload();"
ondialogaccept="return Zotero_Citation_Dialog.accept();"
ondialogcancel="Zotero_Citation_Dialog.cancel();"
onclose="Zotero_Citation_Dialog.cancel(); event.preventDefault(); event.stopPropagation();"
onclose="Zotero_Citation_Dialog.cancel();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
persist="screenX screenY width height"
resizable="true"

View file

@ -235,15 +235,18 @@ var Zotero_Bibliography_Dialog = new function () {
* Called when OK button is pressed
*/
this.accept = function() {
_accepted = true;
if(_accepted) return;
_updatePreview(true);
_accepted = true;
}
/**
* Called when Cancel button is pressed
*/
this.close = function() {
if(!_accepted) bibEditInterface.cancel();
if(_accepted) return;
bibEditInterface.cancel();
_accepted = true;
}
/**

View file

@ -38,7 +38,7 @@
onload="Zotero_Bibliography_Dialog.load();"
ondialogaccept="Zotero_Bibliography_Dialog.accept();"
ondialogcancel="Zotero_Bibliography_Dialog.close();"
onclose="Zotero_Bibliography_Dialog.close(); event.preventDefault(); event.stopPropagation();"
onclose="Zotero_Bibliography_Dialog.close();"
onunload="doUnload();"
buttons="extra1,extra2,accept,cancel" buttonpack="end"
xmlns:html="http://www.w3.org/1999/xhtml"