var Whisper = Whisper || {};
(function () {
'use strict';
var destroyer = Backbone.View.extend({
tagName: 'button',
className: 'btn btn-square btn-sm destroy',
initialize: function() {
this.$el.html('×');
this.$el.click(this.destroy.bind(this));
},
destroy: function() {
_.each(this.model.messages(), function(message) { message.destroy(); });
this.model.destroy();
}
});
var menu = Backbone.View.extend({
tagName: 'ul',
className: 'menu',
initialize: function() {
this.$el.html("
delete");
}
});
Whisper.ConversationView = Backbone.View.extend({
tagName: 'li',
className: 'conversation',
initialize: function() {
this.listenTo(this.model, 'change', this.render); // auto update
this.listenTo(this.model, 'message', this.addMessage); // auto update
this.listenTo(this.model, 'destroy', this.remove); // auto update
this.listenTo(this.model, 'select', this.open);
this.$el.addClass('closed');
this.$destroy = (new destroyer({model: this.model})).$el;
this.$image = $('');
this.$name = $('');
this.$header = $('