implemented javascripts for approval/disapproval/unapproval from post/show page

This commit is contained in:
albert
2011-02-10 19:08:23 -05:00
parent 00ea319743
commit 33f5350677
19 changed files with 234 additions and 17 deletions

View File

@@ -0,0 +1,2 @@
Danbooru.Utility.j_error(<%= @exception.message.to_json.html_safe %>);
$("img#approve-wait").hide();

View File

@@ -0,0 +1,4 @@
$("a#approve").hide();
$("a#disapprove").hide();
$("a#unapprove").show();
$("img#approve-wait").hide();

View File

@@ -0,0 +1,2 @@
Danbooru.Utility.j_error("You have already disapproved this post");
$("img#disapprove-wait").hide();

View File

@@ -0,0 +1,4 @@
$("a#approve").hide();
$("a#disapprove").hide();
$("a#unapprove").hide();
$("img#disapprove-wait").hide();

View File

@@ -1,16 +1,12 @@
<ul>
<%= resize_image_links(post, CurrentUser.user) %>
<li><%= link_to "Favorite", "#", :id => "add-to-favorites" %> <img src="/images/wait.gif" style="display: none;" id="add-to-favorites-wait"></li>
<li><%= link_to "Unfavorite", "#", :id => "remove-from-favorites" %> <img src="/images/wait.gif" style="display: none;" id="remove-from-favorites-wait"></li>
<li><%= link_to "Favorite", "#", :id => "add-to-favorites" %> <%= wait_image("add-to-favorites-wait") %></li>
<li><%= link_to "Unfavorite", "#", :id => "remove-from-favorites" %> <%= wait_image("remove-from-favorites-wait") %></li>
<li><%= link_to "Translate", "#" %></li>
<% if !post.is_flagged? %>
<li><%= link_to "Unapprove", new_unapproval_path(:post_id => post.id), :id => "unapprove" %></li>
<% end %>
<li><%= link_to "Unapprove", new_unapproval_path(:post_id => post.id), :id => "unapprove" %></li>
<% if CurrentUser.is_janitor? %>
<% if post.is_pending? || post.is_flagged? %>
<li><%= link_to "Approve", "#", :id => "approve" %> <img src="/images/wait.gif" style="display: none;" id="approve-wait"></li>
<li><%= link_to "Disapprove", "#", :id => "disapprove" %> <img src="/images/wait.gif" style="display: none;" id="disapprove-wait"></li>
<% end %>
<li><%= link_to "Approve", "#", :id => "approve" %> <%= wait_image("approve-wait") %></li>
<li><%= link_to "Disapprove", "#", :id => "disapprove" %> <%= wait_image("disapprove-wait") %></li>
<% end %>
<% if CurrentUser.is_moderator? %>
<% if post.is_removed? %>

View File

@@ -68,6 +68,7 @@
<meta name="pools" content="<%= @post.pool_string %>">
<meta name="post-id" content="<%= @post.id %>">
<meta name="post-is-unapprovable" content="<%= @post.is_unapprovable? %>">
<meta name="post-is-approvable" content="<%= @post.is_approvable? %>">
<% end %>
<%= render :partial => "posts/partials/common/secondary_links" %>

View File

@@ -0,0 +1,9 @@
var errors = <%= @unapproval.errors.full_messages.to_json.html_safe %>;
if (errors.length > 0) {
Danbooru.Utility.j_error(errors.join("; "));
} else {
Danbooru.Utility.j_alert("Unapproval", "Unapproval successful");
$("a#approve").show();
$("a#disapprove").show();
$("a#unapprove").hide();
}

View File

@@ -1,4 +1,5 @@
<p>You can unapprove a post if you believe it breaks the rules or doesn't belong on this site. You must provide a reason.</p>
<%= form_for(@unapproval) do |f| %>
<%= form_for(@unapproval, :remote => true, :format => :js) do |f| %>
<%= hidden_field_tag "unapproval[post_id]", @unapproval.post_id %>
<%= f.text_area :reason, :size => "40x5" %>
<% end %>