Warn on non-empty annotation close
This commit is contained in:
parent
63a9995227
commit
a0d996d14d
|
@ -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]);
|
||||
|
|
|
@ -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
|
||||
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.
|
Loading…
Reference in New Issue
Block a user