var Whisper = Whisper || {}; (function () { 'use strict'; var destroyer = Backbone.View.extend({ tagName: 'button', className: 'btn btn-square btn-sm destroy', events: { 'click': 'destroy' }, initialize: function() { this.$el.html('×'); }, destroy: function() { this.model.messages().each(function(message) { message.destroy(); }); this.model.set('active', false); this.model.save(); this.model.trigger('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', events: { 'click': 'toggle', 'submit form': 'sendMessage' }, 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(Whisper.Messages, 'reset', this.addAllMessages); // auto update this.$el.addClass('closed'); this.$destroy = (new destroyer({model: this.model})).$el; this.$image = $('
    '); this.$name = $(''); this.$header = $('
    ').append(this.$image, this.$name); this.$button = $('