rebuilt comment tree DOM structure as valid HTML
This commit is contained in:
parent
41c9dfad5d
commit
42ce1e3b4c
|
@ -32,7 +32,7 @@ var _Lobsters = Class.extend({
|
||||||
if (!Lobsters.curUser)
|
if (!Lobsters.curUser)
|
||||||
return Lobsters.bounceToLogin();
|
return Lobsters.bounceToLogin();
|
||||||
|
|
||||||
var li = $(voterEl).parents("li").first();
|
var li = $(voterEl).closest(".story, .comment");
|
||||||
if (li.hasClass("downvoted")) {
|
if (li.hasClass("downvoted")) {
|
||||||
/* already upvoted, neutralize */
|
/* already upvoted, neutralize */
|
||||||
Lobsters.vote(thingType, voterEl, -1, null);
|
Lobsters.vote(thingType, voterEl, -1, null);
|
||||||
|
@ -91,7 +91,7 @@ var _Lobsters = Class.extend({
|
||||||
if (!Lobsters.curUser)
|
if (!Lobsters.curUser)
|
||||||
return Lobsters.bounceToLogin();
|
return Lobsters.bounceToLogin();
|
||||||
|
|
||||||
var li = $(voterEl).parents("li").first();
|
var li = $(voterEl).closest(".story, .comment");
|
||||||
var scoreDiv = li.find("div.score").get(0);
|
var scoreDiv = li.find("div.score").get(0);
|
||||||
var score = parseInt(scoreDiv.innerHTML);
|
var score = parseInt(scoreDiv.innerHTML);
|
||||||
var action = "";
|
var action = "";
|
||||||
|
@ -136,7 +136,7 @@ var _Lobsters = Class.extend({
|
||||||
Lobsters.commentDownvoteReasons[reason].toLowerCase() + ")");
|
Lobsters.commentDownvoteReasons[reason].toLowerCase() + ")");
|
||||||
|
|
||||||
$.post("/" + (thingType == "story" ? "stories" : thingType + "s") + "/" +
|
$.post("/" + (thingType == "story" ? "stories" : thingType + "s") + "/" +
|
||||||
$(voterEl).parents("li").first().attr("data-shortid") + "/" +
|
li.attr("data-shortid") + "/" +
|
||||||
action, { reason: reason });
|
action, { reason: reason });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -225,11 +225,11 @@ var _Lobsters = Class.extend({
|
||||||
var Lobsters = new _Lobsters();
|
var Lobsters = new _Lobsters();
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("li.comment a.downvoter").click(function() {
|
$(".comment a.downvoter").click(function() {
|
||||||
Lobsters.downvoteComment(this);
|
Lobsters.downvoteComment(this);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$("li.comment a.upvoter").click(function() {
|
$(".comment a.upvoter").click(function() {
|
||||||
Lobsters.upvoteComment(this);
|
Lobsters.upvoteComment(this);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -279,7 +279,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$(document).on("click", "a.comment_deletor", function() {
|
$(document).on("click", "a.comment_deletor", function() {
|
||||||
if (confirm("Are you sure you want to delete this comment?")) {
|
if (confirm("Are you sure you want to delete this comment?")) {
|
||||||
var li = $(this).parents("li.comment").first();
|
var li = $(this).closest(".comment");
|
||||||
$.post("/comments/" + $(li).attr("data-shortid") + "/delete",
|
$.post("/comments/" + $(li).attr("data-shortid") + "/delete",
|
||||||
function(d) {
|
function(d) {
|
||||||
$(li).replaceWith(d);
|
$(li).replaceWith(d);
|
||||||
|
@ -289,7 +289,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$(document).on("click", "a.comment_undeletor", function() {
|
$(document).on("click", "a.comment_undeletor", function() {
|
||||||
if (confirm("Are you sure you want to undelete this comment?")) {
|
if (confirm("Are you sure you want to undelete this comment?")) {
|
||||||
var li = $(this).parents("li.comment").first();
|
var li = $(this).closest(".comment");
|
||||||
$.post("/comments/" + $(li).attr("data-shortid") + "/undelete",
|
$.post("/comments/" + $(li).attr("data-shortid") + "/undelete",
|
||||||
function(d) {
|
function(d) {
|
||||||
$(li).replaceWith(d);
|
$(li).replaceWith(d);
|
||||||
|
|
|
@ -402,7 +402,7 @@ div.voters .downvoter {
|
||||||
}
|
}
|
||||||
|
|
||||||
div.voters .upvoter:hover,
|
div.voters .upvoter:hover,
|
||||||
li.upvoted div.voters .upvoter {
|
.upvoted div.voters .upvoter {
|
||||||
border-bottom-color: #ac130d;
|
border-bottom-color: #ac130d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ div.voters .downvoter {
|
||||||
border-top-width: 9px;
|
border-top-width: 9px;
|
||||||
}
|
}
|
||||||
div.voters .downvoter:hover,
|
div.voters .downvoter:hover,
|
||||||
li.downvoted div.voters .downvoter {
|
.downvoted div.voters .downvoter {
|
||||||
border-top-color: gray;
|
border-top-color: gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,17 +428,17 @@ div.voters .downvoter.downvoter_stub {
|
||||||
}
|
}
|
||||||
|
|
||||||
li.story,
|
li.story,
|
||||||
li.comment {
|
.comment {
|
||||||
clear: both;
|
clear: both;
|
||||||
padding-top: 0.4em;
|
padding-top: 0.4em;
|
||||||
padding-bottom: 0.4em;
|
padding-bottom: 0.4em;
|
||||||
}
|
}
|
||||||
li.comment {
|
.comment {
|
||||||
padding-top: 0.5em;
|
padding-top: 0.5em;
|
||||||
padding-bottom: 0.5em;
|
padding-bottom: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.comment a {
|
.comment a {
|
||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,21 +449,21 @@ li div.details {
|
||||||
padding-top: 0.1em;
|
padding-top: 0.1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.negative {
|
.negative {
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
color: gray !important;
|
color: gray !important;
|
||||||
}
|
}
|
||||||
li.negative_3 {
|
.negative_3 {
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
}
|
}
|
||||||
li.negative_5 {
|
.negative_5 {
|
||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
}
|
}
|
||||||
li.negative_7 {
|
.negative_7 {
|
||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.comment.highlighted {
|
.comment.highlighted {
|
||||||
background-color: #ffffbf;
|
background-color: #ffffbf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,6 +677,9 @@ div.markdown_help_label {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comment .preview {
|
||||||
|
padding-left: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
div#story_preview {
|
div#story_preview {
|
||||||
margin-top: 2em;
|
margin-top: 2em;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<li id="comment_<%= comment.short_id %>" data-shortid="<%= comment.short_id %>"
|
<div id="comment_<%= comment.short_id %>" data-shortid="<%= comment.short_id %>"
|
||||||
class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
||||||
"upvoted" : "downvoted") : "" %>
|
"upvoted" : "downvoted") : "" %>
|
||||||
<%= comment.highlighted ? "highlighted" : "" %>
|
<%= comment.highlighted ? "highlighted" : "" %>
|
||||||
|
@ -92,7 +92,7 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
|
|
||||||
<% if comment.highlighted %>
|
<% if comment.highlighted %>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<li class="comment">
|
<div class="comment comment_form_container">
|
||||||
<div class="comment_form_container">
|
|
||||||
<%= form_tag comment.new_record? ?
|
<%= form_tag comment.new_record? ?
|
||||||
"/comments/post_to/#{comment.story.short_id}" :
|
"/comments/post_to/#{comment.story.short_id}" :
|
||||||
"/comments/#{comment.short_id}/update" do |f| %>
|
"/comments/#{comment.short_id}/update" do |f| %>
|
||||||
|
@ -44,9 +43,8 @@
|
||||||
<p></p>
|
<p></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if defined?(show_comment) && show_comment.valid? %>
|
<% if defined?(show_comment) && show_comment.valid? %>
|
||||||
<ol class="comments comments1 preview">
|
<div class="preview">
|
||||||
<%= render "comments/comment", :comment => show_comment %>
|
<%= render "comments/comment", :comment => show_comment %>
|
||||||
</ol>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<ol class="comments comments1">
|
<ol class="comments comments1">
|
||||||
<% @comments.each do |comment| %>
|
<% @comments.each do |comment| %>
|
||||||
<%= render "comments/comment", :comment => comment,
|
<li><%= render "comments/comment", :comment => comment,
|
||||||
:show_story => true %>
|
:show_story => true %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
<% while subtree %>
|
<% while subtree %>
|
||||||
<% if (comment = subtree.shift) %>
|
<% if (comment = subtree.shift) %>
|
||||||
|
<li>
|
||||||
<%= render "comments/comment", :comment => comment,
|
<%= render "comments/comment", :comment => comment,
|
||||||
:show_story => ancestors.empty? %>
|
:show_story => ancestors.empty? %>
|
||||||
|
|
||||||
|
@ -15,10 +16,10 @@
|
||||||
<% subtree = children %>
|
<% subtree = children %>
|
||||||
<ol class="comments">
|
<ol class="comments">
|
||||||
<% else %>
|
<% else %>
|
||||||
<ol class="comments"></ol>
|
<ol class="comments"></ol></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif (subtree = ancestors.pop) %>
|
<% elsif (subtree = ancestors.pop) %>
|
||||||
</ol>
|
</ol></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
|
@ -62,9 +62,8 @@
|
||||||
<%= render :partial => "stories/listdetail",
|
<%= render :partial => "stories/listdetail",
|
||||||
:locals => { :story => res } %>
|
:locals => { :story => res } %>
|
||||||
<% elsif res.class == Comment %>
|
<% elsif res.class == Comment %>
|
||||||
<%= render :partial => "comments/comment",
|
<li><%= render "comments/comment", :comment => res,
|
||||||
:locals => { :comment => res,
|
:show_story => true, :hide_voters => true %></li>
|
||||||
:show_story => true, :hide_voters => true } %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
<ol class="comments comments1">
|
<ol class="comments comments1">
|
||||||
<% if @user && !@story.is_gone? && !@story.previewing %>
|
<% if @user && !@story.is_gone? && !@story.previewing %>
|
||||||
<%= render "comments/commentbox", :comment => @comment %>
|
<li><%= render "comments/commentbox", :comment => @comment %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% comments_by_parent = @comments.group_by(&:parent_comment_id) %>
|
<% comments_by_parent = @comments.group_by(&:parent_comment_id) %>
|
||||||
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
<% while subtree %>
|
<% while subtree %>
|
||||||
<% if (comment = subtree.shift) %>
|
<% if (comment = subtree.shift) %>
|
||||||
|
<li>
|
||||||
<%= render "comments/comment", :comment => comment %>
|
<%= render "comments/comment", :comment => comment %>
|
||||||
|
|
||||||
<% if (children = comments_by_parent[comment.id]) %>
|
<% if (children = comments_by_parent[comment.id]) %>
|
||||||
|
@ -29,10 +30,10 @@
|
||||||
<% subtree = children %>
|
<% subtree = children %>
|
||||||
<ol class="comments">
|
<ol class="comments">
|
||||||
<% else %>
|
<% else %>
|
||||||
<ol class="comments"></ol>
|
<ol class="comments"></ol></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif (subtree = ancestors.pop) %>
|
<% elsif (subtree = ancestors.pop) %>
|
||||||
</ol>
|
</ol></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
Loading…
Reference in a new issue