fixed comments not showing up through websocket on photo show page

This commit is contained in:
danielvincent 2010-10-20 23:40:48 -07:00
parent 82e947a74a
commit 8e175be2ba
6 changed files with 72 additions and 68 deletions

View file

@ -8,10 +8,14 @@
$("#add_album_button").fancybox(); $("#add_album_button").fancybox();
}); });
.span-4.append-1.last %h2
= render "shared/aspect_friends" = @aspect
.friend_pictures.horizontal
= owner_image_link
- for friend in @friends
= person_image_link(friend)
.span-15.last .span-24.last
%h3 %h3
= @aspect = @aspect
Albums Albums

View file

@ -44,17 +44,19 @@
} }
function processComment(post_id, html){ function processComment(post_id, html){
post = $('#' + post_id)[0] post = $("*[data-guid='"+post_id+"']'");
$(' .comment_set li:last', post ).before( $(' .comment_set li:last', post ).before(
$(html).fadeIn("fast", function(){}) $(html).fadeIn("fast", function(){})
); );
toggler = $('.show_post_comments', post) toggler = $('.show_post_comments', post)
toggler.html( if(toggler.length > 0){
toggler.html().replace(/\d+/,$('.comment_set', post)[0].childElementCount -1)); toggler.html(
toggler.html().replace(/\d+/,$('.comment_set', post)[0].childElementCount -1));
if( !$(".comments", post).is(':visible') ){ if( !$(".comments", post).is(':visible') ){
toggler.click(); toggler.click();
}
} }
} }

View file

@ -2,57 +2,58 @@
-# 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.
:javascript - content_for :head do
$(document).keydown(function(e){ :javascript
switch(e.keyCode) { $(document).keydown(function(e){
case 37: switch(e.keyCode) {
if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus case 37:
window.location.replace( "#{url_to_prev(@photo,@album)}" ); if(!$("textarea").hasClass("hasfocus")){//prevent redirect if textarea has focus
window.location.replace( "#{url_to_prev(@photo,@album)}" );
}
break;
case 39:
if(!$("textarea").hasClass("hasfocus")){
window.location.replace( "#{url_to_next(@photo,@album)}" );
}
break;
} }
break;
case 39:
if(!$("textarea").hasClass("hasfocus")){
window.location.replace( "#{url_to_next(@photo,@album)}" );
}
break;
}
});
$(document).ready(function(){
//add a clas to verify if a textarea has focus
$("textarea").live('focus',function(){
$(this).addClass("hasfocus");
});
$("textarea").live('blur',function(){
$(this).removeClass("hasfocus");
}); });
//show form to add description $(document).ready(function(){
$(".edit-desc").click(function(){ //add a clas to verify if a textarea has focus
$(".edit_photo").toggle(); $("textarea").live('focus',function(){
}); $(this).addClass("hasfocus");
});
$("textarea").live('blur',function(){
$(this).removeClass("hasfocus");
});
//Add a description with ajax request //show form to add description
$("#photo_submit").click(function(evenet){ $(".edit-desc").click(function(){
event.preventDefault(); $(".edit_photo").toggle();
var method = $(".edit_photo").attr("method"); });
var url = $(".edit_photo").attr("action");
var data = $(".edit_photo").serialize();
$(".description").text($("#photo_caption").val());
$(".edit_photo").toggle();
$.ajax({ //Add a description with ajax request
type: method, $("#photo_submit").click(function(evenet){
url: url, event.preventDefault();
data: data, var method = $(".edit_photo").attr("method");
success: function(response){ var url = $(".edit_photo").attr("action");
$("#add-description").remove(); var data = $(".edit_photo").serialize();
} $(".description").text($("#photo_caption").val());
}); $(".edit_photo").toggle();
}); $.ajax({
type: method,
url: url,
data: data,
success: function(response){
$("#add-description").remove();
}
});
});//end document ready });
});//end document ready
%h2 %h2
= @aspect = @aspect
@ -64,6 +65,12 @@
%h3 %h3
= link_to @photo.album.name, @photo.album = link_to @photo.album.name, @photo.album
= link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch'
|
= link_to "#{t('.full_size')}", @photo.url
|
= link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch'
.span-14.append-1.last .span-14.append-1.last
%div{:data=>{:guid=>@photo.id}} %div{:data=>{:guid=>@photo.id}}
#show_photo #show_photo
@ -72,8 +79,6 @@
.edit_pane .edit_pane
.controls{:data=>{:actor=>"#{@photo.person.owner.id}",:actor_person=>"#{@photo.person.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}} .controls{:data=>{:actor=>"#{@photo.person.owner.id}",:actor_person=>"#{@photo.person.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}}
= link_to 'make profile photo', '#', :class => "make_profile_photo" = link_to 'make profile photo', '#', :class => "make_profile_photo"
|
= link_to 'edit', '#', :class => "make_profile_photo"
= linked_scaled_photo @photo, @album = linked_scaled_photo @photo, @album
-else -else
= linked_scaled_photo @photo, @album = linked_scaled_photo @photo, @album
@ -100,13 +105,6 @@
= link_to t('.delete_photo'), @photo, :confirm => t('.are_you_sure'), :method => :delete, :class => 'button' = link_to t('.delete_photo'), @photo, :confirm => t('.are_you_sure'), :method => :delete, :class => 'button'
.span-9.last .span-9.last
= link_to "<< #{t('.prev')}", url_to_prev(@photo, @album), :rel => 'prefetch'
|
= link_to "#{t('.full_size')}", @photo.url
|
= link_to "#{t('.next')} >>", url_to_next(@photo, @album), :rel => 'prefetch'
%br
%br
#stream.show #stream.show
%li.message{:id => @photo.id} %li.message{:data=>{:guid=>@photo.id}}
= render "comments/comments", :post => @photo = render "comments/comments", :post => @photo

View file

@ -26,5 +26,5 @@
.span-9.last .span-9.last
#stream.show #stream.show
%li.message{:id => @status_message.id} %li.message{:data=>{:guid=>@status_message.id}}
= render "comments/comments", :post => @status_message = render "comments/comments", :post => @status_message

View file

@ -47,7 +47,7 @@ $(document).ready(function(){
} }
); );
$("#publisher textarea, .comment textarea").keydown( function(e) { $("#publisher textarea, .comment_box").keydown( function(e) {
if (e.keyCode == 13) { if (e.keyCode == 13) {
$(this).closest("form").submit(); $(this).closest("form").submit();
} }

View file

@ -180,7 +180,7 @@ header
#global_search #global_search
:margin :margin
:left 425px :left 432px
#stream #stream
:margin 0 :margin 0
@ -1015,8 +1015,8 @@ ul#settings_nav
:left 20px :left 20px
img img
:width 20px :width 30px
:height 20px :height 30px
:margin-right -4px :margin-right -4px
#thumbnails #thumbnails
@ -1070,7 +1070,7 @@ input[type="search"]
header header
input[type="search"] input[type="search"]
:width 200px :width 192px
.fancybox_content .fancybox_content
:display none :display none