diff --git a/app/controllers/post_appeals_controller.rb b/app/controllers/post_appeals_controller.rb
index 18a14494b..116c94030 100644
--- a/app/controllers/post_appeals_controller.rb
+++ b/app/controllers/post_appeals_controller.rb
@@ -3,7 +3,7 @@ class PostAppealsController < ApplicationController
respond_to :html, :xml, :json, :js
def new
- @post_appeal = PostAppeal.new
+ @post_appeal = PostAppeal.new(post_appeal_params)
respond_with(@post_appeal)
end
diff --git a/app/controllers/post_flags_controller.rb b/app/controllers/post_flags_controller.rb
index b80bad83b..b64a729e5 100644
--- a/app/controllers/post_flags_controller.rb
+++ b/app/controllers/post_flags_controller.rb
@@ -3,7 +3,7 @@ class PostFlagsController < ApplicationController
respond_to :html, :xml, :json, :js
def new
- @post_flag = PostFlag.new
+ @post_flag = PostFlag.new(post_flag_params)
respond_with(@post_flag)
end
diff --git a/app/controllers/post_replacements_controller.rb b/app/controllers/post_replacements_controller.rb
index c83fd7c8b..8327b2a5e 100644
--- a/app/controllers/post_replacements_controller.rb
+++ b/app/controllers/post_replacements_controller.rb
@@ -1,9 +1,10 @@
class PostReplacementsController < ApplicationController
- respond_to :html, :xml, :json
+ respond_to :html, :xml, :json, :js
before_action :moderator_only, except: [:index]
def new
- @post = Post.find(params[:post_id])
+ @post_replacement = Post.find(params[:post_id]).replacements.new
+ respond_with(@post_replacement)
end
def create
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 01ef84c76..3e9fd8e62 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -23,9 +23,7 @@ class PostsController < ApplicationController
def show
@post = Post.find(params[:id])
- @post_flag = PostFlag.new(:post_id => @post.id)
- @post_appeal = PostAppeal.new(:post_id => @post.id)
-
+
include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children?
@parent_post_set = PostSets::PostRelationship.new(@post.parent_id, :include_deleted => include_deleted)
@children_post_set = PostSets::PostRelationship.new(@post.id, :include_deleted => include_deleted)
diff --git a/app/javascript/src/javascripts/post_appeals.js b/app/javascript/src/javascripts/post_appeals.js
deleted file mode 100644
index 814c18343..000000000
--- a/app/javascript/src/javascripts/post_appeals.js
+++ /dev/null
@@ -1,35 +0,0 @@
-let PostAppeal = {};
-
-PostAppeal.initialize_all = function() {
- if ($("#c-posts").length && $("#a-show").length) {
- this.initialize_appeal();
- }
-}
-
-PostAppeal.initialize_appeal = function() {
- $("#appeal-dialog").dialog({
- autoOpen: false,
- width: 700,
- modal: true,
- buttons: {
- "Submit": function() {
- $("#appeal-dialog form").submit();
- $(this).dialog("close");
- },
- "Cancel": function() {
- $(this).dialog("close");
- }
- }
- });
-
- $("#appeal").on("click.danbooru", function(e) {
- e.preventDefault();
- $("#appeal-dialog").dialog("open");
- });
-}
-
-$(document).ready(function() {
- PostAppeal.initialize_all();
-});
-
-export default PostAppeal
diff --git a/app/javascript/src/javascripts/post_flags.js b/app/javascript/src/javascripts/post_flags.js
deleted file mode 100644
index 27f4d56d3..000000000
--- a/app/javascript/src/javascripts/post_flags.js
+++ /dev/null
@@ -1,39 +0,0 @@
-let PostFlag = {};
-
-PostFlag.initialize_all = function() {
- if ($("#c-posts").length && $("#a-show").length) {
- this.initialize_flag();
- }
-}
-
-PostFlag.initialize_flag = function() {
- $("#flag-dialog").dialog({
- autoOpen: false,
- width: 700,
- modal: true,
- buttons: {
- "Submit": function() {
- $("#flag-dialog form").submit();
- $(this).dialog("close");
- },
- "Cancel": function() {
- $(this).dialog("close");
- }
- }
- });
-
- $('#flag-dialog form').submit(function() {
- $('#flag-dialog').dialog('close');
- });
-
- $("#flag").on("click.danbooru", function(e) {
- e.preventDefault();
- $("#flag-dialog").dialog("open");
- });
-}
-
-$(function() {
- PostFlag.initialize_all();
-});
-
-export default PostFlag
diff --git a/app/javascript/src/javascripts/posts.js.erb b/app/javascript/src/javascripts/posts.js.erb
index 9a1eb4b96..795c23e87 100644
--- a/app/javascript/src/javascripts/posts.js.erb
+++ b/app/javascript/src/javascripts/posts.js.erb
@@ -31,7 +31,6 @@ Post.initialize_all = function() {
this.initialize_post_image_resize_links();
this.initialize_post_image_resize_to_window_link();
this.initialize_similar();
- this.initialize_replace_image_dialog();
this.initialize_gestures();
if ((Utility.meta("always-resize-images") === "true") || (Utility.meta("viewport") && (window.screen.width <= 660))) {
@@ -616,32 +615,6 @@ Post.initialize_saved_searches = function() {
});
}
-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").on("click.danbooru", function(e) {
- e.preventDefault();
- $("#replace-image-dialog").dialog("open");
- });
-};
-
$(document).ready(function() {
Post.initialize_all();
});
diff --git a/app/javascript/src/javascripts/utility.js b/app/javascript/src/javascripts/utility.js
index 35ade85ec..802855e17 100644
--- a/app/javascript/src/javascripts/utility.js
+++ b/app/javascript/src/javascripts/utility.js
@@ -36,6 +36,31 @@ Utility.error = function(msg) {
}
}
+Utility.dialog = function(title, html) {
+ const $dialog = $(html).dialog({
+ title: title,
+ width: 700,
+ modal: true,
+ close: function() {
+ // Defer removing the dialog to avoid detaching the
diff --git a/app/views/post_appeals/_new.html.erb b/app/views/post_appeals/_new.html.erb
index c06e3705f..b652c1d08 100644
--- a/app/views/post_appeals/_new.html.erb
+++ b/app/views/post_appeals/_new.html.erb
@@ -1,9 +1,13 @@
-<%= format_text(WikiPage.titled(Danbooru.config.appeal_notice_wiki_page).first.try(&:body)) %>
+
+
+ <%= format_text(WikiPage.titled(Danbooru.config.appeal_notice_wiki_page).first.try(&:body)) %>
+
-<%# XXX dtext_field expects there to be a `post_appeal` instance variable. %>
-<% @post_appeal = post_appeal %>
-<%= simple_form_for(@post_appeal, format: :js, remote: true) do |f| %>
- <%= f.hidden_field :post_id %>
- <%= dtext_field "post_appeal", "reason", preview_id: "dtext-preview-for-post-appeal" %>
- <%= dtext_preview_button "post_appeal", "reason", preview_id: "dtext-preview-for-post-appeal" %>
-<% end %>
+ <%# XXX dtext_field expects there to be a `post_appeal` instance variable. %>
+ <% @post_appeal = post_appeal %>
+ <%= simple_form_for(@post_appeal, format: :js, remote: true) do |f| %>
+ <%= f.hidden_field :post_id %>
+ <%= dtext_field "post_appeal", "reason", preview_id: "dtext-preview-for-post-appeal", type: "string" %>
+ <%= dtext_preview_button "post_appeal", "reason", preview_id: "dtext-preview-for-post-appeal" %>
+ <% end %>
+
diff --git a/app/views/post_appeals/new.js.erb b/app/views/post_appeals/new.js.erb
new file mode 100644
index 000000000..f03b42d35
--- /dev/null
+++ b/app/views/post_appeals/new.js.erb
@@ -0,0 +1 @@
+Danbooru.Utility.dialog("Appeal post", "<%= j render "post_appeals/new", post_appeal: @post_appeal %>");
diff --git a/app/views/post_flags/_new.html.erb b/app/views/post_flags/_new.html.erb
index da735b3b7..280be9949 100644
--- a/app/views/post_flags/_new.html.erb
+++ b/app/views/post_flags/_new.html.erb
@@ -1,9 +1,13 @@
-<%= format_text(WikiPage.titled(Danbooru.config.flag_notice_wiki_page).first.try(&:body)) %>
+
+
+ <%= format_text(WikiPage.titled(Danbooru.config.flag_notice_wiki_page).first.try(&:body)) %>
+
-<%# XXX dtext_field expects there to be a `post_flag` instance variable. %>
-<% @post_flag = post_flag %>
-<%= simple_form_for(@post_flag, format: :js, remote: true) do |f| %>
- <%= f.hidden_field :post_id %>
- <%= dtext_field "post_flag", "reason", preview_id: "dtext-preview-for-post-flag", type: "string" %>
- <%= dtext_preview_button "post_flag", "reason", preview_id: "dtext-preview-for-post-flag" %>
-<% end %>
+ <%# XXX dtext_field expects there to be a `post_flag` instance variable. %>
+ <% @post_flag = post_flag %>
+ <%= simple_form_for(@post_flag, format: :js, remote: true) do |f| %>
+ <%= f.hidden_field :post_id %>
+ <%= dtext_field "post_flag", "reason", preview_id: "dtext-preview-for-post-flag", type: "string" %>
+ <%= dtext_preview_button "post_flag", "reason", preview_id: "dtext-preview-for-post-flag" %>
+ <% end %>
+
diff --git a/app/views/post_flags/new.js.erb b/app/views/post_flags/new.js.erb
new file mode 100644
index 000000000..ec1517cf3
--- /dev/null
+++ b/app/views/post_flags/new.js.erb
@@ -0,0 +1 @@
+Danbooru.Utility.dialog("Flag post", "<%= j render "post_flags/new", post_flag: @post_flag %>");
diff --git a/app/views/post_replacements/_new.html.erb b/app/views/post_replacements/_new.html.erb
index dce3540cb..6cd800187 100644
--- a/app/views/post_replacements/_new.html.erb
+++ b/app/views/post_replacements/_new.html.erb
@@ -1,8 +1,12 @@
-<%= format_text(WikiPage.titled(Danbooru.config.replacement_notice_wiki_page).first.try(&:body)) %>
+
+
+ <%= format_text(WikiPage.titled(Danbooru.config.replacement_notice_wiki_page).first.try(&:body)) %>
+
-<%= simple_form_for(post_replacement, url: post_replacements_path(post_id: post_replacement.post_id), method: :post) do |f| %>
- <%= f.input :replacement_file, label: "File", as: :file %>
- <%= f.input :replacement_url, label: "Replacement URL", hint: "The source URL to download the replacement from.", as: :string, input_html: { value: post_replacement.post.normalized_source } %>
- <%= f.input :final_source, label: "Final Source", hint: "If present, the source field will be changed to this after replacement.", as: :string, input_html: { value: post_replacement.post.source } %>
- <%= f.input :tags, label: "Tags", as: :text, input_html: { value: post_replacement.suggested_tags_for_removal, data: { autocomplete: "tag-edit" } } %>
-<% end %>
+ <%= simple_form_for(post_replacement, url: post_replacements_path(post_id: post_replacement.post_id), method: :post) do |f| %>
+ <%= f.input :replacement_file, label: "File", as: :file %>
+ <%= f.input :replacement_url, label: "Replacement URL", hint: "The source URL to download the replacement from.", as: :string, input_html: { value: post_replacement.post.normalized_source } %>
+ <%= f.input :final_source, label: "Final Source", hint: "If present, the source field will be changed to this after replacement.", as: :string, input_html: { value: post_replacement.post.source } %>
+ <%= f.input :tags, label: "Tags", as: :string, input_html: { value: post_replacement.suggested_tags_for_removal, data: { autocomplete: "tag-edit" } } %>
+ <% end %>
+
diff --git a/app/views/post_replacements/new.html.erb b/app/views/post_replacements/new.html.erb
index 6286252b2..dace2eaa4 100644
--- a/app/views/post_replacements/new.html.erb
+++ b/app/views/post_replacements/new.html.erb
@@ -1,5 +1,5 @@
- <%= render "new", post_replacement: @post.replacements.new %>
+ <%= render "new", post_replacement: @post_replacement %>
diff --git a/app/views/post_replacements/new.js.erb b/app/views/post_replacements/new.js.erb
new file mode 100644
index 000000000..6a6943ff1
--- /dev/null
+++ b/app/views/post_replacements/new.js.erb
@@ -0,0 +1 @@
+Danbooru.Utility.dialog("Replace image", "<%= j render "post_replacements/new", post_replacement: @post_replacement %>");
diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb
index 59545f93b..15352e1c0 100644
--- a/app/views/posts/partials/show/_options.html.erb
+++ b/app/views/posts/partials/show/_options.html.erb
@@ -22,9 +22,9 @@
Status locked
<% else %>
<% if !post.is_deleted? && !post.is_pending? && !post.is_flagged? %>
- <%= link_to "Flag", new_post_flag_path(:post_id => post.id), :id => "flag" %>
+ <%= link_to "Flag", new_post_flag_path(post_flag: { post_id: post.id }), id: "flag", remote: true %>
<% elsif post.is_flagged? || post.is_deleted? %>
- <%= link_to "Appeal", new_post_appeal_path(:post_id => post.id), :id => "appeal" %>
+ <%= link_to "Appeal", new_post_appeal_path(post_appeal: { post_id: post.id }), id: "appeal", remote: true %>
<% end %>
<% if CurrentUser.can_approve_posts? %>
@@ -53,7 +53,7 @@
<% end %>
<% if CurrentUser.is_moderator? %>
- <%= link_to "Replace Image", new_post_replacement_path(:post_id => post.id), :id => "replace-image" %>
+ <%= link_to "Replace Image", new_post_replacement_path(post_id: post.id), id: "replace-image", remote: true %>
<%= link_to "Down vote report", reports_down_voting_post_path(post_id: post.id) %>
<% end %>
<% end %>
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb
index 1388db82f..a6b15d4a1 100644
--- a/app/views/posts/show.html.erb
+++ b/app/views/posts/show.html.erb
@@ -135,18 +135,6 @@
-
- <%= render "post_flags/new", post_flag: @post.flags.new %>
-
-
-
- <%= render "post_appeals/new", post_appeal: @post.appeals.new %>
-
-
-
- <%= render "post_replacements/new", post_replacement: @post.replacements.new %>
-
-
<%= render "pool_elements/new" %>