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({ ...@@ -44,8 +44,9 @@ require.config({
"polyfill": "src/polyfill", "polyfill": "src/polyfill",
// Converse // Converse
"converse-core": "src/converse-core",
"converse-api": "src/converse-api", "converse-api": "src/converse-api",
"converse-controlbox": "src/converse-controlbox",
"converse-core": "src/converse-core",
"converse-muc": "src/converse-muc", "converse-muc": "src/converse-muc",
"converse-otr": "src/converse-otr", "converse-otr": "src/converse-otr",
"converse-ping": "src/converse-ping", "converse-ping": "src/converse-ping",
......
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
describe("Authentication", function () { describe("Authentication", function () {
it("needs either a bosh_service_url a websocket_url or both", function () { it("needs either a bosh_service_url a websocket_url or both", function () {
converse.connection.connected = false;
expect(converse.initConnection.bind({})).toThrow( expect(converse.initConnection.bind({})).toThrow(
new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.")); 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 () { describe("with prebind", function () {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
var connection = mock.mock_connection; var connection = mock.mock_connection;
connection.connected = false; connection.connected = false;
converse._tearDown(); converse._tearDown();
converse.initialized_plugins = [];
converse.initialize({ converse.initialize({
i18n: window.locales.en, i18n: window.locales.en,
bosh_service_url: 'localhost', bosh_service_url: 'localhost',
...@@ -42,6 +43,7 @@ ...@@ -42,6 +43,7 @@
var connection = mock.mock_connection; var connection = mock.mock_connection;
connection.connected = false; connection.connected = false;
converse._tearDown(); converse._tearDown();
converse.initialized_plugins = [];
converse.initialize({ converse.initialize({
i18n: window.locales.en, i18n: window.locales.en,
animate: false, animate: false,
...@@ -59,6 +61,7 @@ ...@@ -59,6 +61,7 @@
connection = mock.mock_connection; connection = mock.mock_connection;
connection.connected = false; connection.connected = false;
converse._tearDown(); converse._tearDown();
converse.initialized_plugins = [];
converse.initialize({ converse.initialize({
i18n: window.locales.en, i18n: window.locales.en,
bosh_service_url: 'localhost', 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 @@ ...@@ -10,7 +10,11 @@
* specified in XEP-0045 Multi-user chat. * specified in XEP-0045 Multi-user chat.
*/ */
(function (root, factory) { (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) { }(this, function (converse, converse_api) {
"use strict"; "use strict";
// Strophe methods for building stanzas // Strophe methods for building stanzas
...@@ -48,10 +52,9 @@ ...@@ -48,10 +52,9 @@
Features: { Features: {
addClientFeatures: function () { addClientFeatures: function () {
var converse = this._super.converse;
this._super.addClientFeatures.apply(this, arguments); this._super.addClientFeatures.apply(this, arguments);
if (converse.allow_muc) { if (this.allow_muc) {
converse.connection.disco.addFeature(Strophe.NS.MUC); this.connection.disco.addFeature(Strophe.NS.MUC);
} }
} }
}, },
...@@ -123,17 +126,6 @@ ...@@ -123,17 +126,6 @@
}, },
ChatBoxes: { 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 () { registerMessageHandler: function () {
/* Override so that we can register a handler /* Override so that we can register a handler
* for chat room invites. * for chat room invites.
...@@ -190,6 +182,19 @@ ...@@ -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 () { initialize: function () {
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
_initialize: function () { _initialize: function () {
this._super._initialize.apply(this, arguments); this._super._initialize.apply(this, arguments);
this._super.converse.otr = new this._super.converse.OTR(); this.otr = new this.OTR();
}, },
registerGlobalEventHandlers: function () { registerGlobalEventHandlers: function () {
......
...@@ -32,14 +32,12 @@ ...@@ -32,14 +32,12 @@
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
onConnected: function () { onConnected: function () {
var converse = this._super.converse; this._super.onConnected().done(this.registerPingHandler);
this._super.onConnected().done(converse.registerPingHandler);
}, },
onReconnected: function () { onReconnected: function () {
// We need to re-register the ping event handler on the newly // We need to re-register the ping event handler on the newly
// created connection. // created connection.
var converse = this._super.converse; this._super.onReconnected().done(this.registerPingHandler);
this._super.onReconnected().done(converse.registerPingHandler);
} }
}, },
......
...@@ -10,7 +10,11 @@ ...@@ -10,7 +10,11 @@
* as specified in XEP-0077. * as specified in XEP-0077.
*/ */
(function (root, factory) { (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) { }(this, function (converse, converse_api) {
"use strict"; "use strict";
// Strophe methods for building stanzas // 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