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); self.contacts.add(contact);
}); });
}); });
}, },
isMe: function (jid) { isMe: function (jid) {
return jid.bare === this.jid.bare; return jid.bare === this.jid.bare;

View File

@ -66,6 +66,22 @@ module.exports = HumanModel.define({
fn: function () { fn: function () {
return !this.acked; 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: { session: {

View File

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

View File

@ -77,7 +77,7 @@ exports.includes.mucListItem = function anonymous(locals) {
exports.includes.mucMessage = function anonymous(locals) { exports.includes.mucMessage = function anonymous(locals) {
var buf = []; var buf = [];
with (locals || {}) { 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(""); 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 float: right
display: block display: block
.sender
display: block
.chatBox .chatBox
borderbox() borderbox()
border-top: 1px solid $grayOutline border-top: 1px solid $grayOutline

View File

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