From 54554e94edb8caa9ba800606f89a3ad581ceb6fb Mon Sep 17 00:00:00 2001 From: JC Brand Date: Mon, 1 Apr 2013 19:53:39 +0200 Subject: [PATCH] Fix closing of controlbox without a connection being present --- converse.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/converse.js b/converse.js index 8b3f10c45..a6d3dbf18 100644 --- a/converse.js +++ b/converse.js @@ -479,7 +479,11 @@ }, closeChat: function () { - this.model.destroy(); + if (xmppchat.connection) { + this.model.destroy(); + } else { + this.model.trigger('hide'); + } }, initialize: function (){ @@ -741,6 +745,9 @@ this.model.on('destroy', $.proxy(function (model, response, options) { this.$el.hide('fast'); }, this)); + this.model.on('hide', $.proxy(function (model, response, options) { + this.$el.hide('fast'); + }, this)); if (this.model.get('visible')) { this.show(); @@ -1875,10 +1882,14 @@ $toggle.bind('click', $.proxy(function (e) { e.preventDefault(); + var controlbox = this.chatboxes.get('controlbox'); if ($("div#controlbox").is(':visible')) { - this.chatboxes.get('controlbox').destroy(); + if (this.connection) { + controlbox.destroy(); + } else { + controlbox.trigger('hide'); + } } else { - var controlbox = this.chatboxes.get('controlbox'); if (!controlbox) { controlbox = this.chatboxes.add({ id: 'controlbox',