Commit ef9fd961 authored by JC Brand's avatar JC Brand

Fix rendering of minimized chatrooms

parent afcb49b6
...@@ -866,7 +866,7 @@ ...@@ -866,7 +866,7 @@
events: { events: {
'click .close-chatbox-button': 'close', 'click .close-chatbox-button': 'close',
'click .toggle-chatbox-button': 'toggle', 'click .toggle-chatbox-button': 'minimize',
'keypress textarea.chat-textarea': 'keyPressed', 'keypress textarea.chat-textarea': 'keyPressed',
'click .toggle-smiley': 'toggleEmoticonMenu', 'click .toggle-smiley': 'toggleEmoticonMenu',
'click .toggle-smiley ul li': 'insertEmoticon', 'click .toggle-smiley ul li': 'insertEmoticon',
...@@ -897,9 +897,8 @@ ...@@ -897,9 +897,8 @@
this.updateVCard(); this.updateVCard();
this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el); this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el);
this.model.messages.fetch({add: true}); this.model.messages.fetch({add: true});
this.render().showStatusMessage(); this.render();
if (this.model.get('minimized')) { if (this.model.get('minimized')) {
this.hide(); this.hide();
} else { } else {
...@@ -925,7 +924,7 @@ ...@@ -925,7 +924,7 @@
setTimeout(function () { setTimeout(function () {
converse.refreshWebkit(); converse.refreshWebkit();
}, 50); }, 50);
return this; return this.showStatusMessage();
}, },
initDragResize: function () { initDragResize: function () {
...@@ -1306,6 +1305,7 @@ ...@@ -1306,6 +1305,7 @@
if (msg) { if (msg) {
this.$el.find('p.user-custom-message').text(msg).attr('title', msg); this.$el.find('p.user-custom-message').text(msg).attr('title', msg);
} }
return this;
}, },
close: function () { close: function () {
...@@ -1318,15 +1318,16 @@ ...@@ -1318,15 +1318,16 @@
}, },
maximize: function () { maximize: function () {
// the opposite of trim, i.e. restoring a trimmed chat box /* Restores a minimized chat box
*/
this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el).show(); this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el).show();
this.focus(); this.focus();
converse.refreshWebkit(); converse.refreshWebkit();
this.model.trigger('maximized', this.model); this.model.trigger('maximized', this.model);
}, },
toggle: function (ev) { minimize: function (ev) {
/* Minimizes or maximizes a chat box /* Minimizes a chat box
*/ */
this.model.save({ this.model.save({
'minimized': true, 'minimized': true,
...@@ -1439,8 +1440,8 @@ ...@@ -1439,8 +1440,8 @@
hide: function () { hide: function () {
if (this.$el.is(':visible') && this.$el.css('opacity') == "1") { if (this.$el.is(':visible') && this.$el.css('opacity') == "1") {
this.$el.fadeOut('fast', converse.refreshWebkit); this.$el.hide();
converse.emit('onChatBoxClosed', this); converse.refreshWebkit();
} }
return this; return this;
}, },
...@@ -1886,7 +1887,7 @@ ...@@ -1886,7 +1887,7 @@
className: 'chatroom', className: 'chatroom',
events: { events: {
'click .close-chatbox-button': 'close', 'click .close-chatbox-button': 'close',
'click .toggle-chatbox-button': 'toggle', 'click .toggle-chatbox-button': 'minimize',
'click .configure-chatroom-button': 'configureChatRoom', 'click .configure-chatroom-button': 'configureChatRoom',
'click .toggle-smiley': 'toggleEmoticonMenu', 'click .toggle-smiley': 'toggleEmoticonMenu',
'click .toggle-smiley ul li': 'insertEmoticon', 'click .toggle-smiley ul li': 'insertEmoticon',
...@@ -1915,9 +1916,13 @@ ...@@ -1915,9 +1916,13 @@
undefined); undefined);
}, },
this); this);
this.$el.appendTo(converse.chatboxviews.$el); this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el);
this.render().show().model.messages.fetch({add: true}); this.render().model.messages.fetch({add: true});
this.initDragResize(); if (this.model.get('minimized')) {
this.hide();
} else {
this.show();
}
}, },
render: function () { render: function () {
...@@ -2601,8 +2606,15 @@ ...@@ -2601,8 +2606,15 @@
}, },
render: function () { render: function () {
return this.$el.addClass('chat-head-chatbox').html( var data = this.model.toJSON();
converse.templates.trimmed_chat(this.model.toJSON())); if (this.model.get('chatroom')) {
data['title'] = this.model.get('name');
this.$el.addClass('chat-head-chatroom');
} else {
data['title'] = this.model.get('fullname');
this.$el.addClass('chat-head-chatbox');
}
return this.$el.html(converse.templates.trimmed_chat(data));
}, },
close: function (ev) { close: function (ev) {
...@@ -2612,6 +2624,7 @@ ...@@ -2612,6 +2624,7 @@
ev.preventDefault(); ev.preventDefault();
this.$el.remove(); this.$el.remove();
this.model.destroy(); this.model.destroy();
converse.emit('onChatBoxClosed', this);
return this; return this;
}, },
......
...@@ -743,6 +743,8 @@ input.error { ...@@ -743,6 +743,8 @@ input.error {
} }
#conversejs .chat-title a { #conversejs .chat-title a {
color: white; color: white;
width: 100%;
display: block;
} }
#conversejs .chat-head-chatbox, #conversejs .chat-head-chatbox,
#conversejs .chat-head-chatroom { #conversejs .chat-head-chatroom {
......
...@@ -806,6 +806,8 @@ input.error { ...@@ -806,6 +806,8 @@ input.error {
#conversejs .chat-title a { #conversejs .chat-title a {
color: white; color: white;
width: 100%;
display: block;
} }
#conversejs .chat-head-chatbox, #conversejs .chat-head-chatbox,
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
<div class="chat-title"> <div class="chat-title">
<a href="#" class="restore-chat"> <a href="#" class="restore-chat">
<div class="chat-head-message-count">0</div> <div class="chat-head-message-count">0</div>
{{ fullname }} {{ title }}
</a> </a>
</div> </div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment