signal-desktop/js/views/conversation_list_item_view.js
lilia 511b121a2f Refactor conversation view into two classes
One that resides in the left hand column as a list item, and another
which displays in the main column and handles ui events therein.
2014-07-27 11:35:49 -10:00

38 lines
814 B
JavaScript

var Whisper = Whisper || {};
(function () {
'use strict';
Whisper.ConversationListItemView = Backbone.View.extend({
tagName: 'li',
className: 'conversation',
events: {
'click': 'open',
},
initialize: function() {
this.template = $('#contact').html();
Mustache.parse(this.template);
this.listenTo(this.model, 'change', this.render); // auto update
this.listenTo(this.model, 'destroy', this.remove); // auto update
this.$el.addClass('closed');
},
open: function(e) {
var v = new Whisper.ConversationView({el: $('#main'), model: this.model});
},
render: function() {
this.$el.html(
Mustache.render(this.template, {
name: this.model.get('name')
})
);
return this;
},
});
})();