2014-05-17 06:48:46 +02:00
|
|
|
var Whisper = Whisper || {};
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
2014-07-23 09:24:17 +02:00
|
|
|
Whisper.ConversationListItemView = Backbone.View.extend({
|
2014-05-17 06:48:46 +02:00
|
|
|
tagName: 'li',
|
|
|
|
className: 'conversation',
|
|
|
|
|
2014-06-08 05:32:17 +02:00
|
|
|
events: {
|
2014-07-22 20:55:26 +02:00
|
|
|
'click': 'open',
|
2014-06-08 05:32:17 +02:00
|
|
|
},
|
2014-05-17 06:48:46 +02:00
|
|
|
initialize: function() {
|
2014-07-22 20:55:26 +02:00
|
|
|
this.template = $('#contact').html();
|
|
|
|
Mustache.parse(this.template);
|
|
|
|
|
2014-05-17 06:48:46 +02:00
|
|
|
this.listenTo(this.model, 'change', this.render); // auto update
|
|
|
|
this.listenTo(this.model, 'destroy', this.remove); // auto update
|
|
|
|
|
|
|
|
this.$el.addClass('closed');
|
2014-06-08 05:32:17 +02:00
|
|
|
},
|
2014-05-17 06:48:46 +02:00
|
|
|
|
|
|
|
open: function(e) {
|
2014-07-23 10:52:59 +02:00
|
|
|
$('#main').trigger('close'); // detach any existing conversation views
|
2014-07-23 09:24:17 +02:00
|
|
|
var v = new Whisper.ConversationView({el: $('#main'), model: this.model});
|
2014-05-17 06:48:46 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2014-07-22 20:55:26 +02:00
|
|
|
this.$el.html(
|
|
|
|
Mustache.render(this.template, {
|
|
|
|
name: this.model.get('name')
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2014-05-17 06:48:46 +02:00
|
|
|
return this;
|
2014-07-22 20:55:26 +02:00
|
|
|
},
|
|
|
|
|
2014-05-17 06:48:46 +02:00
|
|
|
});
|
|
|
|
})();
|