Update display when contact colors change
// FREEBIE
This commit is contained in:
parent
6a4b720b89
commit
edd6f58539
3 changed files with 37 additions and 8 deletions
|
@ -349,11 +349,7 @@
|
||||||
this.trigger('change');
|
this.trigger('change');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getAvatar: function() {
|
getColor: function() {
|
||||||
if (this.avatarUrl === undefined) {
|
|
||||||
this.updateAvatarUrl(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
var title = this.get('name');
|
var title = this.get('name');
|
||||||
var color = this.get('color');
|
var color = this.get('color');
|
||||||
if (!color) {
|
if (!color) {
|
||||||
|
@ -367,6 +363,15 @@
|
||||||
color = 'default';
|
color = 'default';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return color;
|
||||||
|
},
|
||||||
|
getAvatar: function() {
|
||||||
|
if (this.avatarUrl === undefined) {
|
||||||
|
this.updateAvatarUrl(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var title = this.get('name');
|
||||||
|
var color = this.getColor();
|
||||||
|
|
||||||
if (this.avatarUrl) {
|
if (this.avatarUrl) {
|
||||||
return { url: this.avatarUrl, color: color };
|
return { url: this.avatarUrl, color: color };
|
||||||
|
@ -543,4 +548,6 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Whisper.Conversation.COLORS = COLORS.concat(['grey', 'default']).join(' ');
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
},
|
},
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.listenTo(this.model, 'destroy', this.stopListening);
|
this.listenTo(this.model, 'destroy', this.stopListening);
|
||||||
this.listenTo(this.model, 'change:avatar', this.updateAvatar);
|
this.listenTo(this.model, 'change:color', this.updateColor);
|
||||||
this.listenTo(this.model, 'change:name', this.updateTitle);
|
this.listenTo(this.model, 'change:name', this.updateTitle);
|
||||||
this.listenTo(this.model, 'newmessage', this.addMessage);
|
this.listenTo(this.model, 'newmessage', this.addMessage);
|
||||||
this.listenTo(this.model, 'opened', this.onOpened);
|
this.listenTo(this.model, 'opened', this.onOpened);
|
||||||
|
@ -319,12 +319,17 @@
|
||||||
this.$('.conversation-title').text(this.model.getTitle());
|
this.$('.conversation-title').text(this.model.getTitle());
|
||||||
},
|
},
|
||||||
|
|
||||||
updateAvatar: function() {
|
updateColor: function(model, color) {
|
||||||
|
var header = this.$('.conversation-header');
|
||||||
|
header.removeClass(Whisper.Conversation.COLORS);
|
||||||
|
if (color) {
|
||||||
|
header.addClass(color);
|
||||||
|
}
|
||||||
var avatarView = new (Whisper.View.extend({
|
var avatarView = new (Whisper.View.extend({
|
||||||
templateName: 'avatar',
|
templateName: 'avatar',
|
||||||
render_attributes: { avatar: this.model.getAvatar() }
|
render_attributes: { avatar: this.model.getAvatar() }
|
||||||
}))();
|
}))();
|
||||||
this.$('.conversation-header .avatar').replaceWith(avatarView.render().$('.avatar'));
|
header.find('.avatar').replaceWith(avatarView.render().$('.avatar'));
|
||||||
},
|
},
|
||||||
|
|
||||||
updateMessageFieldSize: function (event) {
|
updateMessageFieldSize: function (event) {
|
||||||
|
|
|
@ -39,6 +39,11 @@
|
||||||
this.listenTo(this.model, 'pending', this.renderPending);
|
this.listenTo(this.model, 'pending', this.renderPending);
|
||||||
this.listenTo(this.model, 'done', this.renderDone);
|
this.listenTo(this.model, 'done', this.renderDone);
|
||||||
this.timeStampView = new Whisper.ExtendedTimestampView();
|
this.timeStampView = new Whisper.ExtendedTimestampView();
|
||||||
|
|
||||||
|
this.contact = this.model.isIncoming() ? this.model.getContact() : null;
|
||||||
|
if (this.contact) {
|
||||||
|
this.listenTo(this.contact, 'change:color', this.updateColor);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
'click .retry': 'retryMessage',
|
'click .retry': 'retryMessage',
|
||||||
|
@ -143,6 +148,18 @@
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
updateColor: function(model, color) {
|
||||||
|
var bubble = this.$('.bubble');
|
||||||
|
bubble.removeClass(Whisper.Conversation.COLORS);
|
||||||
|
if (color) {
|
||||||
|
bubble.addClass(color);
|
||||||
|
}
|
||||||
|
var avatarView = new (Whisper.View.extend({
|
||||||
|
templateName: 'avatar',
|
||||||
|
render_attributes: { avatar: model.getAvatar() }
|
||||||
|
}))();
|
||||||
|
this.$('.avatar').replaceWith(avatarView.render().$('.avatar'));
|
||||||
|
},
|
||||||
loadAttachments: function() {
|
loadAttachments: function() {
|
||||||
this.model.get('attachments').forEach(function(attachment) {
|
this.model.get('attachments').forEach(function(attachment) {
|
||||||
var view = new Whisper.AttachmentView({ model: attachment });
|
var view = new Whisper.AttachmentView({ model: attachment });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue