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

View file

@ -371,7 +371,7 @@ ol.search_results li.story {
div.voters {
float: left;
margin-top: -4px;
margin-top: 0px;
width: 40px;
}
@ -383,6 +383,11 @@ div.voters div.score {
text-align: center;
}
li.story div.voters div.score {
font-size: 9.5pt;
margin-top: 2px;
}
div.voters .upvoter,
div.voters .downvoter {
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" %>
<% end %>
<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 class="details">
<span class="link">
@ -88,6 +83,9 @@ class="story <%= story.vote == 1 ? "upvoted" : "" %> <%= story.vote == -1 ?
<% end %>
<% end %>
<% if !story.is_gone? && @user %>
<% if @user && @user.can_downvote?(story) %>
| <a class="flagger">flag</a>
<% end %>
<% if story.vote == 0 %>
| <%= link_to "unhide", story_unhide_url(story.short_id),
:class => "hider" %>