diff --git a/chrome/content/zotero/xpcom/annotate.js b/chrome/content/zotero/xpcom/annotate.js index e4dc78a5b..031b73f7d 100644 --- a/chrome/content/zotero/xpcom/annotate.js +++ b/chrome/content/zotero/xpcom/annotate.js @@ -652,7 +652,11 @@ Zotero.Annotation.prototype._addChildElements = function() { var img = this.document.createElement("img"); img.src = "chrome://zotero/skin/annotation-close.png"; - img.addEventListener("click", function() { me._delete() }, false); + img.addEventListener("click", function(event) { + if (me._confirmDelete(event)) { + me._delete() + } + }, false); div.appendChild(img); this.textarea = this.document.createElement("textarea"); @@ -676,6 +680,31 @@ Zotero.Annotation.prototype._click = function() { this.div.style.zIndex = this.annotationsObj.zIndex; } +Zotero.Annotation.prototype._confirmDelete = function(event) { + if (event.target.parentNode.nextSibling.value == '' || + !Zotero.Prefs.get('annotations.warnOnClose')) { + return true; + } + + var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + + var dontShowAgain = { value: false }; + var del = promptService.confirmCheck( + this.window, + Zotero.getString('annotations.confirmClose.title'), + Zotero.getString('annotations.confirmClose.body'), + Zotero.getString('general.dontShowWarningAgain'), + dontShowAgain + ); + + if (dontShowAgain.value) { + Zotero.Prefs.set('annotations.warnOnClose', false); + } + + return del; +} + Zotero.Annotation.prototype._delete = function() { if(this.annotationID) { Zotero.DB.query("DELETE FROM annotations WHERE annotationID = ?", [this.annotationID]); diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index ba7333e83..82a0fd0a8 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -1,3 +1,5 @@ +general.dontShowWarningAgain = Don't show this warning again. + pane.collections.delete = Are you sure you want to delete the selected collection? pane.collections.deleteSearch = Are you sure you want to delete the selected search? pane.collections.name = Collection name: @@ -293,4 +295,7 @@ date.abbreviation.day = d citation.multipleSources = Multiple Sources... citation.singleSource = Single Source... -report.title.default = Zotero Report \ No newline at end of file +report.title.default = Zotero Report + +annotations.confirmClose.title = Are you sure you want to close this annotation? +annotations.confirmClose.body = All text will be lost. \ No newline at end of file