diff --git a/converse.js b/converse.js index 15f202d68..d2b54be57 100644 --- a/converse.js +++ b/converse.js @@ -804,22 +804,10 @@ tagName: 'div', className: 'chatroom', events: { - 'click .close-chatbox-button': 'closeChatRoom', + 'click a.close-chatbox-button': 'closeChat', '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) { this.appendMessage(body); var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false], @@ -891,6 +879,18 @@ $.proxy(this.onChatRoomMessage, this), $.proxy(this.onChatRoomPresence, 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.render().show(); }, @@ -990,13 +990,6 @@ return true; }, - show: function () { - this.$el.css({'opacity': 0, - 'display': 'inline'}) - .animate({opacity: '1'}, 200); - return this; - }, - render: function () { this.$el.attr('id', this.model.get('box_id')) .html(this.template(this.model.toJSON()));