fix status message show page and break out Post to it's own javascript widget

This commit is contained in:
Dan Hansen 2011-06-02 17:34:03 -05:00
parent 009985169d
commit 864233eb63
6 changed files with 82 additions and 51 deletions

View file

@ -1,32 +1,42 @@
-# Copyright (c) 2010, Diaspora Inc. This file is -# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
.span-16.append-4.prepend-4.last .span-16.append-4.prepend-4.last
#original_post_info #main_stream.stream.status_message_show
= render 'shared/author_info', :person => @status_message.author, :post => @status_message = render 'shared/stream_element', :post => @status_message, :all_aspects => @status_message.aspects
%br
#show_text %br
%p %br
= markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles]) /.span-16.append-4.prepend-4.last
/ #original_post_info
- for photo in @status_message.photos / = render 'shared/author_info', :person => @status_message.author, :post => @status_message
= link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo_path(photo) /
/ #show_text
%p.time / %p
= how_long_ago(@status_message) / = markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles])
/
%hr / - for photo in @status_message.photos
/ = link_to (image_tag photo.url(:thumb_small), :class => 'thumb_small'), photo_path(photo)
= link_to t('.permalink'), post_path(@status_message) if @status_message.public /
%br / %p.time
- if current_user.owns? @status_message / = how_long_ago(@status_message)
= link_to t('.destroy'), @status_message, :confirm => t('are_you_sure'), :method => :delete / - unless (defined?(@commenting_disabled) && @commenting_disabled)
/ %span.like_action
/ = like_action(@status_message, current_user)
%h5 /
= t('_comments') / %hr
#status_message_stream.stream.show //
%div{:data=>{:guid=>@status_message.id}} / = link_to t('.permalink'), post_path(@status_message) if @status_message.public
= render "comments/comments", :post => @status_message, :comments => @status_message.comments, :always_expanded => true / %br
/ - if current_user.owns? @status_message
/ = link_to t('.destroy'), @status_message, :confirm => t('are_you_sure'), :method => :delete
/
/
//
/ .likes
/ - if @status_message.likes.count > 0
/ = render "likes/likes", :post_id => @status_message.id, :likes => @status_message.likes, :dislikes => @status_message.dislikes, :current_user => current_user
/
/ #status_message_stream.stream.show
/ %div{:data=>{:guid=>@status_message.id}}
/ = render "comments/comments", :post => @status_message, :comments => @status_message.comments, :always_expanded => true

View file

@ -34,6 +34,7 @@ javascripts:
- public/javascripts/widgets/directionDetector.js - public/javascripts/widgets/directionDetector.js
- public/javascripts/widgets/notifications.js - public/javascripts/widgets/notifications.js
- public/javascripts/widgets/flashes.js - public/javascripts/widgets/flashes.js
- public/javascripts/widgets/post.js
- public/javascripts/view.js - public/javascripts/view.js
- public/javascripts/stream.js - public/javascripts/stream.js
- public/javascripts/content-updater.js - public/javascripts/content-updater.js

View file

@ -4,6 +4,9 @@
*/ */
var ContentUpdater = { var ContentUpdater = {
elementWithGuid: function(selector, guid) {
return $(selector + "[data-guid='" + guid + "']");
},
addPostToStream: function(html) { addPostToStream: function(html) {
var streamElement = $(html); var streamElement = $(html);
var postId = streamElement.attr("data-guid"); var postId = streamElement.attr("data-guid");
@ -21,5 +24,15 @@ var ContentUpdater = {
Diaspora.widgets.timeago.updateTimeAgo(); Diaspora.widgets.timeago.updateTimeAgo();
Diaspora.widgets.directionDetector.updateBinds(); Diaspora.widgets.directionDetector.updateBinds();
} }
},
addLikesToPost: function(postId, html) {
var post = ContentUpdater.elementWithGuid("div", postId);
$(".likes_container", post)
.fadeOut("fast")
.html(html)
.fadeIn("fast");
} }
}; };

View file

@ -42,15 +42,6 @@ var Stream = {
this.setUpComments(); this.setUpComments();
$("a.expand_likes", this.selector).live('click',function(evt) {
evt.preventDefault();
$(this).siblings(".likes_list").fadeToggle("fast");
});
$("a.expand_dislikes", this.selector).live('click',function(evt) {
evt.preventDefault();
$(this).siblings(".dislikes_list").fadeToggle("fast");
});
}, },
setUpComments: function(){ setUpComments: function(){
@ -88,21 +79,8 @@ var Stream = {
}); });
}, },
setUpLikes: function() {
var likes = $(".like_it, .dislike_it", this.selector);
likes.live("ajax:loading", function() {
$(this).parent().fadeOut("fast");
});
likes.live("ajax:failure", function() {
Diaspora.widgets.alert.alert(Diaspora.widgets.i18n.t("failed_to_like"));
$(this).parent().fadeIn("fast");
});
},
setUpAudioLinks: function() { setUpAudioLinks: function() {
$(".stream a[target='_blank']").each(function() { $(".stream a[target='_blank']").each(function(r){
var link = $(this); var link = $(this);
if(this.href.match(/\.mp3$|\.ogg$/)) { if(this.href.match(/\.mp3$|\.ogg$/)) {
$("<audio/>", { $("<audio/>", {

View file

@ -456,7 +456,24 @@ ul.dropdown
.from .from
a a
:color $blue :color $blue
.status_message_show
.stream_element
.content
p
:font
:size 1em
.comments
:padding
:bottom 6px
> li:last-child
:border-bottom none
.comment_box
:width 475px
:margin
:bottom 5px
.time, .time,
.timeago, .timeago,
.via .via
@ -583,10 +600,21 @@ ul.dropdown
.stream ul.comments .stream ul.comments
:padding
:bottom 6px
> li:last-child
:border-bottom none
.avatar .avatar
:width 30px :width 30px
:height 30px :height 30px
.comment_box
:margin
:bottom 5px
.submit_button .submit_button
:text :text
:align right :align right

View file

@ -32,6 +32,7 @@ src_files:
- public/javascripts/widgets/infinite-scroll.js - public/javascripts/widgets/infinite-scroll.js
- public/javascripts/widgets/notifications.js - public/javascripts/widgets/notifications.js
- public/javascripts/widgets/flashes.js - public/javascripts/widgets/flashes.js
- public/javascripts/widgets/post.js
- public/javascripts/mobile.js - public/javascripts/mobile.js
- public/javascripts/contact-list.js - public/javascripts/contact-list.js
- public/javascripts/web-socket-receiver.js - public/javascripts/web-socket-receiver.js