Fix: Display time of each message

This commit is contained in:
Sébastien Hut 2015-04-07 13:12:20 +02:00 committed by Sébastien Hut
parent 1dc027b0fd
commit 7a1d90fb14
6 changed files with 18 additions and 15 deletions

View File

@ -125,11 +125,7 @@ var Message = module.exports = HumanModel.define({
deps: ['edited', 'pending', 'body', 'urls'],
cache: false,
fn: function () {
if (this.type === 'groupchat') {
return templates.includes.mucBareMessage({message: this, messageDate: Date.create(this.timestamp), hasParent: false});
} else {
return templates.includes.bareMessage({message: this, messageDate: Date.create(this.timestamp), hasParent: false});
}
return this.bareMessageTemplate(false);
}
},
templateHtml: {
@ -137,9 +133,9 @@ var Message = module.exports = HumanModel.define({
cache: false,
fn: function () {
if (this.type === 'groupchat') {
return templates.includes.mucWrappedMessage({message: this, messageDate: Date.create(this.timestamp), hasParent: true});
return templates.includes.mucWrappedMessage({message: this, messageDate: Date.create(this.timestamp), firstEl: true});
} else {
return templates.includes.wrappedMessage({message: this, messageDate: Date.create(this.timestamp), hasParent: true});
return templates.includes.wrappedMessage({message: this, messageDate: Date.create(this.timestamp), firstEl: true});
}
}
},
@ -217,6 +213,13 @@ var Message = module.exports = HumanModel.define({
return true;
},
bareMessageTemplate: function (firstEl) {
if (this.type === 'groupchat') {
return templates.includes.mucBareMessage({message: this, messageDate: Date.create(this.timestamp), firstEl: firstEl});
} else {
return templates.includes.bareMessage({message: this, messageDate: Date.create(this.timestamp), firstEl: firstEl});
}
},
save: function () {
if (this.mid) {
var from = this.type == 'groupchat' ? this.from.full : this.from.bare;

View File

@ -226,7 +226,7 @@ module.exports = BasePage.extend({
},
refreshModel: function (model) {
var existing = this.$('#chat' + model.cid);
existing.replaceWith(model.partialTemplateHtml);
existing.replaceWith(model.bareMessageTemplate(existing.prev().hasClass('message_header')));
existing = this.$('#chat' + model.cid);
embedIt(existing);
},

View File

@ -403,7 +403,7 @@ module.exports = BasePage.extend({
},
refreshModel: function (model) {
var existing = this.$('#chat' + model.cid);
existing.replaceWith(model.partialTemplateHtml);
existing.replaceWith(model.bareMessageTemplate(existing.prev().hasClass('message_header')));
},
connectionChange: function () {
if (app.state.connected) {

View File

@ -32,7 +32,7 @@ exports.includes.bareMessage = function anonymous(locals) {
var buf = [];
with (locals || {}) {
var messageClasses = message.classList;
if (hasParent) {
if (firstEl) {
messageClasses += " first";
}
buf.push("<div" + jade.attrs({
@ -248,7 +248,7 @@ exports.includes.mucBareMessage = function anonymous(locals) {
var buf = [];
with (locals || {}) {
var messageClasses = message.classList;
if (hasParent) {
if (firstEl) {
messageClasses += " first";
}
buf.push("<div" + jade.attrs({
@ -353,7 +353,7 @@ exports.includes.mucWrappedMessage = function anonymous(locals) {
title: true
}) + ">" + jade.escape((jade.interp = messageDate.format("{h}:{mm} {tt}")) == null ? "" : jade.interp) + "</div></div>");
var messageClasses = message.classList;
if (hasParent) {
if (firstEl) {
messageClasses += " first";
}
buf.push("<div" + jade.attrs({
@ -440,7 +440,7 @@ exports.includes.wrappedMessage = function anonymous(locals) {
title: true
}) + ">" + jade.escape((jade.interp = messageDate.format("{h}:{mm} {tt}")) == null ? "" : jade.interp) + "</div></div>");
var messageClasses = message.classList;
if (hasParent) {
if (firstEl) {
messageClasses += " first";
}
buf.push("<div" + jade.attrs({

View File

@ -1,5 +1,5 @@
- var messageClasses = message.classList
if hasParent
if firstEl
- messageClasses += ' first'
.message(id='chat'+message.cid, class=messageClasses)

View File

@ -1,5 +1,5 @@
- var messageClasses = message.classList
if hasParent
if firstEl
- messageClasses += ' first'
.message(id='chat'+message.cid, class=messageClasses)