From df948a8dd65dfcf965c2c07912ccb9c2a6aa5703 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 3 May 2018 17:01:17 +0200 Subject: [PATCH] Also allow a single-user chat to be embedded into the page --- Makefile | 6 --- css/converse.css | 24 +++++---- dev.html | 3 ++ sass/{_muc_embedded.scss => _embedded.scss} | 22 ++++---- sass/converse.scss | 2 +- src/build-no-dependencies.js | 6 +-- src/build.js | 9 ++-- src/config.js | 2 +- src/converse-core.js | 9 +--- src/converse-embedded.js | 59 ++++++++++++++------- src/converse-muc-embedded.js | 42 --------------- src/converse.js | 2 +- 12 files changed, 79 insertions(+), 107 deletions(-) rename sass/{_muc_embedded.scss => _embedded.scss} (93%) delete mode 100644 src/converse-muc-embedded.js diff --git a/Makefile b/Makefile index b979dabe0..f25ee2099 100644 --- a/Makefile +++ b/Makefile @@ -185,8 +185,6 @@ BUILDS = dist/converse.js \ dist/converse.min.js \ dist/converse-headless.js \ dist/converse-headless.min.js \ - dist/converse-muc-embedded.js \ - dist/converse-muc-embedded.min.js \ dist/converse-no-dependencies.min.js \ dist/converse-no-dependencies.js @@ -209,10 +207,6 @@ dist/converse-no-dependencies.js: transpile src stamp-npm $(RJS) -o src/build-no-dependencies.js optimize=none out=dist/converse-no-dependencies.js dist/converse-no-dependencies.min.js: transpile src stamp-npm $(RJS) -o src/build-no-dependencies.js out=dist/converse-no-dependencies.min.js -dist/converse-muc-embedded.js: transpile src stamp-npm - $(RJS) -o src/build.js paths.converse=src/converse-embedded include=converse out=dist/converse-muc-embedded.js optimize=none -dist/converse-muc-embedded.min.js: transpile src stamp-npm - $(RJS) -o src/build.js paths.converse=src/converse-embedded include=converse out=dist/converse-muc-embedded.min.js .PHONY: dist dist:: build diff --git a/css/converse.css b/css/converse.css index 7676908c4..5249a981f 100644 --- a/css/converse.css +++ b/css/converse.css @@ -8628,21 +8628,23 @@ body.reset { bottom: auto; height: 100%; width: 100%; } - #conversejs.converse-embedded .flyout { - bottom: 0; } - #conversejs.converse-embedded .chatroom { + #conversejs.converse-embedded .chatbox { margin: 0; + height: 100%; width: 100%; } - #conversejs.converse-embedded .chatbox .box-flyout { - box-shadow: none; - height: 100%; } - #conversejs.converse-embedded .chatbox .chat-title { - padding: 0.3em; - font-size: 120%; } + #conversejs.converse-embedded .chatbox .flyout.box-flyout { + bottom: 0; + box-shadow: none; + height: 100%; + min-width: auto; + width: 100%; } + #conversejs.converse-embedded .chatbox .chat-title { + padding: 0.3em; + font-size: 120%; } #conversejs.converse-embedded .chatbox-btn { display: none; } - #conversejs.converse-embedded .chatroom .box-flyout { - min-width: auto; + #conversejs.converse-embedded .chatroom { + margin: 0; width: 100%; } #conversejs.converse-embedded .chatroom .box-flyout .occupants-heading { font-size: 120%; } diff --git a/dev.html b/dev.html index aede01bbb..564b7cfce 100644 --- a/dev.html +++ b/dev.html @@ -65,6 +65,9 @@ notify_all_room_messages: [ 'discuss@conference.conversejs.org' ], + auto_join_private_chats: [ + 'opkode@jappix.com' + ], auto_reconnect: true, // bosh_service_url: 'http://chat.example.org:5280/http-bind/', bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes diff --git a/sass/_muc_embedded.scss b/sass/_embedded.scss similarity index 93% rename from sass/_muc_embedded.scss rename to sass/_embedded.scss index e6908f6bb..b53631c8f 100644 --- a/sass/_muc_embedded.scss +++ b/sass/_embedded.scss @@ -21,19 +21,19 @@ width: 100%; } - .flyout { - bottom: 0; - } - - .chatroom { - margin: 0; - width: 100%; - } .chatbox { - .box-flyout { + margin: 0; + height: 100%; + width: 100%; + + .flyout.box-flyout { + bottom: 0; box-shadow: none; height: 100%; + min-width: auto; + width: 100%; } + .chat-title { padding: 0.3em; font-size: 120%; @@ -43,9 +43,9 @@ display: none; } .chatroom { + margin: 0; + width: 100%; .box-flyout { - min-width: auto; - width: 100%; .occupants-heading { font-size: 120%; } diff --git a/sass/converse.scss b/sass/converse.scss index 8aae8d3d3..fc06fd2bd 100644 --- a/sass/converse.scss +++ b/sass/converse.scss @@ -54,4 +54,4 @@ @import "converse/minimized_chats"; @import "bookmarks"; @import "awesomplete"; -@import "muc_embedded"; +@import "embedded"; diff --git a/src/build-no-dependencies.js b/src/build-no-dependencies.js index 610c6007f..0a7dd265c 100644 --- a/src/build-no-dependencies.js +++ b/src/build-no-dependencies.js @@ -28,12 +28,12 @@ "converse-core": "builds/converse-core", "converse-disco": "builds/converse-disco", "converse-dragresize": "builds/converse-dragresize", - "converse-headline": "builds/converse-headline", + "converse-embedded": "builds/converse-embedded", "converse-fullscreen": "builds/converse-fullscreen", + "converse-headline": "builds/converse-headline", "converse-mam": "builds/converse-mam", "converse-minimize": "builds/converse-minimize", "converse-muc": "builds/converse-muc", - "converse-muc-embedded": "builds/converse-muc-embedded", "converse-notification": "builds/converse-notification", "converse-otr": "builds/converse-otr", "converse-ping": "builds/converse-ping", @@ -43,9 +43,9 @@ "converse-rosterview": "builds/converse-rosterview", "converse-singleton": "builds/converse-singleton", "converse-vcard": "builds/converse-vcard", + "form-utils": "builds/utils/form", "i18n": "builds/i18n", "utils": "builds/utils/core", - "form-utils": "builds/utils/form", "muc-utils": "builds/utils/muc" }, wrap: { diff --git a/src/build.js b/src/build.js index 8aab2a903..e41e3ac56 100644 --- a/src/build.js +++ b/src/build.js @@ -11,15 +11,14 @@ "converse-core": "builds/converse-core", "converse-disco": "builds/converse-disco", "converse-dragresize": "builds/converse-dragresize", + "converse-embedded": "builds/converse-embedded", "converse-fullscreen": "builds/converse-fullscreen", "converse-headline": "builds/converse-headline", - "converse-http-file-upload":"builds/converse-http-file-upload", "converse-mam": "builds/converse-mam", "converse-minimize": "builds/converse-minimize", "converse-modal": "builds/converse-modal", "converse-muc": "builds/converse-muc", "converse-muc-views": "builds/converse-muc-views", - "converse-muc-embedded": "builds/converse-muc-embedded", "converse-notification": "builds/converse-notification", "converse-otr": "builds/converse-otr", "converse-ping": "builds/converse-ping", @@ -29,10 +28,10 @@ "converse-rosterview": "builds/converse-rosterview", "converse-singleton": "builds/converse-singleton", "converse-vcard": "builds/converse-vcard", - "i18n": "builds/i18n", - "utils": "builds/utils/core", "form-utils": "builds/utils/form", - "muc-utils": "builds/utils/muc" + "i18n": "builds/i18n", + "muc-utils": "builds/utils/muc", + "utils": "builds/utils/core" }, wrap: { startFile: "start.frag", diff --git a/src/config.js b/src/config.js index ff74ecd5c..34b48a0e2 100644 --- a/src/config.js +++ b/src/config.js @@ -78,6 +78,7 @@ require.config({ "converse-core": "src/converse-core", "converse-disco": "src/converse-disco", "converse-dragresize": "src/converse-dragresize", + "converse-embedded": "src/converse-embedded", "converse-fullscreen": "src/converse-fullscreen", "converse-headline": "src/converse-headline", "converse-mam": "src/converse-mam", @@ -85,7 +86,6 @@ require.config({ "converse-minimize": "src/converse-minimize", "converse-modal": "src/converse-modal", "converse-muc": "src/converse-muc", - "converse-muc-embedded": "src/converse-muc-embedded", "converse-muc-views": "src/converse-muc-views", "converse-notification": "src/converse-notification", "converse-otr": "src/converse-otr", diff --git a/src/converse-core.js b/src/converse-core.js index 3c8557946..d25c6f515 100644 --- a/src/converse-core.js +++ b/src/converse-core.js @@ -77,7 +77,7 @@ 'converse-core', 'converse-disco', 'converse-dragresize', - 'converse-dropdown', + 'converse-embedded', 'converse-fullscreen', 'converse-headline', 'converse-http-file-upload', @@ -86,7 +86,6 @@ 'converse-minimize', 'converse-modal', 'converse-muc', - 'converse-muc-embedded', 'converse-muc-views', 'converse-notification', 'converse-otr', @@ -1848,12 +1847,8 @@ _.forEach([ // eslint-disable-line lodash/prefer-map "converse-bookmarks", "converse-controlbox", - "converse-dragresize", "converse-headline", - "converse-minimize", - "converse-otr", - "converse-register", - "converse-vcard", + "converse-register" ], (name) => { _converse.blacklisted_plugins.push(name) }); diff --git a/src/converse-embedded.js b/src/converse-embedded.js index c1432ceba..f7528e88b 100644 --- a/src/converse-embedded.js +++ b/src/converse-embedded.js @@ -1,20 +1,41 @@ -/*global define */ -if (typeof define !== 'undefined') { - // The section below determines which plugins will be included in a build - define([ - "converse-core", - /* START: Removable components - * -------------------- - * Any of the following components may be removed if they're not needed. - */ - "converse-chatview", // Renders standalone chat boxes for single user chat - "converse-mam", // XEP-0313 Message Archive Management - "converse-muc", // XEP-0045 Multi-user chat - "converse-muc-embedded", - "converse-ping", // XEP-0199 XMPP Ping - "converse-notification",// HTML5 Notifications - /* END: Removable components */ - ], function (converse) { - return converse; +// Converse.js +// http://conversejs.org +// +// Copyright (c) 2012-2018, the Converse.js developers +// Licensed under the Mozilla Public License (MPLv2) + +(function (root, factory) { + define(["converse-core", "converse-muc"], factory); +}(this, function (converse) { + "use strict"; + const { Backbone, _ } = converse.env; + + converse.plugins.add('converse-embedded', { + + enabled (_converse) { + return _converse.view_mode === 'embedded'; + }, + + initialize () { + /* The initialize function gets called as soon as the plugin is + * loaded by converse.js's plugin machinery. + */ + this._converse.api.settings.update({ + 'allow_logout': false, // No point in logging out when we have auto_login as true. + 'allow_muc_invitations': false, // Doesn't make sense to allow because only + // roster contacts can be invited + 'hide_muc_server': true + }); + const { _converse } = this; + if (!_.isArray(_converse.auto_join_rooms) && !_.isArray(_converse.auto_join_private_chats)) { + throw new Error("converse-embedded: auto_join_rooms must be an Array"); + } + if (_converse.auto_join_rooms.length !== 1 && _converse.auto_join_private_chats.length !== 1) { + throw new Error("converse-embedded: It doesn't make "+ + "sense to have the auto_join_rooms setting to zero or "+ + "more then one, since only one chat room can be open "+ + "at any time."); + } + } }); -} +})); diff --git a/src/converse-muc-embedded.js b/src/converse-muc-embedded.js deleted file mode 100644 index be4b4d41d..000000000 --- a/src/converse-muc-embedded.js +++ /dev/null @@ -1,42 +0,0 @@ -// Converse.js -// http://conversejs.org -// -// Copyright (c) 2012-2018, the Converse.js developers -// Licensed under the Mozilla Public License (MPLv2) - -(function (root, factory) { - define(["converse-core", "converse-muc"], factory); -}(this, function (converse) { - "use strict"; - const { Backbone, _ } = converse.env; - - converse.plugins.add('converse-muc-embedded', { - - enabled (_converse) { - return _converse.view_mode === 'embedded'; - }, - - initialize () { - /* The initialize function gets called as soon as the plugin is - * loaded by converse.js's plugin machinery. - */ - this._converse.api.settings.update({ - 'allow_logout': false, // No point in logging out when we have auto_login as true. - 'allow_muc_invitations': false, // Doesn't make sense to allow because only - // roster contacts can be invited - 'hide_muc_server': true, // Federation is disabled, so no use in - // showing the MUC server. - }); - const { _converse } = this; - if (!_.isArray(_converse.auto_join_rooms)) { - throw new Error("converse-muc-embedded: auto_join_rooms must be an Array"); - } - if (_converse.auto_join_rooms.length !== 1) { - throw new Error("converse-muc-embedded: It doesn't make "+ - "sense to have the auto_join_rooms setting to zero or "+ - "more then one, since only one chat room can be open "+ - "at any time."); - } - } - }); -})); diff --git a/src/converse.js b/src/converse.js index 08344fcf0..f2f317031 100644 --- a/src/converse.js +++ b/src/converse.js @@ -11,12 +11,12 @@ if (typeof define !== 'undefined') { "converse-chatview", // Renders standalone chat boxes for single user chat "converse-controlbox", // The control box "converse-dragresize", // Allows chat boxes to be resized by dragging them + "converse-embedded", "converse-fullscreen", "converse-headline", // Support for headline messages "converse-mam", // XEP-0313 Message Archive Management "converse-minimize", // Allows chat boxes to be minimized "converse-muc", // XEP-0045 Multi-user chat - "converse-muc-embedded", "converse-muc-views", "converse-muc-views", // Views related to MUC "converse-notification", // HTML5 Notifications