[Posts] Change the way JS is initialized on the post deletion page

This commit is contained in:
bitWolfy 2021-10-17 09:31:26 -07:00
parent c70ed04e40
commit e5a19272bd
2 changed files with 53 additions and 51 deletions

View File

@ -51,4 +51,9 @@ PostDeletion.init = function() {
});
}
$(function() {
if($("div#c-confirm-delete").length)
Danbooru.PostDeletion.init();
});
export default PostDeletion

View File

@ -1,62 +1,59 @@
<h1>Delete Post</h1>
<div id="c-confirm-delete">
<h1>Delete Post</h1>
<div>
<%= PostPresenter.preview(@post, tags: "status:any", no_blacklist: true) %>
</div>
<%= form_tag(delete_moderator_post_post_path, :style => "clear: both;", :class => "simple_form") do %>
<div class="input">
<label for="reason">Reason</label>
<%= text_field_tag "reason", @reason %>
<div>
<%= PostPresenter.preview(@post, tags: "status:any", no_blacklist: true) %>
</div>
<% if @post.parent_id %>
<div class="post_delete_options">
<%= PostPresenter.preview(@post.parent, tags: 'status:any', no_blacklist: true) %>
<div class="input">
<label for="move_favorites">
<%= check_box_tag "move_favorites", true, true %>
Move favorites to parent?
</label>
<label for="copy_tags">
<%= check_box_tag "copy_tags", false, false %>
Merge tags into parent?
</label>
<label for="copy_sources">
<%= check_box_tag "copy_sources", false, false %>
Merge sources into parent?
</label>
</div>
<%= form_tag(delete_moderator_post_post_path, :style => "clear: both;", :class => "simple_form") do %>
<div class="input">
<label for="reason">Reason</label>
<%= text_field_tag "reason", @reason %>
</div>
<% if @post.parent_id %>
<div class="post_delete_options">
<%= PostPresenter.preview(@post.parent, tags: 'status:any', no_blacklist: true) %>
<div class="input">
<label for="move_favorites">
<%= check_box_tag "move_favorites", true, true %>
Move favorites to parent?
</label>
<label for="copy_tags">
<%= check_box_tag "copy_tags", false, false %>
Merge tags into parent?
</label>
<label for="copy_sources">
<%= check_box_tag "copy_sources", false, false %>
Merge sources into parent?
</label>
</div>
</div>
<% end %>
<%= submit_tag "Delete" %>
<%= submit_tag "Cancel" %>
<%= button_tag "Clear", :type => "button", :id => "delreason-clear" %>
<% end %>
<%= submit_tag "Delete" %>
<%= submit_tag "Cancel" %>
<%= button_tag "Clear", :type => "button", :id => "delreason-clear" %>
<% end %>
<div id="delreason-prebuilt" class="simple_form">
<b>Reason</b>
<% Danbooru.config.deletion_reasons.each do |deletion_reason| %>
<% if deletion_reason.nil? || deletion_reason.empty? %>
<br />
<% else %>
<a class="button delreason-button" data-text="<%= deletion_reason.gsub(/%(PARENT|OTHER)_ID%/, "%ID%") %>">
<%= deletion_reason
.gsub("%PARENT_ID%", "<input type=\"text\" value=\"" + (@post.parent_id || "").to_s + "\" />")
.gsub("%OTHER_ID%", "<input type=\"text\" />")
.html_safe
%>
</a>
<% end %>
<% end %>
<div id="delreason-prebuilt" class="simple_form">
<b>Reason</b>
<% Danbooru.config.deletion_reasons.each do |deletion_reason| %>
<% if deletion_reason.nil? || deletion_reason.empty? %>
<br />
<% else %>
<a class="button delreason-button" data-text="<%= deletion_reason.gsub(/%(PARENT|OTHER)_ID%/, "%ID%") %>">
<%= deletion_reason
.gsub("%PARENT_ID%", "<input type=\"text\" value=\"" + (@post.parent_id || "").to_s + "\" />")
.gsub("%OTHER_ID%", "<input type=\"text\" />")
.html_safe
%>
</a>
<% end %>
<% end %>
</div>
</div>
<div id="deletion-reason-suggestions"></div>
<%= javascript_tag nonce: true do -%>
Danbooru.PostDeletion.init();
<% end -%>
<% content_for(:page_title) do %>
Delete Post - #<%= @post.id %>
<% end %>