Skip to content

Commit

Permalink
Merge pull request #41 from nextcloud/live-timestamps
Browse files Browse the repository at this point in the history
Use live-timestamps for announcements and comments
  • Loading branch information
nickvergessen authored Oct 10, 2016
2 parents ea6810e + eb684e9 commit 428d241
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 4 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@
.icon-announcement {
background-image: url('../img/announcementcenter-dark.svg');
}

.section > span {
opacity: 0.5;
}
3 changes: 2 additions & 1 deletion js/commentstabview.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
'{{#if isUserAuthor}}' +
' <a href="#" class="action edit icon icon-rename has-tooltip" title="{{editTooltip}}"></a>' +
'{{/if}}' +
' <div class="date has-tooltip" title="{{altDate}}">{{date}}</div>' +
' <div class="date has-tooltip live-relative-timestamp" data-timestamp="{{timestamp}}" title="{{altDate}}">{{date}}</div>' +
' </div>' +
' <div class="message">{{{formattedMessage}}}</div>' +
'{{#if isLong}}' +
Expand Down Expand Up @@ -187,6 +187,7 @@
var data = _.extend({
date: OC.Util.relativeModifiedDate(timestamp),
altDate: OC.Util.formatDate(timestamp),
timestamp: timestamp,
formattedMessage: this._formatMessage(commentModel.get('message'))
}, commentModel.attributes);
return data;
Expand Down
18 changes: 5 additions & 13 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
compiledTemplate: null,
handlebarTemplate: '<div class="section" data-announcement-id="{{{announcementId}}}">' +
'<h2>{{{subject}}}</h2>' +
'<em>' +
'{{time}} {{{author}}} ' +
'<span class="has-tooltip live-relative-timestamp" data-timestamp="{{timestamp}}" title="{{dateFormat}}">{{dateRelative}}</span> <span>{{{author}}}</span> ' +
'{{#if isAdmin}}' +
'<span class="visibility has-tooltip" title="{{{visibilityString}}}">' +
'{{#if visibilityEveryone}}' +
Expand All @@ -47,7 +46,6 @@
'</a>' +
'</span>' +
'{{/if}}' +
'</em>' +
'{{#if message}}' +
'<br /><br /><p>{{{message}}}</p>' +
'{{/if}}' +
Expand Down Expand Up @@ -180,18 +178,12 @@
},

announcementToHtml: function (announcement) {

var currentTimestamp = new Date().getTime();
var details = '';
if (currentTimestamp >= announcement.time * 1000 + this.sevenDaysMilliseconds) {
// Old announcement show full date
details += OC.Util.formatDate(announcement.time * 1000)
} else {
details += OC.Util.relativeModifiedDate(announcement.time * 1000)
}
var timestamp = announcement.time * 1000;

var object = {
time: details,
dateFormat: OC.Util.formatDate(timestamp),
dateRelative: OC.Util.relativeModifiedDate(timestamp),
timestamp: timestamp,
author: t('announcementcenter', 'by {author}', announcement),
subject: announcement.subject,
message: announcement.message,
Expand Down

0 comments on commit 428d241

Please sign in to comment.