2013-09-16 19:12:00 -04:00
|
|
|
/*global $, app, me*/
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var _ = require('underscore');
|
|
|
|
var HumanView = require('human-view');
|
|
|
|
var templates = require('../templates');
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = HumanView.extend({
|
|
|
|
template: templates.includes.mucListItem,
|
|
|
|
classBindings: {
|
|
|
|
activeContact: '',
|
2015-02-09 08:56:02 -05:00
|
|
|
hasUnread: '',
|
|
|
|
joined: '',
|
|
|
|
persistent: ''
|
2013-09-16 19:12:00 -04:00
|
|
|
},
|
|
|
|
textBindings: {
|
|
|
|
displayName: '.name',
|
2013-09-25 13:39:57 -04:00
|
|
|
displayUnreadCount: '.unread'
|
2013-09-16 19:12:00 -04:00
|
|
|
},
|
|
|
|
events: {
|
2015-01-24 09:46:19 -05:00
|
|
|
'click': 'handleClick',
|
2015-02-09 10:20:28 -05:00
|
|
|
'click .join': 'handleJoinRoom',
|
2015-04-04 12:51:05 -04:00
|
|
|
'click .remove': 'handleDestroyRoom'
|
2013-09-16 19:12:00 -04:00
|
|
|
},
|
|
|
|
render: function () {
|
|
|
|
this.renderAndBind({contact: this.model});
|
|
|
|
return this;
|
|
|
|
},
|
2015-02-09 08:56:02 -05:00
|
|
|
handleClick: function (e) {
|
2014-12-10 05:25:19 -05:00
|
|
|
app.navigate('groupchat/' + encodeURIComponent(this.model.jid));
|
2015-02-09 08:56:02 -05:00
|
|
|
},
|
|
|
|
handleJoinRoom: function (e) {
|
|
|
|
this.model.join();
|
|
|
|
},
|
2015-04-04 12:51:05 -04:00
|
|
|
handleDestroyRoom: function (e) {
|
|
|
|
var muc = this.model;
|
|
|
|
|
|
|
|
$.prompt('Are you sure you want to remove this room: ' + muc.displayName + '?', {
|
|
|
|
title: 'Remove Room',
|
|
|
|
buttons: { "Yes": true, "Cancel": false },
|
|
|
|
persistent: true,
|
|
|
|
submit:function (e, v, m, f) {
|
|
|
|
if (v) {
|
|
|
|
muc.destroy(function (err) {
|
|
|
|
if (err) {
|
|
|
|
$.prompt(err.error.text, { title: 'Remove Room' });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-09-16 19:12:00 -04:00
|
|
|
}
|
|
|
|
});
|