diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml
index 4ecef5d38..3a33077fe 100644
--- a/app/views/comments/_comment.html.haml
+++ b/app/views/comments/_comment.html.haml
@@ -21,7 +21,8 @@
= comment.created_at ? timeago(comment.created_at) : timeago(Time.now)
.likes
- = render "likes/likes_container", :target_id => comment.id, :likes_count => comment.likes_count, :target_type => "Comment"
+ .likes_container
+ = render "likes/likes_container", :target_id => comment.id, :likes_count => comment.likes_count, :target_type => "Comment"
- unless !user_signed_in? || @commenting_disabled
%span.like_action
diff --git a/app/views/likes/_likes_container.haml b/app/views/likes/_likes_container.haml
index 139e371c6..9fcf3afcb 100644
--- a/app/views/likes/_likes_container.haml
+++ b/app/views/likes/_likes_container.haml
@@ -2,13 +2,11 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
-.likes_container
- - if likes_count > 0
- = image_tag('icons/heart.svg')
- - if target_type == "Comment"
- = link_to t('likes.likes.people_like_this_comment', :count => likes_count), comment_likes_path(target_id), :class => "expand_likes"
- - else
- = link_to t('likes.likes.people_like_this', :count => likes_count), post_likes_path(target_id), :class => "expand_likes"
- %span.hidden.likes_list
- /= render 'likes/likes', :likes => likes
+- if likes_count > 0
+ = image_tag('icons/heart.svg')
+ - if target_type == "Comment"
+ = link_to t('likes.likes.people_like_this_comment', :count => likes_count), comment_likes_path(target_id), :class => "expand_likes"
+ - else
+ = link_to t('likes.likes.people_like_this', :count => likes_count), post_likes_path(target_id), :class => "expand_likes"
+ %span.hidden.likes_list
diff --git a/app/views/likes/update.js.erb b/app/views/likes/update.js.erb
index 250d1f74e..1eaa8dfe2 100644
--- a/app/views/likes/update.js.erb
+++ b/app/views/likes/update.js.erb
@@ -1,2 +1,3 @@
-$(".like_action", "#<%=@like.target.guid%>").first().html("<%= escape_javascript(like_action(@like.target))%>");
-ContentUpdater.addLikesToPost("<%=@like.target.guid%>", "<%= escape_javascript(render("likes/likes_container", :target_id => @like.target_id, :likes_count => @like.target.reload.likes_count, :target_type => @like.target_type)) %>");
\ No newline at end of file
+var targetGuid = "<%=@like.target.guid%>";
+$(".like_action", "#"+targetGuid).first().html("<%= escape_javascript(like_action(@like.target))%>");
+ContentUpdater.addLikesToPost(targetGuid, "<%= escape_javascript(render("likes/likes_container", :target_id => @like.target_id, :likes_count => @like.target.reload.likes_count, :target_type => @like.target_type)) %>");
diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml
index aaf0efc31..71dd75bba 100644
--- a/app/views/shared/_stream_element.html.haml
+++ b/app/views/shared/_stream_element.html.haml
@@ -74,6 +74,7 @@
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
.likes.on_post
- = render "likes/likes_container", :target_id => post.id, :likes_count => post.likes_count, :current_user => current_user, :target_type => "Post"
+ .likes_container
+ = render "likes/likes_container", :target_id => post.id, :likes_count => post.likes_count, :current_user => current_user, :target_type => "Post"
= render "comments/comments", :post => post, :current_user => current_user, :commenting_disabled => @commenting_disabled
diff --git a/public/javascripts/content-updater.js b/public/javascripts/content-updater.js
index 199f2f7ce..eb28bedb5 100644
--- a/public/javascripts/content-updater.js
+++ b/public/javascripts/content-updater.js
@@ -16,7 +16,7 @@ var ContentUpdater = {
streamElement.prependTo("#main_stream:not('.show')").fadeIn("fast", function() {
streamElement.find("label").inFieldLabels();
});
-
+ Diaspora.page.stream.addPost(streamElement);
Diaspora.page.publish("stream/postAdded", [postGUID]);
}
},
@@ -51,10 +51,7 @@ var ContentUpdater = {
.fadeOut("fast")
.html(html);
- Diaspora.page
- .stream
- .streamElements[postGUID]
- .likes.publish("widget/ready", [likesContainer]);
+ Diaspora.page.publish("likes/" + postGUID + "/updated");
likesContainer.fadeIn("fast");
}
diff --git a/public/javascripts/diaspora.js b/public/javascripts/diaspora.js
index 0665044b7..087233131 100644
--- a/public/javascripts/diaspora.js
+++ b/public/javascripts/diaspora.js
@@ -61,6 +61,7 @@
$.extend(this, {
backToTop: this.instantiate("BackToTop", body.find("#back-to-top")),
directionDetector: this.instantiate("DirectionDetector"),
+ events: function() { return Diaspora.page.eventsContainer.data("events"); },
flashMessages: this.instantiate("FlashMessages"),
header: this.instantiate("Header", body.find("header")),
hoverCard: this.instantiate("HoverCard", body.find("#hovercard"))
diff --git a/public/javascripts/widgets/comment.js b/public/javascripts/widgets/comment.js
index 468035074..2e75eb649 100644
--- a/public/javascripts/widgets/comment.js
+++ b/public/javascripts/widgets/comment.js
@@ -13,13 +13,17 @@
self.deleteCommentLink.click(self.removeComment);
self.deleteCommentLink.tipsy({ trigger: "hover" });
-
+
self.content.expander({
slicePoint: 200,
widow: 18,
expandText: Diaspora.I18n.t("show_more"),
userCollapse: false
});
+
+ self.globalSubscribe("likes/" + self.comment.attr('id') + "/updated", function(){
+ self.likes = self.instantiate("Likes", self.comment.find(".likes_container"));
+ });
});
this.removeComment = function(evt) {
diff --git a/public/javascripts/widgets/likes.js b/public/javascripts/widgets/likes.js
index 5be3f7c54..eda7356fa 100644
--- a/public/javascripts/widgets/likes.js
+++ b/public/javascripts/widgets/likes.js
@@ -15,6 +15,7 @@
this.expandLikes = function(evt) {
evt.preventDefault();
+ console.log("called again");
if(self.likesList.children().length == 0) {
self.loadingImage.appendTo(self.likesContainer);
@@ -33,4 +34,4 @@
};
Diaspora.Widgets.Likes = Likes;
-})();
\ No newline at end of file
+})();
diff --git a/public/javascripts/widgets/stream-element.js b/public/javascripts/widgets/stream-element.js
index dd3a9d9ac..8d26f5ef7 100644
--- a/public/javascripts/widgets/stream-element.js
+++ b/public/javascripts/widgets/stream-element.js
@@ -18,6 +18,7 @@
focusCommentLink: element.find("a.focus_comment_textarea"),
hidePostLoader: element.find("img.hide_loader"),
hidePostUndo: element.find("a.stream_element_hide_undo"),
+ post: element,
postScope: element.find("span.post_scope")
});
@@ -33,6 +34,10 @@
userCollapse: false
});
+ self.globalSubscribe("likes/" + self.postGuid + "/updated", function() {
+ self.likes = self.instantiate("Likes", self.post.find(".likes_container:first"));
+ });
+
self.deletePostLink.click(function(evt) {
evt.preventDefault();