Rename ChatBoxesView to ChatBoxViews

This commit is contained in:
JC Brand 2014-03-04 15:54:36 +02:00
parent 1567b212c3
commit b14538b441
5 changed files with 51 additions and 51 deletions

View File

@ -348,7 +348,7 @@
};
this.showLoginButton = function () {
var view = converse.chatboxesview.get('controlbox');
var view = converse.chatboxviews.get('controlbox');
if (typeof view.loginpanel !== 'undefined') {
view.loginpanel.showLoginButton();
}
@ -893,7 +893,7 @@
}, this);
this.updateVCard();
this.$el.appendTo(converse.chatboxesview.$el);
this.$el.appendTo(converse.chatboxviews.$el);
this.render().show().focus().model.messages.fetch({add: true});
if (this.model.get('status')) {
this.showStatusMessage(this.model.get('status'));
@ -1750,7 +1750,7 @@
}
}
if (!nick) { return; }
chatroom = converse.chatboxesview.showChatBox({
chatroom = converse.chatboxviews.showChatBox({
'id': jid,
'jid': jid,
'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)),
@ -1759,7 +1759,7 @@
'box_id' : hex_sha1(jid)
});
if (!chatroom.get('connected')) {
converse.chatboxesview.get(jid).connect(null);
converse.chatboxviews.get(jid).connect(null);
}
}
});
@ -1775,7 +1775,7 @@
},
initialize: function () {
this.$el.appendTo(converse.chatboxesview.$el);
this.$el.appendTo(converse.chatboxviews.$el);
this.model.on('change', $.proxy(function (item, changed) {
var i;
if (_.has(item.changed, 'connected')) {
@ -1898,7 +1898,7 @@
undefined);
},
this);
this.$el.appendTo(converse.chatboxesview.$el);
this.$el.appendTo(converse.chatboxviews.$el);
this.render().show().model.messages.fetch({add: true});
this.initDragResize();
},
@ -2351,7 +2351,7 @@
onChatRoomRoster: function (roster, room) {
this.renderChatArea();
var controlboxview = converse.chatboxesview.get('controlbox'),
var controlboxview = converse.chatboxviews.get('controlbox'),
roster_size = _.size(roster),
$participant_list = this.$el.find('.participant-list'),
participants = [], keys = _.keys(roster), i;
@ -2462,7 +2462,7 @@
}
});
this.ChatBoxesView = Backbone.View.extend({
this.ChatBoxViews = Backbone.View.extend({
el: '#conversejs',
initialize: function () {
@ -2539,7 +2539,7 @@
openChat: function (ev) {
ev.preventDefault();
return converse.chatboxesview.showChatBox({
return converse.chatboxviews.showChatBox({
'id': this.model.get('jid'),
'jid': this.model.get('jid'),
'fullname': this.model.get('fullname'),
@ -3467,7 +3467,7 @@
// --------------
// This is the end of the initialize method.
this.chatboxes = new this.ChatBoxes();
this.chatboxesview = new this.ChatBoxesView({model: this.chatboxes});
this.chatboxviews = new this.ChatBoxViews({model: this.chatboxes});
this.controlboxtoggle = new this.ControlBoxToggle();
this.otr = new this.OTR();

View File

@ -79,8 +79,8 @@
it("can be closed by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
var chatbox = utils.openChatBoxes(1)[0],
controlview = this.chatboxesview.get('controlbox'), // The controlbox is currently open
chatview = this.chatboxesview.get(chatbox.get('jid'));
controlview = this.chatboxviews.get('controlbox'), // The controlbox is currently open
chatview = this.chatboxviews.get(chatbox.get('jid'));
spyOn(chatview, 'closeChat').andCallThrough();
spyOn(controlview, 'closeChat').andCallThrough();
spyOn(converse, 'emit');
@ -141,7 +141,7 @@
var contact_jid = mock.cur_names[2].replace(' ','.').toLowerCase() + '@localhost';
utils.openChatBoxFor(contact_jid);
var chatbox = this.chatboxes.get(contact_jid);
var view = this.chatboxesview.get(contact_jid);
var view = this.chatboxviews.get(contact_jid);
expect(chatbox).toBeDefined();
expect(view).toBeDefined();
var $toolbar = view.$el.find('ul.chat-toolbar');
@ -153,7 +153,7 @@
var contact_jid = mock.cur_names[2].replace(' ','.').toLowerCase() + '@localhost';
utils.openChatBoxFor(contact_jid);
var chatbox = this.chatboxes.get(contact_jid);
var view = this.chatboxesview.get(contact_jid);
var view = this.chatboxviews.get(contact_jid);
var $toolbar = view.$el.find('ul.chat-toolbar');
var $textarea = view.$el.find('textarea.chat-textarea');
expect($toolbar.children('li.toggle-smiley').length).toBe(1);
@ -213,7 +213,7 @@
var contact_jid = mock.cur_names[2].replace(' ','.').toLowerCase() + '@localhost';
utils.openChatBoxFor(contact_jid);
var chatbox = this.chatboxes.get(contact_jid);
var view = this.chatboxesview.get(contact_jid);
var view = this.chatboxviews.get(contact_jid);
var $toolbar = view.$el.find('ul.chat-toolbar');
expect($toolbar.children('li.toggle-otr').length).toBe(1);
// Register spies
@ -239,7 +239,7 @@
var contact_jid = mock.cur_names[2].replace(' ','.').toLowerCase() + '@localhost';
utils.openChatBoxFor(contact_jid);
var chatbox = this.chatboxes.get(contact_jid);
var view = this.chatboxesview.get(contact_jid);
var view = this.chatboxviews.get(contact_jid);
var $toolbar = view.$el.find('ul.chat-toolbar');
var callButton = $toolbar.find('.toggle-call');
@ -278,7 +278,7 @@
runs($.proxy(function () {
// Check that the chatbox and its view now exist
var chatbox = this.chatboxes.get(sender_jid);
var chatboxview = this.chatboxesview.get(sender_jid);
var chatboxview = this.chatboxviews.get(sender_jid);
expect(chatbox).toBeDefined();
expect(chatboxview).toBeDefined();
// Check that the message was received and check the
@ -311,7 +311,7 @@
var one_day_ago = new Date(new Date().setDate(new Date().getDate()-1));
var message = 'This is a day old message';
var chatbox = this.chatboxes.get(contact_jid);
var chatboxview = this.chatboxesview.get(contact_jid);
var chatboxview = this.chatboxviews.get(contact_jid);
var $chat_content = chatboxview.$el.find('.chat-content');
var msg_obj;
var msg_txt;
@ -380,7 +380,7 @@
waits(250);
runs(function () {
expect(converse.emit).toHaveBeenCalledWith('onChatBoxFocused', jasmine.any(Object));
var view = this.chatboxesview.get(contact_jid);
var view = this.chatboxviews.get(contact_jid);
var message = 'This message is sent from this chatbox';
spyOn(view, 'sendMessage').andCallThrough();
view.$el.find('.chat-textarea').text(message);
@ -396,7 +396,7 @@
it("are sanitized to prevent Javascript injection attacks", $.proxy(function () {
var contact_jid = mock.cur_names[0].replace(' ','.').toLowerCase() + '@localhost';
utils.openChatBoxFor(contact_jid);
var view = this.chatboxesview.get(contact_jid);
var view = this.chatboxviews.get(contact_jid);
var message = 'This message contains <b>markup</b>';
spyOn(view, 'sendMessage').andCallThrough();
view.$el.find('.chat-textarea').text(message);
@ -413,7 +413,7 @@
it("'/clear' can be used to clear messages in a conversation", $.proxy(function () {
spyOn(converse, 'emit');
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
var view = this.chatboxesview.get(contact_jid);
var view = this.chatboxviews.get(contact_jid);
var message = 'This message is another sent from this chatbox';
// Lets make sure there is at least one message already
// (e.g for when this test is run on its own).

View File

@ -24,7 +24,7 @@
waits(300);
runs(function () {
// Open a new chatroom
var roomspanel = converse.chatboxesview.get('controlbox').roomspanel;
var roomspanel = converse.chatboxviews.get('controlbox').roomspanel;
var $input = roomspanel.$el.find('input.new-chatroom-name');
var $nick = roomspanel.$el.find('input.new-chatroom-nick');
var $server = roomspanel.$el.find('input.new-chatroom-server');
@ -42,7 +42,7 @@
});
it("shows users currently present in the room", $.proxy(function () {
var chatroomview = this.chatboxesview.get('lounge@muc.localhost'),
var chatroomview = this.chatboxviews.get('lounge@muc.localhost'),
$participant_list;
var roster = {}, room = {}, i;
for (i=0; i<mock.chatroom_names.length-1; i++) {
@ -57,7 +57,7 @@
}, converse));
it("indicates moderators by means of a special css class and tooltip", $.proxy(function () {
var chatroomview = this.chatboxesview.get('lounge@muc.localhost');
var chatroomview = this.chatboxviews.get('lounge@muc.localhost');
var roster = {}, idx = mock.chatroom_names.length-1;
roster[mock.chatroom_names[idx]] = {};
roster[mock.chatroom_names[idx]].role = 'moderator';
@ -71,7 +71,7 @@
it("shows received groupchat messages", $.proxy(function () {
spyOn(converse, 'emit');
var view = this.chatboxesview.get('lounge@muc.localhost');
var view = this.chatboxviews.get('lounge@muc.localhost');
if (!view.$el.find('.chat-area').length) { view.renderChatArea(); }
var nick = mock.chatroom_names[0];
var text = 'This is a received message';
@ -90,7 +90,7 @@
it("shows sent groupchat messages", $.proxy(function () {
spyOn(converse, 'emit');
var view = this.chatboxesview.get('lounge@muc.localhost');
var view = this.chatboxviews.get('lounge@muc.localhost');
if (!view.$el.find('.chat-area').length) { view.renderChatArea(); }
var nick = mock.chatroom_names[0];
var text = 'This is a sent message';
@ -133,7 +133,7 @@
}, converse));
it("can be closed again by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
var view = this.chatboxesview.get('lounge@muc.localhost'), chatroom = view.model, $el;
var view = this.chatboxviews.get('lounge@muc.localhost'), chatroom = view.model, $el;
spyOn(view, 'closeChat').andCallThrough();
spyOn(converse, 'emit');
spyOn(converse.connection.muc, 'leave');
@ -152,7 +152,7 @@
describe("When attempting to enter a chatroom", $.proxy(function () {
beforeEach($.proxy(function () {
var roomspanel = this.chatboxesview.get('controlbox').roomspanel;
var roomspanel = this.chatboxviews.get('controlbox').roomspanel;
var $input = roomspanel.$el.find('input.new-chatroom-name');
var $nick = roomspanel.$el.find('input.new-chatroom-nick');
var $server = roomspanel.$el.find('input.new-chatroom-server');
@ -163,7 +163,7 @@
}, converse));
afterEach($.proxy(function () {
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
view.closeChat();
}, converse));
@ -177,7 +177,7 @@
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'auth'})
.c('not-authorized').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'renderPasswordForm').andCallThrough();
runs(function () {
view.onChatRoomPresence(presence, {'nick': 'dummy'});
@ -200,7 +200,7 @@
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'auth'})
.c('registration-required').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe('You are not on the member list of this room');
@ -215,7 +215,7 @@
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'auth'})
.c('forbidden').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe('You have been banned from this room');
@ -230,7 +230,7 @@
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'modify'})
.c('jid-malformed').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe('No nickname was specified');
@ -245,7 +245,7 @@
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('not-allowed').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe('You are not allowed to create new rooms');
@ -260,7 +260,7 @@
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('not-acceptable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe("Your nickname doesn't conform to this room's policies");
@ -275,7 +275,7 @@
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe("Your nickname is already taken");
@ -290,7 +290,7 @@
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('item-not-found').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe("This room does not (yet) exist");
@ -305,7 +305,7 @@
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
.c('service-unavailable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
var view = this.chatboxesview.get('problematic@muc.localhost');
var view = this.chatboxviews.get('problematic@muc.localhost');
spyOn(view, 'showErrorMessage').andCallThrough();
view.onChatRoomPresence(presence, {'nick': 'dummy'});
expect(view.$el.find('.chat-body p').text()).toBe("This room has reached it's maximum number of occupants");

View File

@ -481,7 +481,7 @@
describe("The 'Add Contact' widget", $.proxy(function (mock, utils) {
it("opens up an add form when you click on it", $.proxy(function () {
var panel = this.chatboxesview.get('controlbox').contactspanel;
var panel = this.chatboxviews.get('controlbox').contactspanel;
spyOn(panel, 'toggleContactForm').andCallThrough();
panel.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
panel.$el.find('a.toggle-xmpp-contact-form').click();
@ -506,7 +506,7 @@
}, converse));
it("contains two tabs, 'Contacts' and 'ChatRooms'", $.proxy(function () {
var cbview = this.chatboxesview.get('controlbox');
var cbview = this.chatboxviews.get('controlbox');
var $panels = cbview.$el.find('.controlbox-panes');
expect($panels.children().length).toBe(2);
expect($panels.children().first().attr('id')).toBe('users');
@ -529,7 +529,7 @@
}, converse));
it("is opened by clicking the 'Chatrooms' tab", $.proxy(function () {
var cbview = this.chatboxesview.get('controlbox');
var cbview = this.chatboxviews.get('controlbox');
var $tabs = cbview.$el.find('#controlbox-tabs');
var $panels = cbview.$el.find('.controlbox-panes');
var $contacts = $panels.children().first();
@ -548,7 +548,7 @@
}, converse));
it("contains a form through which a new chatroom can be created", $.proxy(function () {
var roomspanel = this.chatboxesview.get('controlbox').roomspanel;
var roomspanel = this.chatboxviews.get('controlbox').roomspanel;
var $input = roomspanel.$el.find('input.new-chatroom-name');
var $nick = roomspanel.$el.find('input.new-chatroom-nick');
var $server = roomspanel.$el.find('input.new-chatroom-server');

View File

@ -13,7 +13,7 @@
var i, chatbox;
for (i=converse.chatboxes.models.length-1; i>-1; i--) {
chatbox = converse.chatboxes.models[i];
converse.chatboxesview.get(chatbox.get('id')).closeChat();
converse.chatboxviews.get(chatbox.get('id')).closeChat();
}
return this;
};
@ -22,17 +22,17 @@
var i, chatbox, num_chatboxes = converse.chatboxes.models.length;
for (i=num_chatboxes-1; i>-1; i--) {
chatbox = converse.chatboxes.models[i];
converse.chatboxesview.get(chatbox.get('id')).closeChat();
converse.chatboxesview.get(chatbox.get('id')).$el.remove();
converse.chatboxviews.get(chatbox.get('id')).closeChat();
converse.chatboxviews.get(chatbox.get('id')).$el.remove();
}
converse.chatboxesview.get('controlbox').closeChat();
converse.chatboxesview.get('controlbox').$el.remove();
converse.chatboxviews.get('controlbox').closeChat();
converse.chatboxviews.get('controlbox').$el.remove();
return this;
};
utils.initConverse = function () {
converse.chatboxes = new converse.ChatBoxes();
converse.chatboxesview = new converse.ChatBoxesView({model: converse.chatboxes});
converse.chatboxviews = new converse.ChatBoxViews({model: converse.chatboxes});
converse.onConnected();
};
@ -66,13 +66,13 @@
};
utils.openContactsPanel = function () {
var cbview = converse.chatboxesview.get('controlbox');
var cbview = converse.chatboxviews.get('controlbox');
var $tabs = cbview.$el.find('#controlbox-tabs');
$tabs.find('li').first().find('a').click();
};
utils.openRoomsPanel = function () {
var cbview = converse.chatboxesview.get('controlbox');
var cbview = converse.chatboxviews.get('controlbox');
var $tabs = cbview.$el.find('#controlbox-tabs');
$tabs.find('li').last().find('a').click();
};
@ -91,7 +91,7 @@
};
utils.clearChatBoxMessages = function (jid) {
var view = converse.chatboxesview.get(jid);
var view = converse.chatboxviews.get(jid);
view.$el.find('.chat-content').empty();
view.model.messages.reset().localStorage._clear();
};