From 9a2dce89aab73aa18d0698079f47711e2c3e47ee Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 26 May 2013 10:25:00 -0400 Subject: [PATCH] fixes #1674 --- app/assets/javascripts/notes.js | 8 +++++++- app/controllers/notes_controller.rb | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 0c1eacbaf..3818b4413 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -32,6 +32,7 @@ Danbooru.Note = { "dragstart resizestart", function(e) { var $note_box_inner = $(e.currentTarget); + $note_box_inner.find(".note-box-inner-border").addClass("unsaved"); Danbooru.Note.dragging = true; Danbooru.Note.clear_timeouts(); Danbooru.Note.Body.hide_all(); @@ -356,12 +357,15 @@ Danbooru.Note = { }, success_handler: function(data, status, xhr) { - if (data.html_id) { + if (data.html_id) { // new note var $note_body = Danbooru.Note.Body.find(data.html_id); var $note_box = Danbooru.Note.Box.find(data.html_id); $note_body.data("id", String(data.id)).attr("data-id", data.id); $note_box.data("id", String(data.id)).attr("data-id", data.id); $note_box.find(".note-box-inner-border").removeClass("unsaved"); + } else { + var $note_box = Danbooru.Note.Box.find(data.id); + $note_box.find(".note-box-inner-border").removeClass("unsaved"); } }, @@ -403,6 +407,8 @@ Danbooru.Note = { var id = $this.data("id"); var $note_body = Danbooru.Note.Body.find(id); var text = $textarea.val(); + var $note_box = Danbooru.Note.Box.find(id); + $note_box.find(".note-box-inner-border").addClass("unsaved"); Danbooru.Note.Body.set_text($note_body, "Loading..."); $.get("/note_previews.json", {body: text}).success(function(data) { Danbooru.Note.Body.set_text($note_body, data.body); diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 45a09f83a..b03f57ef1 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -31,7 +31,11 @@ class NotesController < ApplicationController def update @note = Note.find(params[:id]) @note.update_attributes(params[:note]) - respond_with(@note) + respond_with(@note) do |format| + format.json do + render :json => @note.to_json + end + end end def destroy