change story downvoting to be called "flag", but still count as a downvote

been in production for a while
This commit is contained in:
joshua stein 2014-07-02 10:04:48 -05:00
parent 6174573fbe
commit 452c75908d
3 changed files with 29 additions and 15 deletions

View file

@ -7,7 +7,7 @@
var _Lobsters = Class.extend({ var _Lobsters = Class.extend({
curUser: null, curUser: null,
storyDownvoteReasons: { <%= Vote::STORY_REASONS.map{|k,v| storyFlagReasons: { <%= Vote::STORY_REASONS.map{|k,v|
"#{k.inspect}: #{v.inspect}" }.join(", ") %> }, "#{k.inspect}: #{v.inspect}" }.join(", ") %> },
commentDownvoteReasons: { <%= Vote::COMMENT_REASONS.map{|k,v| commentDownvoteReasons: { <%= Vote::COMMENT_REASONS.map{|k,v|
"#{k.inspect}: #{v.inspect}" }.join(", ") %> }, "#{k.inspect}: #{v.inspect}" }.join(", ") %> },
@ -15,7 +15,7 @@ var _Lobsters = Class.extend({
upvoteStory: function(voterEl) { upvoteStory: function(voterEl) {
Lobsters.vote("story", voterEl, 1); Lobsters.vote("story", voterEl, 1);
}, },
downvoteStory: function(voterEl) { flagStory: function(voterEl) {
Lobsters._showDownvoteWhyAt("story", voterEl, function(k) { Lobsters._showDownvoteWhyAt("story", voterEl, function(k) {
Lobsters.vote("story", voterEl, -1, k); }); Lobsters.vote("story", voterEl, -1, k); });
}, },
@ -30,7 +30,8 @@ var _Lobsters = Class.extend({
act = "unhide"; act = "unhide";
li.removeClass("hidden"); li.removeClass("hidden");
hiderEl.innerHTML = "hide"; hiderEl.innerHTML = "hide";
} else { }
else {
act = "hide"; act = "hide";
li.addClass("hidden"); li.addClass("hidden");
hiderEl.innerHTML = "unhide"; hiderEl.innerHTML = "unhide";
@ -75,7 +76,7 @@ var _Lobsters = Class.extend({
if (thingType == "comment") if (thingType == "comment")
reasons = Lobsters.commentDownvoteReasons; reasons = Lobsters.commentDownvoteReasons;
else else
reasons = Lobsters.storyDownvoteReasons; reasons = Lobsters.storyFlagReasons;
$.each(reasons, function(k, v) { $.each(reasons, function(k, v) {
var a = $("<a href=\"#\"" + (k == "" ? " class=\"cancelreason\"" : "") + var a = $("<a href=\"#\"" + (k == "" ? " class=\"cancelreason\"" : "") +
@ -103,6 +104,10 @@ var _Lobsters = Class.extend({
of: $(voterEl), of: $(voterEl),
collision: "none", collision: "none",
}); });
/* XXX: why is this needed? */
if (thingType == "story")
d.css("left", $(voterEl).position().left);
}, },
vote: function(thingType, voterEl, point, reason) { vote: function(thingType, voterEl, point, reason) {
@ -147,11 +152,17 @@ var _Lobsters = Class.extend({
scoreDiv.innerHTML = score; scoreDiv.innerHTML = score;
if (action == "upvote" || action == "unvote") if (action == "upvote" || action == "unvote") {
li.find(".reason").html(""); li.find(".reason").html("");
if (action == "unvote" && thingType == "story" && point < 0)
li.find(".flagger").text("flag");
}
else if (action == "downvote" && thingType == "comment") else if (action == "downvote" && thingType == "comment")
li.find(".reason").html("(" + li.find(".reason").html("| " +
Lobsters.commentDownvoteReasons[reason].toLowerCase() + ")"); Lobsters.commentDownvoteReasons[reason].toLowerCase());
else if (action == "downvote" && thingType == "story")
li.find(".flagger").text("unflag");
$.post("/" + (thingType == "story" ? "stories" : thingType + "s") + "/" + $.post("/" + (thingType == "story" ? "stories" : thingType + "s") + "/" +
li.attr("data-shortid") + "/" + li.attr("data-shortid") + "/" +
@ -253,8 +264,8 @@ $(document).ready(function() {
return false; return false;
}); });
$("li.story a.downvoter").click(function() { $("li.story a.flagger").click(function() {
Lobsters.downvoteStory(this); Lobsters.flagStory(this);
return false; return false;
}); });
$("li.story a.upvoter").click(function() { $("li.story a.upvoter").click(function() {

View file

@ -371,7 +371,7 @@ ol.search_results li.story {
div.voters { div.voters {
float: left; float: left;
margin-top: -4px; margin-top: 0px;
width: 40px; width: 40px;
} }
@ -383,6 +383,11 @@ div.voters div.score {
text-align: center; text-align: center;
} }
li.story div.voters div.score {
font-size: 9.5pt;
margin-top: 2px;
}
div.voters .upvoter, div.voters .upvoter,
div.voters .downvoter { div.voters .downvoter {
border-color: transparent transparent #bbb transparent; border-color: transparent transparent #bbb transparent;

View file

@ -10,11 +10,6 @@ class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ?
<%= link_to "", login_url, :class => "upvoter" %> <%= link_to "", login_url, :class => "upvoter" %>
<% end %> <% end %>
<div class="score"><%= story.score %></div> <div class="score"><%= story.score %></div>
<% if @user && @user.can_downvote?(story) %>
<a class="downvoter"></a>
<% else %>
<span class="downvoter downvoter_stub"></span>
<% end %>
</div> </div>
<div class="details"> <div class="details">
<span class="link"> <span class="link">
@ -88,6 +83,9 @@ class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ?
<% end %> <% end %>
<% end %> <% end %>
<% if !story.is_gone? && @user %> <% if !story.is_gone? && @user %>
<% if @user && @user.can_downvote?(story) %>
| <a class="flagger">flag</a>
<% end %>
<% if story.vote == 0 %> <% if story.vote == 0 %>
| <%= link_to "unhide", story_unhide_url(story.short_id), | <%= link_to "unhide", story_unhide_url(story.short_id),
:class => "hider" %> :class => "hider" %>