2013-08-29 20:38:28 -07:00
|
|
|
/*global $, app, me*/
|
|
|
|
"use strict";
|
|
|
|
|
2013-08-20 10:45:06 -07:00
|
|
|
var _ = require('underscore');
|
2013-09-03 19:18:31 -07:00
|
|
|
var HumanView = require('human-view');
|
2013-08-29 20:38:28 -07:00
|
|
|
var templates = require('../templates');
|
2013-08-20 10:45:06 -07:00
|
|
|
|
|
|
|
|
2013-09-03 19:18:31 -07:00
|
|
|
module.exports = HumanView.extend({
|
2013-08-20 10:45:06 -07:00
|
|
|
template: templates.includes.contactListItem,
|
|
|
|
classBindings: {
|
|
|
|
show: '',
|
|
|
|
subscription: '',
|
2013-09-11 20:59:50 -07:00
|
|
|
chatState: '',
|
|
|
|
activeContact: '',
|
2013-09-26 21:29:45 -07:00
|
|
|
hasUnread: '',
|
2015-02-09 14:56:02 +01:00
|
|
|
idle: '',
|
|
|
|
persistent: ''
|
2013-08-20 10:45:06 -07:00
|
|
|
},
|
2013-08-29 20:38:28 -07:00
|
|
|
textBindings: {
|
2013-08-20 10:45:06 -07:00
|
|
|
displayName: '.name',
|
2013-09-25 01:47:11 -07:00
|
|
|
displayUnreadCount: '.unread'
|
2013-08-20 10:45:06 -07:00
|
|
|
},
|
2013-08-29 20:38:28 -07:00
|
|
|
srcBindings: {
|
2015-04-09 15:18:28 +02:00
|
|
|
avatar: '.avatar'
|
2013-08-20 10:45:06 -07:00
|
|
|
},
|
|
|
|
events: {
|
2015-02-09 16:20:28 +01:00
|
|
|
'click': 'handleClick',
|
|
|
|
'click .remove': 'handleRemoveContact'
|
2013-08-20 10:45:06 -07:00
|
|
|
},
|
|
|
|
render: function () {
|
2013-08-29 20:38:28 -07:00
|
|
|
this.renderAndBind({contact: this.model});
|
2013-08-20 10:45:06 -07:00
|
|
|
return this;
|
|
|
|
},
|
2013-09-16 02:19:07 -07:00
|
|
|
handleClick: function () {
|
2015-02-09 16:20:28 +01:00
|
|
|
if (me.contacts.get(this.model.jid)) {
|
2014-12-10 11:25:19 +01:00
|
|
|
app.navigate('chat/' + encodeURIComponent(this.model.jid));
|
2015-02-09 16:20:28 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
handleRemoveContact: function() {
|
|
|
|
me.removeContact(this.model.jid);
|
2014-12-10 11:25:19 +01:00
|
|
|
if (app.history.fragment === 'chat/' + encodeURIComponent(this.model.jid)) {
|
2015-02-09 16:20:28 +01:00
|
|
|
app.navigate('/');
|
|
|
|
}
|
2013-08-20 10:45:06 -07:00
|
|
|
}
|
|
|
|
});
|