From 3880fbe13e1ea53f8eadf39ae8dc85568727175a Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 4 Jun 2017 10:01:00 -0500 Subject: [PATCH] /posts/$id: fix shift+O to approve shortcut. `Danbooru.Post.approve` is used for approving posts via the mode menu. It doesn't hide all the notices or the approve/disapprove/flag buttons. Click the link instead to hide those things. Click the #quick-mod-approve link instead of #approve because #approve prompts for confirmation. --- app/assets/javascripts/posts.js | 6 ++++++ app/assets/javascripts/shortcuts.js | 8 -------- app/views/posts/partials/show/_notices.html.erb | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index a54408d8f..735f4b8ec 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -174,6 +174,12 @@ e.preventDefault(); }); + if (Danbooru.meta("current-user-can-approve-posts") === "true") { + Danbooru.keydown("shift+o", "approve", function(e) { + $("#quick-mod-approve").click(); + }); + } + Danbooru.keydown("a", "prev_page", Danbooru.Post.nav_prev); Danbooru.keydown("d", "next_page", Danbooru.Post.nav_next); Danbooru.keydown("f", "favorite", Danbooru.Post.favorite); diff --git a/app/assets/javascripts/shortcuts.js b/app/assets/javascripts/shortcuts.js index ac10cbe37..86c143aaa 100644 --- a/app/assets/javascripts/shortcuts.js +++ b/app/assets/javascripts/shortcuts.js @@ -30,14 +30,6 @@ }); } - if ($("#c-posts").length && $("#a-show").length) { - Danbooru.keydown("shift+o", "approve", function(e) { - if (Danbooru.meta("current-user-can-approve-posts") === "true") { - Danbooru.Post.approve(Danbooru.meta("post-id")); - } - }); - } - if ($("#c-posts #a-index, #c-posts #a-show, #c-favorites #a-index").length) { Danbooru.keydown("r", "random", function(e) { $("#random-post")[0].click(); diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 00fa8b540..27b664184 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -43,7 +43,7 @@ <% if CurrentUser.can_approve_posts? && !post.disapproved_by?(CurrentUser.user) %>
<% unless post.is_status_locked? %> - <%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :method => :post, :remote => true, :class => "btn" %> | + <%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :id => "quick-mod-approve", :method => :post, :remote => true, :class => "btn" %> | <% end %> <%= link_to "Breaks Rules", moderator_post_disapproval_path(:post_id => post.id, :reason => "breaks_rules"), :method => :post, :remote => true, :class => "btn" %> | <%= link_to "Poor Quality", moderator_post_disapproval_path(:post_id => post.id, :reason => "poor_quality"), :method => :post, :remote => true, :class => "btn" %> |