You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/js/views/conversation_view.js

38 lines
987 B
JavaScript

var Whisper = Whisper || {};
(function () {
'use strict';
Whisper.ConversationView = Backbone.View.extend({
className: 'conversation',
initialize: function() {
this.listenTo(this.model, 'destroy', this.stopListening); // auto update
this.template = $('#conversation').html();
Mustache.parse(this.template);
this.$el.html(Mustache.render(this.template));
this.view = new Whisper.MessageListView({collection: this.model.messages()});
this.$el.find('.discussion-container').append(this.view.el);
},
events: {
'submit .send': 'sendMessage',
'close': 'remove'
},
sendMessage: function(e) {
e.preventDefault();
var input = this.$el.find('.send input');
if (input.val().length > 0) {
this.model.sendMessage(input.val());
input.val("");
}
},
render: function() {
this.$el.show().insertAfter($('#gutter'));
resizer();
return this;
}
});
})();