1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-22 17:22:22 -05:00

Add sender to muc messages

This commit is contained in:
Lance Stout 2013-09-24 13:24:35 -07:00
parent 057038f000
commit 96bfcec2ea
9 changed files with 63 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -94,7 +94,6 @@ module.exports = HumanModel.define({
self.contacts.add(contact);
});
});
},
isMe: function (jid) {
return jid.bare === this.jid.bare;

View File

@ -66,6 +66,22 @@ module.exports = HumanModel.define({
fn: function () {
return !this.acked;
}
},
nick: {
deps: ['mine', 'type'],
fn: function () {
if (this.mine) {
if (this.type === 'groupchat') {
return me.mucs.get(this.to.bare).nick;
} else {
return 'me';
}
}
if (this.type === 'groupchat') {
return this.from.resource;
}
return me.getContact(this.from.bare).displayName;
}
}
},
session: {

View File

@ -3,7 +3,7 @@
var BasePage = require('./base');
var templates = require('../templates');
var Message = require('../views/message');
var Message = require('../views/mucMessage');
var MessageModel = require('../models/message');
@ -23,7 +23,7 @@ module.exports = BasePage.extend({
avatar: 'header .avatar'
},
textBindings: {
displayName: 'header .name',
displayName: 'header .name'
},
show: function (animation) {
BasePage.prototype.show.apply(this, [animation]);
@ -124,7 +124,7 @@ module.exports = BasePage.extend({
if (val) {
message = {
to: this.model.lockedResource || this.model.jid,
to: this.model.jid,
type: 'groupchat',
body: val,
chatState: 'active'

View File

@ -77,7 +77,7 @@ exports.includes.mucListItem = function anonymous(locals) {
exports.includes.mucMessage = function anonymous(locals) {
var buf = [];
with (locals || {}) {
buf.push('<li><div class="message"><span class="sender">' + jade.escape(null == (jade.interp = message.nick) ? "" : jade.interp) + '</span><span class="timestamp">' + jade.escape(null == (jade.interp = message.created) ? "" : jade.interp) + '</span><p class="body">' + jade.escape(null == (jade.interp = message.body) ? "" : jade.interp) + "</p></div></li>");
buf.push('<li><div class="message"><span class="timestamp">' + jade.escape(null == (jade.interp = message.created) ? "" : jade.interp) + '</span><p class="body">' + jade.escape(null == (jade.interp = message.body) ? "" : jade.interp) + '</p><span class="sender">' + jade.escape(null == (jade.interp = message.nick) ? "" : jade.interp) + "</span></div></li>");
}
return buf.join("");
};

View File

@ -0,0 +1,5 @@
li
.message
span.timestamp=message.created
p.body=message.body
span.sender=message.nick

View File

@ -0,0 +1,29 @@
/*global $*/
"use strict";
var _ = require('underscore');
var HumanView = require('human-view');
var templates = require('../templates');
module.exports = HumanView.extend({
template: templates.includes.mucMessage,
initialize: function (opts) {
this.render();
},
classBindings: {
mine: '.message',
acked: '.message',
delayed: '.message',
edited: '.message'
},
textBindings: {
body: '.body',
nick: '.nick',
formattedTime: '.timestamp'
},
render: function () {
this.renderAndBind({message: this.model});
return this;
}
});

View File

@ -124,6 +124,9 @@
float: right
display: block
.sender
display: block
.chatBox
borderbox()
border-top: 1px solid $grayOutline

View File

@ -738,6 +738,9 @@ h4 {
float: right;
display: block;
}
.messages .message .sender {
display: block;
}
.chatBox {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;