diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index 2ba3c2320..fc303a44f 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -23,6 +23,7 @@ this.initialize_post_image_resize_links(); this.initialize_post_image_resize_to_window_link(); this.initialize_similar(); + this.initialize_replace_image_dialog(); if (Danbooru.meta("always-resize-images") === "true") { $("#image-resize-to-window-link").click(); @@ -606,6 +607,32 @@ e.preventDefault(); }); } + + Danbooru.Post.initialize_replace_image_dialog = function() { + $("#replace-image-dialog").dialog({ + autoOpen: false, + width: 700, + modal: true, + buttons: { + "Submit": function() { + $("#replace-image-dialog form").submit(); + $(this).dialog("close"); + }, + "Cancel": function() { + $(this).dialog("close"); + } + } + }); + + $('#replace-image-dialog form').submit(function() { + $('#replace-image-dialog').dialog('close'); + }); + + $("#replace-image").click(function(e) { + e.preventDefault(); + $("#replace-image-dialog").dialog("open"); + }); + }; })(); $(document).ready(function() { diff --git a/app/views/moderator/post/posts/_replace.html.erb b/app/views/moderator/post/posts/_replace.html.erb new file mode 100644 index 000000000..7b43d6e0c --- /dev/null +++ b/app/views/moderator/post/posts/_replace.html.erb @@ -0,0 +1,11 @@ +<%= simple_form_for(@post, url: replace_moderator_post_post_path, method: :post) do |f| %> +
+ Delete the current image and replace it with another one, keeping + everything else in the post intact. This is meant for upgrading + lower-quality images, such as image samples, to higher-quality versions. +
+ + <%= f.input :source, label: "New Source", input_html: { value: "" } %> +<% end %> diff --git a/app/views/moderator/post/posts/replace.html.erb b/app/views/moderator/post/posts/replace.html.erb new file mode 100644 index 000000000..3ef8b5d68 --- /dev/null +++ b/app/views/moderator/post/posts/replace.html.erb @@ -0,0 +1,5 @@ +