Merge branch 'inline-editable-posts'
This commit is contained in:
@@ -6,6 +6,10 @@
|
|||||||
this.initialize_response_link();
|
this.initialize_response_link();
|
||||||
this.initialize_reply_links();
|
this.initialize_reply_links();
|
||||||
this.initialize_expand_links();
|
this.initialize_expand_links();
|
||||||
|
|
||||||
|
if (!$("#a-edit").length) {
|
||||||
|
this.initialize_edit_links();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#c-posts").length && $("#a-show").length) {
|
if ($("#c-posts").length && $("#a-show").length) {
|
||||||
@@ -63,6 +67,16 @@
|
|||||||
$("div.new-comment form").hide();
|
$("div.new-comment form").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Danbooru.Comment.initialize_edit_links = function() {
|
||||||
|
$(".edit_comment").hide();
|
||||||
|
$(".edit_comment_link").click(function(e) {
|
||||||
|
var link_id = $(this).attr("id");
|
||||||
|
var comment_id = link_id.match(/^edit_comment_link_(\d+)$/)[1];
|
||||||
|
$("#edit_comment_" + comment_id).fadeToggle("fast");
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Danbooru.Comment.highlight_threshold_comments = function(post_id) {
|
Danbooru.Comment.highlight_threshold_comments = function(post_id) {
|
||||||
var threshold = parseInt(Danbooru.meta("user-comment-threshold"));
|
var threshold = parseInt(Danbooru.meta("user-comment-threshold"));
|
||||||
var articles = $("article.comment[data-post-id=" + post_id + "]");
|
var articles = $("article.comment[data-post-id=" + post_id + "]");
|
||||||
|
|||||||
31
app/assets/javascripts/forum_posts.js
Normal file
31
app/assets/javascripts/forum_posts.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
(function() {
|
||||||
|
Danbooru.ForumPost = {};
|
||||||
|
|
||||||
|
Danbooru.ForumPost.initialize_all = function() {
|
||||||
|
if ($("#c-forum-topics").length && $("#a-show").length) {;
|
||||||
|
this.initialize_edit_links();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Danbooru.ForumPost.initialize_edit_links = function() {
|
||||||
|
$(".edit_forum_post, .edit_forum_topic").hide();
|
||||||
|
|
||||||
|
$(".edit_forum_post_link").click(function(e) {
|
||||||
|
var link_id = $(this).attr("id");
|
||||||
|
var forum_post_id = link_id.match(/^edit_forum_post_link_(\d+)$/)[1];
|
||||||
|
$("#edit_forum_post_" + forum_post_id).fadeToggle("fast");
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".edit_forum_topic_link").click(function(e) {
|
||||||
|
var link_id = $(this).attr("id");
|
||||||
|
var forum_topic_id = link_id.match(/^edit_forum_topic_link_(\d+)$/)[1];
|
||||||
|
$("#edit_forum_topic_" + forum_topic_id).fadeToggle("fast");
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
Danbooru.ForumPost.initialize_all();
|
||||||
|
});
|
||||||
5
app/views/comments/_form.html.erb
Normal file
5
app/views/comments/_form.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<%= simple_form_for(comment) do |f| %>
|
||||||
|
<%= dtext_field "comment", "body", :value => comment.body, :input_id => "comment_body_for_#{comment.id}", :preview_id => "dtext-preview-for-#{comment.id}" %>
|
||||||
|
<%= f.button :submit, "Submit" %>
|
||||||
|
<%= dtext_preview_button "comment", "body", :input_id => "comment_body_for_#{comment.id}", :preview_id => "dtext-preview-for-#{comment.id}" %>
|
||||||
|
<% end %>
|
||||||
@@ -20,12 +20,15 @@
|
|||||||
<li><%= link_to "Reply", new_comment_path(:post_id => comment.post_id), :class => "reply-link", "data-comment-id" => comment.id %></li>
|
<li><%= link_to "Reply", new_comment_path(:post_id => comment.post_id), :class => "reply-link", "data-comment-id" => comment.id %></li>
|
||||||
<% if comment.editable_by?(CurrentUser.user) %>
|
<% if comment.editable_by?(CurrentUser.user) %>
|
||||||
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Are you sure you want to delete this comment?", :method => :delete, :remote => true %></li>
|
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Are you sure you want to delete this comment?", :method => :delete, :remote => true %></li>
|
||||||
<li><%= link_to "Edit", edit_comment_path(comment.id) %></li>
|
<li><%= link_to "Edit", edit_comment_path(comment.id), :id => "edit_comment_link_#{comment.id}", :class => "edit_comment_link" %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li id="comment-vote-up-link-for-<%= comment.id %>"><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
|
<li id="comment-vote-up-link-for-<%= comment.id %>"><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
|
||||||
<li id="comment-vote-down-link-for-<%= comment.id %>"><%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %></li>
|
<li id="comment-vote-down-link-for-<%= comment.id %>"><%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
|
<% if comment.editable_by?(CurrentUser.user) %>
|
||||||
|
<%= render "comments/form", :comment => comment %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
<%= simple_form_for(forum_post) do |f| %>
|
<%= simple_form_for(forum_post) do |f| %>
|
||||||
<%= f.input :topic_id, :as => :hidden %>
|
<%= f.input :topic_id, :as => :hidden %>
|
||||||
<%= dtext_field "forum_post", "body" %>
|
<%= dtext_field "forum_post", "body", :value => forum_post.body, :input_id => "forum_post_body_for_#{forum_post.id}", :preview_id => "dtext-preview-for-#{forum_post.id}" %>
|
||||||
|
|
||||||
<%= f.button :submit, "Submit" %>
|
<%= f.button :submit, "Submit" %>
|
||||||
<%= dtext_preview_button "forum_post", "body" %>
|
<%= dtext_preview_button "forum_post", "body", :input_id => "forum_post_body_for_#{forum_post.id}", :preview_id => "dtext-preview-for-#{forum_post.id}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -32,9 +32,9 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% if forum_post.editable_by?(CurrentUser.user) %>
|
<% if forum_post.editable_by?(CurrentUser.user) %>
|
||||||
<% if forum_post.is_original_post? %>
|
<% if forum_post.is_original_post? %>
|
||||||
<li><%= link_to "Edit", edit_forum_topic_path(forum_post.topic) %></li>
|
<li><%= link_to "Edit", edit_forum_topic_path(forum_post.topic), :id => "edit_forum_topic_link_#{forum_post.topic.id}", :class => "edit_forum_topic_link" %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id) %></li>
|
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id), :id => "edit_forum_post_link_#{forum_post.id}", :class => "edit_forum_post_link" %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if params[:controller] == "forum_posts" %>
|
<% if params[:controller] == "forum_posts" %>
|
||||||
@@ -42,6 +42,13 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to "Permalink", forum_post_path(forum_post) %></li>
|
<li><%= link_to "Permalink", forum_post_path(forum_post) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if forum_post.editable_by?(CurrentUser.user) %>
|
||||||
|
<% if forum_post.is_original_post? %>
|
||||||
|
<%= render "forum_topics/form", :forum_topic => forum_post.topic %>
|
||||||
|
<% else %>
|
||||||
|
<%= render "forum_posts/form", :forum_post => forum_post %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div id="form-content">
|
<div id="form-content">
|
||||||
<%= simple_form_for(@forum_topic) do |f| %>
|
<%= simple_form_for(forum_topic) do |f| %>
|
||||||
<%= f.input :title %>
|
<%= f.input :title %>
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
@@ -8,11 +8,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= f.simple_fields_for :original_post do |pf| %>
|
<%= f.simple_fields_for :original_post do |pf| %>
|
||||||
<% if !@forum_topic.new_record? %>
|
<% if !forum_topic.new_record? %>
|
||||||
<%= hidden_field_tag "forum_topic[original_post_attributes][topic_id]", @forum_topic.id %>
|
<%= hidden_field_tag "forum_topic[original_post_attributes][topic_id]", forum_topic.id %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= dtext_field "forum_post", "body", :input_name => "forum_topic[original_post_attributes][body]", :value => @forum_topic.original_post.body %>
|
<%= dtext_field "forum_post", "body", :input_name => "forum_topic[original_post_attributes][body]", :value => forum_topic.original_post.body, :input_id => "forum_post_body_for_#{forum_topic.original_post.id}", :preview_id => "dtext-preview-for-#{forum_topic.original_post.id}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if CurrentUser.is_janitor? %>
|
<% if CurrentUser.is_janitor? %>
|
||||||
@@ -21,6 +21,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= f.button :submit, "Submit" %>
|
<%= f.button :submit, "Submit" %>
|
||||||
<%= dtext_preview_button "forum_post", "body" %>
|
<%= dtext_preview_button "forum_post", "body", :input_id => "forum_post_body_for_#{forum_topic.original_post.id}", :preview_id => "dtext-preview-for-#{forum_topic.original_post.id}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div id="a-edit">
|
<div id="a-edit">
|
||||||
<h1>Edit Forum Topic</h1>
|
<h1>Edit Forum Topic</h1>
|
||||||
|
|
||||||
<%= render "form" %>
|
<%= render "form", :forum_topic => @forum_topic %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user