Fix timeago for notifications, add 'no notifications yet' message

This commit is contained in:
Steffen van Bergerem 2014-11-23 13:34:34 +01:00
parent dce1e3c6f5
commit 3312f97981
10 changed files with 53 additions and 29 deletions

View file

@ -0,0 +1,9 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
(function(){
app.helpers.timeago = function(el) {
el.find('time.timeago').each(function(i,e) {
$(e).attr('title', new Date($(e).attr('datetime')).toLocaleString());
}).timeago().tooltip();
};
})();
// @license-end

View file

@ -17,13 +17,7 @@ app.views.Conversations = Backbone.View.extend({
} }
new app.views.ConversationsForm({contacts: gon.contacts}); new app.views.ConversationsForm({contacts: gon.contacts});
app.helpers.timeago($(this.el));
$('.timeago').each(function(i,e) {
var jqe = $(e);
jqe.attr('title', new Date(jqe.attr('datetime')).toLocaleString());
})
.timeago()
.tooltip();
}, },
hideParticipants: function(e){ hideParticipants: function(e){

View file

@ -9,6 +9,7 @@ app.views.Notifications = Backbone.View.extend({
initialize: function() { initialize: function() {
Diaspora.page.header.notifications.setUpNotificationPage(this); Diaspora.page.header.notifications.setUpNotificationPage(this);
$(".unread-toggle .entypo").tooltip(); $(".unread-toggle .entypo").tooltip();
app.helpers.timeago($(document));
}, },
toggleUnread: function(evt) { toggleUnread: function(evt) {

View file

@ -83,7 +83,8 @@
self.dropdownNotifications.append(notification.note_html); self.dropdownNotifications.append(notification.note_html);
}); });
}); });
self.dropdownNotifications.find("time.timeago").timeago();
app.helpers.timeago(self.dropdownNotifications);
self.dropdownNotifications.find('.unread').each(function() { self.dropdownNotifications.find('.unread').each(function() {
Diaspora.page.header.notifications.setUpUnread( $(this) ); Diaspora.page.header.notifications.setUpUnread( $(this) );

View file

@ -174,6 +174,7 @@ body > header {
.notification_message { .notification_message {
margin-left: 40px; margin-left: 40px;
.tooltip { position: fixed; }
} }
.unread-toggle { .unread-toggle {

View file

@ -78,5 +78,7 @@
} }
.pagination { text-align: center; } .pagination { text-align: center; }
.no_notifications { text-align: center; }
} }
} }

View file

@ -10,19 +10,8 @@ $(".stream_element", "#conversation_inbox").removeClass('selected');
$(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").addClass('selected'); $(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").addClass('selected');
$(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").find(".unread_message_count").remove() $(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").find(".unread_message_count").remove()
$('time.timeago').each(function(i,e) { app.helpers.timeago($(document));
var jqe = $(e);
jqe.attr('data-original-title', new Date(jqe.attr('datetime')).toLocaleString());
});
if ($('#first_unread') > 0) { if ($('#first_unread') > 0) {
$("html").scrollTop($('#first_unread').offset().top-50); $("html").scrollTop($('#first_unread').offset().top-50);
} }
$(".timeago").tooltip();
$("time.timeago").timeago();
$('time.timeago').each(function(i,e) {
var jqe = $(e);
jqe.attr('title', '');
});

View file

@ -42,17 +42,23 @@
= t('.mark_all_shown_as_read') = t('.mark_all_shown_as_read')
-else -else
= t('.mark_all_as_read') = t('.mark_all_as_read')
- @group_days.each do |day, notes| - if @group_days.length > 0
.day_group.row-fluid - @group_days.each do |day, notes|
.date.span2 .day_group.row-fluid
.day= the_day(day.split(' ')) .date.span2
.month= the_month(day.split(' ')) .day= the_day(day.split(' '))
.month= the_month(day.split(' '))
.notifications_for_day.span10 .notifications_for_day.span10
- notes.each do |note| - notes.each do |note|
= render :partial => 'notifications/notification', :locals => { :note => note } = render :partial => 'notifications/notification', :locals => { :note => note }
= will_paginate @notifications, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer = will_paginate @notifications, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer
- else
.no_notifications.well
%h4
= t('.no_notifications')
:javascript :javascript
$(document).ready(function(){ $(document).ready(function(){

View file

@ -722,6 +722,7 @@ en:
mentioned: "Mentioned" mentioned: "Mentioned"
reshared: "Reshared" reshared: "Reshared"
started_sharing: "Started sharing" started_sharing: "Started sharing"
no_notifications: "You don't have any notifications yet."
and_others: and_others:
zero: "and nobody else" zero: "and nobody else"
one: "and one more" one: "and one more"

View file

@ -0,0 +1,20 @@
describe("app.helpers.timeago", function() {
beforeEach(function(){
this.date = '2015-02-08T13:37:42.000Z';
this.datestring = new Date(this.date).toLocaleString();
var html = '<time class="timeago" datetime="' + this.date + '"></time>';
this.content = spec.content().html(html);
});
it("converts the date into a locale string for the tooltip", function() {
var timeago = this.content.find('time.timeago');
expect(timeago.attr('datetime')).toEqual(this.date);
expect(timeago.data('original-title')).toEqual(undefined);
app.helpers.timeago(this.content);
timeago = this.content.find('time.timeago');
expect(timeago.attr('datetime')).toEqual(this.date);
expect(timeago.data('original-title')).toEqual(this.datestring);
});
});