Add link to user profile URL from name in chatbox header

This commit is contained in:
JC Brand 2012-10-22 14:47:16 +02:00
parent 54b7565e3b
commit 07ca5d3506

View File

@ -163,7 +163,8 @@
'user_id' : Strophe.getNodeFromJid(this.get('jid')), 'user_id' : Strophe.getNodeFromJid(this.get('jid')),
'box_id' : hex_sha1(this.get('jid')), 'box_id' : hex_sha1(this.get('jid')),
'fullname' : this.get('fullname'), 'fullname' : this.get('fullname'),
'portrait_url': this.get('portrait_url') 'portrait_url': this.get('portrait_url'),
'user_profile_url': this.get('user_profile_url')
}); });
} }
}); });
@ -400,7 +401,7 @@
template: _.template( template: _.template(
'<div class="chat-head chat-head-chatbox">' + '<div class="chat-head chat-head-chatbox">' +
'<a href="javascript:void(0)" class="chatbox-button close-chatbox-button">X</a>' + '<a href="javascript:void(0)" class="chatbox-button close-chatbox-button">X</a>' +
'<a href="#" class="user">' + '<a href="{{user_profile_url}}" class="user">' +
'<img src="{{portrait_url}}" alt="Avatar of {{fullname}}" class="avatar" />' + '<img src="{{portrait_url}}" alt="Avatar of {{fullname}}" class="avatar" />' +
'<div class="chat-title"> {{ fullname }} </div>' + '<div class="chat-title"> {{ fullname }} </div>' +
'</a>' + '</a>' +
@ -798,12 +799,12 @@
that = this; that = this;
if (_.indexOf(open_chats, 'controlbox') != -1) { if (_.indexOf(open_chats, 'controlbox') != -1) {
this.createChatRoom('controlbox'); this.createChatBox('controlbox');
} }
_.each(open_chats, $.proxy(function (jid) { _.each(open_chats, $.proxy(function (jid) {
if (jid != 'controlbox') { if (jid != 'controlbox') {
if (_.str.include(jid, xmppchat.connection.muc_domain)) { if (_.str.include(jid, xmppchat.connection.muc_domain)) {
this.createChatRoom(jid); this.createChatBox(jid);
} else { } else {
this.openChat(jid); this.openChat(jid);
} }
@ -815,7 +816,7 @@
return Strophe.getDomainFromJid(jid) === xmppchat.connection.muc_domain; return Strophe.getDomainFromJid(jid) === xmppchat.connection.muc_domain;
}, },
createChatRoom: function (jid, data) { createChatBox: function (jid, data) {
var box, view; var box, view;
if (jid === 'controlbox') { if (jid === 'controlbox') {
box = new xmppchat.ControlBox({'id': jid, 'jid': jid}); box = new xmppchat.ControlBox({'id': jid, 'jid': jid});
@ -829,7 +830,13 @@
'model': box 'model': box
}); });
} else { } else {
box = new xmppchat.ChatBox({'id': jid, 'jid': jid, 'fullname': data.fullname, 'portrait_url': data.portrait_url}); box = new xmppchat.ChatBox({
'id': jid,
'jid': jid,
'fullname': data.fullname,
'portrait_url': data.portrait_url,
'user_profile_url': data.user_profile_url
});
view = new xmppchat.ChatBoxView({ view = new xmppchat.ChatBoxView({
model: box model: box
}); });
@ -851,7 +858,7 @@
openChat: function (jid) { openChat: function (jid) {
if (!this.model.get(jid)) { if (!this.model.get(jid)) {
$.getJSON(portal_url + "/xmpp-userinfo?user_id=" + Strophe.getNodeFromJid(jid), $.proxy(function (data) { $.getJSON(portal_url + "/xmpp-userinfo?user_id=" + Strophe.getNodeFromJid(jid), $.proxy(function (data) {
view = this.createChatRoom(jid, data); view = this.createChatBox(jid, data);
}, this)); }, this));
} else { } else {
this.showChat(jid); this.showChat(jid);
@ -882,7 +889,7 @@
if (!view) { if (!view) {
$.getJSON(portal_url + "/xmpp-userinfo?user_id=" + Strophe.getNodeFromJid(bare_jid), $.proxy(function (data) { $.getJSON(portal_url + "/xmpp-userinfo?user_id=" + Strophe.getNodeFromJid(bare_jid), $.proxy(function (data) {
view = this.createChatRoom(jid, data); view = this.createChatBox(jid, data);
view.messageReceived(message); view.messageReceived(message);
xmppchat.roster.addResource(bare_jid, resource); xmppchat.roster.addResource(bare_jid, resource);
}, this)); }, this));