Remove closeChatRoom and reuse closeChat on ChatBoxView

This commit is contained in:
JC Brand 2013-03-24 17:54:29 +02:00
parent 2d08916ce7
commit b49f21558c

View File

@ -804,22 +804,10 @@
tagName: 'div', tagName: 'div',
className: 'chatroom', className: 'chatroom',
events: { events: {
'click .close-chatbox-button': 'closeChatRoom', 'click a.close-chatbox-button': 'closeChat',
'keypress textarea.chat-textarea': 'keyPressed' 'keypress textarea.chat-textarea': 'keyPressed'
}, },
closeChatRoom: function () {
this.closeChat();
xmppchat.connection.muc.leave(
this.model.get('jid'),
this.model.get('nick'),
this.onLeave,
undefined);
delete xmppchat.chatboxesview.views[this.model.get('jid')];
xmppchat.chatboxesview.model.remove(this.model.get('jid'));
this.remove();
},
sendChatRoomMessage: function (body) { sendChatRoomMessage: function (body) {
this.appendMessage(body); this.appendMessage(body);
var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false], var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false],
@ -891,6 +879,18 @@
$.proxy(this.onChatRoomMessage, this), $.proxy(this.onChatRoomMessage, this),
$.proxy(this.onChatRoomPresence, this), $.proxy(this.onChatRoomPresence, this),
$.proxy(this.onChatRoomRoster, this)); $.proxy(this.onChatRoomRoster, this));
this.model.on('destroy', function (model, response, options) {
this.$el.hide('fast');
xmppchat.connection.muc.leave(
this.model.get('jid'),
this.model.get('nick'),
this.onLeave,
undefined);
},
this);
this.$el.appendTo(xmppchat.chatboxesview.$el); this.$el.appendTo(xmppchat.chatboxesview.$el);
this.render().show(); this.render().show();
}, },
@ -990,13 +990,6 @@
return true; return true;
}, },
show: function () {
this.$el.css({'opacity': 0,
'display': 'inline'})
.animate({opacity: '1'}, 200);
return this;
},
render: function () { render: function () {
this.$el.attr('id', this.model.get('box_id')) this.$el.attr('id', this.model.get('box_id'))
.html(this.template(this.model.toJSON())); .html(this.template(this.model.toJSON()));