scroll to post on page if you can see it (via notification popup)
This commit is contained in:
parent
18c7c467c7
commit
b6d5165f2d
3 changed files with 14 additions and 3 deletions
|
|
@ -15,14 +15,14 @@ module NotificationsHelper
|
|||
elsif note.instance_of?(Notifications::CommentOnPost)
|
||||
post = Post.where(:id => note.target_id).first
|
||||
if post
|
||||
"#{translation(target_type)} #{link_to t('notifications.post'), object_path(post)}".html_safe
|
||||
"#{translation(target_type)} #{link_to t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe
|
||||
else
|
||||
"#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}"
|
||||
end
|
||||
elsif note.instance_of?(Notifications::AlsoCommented)
|
||||
post = Post.where(:id => note.target_id).first
|
||||
if post
|
||||
"#{translation(target_type, post.author.name)} #{link_to t('notifications.post'), object_path(post)}".html_safe
|
||||
"#{translation(target_type, post.author.name)} #{link_to t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe
|
||||
else
|
||||
t('notifications.also_commented_deleted')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
%li.comment{:data=>{:guid => comment.id}, :class => ("hidden" if(defined? hidden))}
|
||||
%li.comment.posted{:data=>{:guid => comment.id}, :class => ("hidden" if(defined? hidden))}
|
||||
= person_image_link(comment.author)
|
||||
.content
|
||||
.from
|
||||
|
|
|
|||
|
|
@ -61,6 +61,17 @@ var View = {
|
|||
|
||||
/* facebox 'done' buttons */
|
||||
$("a[rel*=close]").live('click', function(){ $.facebox.close() });
|
||||
|
||||
/* notification routing */
|
||||
$("#notification").delegate('.hard_object_link', 'click', function(evt){
|
||||
var post = $("*[data-guid='"+ $(this).attr('data-ref') +"']"),
|
||||
lastComment = post.find('.comment.posted').last();
|
||||
|
||||
if(post.length > 0){
|
||||
evt.preventDefault();
|
||||
$('html, body').animate({scrollTop: parseInt(lastComment.offset().top)-80 }, 'fast');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
addAspectButton: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue