parent
5efb4a912e
commit
c9d49c89a6
8 changed files with 40 additions and 51 deletions
|
|
@ -189,11 +189,11 @@
|
||||||
increaseReactionCount: function(bottomBar) {
|
increaseReactionCount: function(bottomBar) {
|
||||||
var toggleReactionsLink = bottomBar.find(".show-comments").first();
|
var toggleReactionsLink = bottomBar.find(".show-comments").first();
|
||||||
var count = toggleReactionsLink.text().match(/.*(\d+).*/);
|
var count = toggleReactionsLink.text().match(/.*(\d+).*/);
|
||||||
var text = "";
|
count = parseInt(count, 10);
|
||||||
|
var text = Diaspora.I18n.t("stream.comments", {count: count + 1});
|
||||||
|
|
||||||
// No previous comment
|
// No previous comment
|
||||||
if(!count){
|
if (count === 0) {
|
||||||
text = Diaspora.I18n.t("stream.reactions", {count: 1});
|
|
||||||
var parent = toggleReactionsLink.parent();
|
var parent = toggleReactionsLink.parent();
|
||||||
var postGuid = bottomBar.parents(".stream-element").data("guid");
|
var postGuid = bottomBar.parents(".stream-element").data("guid");
|
||||||
|
|
||||||
|
|
@ -204,8 +204,6 @@
|
||||||
bottomBar.removeClass("inactive").addClass("active");
|
bottomBar.removeClass("inactive").addClass("active");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
count = parseInt(count, 10) + 1;
|
|
||||||
text = Diaspora.I18n.t("stream.reactions", {count: count});
|
|
||||||
toggleReactionsLink.html(text + "<i class='entypo-chevron-up'/>");
|
toggleReactionsLink.html(text + "<i class='entypo-chevron-up'/>");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -38,29 +38,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-stats {
|
.post-stats {
|
||||||
top: -5px;
|
|
||||||
float: right;
|
float: right;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: -15px;
|
|
||||||
|
|
||||||
.count {
|
.count {
|
||||||
background-color: $background-grey;
|
line-height: 22px;
|
||||||
text-align: center;
|
margin-left: 5px;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-count-group {
|
.icon-count-group {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
|
||||||
justify-content: center;
|
|
||||||
margin: 0 7px;
|
margin: 0 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
[class^="entypo"] {
|
[class^="entypo"] {
|
||||||
color: $text-grey;
|
color: $text-grey;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
height: 28px;
|
line-height: 24px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
@ -77,21 +73,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-action {
|
.post-action {
|
||||||
height: 28px;
|
|
||||||
|
|
||||||
.disabled { color: $medium-gray; }
|
.disabled { color: $medium-gray; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-comment-switcher { padding-top: 10px; }
|
.add-comment-switcher { padding-top: 10px; }
|
||||||
|
|
||||||
&.inactive .post-stats .count,
|
&.inactive {
|
||||||
&.inactive .comment-container {
|
padding-bottom: 8px;
|
||||||
display: none;
|
|
||||||
|
.comment-container {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.stream-element .comments {
|
.stream-element .comments {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
margin-top: 10px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,20 +36,20 @@ module MobileHelper
|
||||||
link_to "", new_post_comment_path(post), class: "entypo-comment comment-action inactive"
|
link_to "", new_post_comment_path(post), class: "entypo-comment comment-action inactive"
|
||||||
end
|
end
|
||||||
|
|
||||||
def reactions_link(post, klass="")
|
def show_comments_link(post, klass="")
|
||||||
reactions_count = post.comments_count + post.likes_count
|
|
||||||
if klass == "active"
|
if klass == "active"
|
||||||
entypo_class = "entypo-chevron-up"
|
entypo_class = "entypo-chevron-up"
|
||||||
else
|
else
|
||||||
entypo_class = "entypo-chevron-down"
|
entypo_class = "entypo-chevron-down"
|
||||||
end
|
end
|
||||||
if reactions_count > 0
|
|
||||||
link_to "#{t('reactions', count: reactions_count)}<i class='#{entypo_class}'></i>".html_safe,
|
if post.comments_count > 0
|
||||||
|
link_to "#{t('admins.stats.comments', count: post.comments_count)}<i class='#{entypo_class}'></i>".html_safe,
|
||||||
post_comments_path(post, format: "mobile"),
|
post_comments_path(post, format: "mobile"),
|
||||||
class: "show-comments #{klass}"
|
class: "show-comments #{klass}"
|
||||||
else
|
else
|
||||||
html = "<span class='show-comments'>"
|
html = "<span class='show-comments'>"
|
||||||
html << "#{t('reactions', count: reactions_count)}"
|
html << t("admins.stats.comments", count: post.comments_count)
|
||||||
html << "</span>"
|
html << "</span>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@
|
||||||
= render partial: "comments/post_stats", locals: {post: post}
|
= render partial: "comments/post_stats", locals: {post: post}
|
||||||
|
|
||||||
- if defined?(expanded_info) && expanded_info
|
- if defined?(expanded_info) && expanded_info
|
||||||
!= reactions_link(post, "active")
|
!= show_comments_link(post, "active")
|
||||||
.comment-container
|
.comment-container
|
||||||
%ul.comments
|
%ul.comments
|
||||||
= render partial: "comments/comment", collection: post.comments.for_a_stream, locals: {post: post}
|
= render partial: "comments/comment", collection: post.comments.for_a_stream, locals: {post: post}
|
||||||
|
|
||||||
- else
|
- else
|
||||||
!= reactions_link(post)
|
!= show_comments_link(post)
|
||||||
|
|
||||||
.ajax-loader.hidden
|
.ajax-loader.hidden
|
||||||
.loader
|
.loader
|
||||||
|
|
|
||||||
|
|
@ -246,11 +246,6 @@ en:
|
||||||
comment: "Comment"
|
comment: "Comment"
|
||||||
commenting: "Commenting..."
|
commenting: "Commenting..."
|
||||||
|
|
||||||
reactions:
|
|
||||||
zero: "No reactions"
|
|
||||||
one: "1 reaction"
|
|
||||||
other: "%{count} reactions"
|
|
||||||
|
|
||||||
contacts:
|
contacts:
|
||||||
index:
|
index:
|
||||||
start_a_conversation: "Start a conversation"
|
start_a_conversation: "Start a conversation"
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,11 @@ en:
|
||||||
one: "<%= count %> Reshare"
|
one: "<%= count %> Reshare"
|
||||||
other: "<%= count %> Reshares"
|
other: "<%= count %> Reshares"
|
||||||
|
|
||||||
|
comments:
|
||||||
|
zero: "<%= count %> comments"
|
||||||
|
one: "<%= count %> comment"
|
||||||
|
other: "<%= count %> comments"
|
||||||
|
|
||||||
more_comments:
|
more_comments:
|
||||||
zero: "Show <%= count %> more comments"
|
zero: "Show <%= count %> more comments"
|
||||||
one: "Show <%= count %> more comment"
|
one: "Show <%= count %> more comment"
|
||||||
|
|
@ -299,11 +304,6 @@ en:
|
||||||
follow_error: "Couldn’t follow #<%= tag %> :("
|
follow_error: "Couldn’t follow #<%= tag %> :("
|
||||||
stop_following_error: "Couldn’t stop following #<%= tag %> :("
|
stop_following_error: "Couldn’t stop following #<%= tag %> :("
|
||||||
|
|
||||||
reactions:
|
|
||||||
zero: "<%= count%> reactions"
|
|
||||||
one: "<%= count%> reaction"
|
|
||||||
other: "<%= count%> reactions"
|
|
||||||
|
|
||||||
header:
|
header:
|
||||||
home: "Home"
|
home: "Home"
|
||||||
profile: "Profile"
|
profile: "Profile"
|
||||||
|
|
|
||||||
|
|
@ -14,23 +14,21 @@ Feature: reactions mobile post
|
||||||
And I sign in as "bob@bob.bob" on the mobile website
|
And I sign in as "bob@bob.bob" on the mobile website
|
||||||
|
|
||||||
Scenario: like on a mobile post
|
Scenario: like on a mobile post
|
||||||
When I should see "No reactions" within ".show-comments"
|
When I click on selector "a.like-action.inactive"
|
||||||
And I click on selector "a.like-action.inactive"
|
|
||||||
Then I should see a "a.like-action.active"
|
Then I should see a "a.like-action.active"
|
||||||
|
And I should see "1" within ".like-count"
|
||||||
When I go to the stream page
|
When I go to the stream page
|
||||||
And I should see "1 reaction" within ".show-comments"
|
Then I should see a "a.like-action.active"
|
||||||
And I click on selector "a.show-comments"
|
And I should see "1" within ".like-count"
|
||||||
Then I should see "1" within ".like-count"
|
|
||||||
|
|
||||||
Scenario: liking from the profile view
|
Scenario: liking from the profile view
|
||||||
When I am on "alice@alice.alice"'s page
|
When I am on "alice@alice.alice"'s page
|
||||||
Then I should see "No reactions" within ".show-comments"
|
|
||||||
And I click on selector "a.like-action.inactive"
|
And I click on selector "a.like-action.inactive"
|
||||||
Then I should see a "a.like-action.active"
|
Then I should see a "a.like-action.active"
|
||||||
|
And I should see "1" within ".like-count"
|
||||||
When I go to the stream page
|
When I go to the stream page
|
||||||
And I should see "1 reaction" within ".show-comments"
|
Then I should see a "a.like-action.active"
|
||||||
And I click on selector "a.show-comments"
|
And I should see "1" within ".like-count"
|
||||||
Then I should see "1" within ".like-count"
|
|
||||||
|
|
||||||
Scenario: comment and delete a mobile post
|
Scenario: comment and delete a mobile post
|
||||||
When I click on selector "a.comment-action.inactive"
|
When I click on selector "a.comment-action.inactive"
|
||||||
|
|
@ -39,9 +37,9 @@ Feature: reactions mobile post
|
||||||
And I press "Comment"
|
And I press "Comment"
|
||||||
Then I should see "is that a poodle?" within ".comment-container"
|
Then I should see "is that a poodle?" within ".comment-container"
|
||||||
When I go to the stream page
|
When I go to the stream page
|
||||||
And I should see "1 reaction" within ".show-comments"
|
And I should see "1 comment" within ".show-comments"
|
||||||
And I click on selector "a.show-comments"
|
|
||||||
And I should see "1" within ".comment-count"
|
And I should see "1" within ".comment-count"
|
||||||
When I click on selector "a.comment-action"
|
When I click on selector "a.show-comments"
|
||||||
|
And I click on selector "a.comment-action"
|
||||||
And I confirm the alert after I click on selector "a.remove"
|
And I confirm the alert after I click on selector "a.remove"
|
||||||
Then I should not see "1 reaction" within ".show-comments"
|
Then I should see "0 comments" within ".show-comments"
|
||||||
|
|
|
||||||
|
|
@ -103,20 +103,20 @@ describe("Diaspora.Mobile.Comments", function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Increase reaction count from 1", function(){
|
it("Increase reaction count from 1", function(){
|
||||||
expect(this.toggleReactionsLink.text().trim()).toBe("5 reactions");
|
expect(this.toggleReactionsLink.text().trim()).toBe("5 comments");
|
||||||
Diaspora.Mobile.Comments.increaseReactionCount(this.bottomBar);
|
Diaspora.Mobile.Comments.increaseReactionCount(this.bottomBar);
|
||||||
expect(this.toggleReactionsLink.text().trim()).toBe("6 reactions");
|
expect(this.toggleReactionsLink.text().trim()).toBe("6 comments");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Creates the reaction link when no reactions", function(){
|
it("Creates the reaction link when no reactions", function(){
|
||||||
var parent = this.toggleReactionsLink.parent();
|
var parent = this.toggleReactionsLink.parent();
|
||||||
var postGuid = this.bottomBar.parents(".stream-element").data("guid");
|
var postGuid = this.bottomBar.parents(".stream-element").data("guid");
|
||||||
this.toggleReactionsLink.remove();
|
this.toggleReactionsLink.remove();
|
||||||
parent.prepend($("<span/>", {"class": "show-comments"}).text("No reaction"));
|
parent.prepend($("<span/>", {"class": "show-comments"}).text("0 comments"));
|
||||||
|
|
||||||
Diaspora.Mobile.Comments.increaseReactionCount(this.bottomBar);
|
Diaspora.Mobile.Comments.increaseReactionCount(this.bottomBar);
|
||||||
this.toggleReactionsLink = this.bottomBar.find(".show-comments").first();
|
this.toggleReactionsLink = this.bottomBar.find(".show-comments").first();
|
||||||
expect(this.toggleReactionsLink.text().trim()).toBe("1 reaction");
|
expect(this.toggleReactionsLink.text().trim()).toBe("1 comment");
|
||||||
expect(this.toggleReactionsLink.attr("href")).toBe("/posts/" + postGuid + "/comments.mobile");
|
expect(this.toggleReactionsLink.attr("href")).toBe("/posts/" + postGuid + "/comments.mobile");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue