Commit dcd090ff authored by JC Brand's avatar JC Brand

Rip out the controlbox code and put it in src/converse-controlbox.js

Also fixed an issue w.r.t the plugin architecture. Previously infinite
recursion would happen when more than one plugin was overriding a method.

Resolved now by using a wrapper function that lazily sets the correct super
method.
parent 9ae2f717
......@@ -44,8 +44,9 @@ require.config({
"polyfill": "src/polyfill",
// Converse
"converse-core": "src/converse-core",
"converse-api": "src/converse-api",
"converse-controlbox": "src/converse-controlbox",
"converse-core": "src/converse-core",
"converse-muc": "src/converse-muc",
"converse-otr": "src/converse-otr",
"converse-ping": "src/converse-ping",
......
......@@ -16,8 +16,10 @@
describe("Authentication", function () {
it("needs either a bosh_service_url a websocket_url or both", function () {
converse.connection.connected = false;
expect(converse.initConnection.bind({})).toThrow(
new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both."));
converse.connection.connected = true;
});
describe("with prebind", function () {
......
......@@ -18,6 +18,7 @@
var connection = mock.mock_connection;
connection.connected = false;
converse._tearDown();
converse.initialized_plugins = [];
converse.initialize({
i18n: window.locales.en,
bosh_service_url: 'localhost',
......@@ -42,6 +43,7 @@
var connection = mock.mock_connection;
connection.connected = false;
converse._tearDown();
converse.initialized_plugins = [];
converse.initialize({
i18n: window.locales.en,
animate: false,
......@@ -59,6 +61,7 @@
connection = mock.mock_connection;
connection.connected = false;
converse._tearDown();
converse.initialized_plugins = [];
converse.initialize({
i18n: window.locales.en,
bosh_service_url: 'localhost',
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,7 +10,11 @@
* specified in XEP-0045 Multi-user chat.
*/
(function (root, factory) {
define("converse-muc", ["converse-core", "converse-api"], factory);
define("converse-muc", [
"converse-core",
"converse-api",
"converse-controlbox"
], factory);
}(this, function (converse, converse_api) {
"use strict";
// Strophe methods for building stanzas
......@@ -48,10 +52,9 @@
Features: {
addClientFeatures: function () {
var converse = this._super.converse;
this._super.addClientFeatures.apply(this, arguments);
if (converse.allow_muc) {
converse.connection.disco.addFeature(Strophe.NS.MUC);
if (this.allow_muc) {
this.connection.disco.addFeature(Strophe.NS.MUC);
}
}
},
......@@ -123,17 +126,6 @@
},
ChatBoxes: {
onChatBoxAdded: function (item) {
var view = this.get(item.get('id'));
if (!view && item.get('chatroom')) {
view = new converse.ChatRoomView({'model': item});
this.add(item.get('id'), view);
this.trimChats(view);
} else {
this._super.onChatBoxAdded.apply(this, arguments);
}
},
registerMessageHandler: function () {
/* Override so that we can register a handler
* for chat room invites.
......@@ -190,6 +182,19 @@
}
}
},
ChatBoxViews: {
onChatBoxAdded: function (item) {
var view = this.get(item.get('id'));
if (!view && item.get('chatroom')) {
view = new converse.ChatRoomView({'model': item});
this.add(item.get('id'), view);
this.trimChats(view);
} else {
this._super.onChatBoxAdded.apply(this, arguments);
}
}
}
},
initialize: function () {
......
......@@ -57,7 +57,7 @@
_initialize: function () {
this._super._initialize.apply(this, arguments);
this._super.converse.otr = new this._super.converse.OTR();
this.otr = new this.OTR();
},
registerGlobalEventHandlers: function () {
......
......@@ -32,14 +32,12 @@
// New functions which don't exist yet can also be added.
onConnected: function () {
var converse = this._super.converse;
this._super.onConnected().done(converse.registerPingHandler);
this._super.onConnected().done(this.registerPingHandler);
},
onReconnected: function () {
// We need to re-register the ping event handler on the newly
// created connection.
var converse = this._super.converse;
this._super.onReconnected().done(converse.registerPingHandler);
this._super.onReconnected().done(this.registerPingHandler);
}
},
......
......@@ -10,7 +10,11 @@
* as specified in XEP-0077.
*/
(function (root, factory) {
define("converse-register", ["converse-core", "converse-api"], factory);
define("converse-register", [
"converse-core",
"converse-api",
"converse-controlbox"
], factory);
}(this, function (converse, converse_api) {
"use strict";
// Strophe methods for building stanzas
......
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