1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-25 02:32:26 -05:00
kaiwa/clientapp/views/mucListItem.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

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: '',
hasUnread: '',
joined: '',
persistent: ''
2013-09-16 19:12:00 -04:00
},
textBindings: {
displayName: '.name',
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;
},
handleClick: function (e) {
2014-12-10 05:25:19 -05:00
app.navigate('groupchat/' + encodeURIComponent(this.model.jid));
},
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
}
});