diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index d00b13717..6ba61a8aa 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -7,13 +7,14 @@ Danbooru.Note = { var $note_box = $('
'); $note_box.addClass("note-box"); - $note_box.data("id", id); - $note_box.attr("data-id", id); + $note_box.data("id", String(id)); + $note_box.attr("data-id", String(id)); $note_box.draggable({containment: "parent"}); $note_box.resizable({ containment: "parent", handles: "se" }); + $note_box.css({position: "absolute"}); $note_box.append($inner_border); Danbooru.Note.Box.bind_events($note_box); @@ -120,8 +121,8 @@ Danbooru.Note = { create: function(id) { var $note_body = $(''); $note_body.addClass("note-body"); - $note_body.data("id", id); - $note_body.attr("data-id", id); + $note_body.data("id", String(id)); + $note_body.attr("data-id", String(id)); $note_body.hide(); Danbooru.Note.Body.bind_events($note_body); return $note_body; @@ -172,6 +173,8 @@ Danbooru.Note = { }, resize: function($note_body) { + return; + var w = $note_body.width(); var h = $note_body.height(); var golden_ratio = 1.6180339887; @@ -285,8 +288,8 @@ Danbooru.Note = { if (data.html_id) { var $note_body = Danbooru.Note.Body.find(data.html_id); var $note_box = Danbooru.Note.Box.find(data.html_id); - $note_body.data("id", data.id).attr("data-id", data.id); - $note_box.data("id", data.id).attr("data-id", data.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"); } }, @@ -436,6 +439,20 @@ Danbooru.Note = { }); Danbooru.Note.timeouts = []; + }, + + load_all: function() { + $.each($("section#notes article"), function(i, article) { + var $article = $(article); + Danbooru.Note.add( + $article.data("id"), + $article.data("x"), + $article.data("y"), + $article.data("width"), + $article.data("height"), + $article.html() + ); + }); } } @@ -454,5 +471,7 @@ $(function() { Danbooru.Note.Image.resize(); } }); + + Danbooru.Note.load_all(); } }); diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 3cbd49a9c..0807ffd7d 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -629,6 +629,10 @@ div#c-posts { color: $link_color; } } + + section#notes article { + margin-bottom: 1em; + } } } @@ -904,6 +908,8 @@ div#note-container { min-height: 1em; cursor: pointer; padding: 4px; + z-index: 1000; + overflow: auto; p.tn { font-size: 0.8em; diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 581c77b49..561b97377 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -33,7 +33,7 @@ class NotesController < ApplicationController def destroy @note = Note.find(params[:id]) - @note.destroy + @note.update_attribute(:is_active, false) respond_with(@note) end diff --git a/app/views/posts/partials/show/_notes.html.erb b/app/views/posts/partials/show/_notes.html.erb index f455db603..e88caea55 100644 --- a/app/views/posts/partials/show/_notes.html.erb +++ b/app/views/posts/partials/show/_notes.html.erb @@ -1,3 +1,3 @@ <% notes.each do |note| %> - <%= content_tag(:article, "", "data-width" => note.width, "data-height" => note.height, "data-x" => note.x, "data-y" => note.y, "data-body" => note.body) %> + <%= content_tag(:article, "", "data-width" => note.width, "data-height" => note.height, "data-x" => note.x, "data-y" => note.y, "data-body" => note.body, "data-id" => note.id) %> <% end %>