diff --git a/app/assets/javascripts/mobile/mobile_comments.js b/app/assets/javascripts/mobile/mobile_comments.js index 270799f7b..78fed45da 100644 --- a/app/assets/javascripts/mobile/mobile_comments.js +++ b/app/assets/javascripts/mobile/mobile_comments.js @@ -111,6 +111,8 @@ self.showCommentBox(commentActionLink); bottomBarContainer.getCommentsContainer().find("time.timeago").timeago(); bottomBarContainer.activate(); + // Inform the comment action for new comments + $(".stream").trigger("comments.loaded"); }, error: function(){ bottomBarContainer.deactivate(); diff --git a/app/assets/javascripts/mobile/mobile_post_actions.js b/app/assets/javascripts/mobile/mobile_post_actions.js index 75946eff5..6698e6641 100644 --- a/app/assets/javascripts/mobile/mobile_post_actions.js +++ b/app/assets/javascripts/mobile/mobile_post_actions.js @@ -3,6 +3,11 @@ initialize: function() { $(".like-action", ".stream").bind("tap click", this.onLike); $(".reshare-action", ".stream").bind("tap click", this.onReshare); + // Add handler to newly loaded comments + var self = this; + $(".stream").bind("comments.loaded", function() { + $(".like-action", ".stream").bind("tap click", self.onLike); + }); }, showLoader: function(link) { diff --git a/app/assets/stylesheets/mobile/comments.scss b/app/assets/stylesheets/mobile/comments.scss index 9760492f5..704b33db2 100644 --- a/app/assets/stylesheets/mobile/comments.scss +++ b/app/assets/stylesheets/mobile/comments.scss @@ -37,7 +37,7 @@ } } - .post-stats { + %stats { float: right; position: relative; display: flex; @@ -71,20 +71,28 @@ .entypo-heart.active { color: $red; } } + .post-stats { + @extend %stats; + } + .comment-stats { - @extend .post-stats; + @extend %stats; bottom: 25px; } - .post-action { + %action { display: flex; margin: 0 7px; .disabled { color: $medium-gray; } } - + + .post-action { + @extend %action; + } + .comment-action { - @extend .post-action; + @extend %action; } .add-comment-switcher { padding-top: 10px; } diff --git a/app/helpers/mobile_helper.rb b/app/helpers/mobile_helper.rb index 5be8d0d1e..b3e81885f 100644 --- a/app/helpers/mobile_helper.rb +++ b/app/helpers/mobile_helper.rb @@ -26,7 +26,7 @@ module MobileHelper end def mobile_like_icon(post) - if current_user && current_user.liked?(post) + if current_user&.liked?(post) link_to content_tag(:span, post.likes.size, class: "count like-count"), "#", data: {url: post_like_path(post.id, current_user.like_for(post).id)}, @@ -40,8 +40,7 @@ module MobileHelper end def mobile_like_comment_icon(comment) - puts "Mobile like on comment!" - if current_user && current_user.liked?(comment) + if current_user&.liked?(comment) link_to content_tag(:span, comment.likes.size, class: "count like-count"), "#", data: {url: comment_like_path(comment.id, current_user.like_for(comment).id)},