diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 4da938b0b..be0119e37 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -62,9 +62,6 @@ = button_to t('.delete_photo'), @photo, :confirm => t('are_you_sure'), :method => :delete .span-16.prepend-4.append-4.last - %h5 - = t('_comments') - #photo_stream.stream.show // TODO(likes) /- if (defined?(current_user) && !current_user.liked?(@parent)) diff --git a/public/javascripts/widgets/post.js b/public/javascripts/widgets/post.js new file mode 100644 index 000000000..79bd975c8 --- /dev/null +++ b/public/javascripts/widgets/post.js @@ -0,0 +1,43 @@ +/* Copyright (c) 2011, Diaspora Inc. This file is + * licensed under the Affero General Public License version 3 or later. See + * the COPYRIGHT file. + */ + +(function() { + var Post = function() { + this.likesSelector = ".like_it, .dislike_it"; + this.expandLikesSelector = "a.expand_likes, a.expand_dislikes"; + this.start = function() { + //timeago + //set up ikes + //comments + //audio video links + //embedder + // + + + this.setUpLikes(); + }; + + this.setUpLikes = function() { + $(this.expandLikesSelector).live("click", function(evt) { + evt.preventDefault(); + $(this).siblings(".likes_list") + .fadeToggle("fast"); + }); + + var likeIt = $(this.likesSelector); + + likeIt.live("ajax:loading", function() { + $(this).parent().fadeOut("fast"); + }); + + likeIt.live("ajax:failure", function() { + Diaspora.widgets.alert.alert(Diaspora.widgets.i18n.t("failed_to_like")); + $(this).parent().fadeIn("fast"); + }); + }; + }; + + Diaspora.widgets.add("post", Post); +})(); \ No newline at end of file diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 556af64db..74c5c5298 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -2346,7 +2346,7 @@ ul.show_comments, .likes_container > * :font - :size smaller + :size 8px :weight bold img diff --git a/spec/javascripts/widgets/post-spec.js b/spec/javascripts/widgets/post-spec.js new file mode 100644 index 000000000..b31e193dc --- /dev/null +++ b/spec/javascripts/widgets/post-spec.js @@ -0,0 +1,35 @@ +/* Copyright (c) 2011, Diaspora Inc. This file is + * licensed under the Affero General Public License version 3 or later. See + * the COPYRIGHT file. + */ + +describe("Diaspora", function() { + describe("widgets", function() { + describe("post", function() { + describe("start", function() { + it("should set up like on initialize", function() { + spyOn(Diaspora.widgets.post, "setUpLikes"); + Diaspora.widgets.post.start(); + expect(Diaspora.widgets.post.setUpLikes).toHaveBeenCalled(); + }); + }); + describe("setUpLikes", function() { + it("adds a listener for the click event on a.expand_likes", function() { + spyOn(window, "$").andCallThrough(); + Diaspora.widgets.post.start(); + expect($).toHaveBeenCalledWith(Diaspora.widgets.post.expandLikesSelector); + $.reset(); + }); + + it("adds a listener for ajax:success and ajax:failure", function() { + spyOn(window, "$").andCallThrough(); + Diaspora.widgets.post.start(); + expect($).toHaveBeenCalledWith(Diaspora.widgets.post.likesSelector); + $.reset(); + }); + }); + + }); + }); +}); +