1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-16 22:35:11 -05:00
kaiwa/clientapp/views/mucListItem.js
2015-04-04 19:15:50 +02:00

55 lines
1.5 KiB
JavaScript

/*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: '',
hasUnread: '',
joined: '',
persistent: ''
},
textBindings: {
displayName: '.name',
displayUnreadCount: '.unread'
},
events: {
'click': 'handleClick',
'click .join': 'handleJoinRoom',
'click .remove': 'handleDestroyRoom'
},
render: function () {
this.renderAndBind({contact: this.model});
return this;
},
handleClick: function (e) {
app.navigate('groupchat/' + encodeURIComponent(this.model.jid));
},
handleJoinRoom: function (e) {
this.model.join();
},
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' });
}
});
}
}
});
}
});