Adding eventhandler for Mobile views

This commit is contained in:
Thorsten Claus 2021-02-27 14:51:51 +01:00 committed by Benjamin Neff
parent 06a0dc68a9
commit 9b19be18f2
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
4 changed files with 22 additions and 8 deletions

View file

@ -111,6 +111,8 @@
self.showCommentBox(commentActionLink); self.showCommentBox(commentActionLink);
bottomBarContainer.getCommentsContainer().find("time.timeago").timeago(); bottomBarContainer.getCommentsContainer().find("time.timeago").timeago();
bottomBarContainer.activate(); bottomBarContainer.activate();
// Inform the comment action for new comments
$(".stream").trigger("comments.loaded");
}, },
error: function(){ error: function(){
bottomBarContainer.deactivate(); bottomBarContainer.deactivate();

View file

@ -3,6 +3,11 @@
initialize: function() { initialize: function() {
$(".like-action", ".stream").bind("tap click", this.onLike); $(".like-action", ".stream").bind("tap click", this.onLike);
$(".reshare-action", ".stream").bind("tap click", this.onReshare); $(".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) { showLoader: function(link) {

View file

@ -37,7 +37,7 @@
} }
} }
.post-stats { %stats {
float: right; float: right;
position: relative; position: relative;
display: flex; display: flex;
@ -71,20 +71,28 @@
.entypo-heart.active { color: $red; } .entypo-heart.active { color: $red; }
} }
.post-stats {
@extend %stats;
}
.comment-stats { .comment-stats {
@extend .post-stats; @extend %stats;
bottom: 25px; bottom: 25px;
} }
.post-action { %action {
display: flex; display: flex;
margin: 0 7px; margin: 0 7px;
.disabled { color: $medium-gray; } .disabled { color: $medium-gray; }
} }
.post-action {
@extend %action;
}
.comment-action { .comment-action {
@extend .post-action; @extend %action;
} }
.add-comment-switcher { padding-top: 10px; } .add-comment-switcher { padding-top: 10px; }

View file

@ -26,7 +26,7 @@ module MobileHelper
end end
def mobile_like_icon(post) 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"), 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)}, data: {url: post_like_path(post.id, current_user.like_for(post).id)},
@ -40,8 +40,7 @@ module MobileHelper
end end
def mobile_like_comment_icon(comment) def mobile_like_comment_icon(comment)
puts "Mobile like on comment!" if current_user&.liked?(comment)
if current_user && current_user.liked?(comment)
link_to content_tag(:span, comment.likes.size, class: "count like-count"), 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)}, data: {url: comment_like_path(comment.id, current_user.like_for(comment).id)},