kaiwa/clientapp/views/contactListItem.js

47 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

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