made 3+ plus collapse in notifications index

This commit is contained in:
maxwell 2011-03-14 18:09:51 -07:00
parent 1666843aa9
commit 2e72fc09c6
3 changed files with 26 additions and 9 deletions

View file

@ -44,7 +44,15 @@ module NotificationsHelper
end end
def notification_people_link(note) def notification_people_link(note)
note.actors.collect{ |person| link_to("#{h(person.name.titlecase)}", person_path(person))}.join(", ").html_safe actors = note.actors
number_of_actors = actors.count
actor_links = actors.collect{ |person| link_to("#{h(person.name.titlecase)}", person_path(person))}
if number_of_actors < 4
message = actor_links.join(',')
else
message = actor_links[0..2].join(', ') << "<a class='more' href='#'> #{t('.and_others', :number =>(number_of_actors - 3))}</a><span class='hidden'>, " << actor_links[3..(number_of_actors-2)].join(', ')<< " #{t('.and')} "<< actor_links.last << '</span>'
end
message.html_safe
end end
def peoples_names(note) def peoples_names(note)

View file

@ -11,7 +11,7 @@
type: 'PUT' type: 'PUT'
}); });
} }
if(nBadge.html() != null) {
nBadge.html().replace(/\d+/, function(num){ nBadge.html().replace(/\d+/, function(num){
num = parseInt(num); num = parseInt(num);
nBadge.html(parseInt(num)-1); nBadge.html(parseInt(num)-1);
@ -19,6 +19,13 @@
nBadge.addClass("hidden"); nBadge.addClass("hidden");
} }
}); });
}
});
$('a.more').live('click', function(){
$(this).hide();
$(this).next('span').removeClass('hidden');
}); });
.span-1 .span-1

View file

@ -274,6 +274,8 @@ en:
index: index:
notifications: "Notifications" notifications: "Notifications"
mark_all_as_read: "Mark All as Read" mark_all_as_read: "Mark All as Read"
and_others: "and %{number} others"
and: 'and'
helper: helper:
new_notifications: new_notifications:
zero: "no new notifications" zero: "no new notifications"