From 2e72fc09c6ae1280ea73691636425ba988354b8c Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 14 Mar 2011 18:09:51 -0700 Subject: [PATCH] made 3+ plus collapse in notifications index --- app/helpers/notifications_helper.rb | 12 ++++++++++-- app/views/notifications/index.html.haml | 21 ++++++++++++++------- config/locales/diaspora/en.yml | 2 ++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 443ef1c99..3a22c8738 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -44,10 +44,18 @@ module NotificationsHelper end 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(', ') << " #{t('.and_others', :number =>(number_of_actors - 3))}' + end + message.html_safe end def peoples_names(note) - note.actors.map{|p| p.name}.join(",") + note.actors.map{|p| p.name}.join(", ") end end diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 8412a92b5..02f189bb3 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -11,14 +11,21 @@ type: 'PUT' }); } - - nBadge.html().replace(/\d+/, function(num){ - num = parseInt(num); - nBadge.html(parseInt(num)-1); - if(num == 1) { - nBadge.addClass("hidden"); - } + if(nBadge.html() != null) { + nBadge.html().replace(/\d+/, function(num){ + num = parseInt(num); + nBadge.html(parseInt(num)-1); + if(num == 1) { + nBadge.addClass("hidden"); + } }); + + } + }); + + $('a.more').live('click', function(){ + $(this).hide(); + $(this).next('span').removeClass('hidden'); }); .span-1 diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 839d587ea..e80e9904c 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -274,6 +274,8 @@ en: index: notifications: "Notifications" mark_all_as_read: "Mark All as Read" + and_others: "and %{number} others" + and: 'and' helper: new_notifications: zero: "no new notifications"