From 4e841c4ea5d968cb52aaa49823f56ce6b64ad18a Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 31 Mar 2017 13:37:57 -0500 Subject: [PATCH] post replacement: add "Replace Image" dialog to post sidebar. --- app/assets/javascripts/posts.js | 27 +++++++++++++++++++ .../moderator/post/posts/_replace.html.erb | 11 ++++++++ .../moderator/post/posts/replace.html.erb | 5 ++++ .../posts/partials/show/_options.html.erb | 2 ++ app/views/posts/show.html.erb | 4 +++ 5 files changed, 49 insertions(+) create mode 100644 app/views/moderator/post/posts/_replace.html.erb create mode 100644 app/views/moderator/post/posts/replace.html.erb 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| %> +

Replace Image

+ +

+ 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 @@ +
+
+ <%= render "moderator/post/posts/replace" %> +
+
diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index 8776640a9..b047cde99 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -55,6 +55,8 @@
  • <%= link_to "Expunge", expunge_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "expunge", :data => {:confirm => "This will permanently delete this post (meaning the file will be deleted). Are you sure you want to delete this post?"} %>
  • <% end %> +
  • <%= link_to "Replace Image", replace_moderator_post_post_path(:post_id => post.id), :id => "replace-image" %>
  • +
  • <%= link_to "Mobile version", mobile_post_path(post) %>
  • <% end %> <% end %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 07e89ba36..d121e60b9 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -121,6 +121,10 @@ <%= render "post_appeals/new", post_appeal: @post.appeals.new %> + +