Bugfix. Opened chatboxes weren't focused...
...when clicking on a contact in the roster
This commit is contained in:
parent
30fe6de7c3
commit
dec674fae2
|
@ -1479,11 +1479,12 @@
|
|||
this.$el.hide('fast', converse.refreshWebkit);
|
||||
converse.emit('onChatBoxClosed', this);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
show: function (callback) {
|
||||
if (this.$el.is(':visible') && this.$el.css('opacity') == "1") {
|
||||
return this;
|
||||
return this.focus();
|
||||
}
|
||||
this.$el.show(callback);
|
||||
if (converse.connection) {
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
// visible, but no other chat boxes have been created.
|
||||
expect(this.chatboxes.length).toEqual(1);
|
||||
|
||||
var online_contacts = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.online').find('a.open-chat');
|
||||
var online_contacts = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact').find('a.open-chat');
|
||||
for (i=0; i<online_contacts.length; i++) {
|
||||
$el = $(online_contacts[i]);
|
||||
jid = $el.text().replace(' ','.').toLowerCase() + '@localhost';
|
||||
|
@ -48,6 +48,26 @@
|
|||
}
|
||||
}, converse));
|
||||
|
||||
it("is focused if its already open and you click on its corresponding roster item", $.proxy(function () {
|
||||
var contact_jid = mock.cur_names[2].replace(' ','.').toLowerCase() + '@localhost';
|
||||
var i, $el, click, jid, view, chatboxview, chatbox;
|
||||
// openControlBox was called earlier, so the controlbox is
|
||||
// visible, but no other chat boxes have been created.
|
||||
expect(this.chatboxes.length).toEqual(1);
|
||||
chatbox = utils.openChatBoxFor(contact_jid);
|
||||
chatboxview = this.chatboxviews.get(contact_jid);
|
||||
spyOn(chatboxview, 'focus');
|
||||
var $el = this.rosterview.$el.find('a.open-chat:contains("'+chatbox.get('fullname')+'")');
|
||||
jid = $el.text().replace(' ','.').toLowerCase() + '@localhost';
|
||||
view = this.rosterview.get(jid);
|
||||
spyOn(view, 'openChat').andCallThrough();
|
||||
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
|
||||
$el.click();
|
||||
expect(view.openChat).toHaveBeenCalled();
|
||||
expect(this.chatboxes.length).toEqual(2);
|
||||
expect(chatboxview.focus).toHaveBeenCalled();
|
||||
}, converse));
|
||||
|
||||
it("can be saved to, and retrieved from, localStorage", $.proxy(function () {
|
||||
spyOn(converse, 'emit');
|
||||
runs(function () {
|
||||
|
@ -527,7 +547,6 @@
|
|||
utils.sendMessage(view, message);
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.messages.length, 2);
|
||||
expect(converse.emit.callCount).toEqual(3);
|
||||
expect(converse.emit.mostRecentCall.args, ['onMessageSend', message]);
|
||||
expect(view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content').text()).toEqual(message);
|
||||
}.bind(converse));
|
||||
|
|
Loading…
Reference in New Issue
Block a user