notes: don't mark note as unsaved when previewing.
Bug: previewing a note would mark the note as unsaved even if the note hadn't been changed. Fix: mark the note as unsaved when the user types something into the note edit box, not when the note is previewed.
This commit is contained in:
@@ -569,16 +569,13 @@ class Note {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let $textarea = $('<textarea></textarea>');
|
let $textarea = $('<textarea></textarea>');
|
||||||
|
$textarea.val(note.original_body);
|
||||||
$textarea.css({
|
$textarea.css({
|
||||||
width: "97%",
|
width: "97%",
|
||||||
height: "85%",
|
height: "85%",
|
||||||
resize: "none",
|
resize: "none",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!note.is_new()) {
|
|
||||||
$textarea.val(note.original_body);
|
|
||||||
}
|
|
||||||
|
|
||||||
let $dialog = $('<div></div>');
|
let $dialog = $('<div></div>');
|
||||||
let note_title = note.is_new() ? 'Creating new note' : `Editing note #${note.id}`;
|
let note_title = note.is_new() ? 'Creating new note' : `Editing note #${note.id}`;
|
||||||
|
|
||||||
@@ -598,6 +595,7 @@ class Note {
|
|||||||
},
|
},
|
||||||
open: () => {
|
open: () => {
|
||||||
Utility.keydown("ctrl+return", "save_note", () => this.save($dialog, note), ".note-edit-dialog textarea");
|
Utility.keydown("ctrl+return", "save_note", () => this.save($dialog, note), ".note-edit-dialog textarea");
|
||||||
|
$(".note-edit-dialog textarea").on("input.danbooru", (e) => this.on_input(note));
|
||||||
$(".note-box").addClass("editing");
|
$(".note-box").addClass("editing");
|
||||||
},
|
},
|
||||||
close: () => {
|
close: () => {
|
||||||
@@ -615,6 +613,10 @@ class Note {
|
|||||||
$textarea.selectEnd();
|
$textarea.selectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static on_input(note) {
|
||||||
|
note.box.$note_box.addClass("unsaved");
|
||||||
|
}
|
||||||
|
|
||||||
static async save($dialog, note) {
|
static async save($dialog, note) {
|
||||||
let $note_box = note.box.$note_box;
|
let $note_box = note.box.$note_box;
|
||||||
let text = $dialog.find("textarea").val();
|
let text = $dialog.find("textarea").val();
|
||||||
@@ -648,8 +650,6 @@ class Note {
|
|||||||
|
|
||||||
static async preview($dialog, note) {
|
static async preview($dialog, note) {
|
||||||
let text = $dialog.find("textarea").val();
|
let text = $dialog.find("textarea").val();
|
||||||
|
|
||||||
note.box.$note_box.addClass("unsaved");
|
|
||||||
note.body.preview_text(text);
|
note.body.preview_text(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user