Commit 6904f9a8 authored by JC Brand's avatar JC Brand

Use es2015 modules instead of UMD

parent 3a33d6f9
{ {
"parserOptions": { "parserOptions": {
"ecmaVersion": 2017 "ecmaVersion": 2017,
"sourceType": "module"
}, },
"env": { "env": {
"browser": true, "browser": true,
......
# Changelog # Changelog
## 4.1.0 (Unreleased)
- Use [Lerna](https://lernajs.io/) to create the @converse/headless package
- Use ES2015 modules instead of UMD.
## 4.0.3 (2018-10-22) ## 4.0.3 (2018-10-22)
- New translations: Arabic, Basque, Czech, French, German, Hungarian, Japanese, Norwegian Bokmål, Polish, Romanian, Spanish - New translations: Arabic, Basque, Czech, French, German, Hungarian, Japanese, Norwegian Bokmål, Polish, Romanian, Spanish
......
...@@ -157,12 +157,16 @@ watchcss: dev ...@@ -157,12 +157,16 @@ watchcss: dev
$(SASS) --watch -I $(BOURBON) -I $(BOOTSTRAP) sass:css $(SASS) --watch -I $(BOURBON) -I $(BOOTSTRAP) sass:css
.PHONY: watchjs .PHONY: watchjs
watchjs: dev watchjs: dev dist/converse-headless.js
./node_modules/.bin/npx webpack --mode=development --watch ./node_modules/.bin/npx webpack --mode=development --watch
.PHONY: watchjsheadless
watchjsheadless: dev
./node_modules/.bin/npx webpack --mode=development --watch --type=headless
.PHONY: watch .PHONY: watch
watch: dev watch: dev
make -j 2 watchjs watchcss make -j 3 watchcss watchjsheadless watchjs
.PHONY: logo .PHONY: logo
logo: logo/conversejs-transparent16.png \ logo: logo/conversejs-transparent16.png \
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1555,10 +1555,9 @@ ...@@ -1555,10 +1555,9 @@
it("properly handles notification that a room has been destroyed", it("properly handles notification that a room has been destroyed",
mock.initConverseWithPromises( mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { async function (done, _converse) {
test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') await test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy')
.then(function () {
const presence = $pres().attrs({ const presence = $pres().attrs({
from:'problematic@muc.localhost', from:'problematic@muc.localhost',
id:'n13mt3l', id:'n13mt3l',
...@@ -1582,7 +1581,6 @@ ...@@ -1582,7 +1581,6 @@
expect(view.el.querySelector('.chatroom-body .moved-link').textContent.trim()) expect(view.el.querySelector('.chatroom-body .moved-link').textContent.trim())
.toBe(`other-room@chat.jabberfr.org`); .toBe(`other-room@chat.jabberfr.org`);
done(); done();
}).catch(_.partial(console.error, _));
})); }));
it("will use the user's reserved nickname, if it exists", it("will use the user's reserved nickname, if it exists",
......
...@@ -15,27 +15,23 @@ ...@@ -15,27 +15,23 @@
null, ['rosterGroupsFetched', 'chatBoxesFetched'], null, ['rosterGroupsFetched', 'chatBoxesFetched'],
{ allow_bookmarks: false // Makes testing easier, otherwise we { allow_bookmarks: false // Makes testing easier, otherwise we
// have to mock stanza traffic. // have to mock stanza traffic.
}, }, async function (done, _converse) {
function (done, _converse) {
test_utils.openControlBox(); test_utils.openControlBox();
const controlbox = _converse.chatboxviews.get('controlbox'); const controlbox = _converse.chatboxviews.get('controlbox');
let list = controlbox.el.querySelector('div.rooms-list-container'); let list = controlbox.el.querySelector('div.rooms-list-container');
expect(_.includes(list.classList, 'hidden')).toBeTruthy(); expect(_.includes(list.classList, 'hidden')).toBeTruthy();
let room_els; await test_utils.openChatRoom(_converse, 'room', 'conference.shakespeare.lit', 'JC');
test_utils.openChatRoom(_converse, 'room', 'conference.shakespeare.lit', 'JC')
.then(() => {
expect(_.isUndefined(_converse.rooms_list_view)).toBeFalsy(); expect(_.isUndefined(_converse.rooms_list_view)).toBeFalsy();
room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room"); let room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(1); expect(room_els.length).toBe(1);
expect(room_els[0].innerText).toBe('room@conference.shakespeare.lit'); expect(room_els[0].innerText).toBe('room@conference.shakespeare.lit');
return test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy'); await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
}).then(() => {
room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room"); room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(2); expect(room_els.length).toBe(2);
var view = _converse.chatboxviews.get('room@conference.shakespeare.lit'); let view = _converse.chatboxviews.get('room@conference.shakespeare.lit');
view.close(); view.close();
room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room"); room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(1); expect(room_els.length).toBe(1);
...@@ -51,7 +47,6 @@ ...@@ -51,7 +47,6 @@
list = controlbox.el.querySelector('div.rooms-list-container'); list = controlbox.el.querySelector('div.rooms-list-container');
expect(_.includes(list.classList, 'hidden')).toBeTruthy(); expect(_.includes(list.classList, 'hidden')).toBeTruthy();
done(); done();
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
)); ));
}); });
......
...@@ -7,15 +7,15 @@ ...@@ -7,15 +7,15 @@
// This plugin started as a fork of Lea Verou's Awesomplete // This plugin started as a fork of Lea Verou's Awesomplete
// https://leaverou.github.io/awesomplete/ // https://leaverou.github.io/awesomplete/
(function (root, factory) {
define(["@converse/headless/converse-core"], factory);
}(this, function (converse) {
const { _, Backbone } = converse.env, import converse from "@converse/headless/converse-core";
const { _, Backbone } = converse.env,
u = converse.env.utils; u = converse.env.utils;
converse.plugins.add("converse-autocomplete", { converse.plugins.add("converse-autocomplete", {
initialize () { initialize () {
const { _converse } = this; const { _converse } = this;
...@@ -411,5 +411,4 @@ ...@@ -411,5 +411,4 @@
_converse.AutoComplete = AutoComplete; _converse.AutoComplete = AutoComplete;
} }
}); });
}));
...@@ -9,28 +9,19 @@ ...@@ -9,28 +9,19 @@
/* This is a Converse.js plugin which add support for bookmarks specified /* This is a Converse.js plugin which add support for bookmarks specified
* in XEP-0048. * in XEP-0048.
*/ */
(function (root, factory) {
define(["@converse/headless/converse-core", import converse from "@converse/headless/converse-core";
"@converse/headless/converse-muc", import muc from "@converse/headless/converse-muc";
"templates/chatroom_bookmark_form.html", import tpl_bookmark from "templates/bookmark.html";
"templates/chatroom_bookmark_toggle.html", import tpl_bookmarks_list from "templates/bookmarks_list.html"
"templates/bookmark.html", import tpl_chatroom_bookmark_form from "templates/chatroom_bookmark_form.html";
"templates/bookmarks_list.html" import tpl_chatroom_bookmark_toggle from "templates/chatroom_bookmark_toggle.html";
],
factory); const { Backbone, Promise, Strophe, $iq, b64_sha1, sizzle, _ } = converse.env;
}(this, function ( const u = converse.env.utils;
converse,
muc,
tpl_chatroom_bookmark_form, converse.plugins.add('converse-bookmarks', {
tpl_chatroom_bookmark_toggle,
tpl_bookmark,
tpl_bookmarks_list
) {
const { Backbone, Promise, Strophe, $iq, b64_sha1, sizzle, _ } = converse.env;
const u = converse.env.utils;
converse.plugins.add('converse-bookmarks', {
/* Plugin dependencies are other plugins which might be /* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
...@@ -42,7 +33,7 @@ ...@@ -42,7 +33,7 @@
* *
* NB: These plugins need to have already been loaded via require.js. * NB: These plugins need to have already been loaded via require.js.
*/ */
dependencies: ["converse-chatboxes", "@converse/headless/converse-muc", "converse-muc-views"], dependencies: ["converse-chatboxes", "converse-muc", "converse-muc-views"],
overrides: { overrides: {
// Overrides mentioned here will be picked up by converse.js's // Overrides mentioned here will be picked up by converse.js's
...@@ -583,5 +574,4 @@ ...@@ -583,5 +574,4 @@
}); });
} }
}); });
}));
...@@ -4,19 +4,18 @@ ...@@ -4,19 +4,18 @@
// Copyright (c) 2013-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) {
define(["@converse/headless/converse-core"], factory);
}(this, function (converse) {
const { Strophe, $build, _, b64_sha1 } = converse.env; import converse from "@converse/headless/converse-core";
Strophe.addNamespace('CAPS', "http://jabber.org/protocol/caps"); const { Strophe, $build, _, b64_sha1 } = converse.env;
function propertySort (array, property) { Strophe.addNamespace('CAPS', "http://jabber.org/protocol/caps");
function propertySort (array, property) {
return array.sort((a, b) => { return a[property] > b[property] ? -1 : 1 }); return array.sort((a, b) => { return a[property] > b[property] ? -1 : 1 });
} }
function generateVerificationString (_converse) { function generateVerificationString (_converse) {
const identities = _converse.api.disco.own.identities.get(), const identities = _converse.api.disco.own.identities.get(),
features = _converse.api.disco.own.features.get(); features = _converse.api.disco.own.features.get();
...@@ -34,18 +33,18 @@ ...@@ -34,18 +33,18 @@
features.sort(); features.sort();
S = _.reduce(features, (result, feature) => `${result}${feature}<`, S); S = _.reduce(features, (result, feature) => `${result}${feature}<`, S);
return b64_sha1(S); return b64_sha1(S);
} }
function createCapsNode (_converse) { function createCapsNode (_converse) {
return $build("c", { return $build("c", {
'xmlns': Strophe.NS.CAPS, 'xmlns': Strophe.NS.CAPS,
'hash': "sha-1", 'hash': "sha-1",
'node': "https://conversejs.org", 'node': "https://conversejs.org",
'ver': generateVerificationString(_converse) 'ver': generateVerificationString(_converse)
}).nodeTree; }).nodeTree;
} }
converse.plugins.add('converse-caps', { converse.plugins.add('converse-caps', {
overrides: { overrides: {
// Overrides mentioned here will be picked up by converse.js's // Overrides mentioned here will be picked up by converse.js's
...@@ -59,5 +58,4 @@ ...@@ -59,5 +58,4 @@
} }
} }
} }
}); });
}));
...@@ -4,20 +4,15 @@ ...@@ -4,20 +4,15 @@
// Copyright (c) 2012-2018, the Converse.js developers // Copyright (c) 2012-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import "@converse/headless/converse-chatboxes";
define([ import "backbone.nativeview";
"@converse/headless/converse-core", import "backbone.overview";
"templates/chatboxes.html", import converse from "@converse/headless/converse-core";
"@converse/headless/converse-chatboxes", import tpl_chatboxes from "templates/chatboxes.html";
"backbone.nativeview",
"backbone.overview"
], factory);
}(this, function (converse, tpl_chatboxes) {
"use strict";
const { Backbone, _ } = converse.env; const { Backbone, _ } = converse.env;
const AvatarMixin = { const AvatarMixin = {
renderAvatar (el) { renderAvatar (el) {
el = el || this.el; el = el || this.el;
...@@ -47,10 +42,10 @@ ...@@ -47,10 +42,10 @@
img.src = img_src; img.src = img_src;
}); });
}, },
}; };
converse.plugins.add('converse-chatboxviews', { converse.plugins.add('converse-chatboxviews', {
dependencies: ["converse-chatboxes"], dependencies: ["converse-chatboxes"],
...@@ -174,6 +169,4 @@ ...@@ -174,6 +169,4 @@
_converse.api.listen.on('clearSession', () => _converse.chatboxviews.closeAllChatBoxes()); _converse.api.listen.on('clearSession', () => _converse.chatboxviews.closeAllChatBoxes());
/************************ END Event Handlers ************************/ /************************ END Event Handlers ************************/
} }
}); });
return converse;
}));
// Converse.js // Converse.js
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2012-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import "converse-chatboxviews";
define([ import "converse-message-view";
"utils/emoji", import "converse-modal";
"@converse/headless/converse-core", import * as twemoji from "twemoji";
"bootstrap", import bootstrap from "bootstrap";
"twemoji", import converse from "@converse/headless/converse-core";
"xss", import tpl_chatbox from "templates/chatbox.html";
"templates/chatbox.html", import tpl_chatbox_head from "templates/chatbox_head.html";
"templates/chatbox_head.html", import tpl_chatbox_message_form from "templates/chatbox_message_form.html";
"templates/chatbox_message_form.html", import tpl_emojis from "templates/emojis.html";
"templates/emojis.html", import tpl_error_message from "templates/error_message.html";
"templates/error_message.html", import tpl_help_message from "templates/help_message.html";
"templates/help_message.html", import tpl_info from "templates/info.html";
"templates/info.html", import tpl_new_day from "templates/new_day.html";
"templates/new_day.html", import tpl_spinner from "templates/spinner.html";
"templates/user_details_modal.html", import tpl_spoiler_button from "templates/spoiler_button.html";
"templates/toolbar_fileupload.html", import tpl_status_message from "templates/status_message.html";
"templates/spinner.html", import tpl_toolbar from "templates/toolbar.html";
"templates/spoiler_button.html", import tpl_toolbar_fileupload from "templates/toolbar_fileupload.html";
"templates/status_message.html", import tpl_user_details_modal from "templates/user_details_modal.html";
"templates/toolbar.html", import u from "utils/emoji";
"converse-modal", import xss from "xss";
"converse-chatboxviews",
"converse-message-view" const { $msg, Backbone, Promise, Strophe, _, b64_sha1, f, sizzle, moment } = converse.env;
], factory);
}(this, function (
u, converse.plugins.add('converse-chatview', {
converse,
bootstrap,
twemoji,
xss,
tpl_chatbox,
tpl_chatbox_head,
tpl_chatbox_message_form,
tpl_emojis,
tpl_error_message,
tpl_help_message,
tpl_info,
tpl_new_day,
tpl_user_details_modal,
tpl_toolbar_fileupload,
tpl_spinner,
tpl_spoiler_button,
tpl_status_message,
tpl_toolbar
) {
"use strict";
const { $msg, Backbone, Promise, Strophe, _, b64_sha1, f, sizzle, moment } = converse.env;
converse.plugins.add('converse-chatview', {
/* Plugin dependencies are other plugins which might be /* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
* this plugin. * this plugin.
...@@ -1340,7 +1317,4 @@ ...@@ -1340,7 +1317,4 @@
}); });
/************************ END API ************************/ /************************ END API ************************/
} }
}); });
return converse;
}));
...@@ -6,36 +6,23 @@ ...@@ -6,36 +6,23 @@
// //
/*global define */ /*global define */
(function (root, factory) { import "converse-chatview";
define(["@converse/headless/converse-core", import "converse-profile";
"bootstrap", import "converse-rosterview";
"formdata-polyfill", import _FormData from "formdata-polyfill";
"@converse/headless/lodash.fp", import bootstrap from "bootstrap";
"templates/converse_brand_heading.html", import converse from "@converse/headless/converse-core";
"templates/controlbox.html", import fp from "@converse/headless/lodash.fp";
"templates/controlbox_toggle.html", import tpl_brand_heading from "templates/converse_brand_heading.html";
"templates/login_panel.html", import tpl_controlbox from "templates/controlbox.html";
"converse-chatview", import tpl_controlbox_toggle from "templates/controlbox_toggle.html";
"converse-rosterview", import tpl_login_panel from "templates/login_panel.html";
"converse-profile"
], factory); const CHATBOX_TYPE = 'chatbox';
}(this, function ( const { Strophe, Backbone, Promise, _, moment } = converse.env;
converse, const u = converse.env.utils;
bootstrap,
_FormData, const CONNECTION_STATUS_CSS_CLASS = {
fp,
tpl_brand_heading,
tpl_controlbox,
tpl_controlbox_toggle,
tpl_login_panel
) {
"use strict";
const CHATBOX_TYPE = 'chatbox';
const { Strophe, Backbone, Promise, _, moment } = converse.env;
const u = converse.env.utils;
const CONNECTION_STATUS_CSS_CLASS = {
'Error': 'error', 'Error': 'error',
'Connecting': 'info', 'Connecting': 'info',
'Connection failure': 'error', 'Connection failure': 'error',
...@@ -47,9 +34,9 @@ ...@@ -47,9 +34,9 @@
'Attached': 'info', 'Attached': 'info',
'Redirect': 'info', 'Redirect': 'info',
'Reconnecting': 'warn' 'Reconnecting': 'warn'
}; };
const PRETTY_CONNECTION_STATUS = { const PRETTY_CONNECTION_STATUS = {
0: 'Error', 0: 'Error',
1: 'Connecting', 1: 'Connecting',
2: 'Connection failure', 2: 'Connection failure',
...@@ -61,9 +48,9 @@ ...@@ -61,9 +48,9 @@
8: 'Attached', 8: 'Attached',
9: 'Redirect', 9: 'Redirect',
10: 'Reconnecting' 10: 'Reconnecting'
}; };
const REPORTABLE_STATUSES = [ const REPORTABLE_STATUSES = [
0, // ERROR' 0, // ERROR'
1, // CONNECTING 1, // CONNECTING
2, // CONNFAIL 2, // CONNFAIL
...@@ -71,9 +58,9 @@ ...@@ -71,9 +58,9 @@
4, // AUTHFAIL 4, // AUTHFAIL
7, // DISCONNECTING 7, // DISCONNECTING
10 // RECONNECTING 10 // RECONNECTING
]; ];
converse.plugins.add('converse-controlbox', { converse.plugins.add('converse-controlbox', {
/* Plugin dependencies are other plugins which might be /* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
* this plugin. * this plugin.
...@@ -624,5 +611,4 @@ ...@@ -624,5 +611,4 @@
_converse.on('disconnected', () => disconnect().renderLoginPanel()); _converse.on('disconnected', () => disconnect().renderLoginPanel());
_converse.on('will-reconnect', disconnect); _converse.on('will-reconnect', disconnect);
} }
}); });
}));
...@@ -6,17 +6,14 @@ ...@@ -6,17 +6,14 @@
// //
/*global define, window, document */ /*global define, window, document */
(function (root, factory) { import "converse-chatview";
define(["@converse/headless/converse-core", import "converse-controlbox";
"templates/dragresize.html", import converse from "@converse/headless/converse-core";
"converse-chatview", import tpl_dragresize from "templates/dragresize.html";
"converse-controlbox"
], factory); const { _ } = converse.env;
}(this, function (converse, tpl_dragresize) {
"use strict"; function renderDragResizeHandles (_converse, view) {
const { _ } = converse.env;
function renderDragResizeHandles (_converse, view) {
const flyout = view.el.querySelector('.box-flyout'); const flyout = view.el.querySelector('.box-flyout');
const div = document.createElement('div'); const div = document.createElement('div');
div.innerHTML = tpl_dragresize(); div.innerHTML = tpl_dragresize();
...@@ -24,10 +21,10 @@ ...@@ -24,10 +21,10 @@
div, div,
flyout.firstChild flyout.firstChild
); );
} }
converse.plugins.add('converse-dragresize', { converse.plugins.add('converse-dragresize', {
/* Plugin dependencies are other plugins which might be /* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
* this plugin. * this plugin.
...@@ -367,5 +364,5 @@ ...@@ -367,5 +364,5 @@
return value; return value;
}; };
} }
}); });
}));
// Converse.js // Converse.js
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2012-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import "@converse/headless/converse-muc";
define(["@converse/headless/converse-core", "@converse/headless/converse-muc"], factory); import converse from "@converse/headless/converse-core";
}(this, function (converse) {
"use strict";
const { Backbone, _ } = converse.env;
converse.plugins.add('converse-embedded', { const { Backbone, _ } = converse.env;
converse.plugins.add('converse-embedded', {
enabled (_converse) { enabled (_converse) {
return _converse.view_mode === 'embedded'; return _converse.view_mode === 'embedded';
...@@ -36,5 +35,4 @@ ...@@ -36,5 +35,4 @@
"since only one chat room can be open at any time."); "since only one chat room can be open at any time.");
} }
} }
}); });
}));
...@@ -4,21 +4,17 @@ ...@@ -4,21 +4,17 @@
// Copyright (c) JC Brand <jc@opkode.com> // Copyright (c) JC Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
// //
/*global define */
import "@converse/headless/converse-muc";
(function (root, factory) { import "converse-chatview";
define(["@converse/headless/converse-core", import "converse-controlbox";
"templates/inverse_brand_heading.html", import "converse-singleton";
"converse-chatview", import converse from "@converse/headless/converse-core";
"converse-controlbox", import tpl_brand_heading from "templates/inverse_brand_heading.html";
"@converse/headless/converse-muc",
"converse-singleton" const { Strophe, _ } = converse.env;
], factory);
}(this, function (converse, tpl_brand_heading) { converse.plugins.add('converse-fullscreen', {
"use strict";
const { Strophe, _ } = converse.env;
converse.plugins.add('converse-fullscreen', {
enabled (_converse) { enabled (_converse) {
return _.includes(['fullscreen', 'embedded'], _converse.view_mode); return _.includes(['fullscreen', 'embedded'], _converse.view_mode);
...@@ -56,5 +52,4 @@ ...@@ -56,5 +52,4 @@
sticky_controlbox: true sticky_controlbox: true
}); });
} }
}); });
}));
...@@ -3,20 +3,15 @@ ...@@ -3,20 +3,15 @@
// //
// Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com> // Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
//
/*global define */ import "converse-chatview";
import converse from "@converse/headless/converse-core";
(function (root, factory) { import tpl_chatbox from "templates/chatbox.html";
define([
"@converse/headless/converse-core", const { _, utils } = converse.env;
"templates/chatbox.html",
"converse-chatview",
], factory); converse.plugins.add('converse-headline', {
}(this, function (converse, tpl_chatbox) {
"use strict";
const { _, utils } = converse.env;
converse.plugins.add('converse-headline', {
/* Plugin dependencies are other plugins which might be /* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
* this plugin. * this plugin.
...@@ -152,5 +147,4 @@ ...@@ -152,5 +147,4 @@
}); });
}); });
} }
}); });
}));
...@@ -4,36 +4,21 @@ ...@@ -4,36 +4,21 @@
// Copyright (c) 2013-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import converse from "@converse/headless/converse-core";
define([ import filesize from "filesize";
"./utils/html", import html from "./utils/html";
"utils/emoji", import tpl_csn from "templates/csn.html";
"@converse/headless/converse-core", import tpl_file_progress from "templates/file_progress.html";
"xss", import tpl_info from "templates/info.html";
"filesize", import tpl_message from "templates/message.html";
"templates/csn.html", import tpl_message_versions_modal from "templates/message_versions_modal.html";
"templates/file_progress.html", import u from "utils/emoji";
"templates/info.html", import xss from "xss";
"templates/message.html",
"templates/message_versions_modal.html",
], factory);
}(this, function (
html,
u,
converse,
xss,
filesize,
tpl_csn,
tpl_file_progress,
tpl_info,
tpl_message,
tpl_message_versions_modal
) {
"use strict";
const { Backbone, _, moment } = converse.env;
const { Backbone, _, moment } = converse.env;
converse.plugins.add('converse-message-view', {
converse.plugins.add('converse-message-view', {
initialize () { initialize () {
/* The initialize function gets called as soon as the plugin is /* The initialize function gets called as soon as the plugin is
...@@ -271,6 +256,4 @@ ...@@ -271,6 +256,4 @@
} }
}); });
} }
}); });
return converse;
}));
// Converse.js (A browser based XMPP chat client) // Converse.js (A browser based XMPP chat client)
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com> // Copyright (c) 2013-2018, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
//
/*global define, window, document */ import "converse-chatview";
import converse from "@converse/headless/converse-core";
(function (root, factory) { import tpl_chatbox_minimize from "templates/chatbox_minimize.html";
define(["@converse/headless/converse-core", import tpl_chats_panel from "templates/chats_panel.html";
"templates/chatbox_minimize.html", import tpl_toggle_chats from "templates/toggle_chats.html";
"templates/toggle_chats.html", import tpl_trimmed_chat from "templates/trimmed_chat.html";
"templates/trimmed_chat.html",
"templates/chats_panel.html",
"converse-chatview" const { _ , Backbone, Promise, Strophe, b64_sha1, moment } = converse.env;
], factory); const u = converse.env.utils;
}(this, function (
converse, converse.plugins.add('converse-minimize', {
tpl_chatbox_minimize,
tpl_toggle_chats,
tpl_trimmed_chat,
tpl_chats_panel
) {
"use strict";
const { _ , Backbone, Promise, Strophe, b64_sha1, moment } = converse.env;
const u = converse.env.utils;
converse.plugins.add('converse-minimize', {
/* Optional dependencies are other plugins which might be /* Optional dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
* this plugin. They are called "optional" because they might not be * this plugin. They are called "optional" because they might not be
...@@ -39,7 +28,7 @@ ...@@ -39,7 +28,7 @@
* *
* NB: These plugins need to have already been loaded via require.js. * NB: These plugins need to have already been loaded via require.js.
*/ */
dependencies: ["converse-chatview", "converse-controlbox", "@converse/headless/converse-muc", "converse-muc-views", "converse-headline"], dependencies: ["converse-chatview", "converse-controlbox", "converse-muc", "converse-muc-views", "converse-headline"],
enabled (_converse) { enabled (_converse) {
return _converse.view_mode == 'overlayed'; return _converse.view_mode == 'overlayed';
...@@ -548,5 +537,4 @@ ...@@ -548,5 +537,4 @@
} }
}); });
} }
}); });
}));
// Converse.js // Converse.js
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import "backbone.vdomview";
if (typeof define === 'function' && define.amd) { import bootstrap from "bootstrap";
define([ import converse from "@converse/headless/converse-core";
"@converse/headless/converse-core", import tpl_alert_modal from "templates/alert_modal.html";
"templates/alert_modal.html",
"bootstrap", const { Strophe, Backbone, _ } = converse.env;
"backbone.vdomview"
], factory);
}
}(this, function (converse, tpl_alert_modal, bootstrap) {
"use strict";
const { Strophe, Backbone, _ } = converse.env;
converse.plugins.add('converse-modal', { converse.plugins.add('converse-modal', {
initialize () { initialize () {
const { _converse } = this; const { _converse } = this;
...@@ -113,5 +107,5 @@ ...@@ -113,5 +107,5 @@
} }
}); });
} }
}); });
}));
...@@ -4,70 +4,39 @@ ...@@ -4,70 +4,39 @@
// Copyright (c) 2013-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import "converse-modal";
define([ import Awesomplete from "awesomplete";
"@converse/headless/converse-core", import _FormData from "formdata-polyfill";
"formdata-polyfill", import converse from "@converse/headless/converse-core";
"utils/muc", import muc_utils from "utils/muc";
"xss", import tpl_add_chatroom_modal from "templates/add_chatroom_modal.html";
"templates/add_chatroom_modal.html", import tpl_chatarea from "templates/chatarea.html";
"templates/chatarea.html", import tpl_chatroom from "templates/chatroom.html";
"templates/chatroom.html", import tpl_chatroom_destroyed from "templates/chatroom_destroyed.html";
"templates/chatroom_details_modal.html", import tpl_chatroom_details_modal from "templates/chatroom_details_modal.html";
"templates/chatroom_destroyed.html", import tpl_chatroom_disconnect from "templates/chatroom_disconnect.html";
"templates/chatroom_disconnect.html", import tpl_chatroom_features from "templates/chatroom_features.html";
"templates/chatroom_features.html", import tpl_chatroom_form from "templates/chatroom_form.html";
"templates/chatroom_form.html", import tpl_chatroom_head from "templates/chatroom_head.html";
"templates/chatroom_head.html", import tpl_chatroom_invite from "templates/chatroom_invite.html";
"templates/chatroom_invite.html", import tpl_chatroom_nickname_form from "templates/chatroom_nickname_form.html";
"templates/chatroom_nickname_form.html", import tpl_chatroom_password_form from "templates/chatroom_password_form.html";
"templates/chatroom_password_form.html", import tpl_chatroom_sidebar from "templates/chatroom_sidebar.html";
"templates/chatroom_sidebar.html", import tpl_info from "templates/info.html";
"templates/info.html", import tpl_list_chatrooms_modal from "templates/list_chatrooms_modal.html";
"templates/list_chatrooms_modal.html", import tpl_occupant from "templates/occupant.html";
"templates/occupant.html", import tpl_room_description from "templates/room_description.html";
"templates/room_description.html", import tpl_room_item from "templates/room_item.html";
"templates/room_item.html", import tpl_room_panel from "templates/room_panel.html";
"templates/room_panel.html", import tpl_rooms_results from "templates/rooms_results.html";
"templates/rooms_results.html", import tpl_spinner from "templates/spinner.html";
"templates/spinner.html", import xss from "xss";
"awesomplete",
"converse-modal"
], factory); const { Backbone, Promise, Strophe, b64_sha1, moment, f, sizzle, _, $build, $iq, $msg, $pres } = converse.env;
}(this, function ( const u = converse.env.utils;
converse,
_FormData, const ROOM_FEATURES_MAP = {
muc_utils,
xss,
tpl_add_chatroom_modal,
tpl_chatarea,
tpl_chatroom,
tpl_chatroom_details_modal,
tpl_chatroom_destroyed,
tpl_chatroom_disconnect,
tpl_chatroom_features,
tpl_chatroom_form,
tpl_chatroom_head,
tpl_chatroom_invite,
tpl_chatroom_nickname_form,
tpl_chatroom_password_form,
tpl_chatroom_sidebar,
tpl_info,
tpl_list_chatrooms_modal,
tpl_occupant,
tpl_room_description,
tpl_room_item,
tpl_room_panel,
tpl_rooms_results,
tpl_spinner,
Awesomplete
) {
"use strict";
const { Backbone, Promise, Strophe, b64_sha1, moment, f, sizzle, _, $build, $iq, $msg, $pres } = converse.env;
const u = converse.env.utils;
const ROOM_FEATURES_MAP = {
'passwordprotected': 'unsecured', 'passwordprotected': 'unsecured',
'unsecured': 'passwordprotected', 'unsecured': 'passwordprotected',
'hidden': 'publicroom', 'hidden': 'publicroom',
...@@ -80,9 +49,9 @@ ...@@ -80,9 +49,9 @@
'semianonymous': 'nonanonymous', 'semianonymous': 'nonanonymous',
'moderated': 'unmoderated', 'moderated': 'unmoderated',
'unmoderated': 'moderated' 'unmoderated': 'moderated'
}; };
converse.plugins.add('converse-muc-views', { converse.plugins.add('converse-muc-views', {
/* Dependencies are other plugins which might be /* Dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
* this plugin. They are "optional" because they might not be * this plugin. They are "optional" because they might not be
...@@ -2145,5 +2114,5 @@ ...@@ -2145,5 +2114,5 @@
} }
}); });
} }
}); });
}));
...@@ -6,14 +6,13 @@ ...@@ -6,14 +6,13 @@
// //
/*global define */ /*global define */
(function (root, factory) { import converse from "@converse/headless/converse-core";
define(["@converse/headless/converse-core"], factory);
}(this, function (converse) { const { Strophe, _, sizzle } = converse.env,
"use strict";
const { Strophe, _, sizzle } = converse.env,
u = converse.env.utils; u = converse.env.utils;
converse.plugins.add('converse-notification', {
converse.plugins.add('converse-notification', {
dependencies: ["converse-chatboxes"], dependencies: ["converse-chatboxes"],
...@@ -287,5 +286,5 @@ ...@@ -287,5 +286,5 @@
_converse.on('connected', _converse.requestPermission); _converse.on('connected', _converse.requestPermission);
}); });
} }
}); });
}));
...@@ -4,24 +4,17 @@ ...@@ -4,24 +4,17 @@
// Copyright (c) 2013-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import converse from "@converse/headless/converse-core";
if (typeof define === 'function' && define.amd) { import hello from "hellojs";
// AMD. Register as a module called "myplugin" import tpl_oauth_providers from "templates/oauth_providers.html";
define(["@converse/headless/converse-core", "templates/oauth_providers.html", "hellojs"], factory);
} else { const _ = converse.env._,
// Browser globals. If you're not using a module loader such as require.js,
// then this line below executes. Make sure that your plugin's <script> tag
// appears after the one from converse.js.
factory(converse);
}
}(this, function (converse, tpl_oauth_providers, hello) {
'use strict';
const _ = converse.env._,
Backbone = converse.env.Backbone, Backbone = converse.env.Backbone,
Strophe = converse.env.Strophe; Strophe = converse.env.Strophe;
// The following line registers your plugin.
converse.plugins.add("converse-oauth", { // The following line registers your plugin.
converse.plugins.add("converse-oauth", {
/* Optional dependencies are other plugins which might be /* Optional dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
...@@ -142,5 +135,5 @@ ...@@ -142,5 +135,5 @@
} }
}); });
} }
}); });
}));
...@@ -6,32 +6,28 @@ ...@@ -6,32 +6,28 @@
/* global libsignal, ArrayBuffer, parseInt, crypto */ /* global libsignal, ArrayBuffer, parseInt, crypto */
(function (root, factory) { import converse from "@converse/headless/converse-core";
define([ import tpl_toolbar_omemo from "templates/toolbar_omemo.html";
"@converse/headless/converse-core",
"templates/toolbar_omemo.html" const { Backbone, Promise, Strophe, moment, sizzle, $iq, $msg, _, f, b64_sha1 } = converse.env;
], factory); const u = converse.env.utils;
}(this, function (converse, tpl_toolbar_omemo) {
Strophe.addNamespace('OMEMO_DEVICELIST', Strophe.NS.OMEMO+".devicelist");
const { Backbone, Promise, Strophe, moment, sizzle, $iq, $msg, _, f, b64_sha1 } = converse.env; Strophe.addNamespace('OMEMO_VERIFICATION', Strophe.NS.OMEMO+".verification");
const u = converse.env.utils; Strophe.addNamespace('OMEMO_WHITELISTED', Strophe.NS.OMEMO+".whitelisted");
Strophe.addNamespace('OMEMO_BUNDLES', Strophe.NS.OMEMO+".bundles");
Strophe.addNamespace('OMEMO_DEVICELIST', Strophe.NS.OMEMO+".devicelist");
Strophe.addNamespace('OMEMO_VERIFICATION', Strophe.NS.OMEMO+".verification"); const UNDECIDED = 0;
Strophe.addNamespace('OMEMO_WHITELISTED', Strophe.NS.OMEMO+".whitelisted"); const TRUSTED = 1;
Strophe.addNamespace('OMEMO_BUNDLES', Strophe.NS.OMEMO+".bundles"); const UNTRUSTED = -1;
const TAG_LENGTH = 128;
const UNDECIDED = 0; const KEY_ALGO = {
const TRUSTED = 1;
const UNTRUSTED = -1;
const TAG_LENGTH = 128;
const KEY_ALGO = {
'name': "AES-GCM", 'name': "AES-GCM",
'length': 128 'length': 128
}; };
function parseBundle (bundle_el) { function parseBundle (bundle_el) {
/* Given an XML element representing a user's OMEMO bundle, parse it /* Given an XML element representing a user's OMEMO bundle, parse it
* and return a map. * and return a map.
*/ */
...@@ -56,10 +52,10 @@ ...@@ -56,10 +52,10 @@
}, },
'prekeys': prekeys 'prekeys': prekeys
} }
} }
converse.plugins.add('converse-omemo', { converse.plugins.add('converse-omemo', {
enabled (_converse) { enabled (_converse) {
return !_.isNil(window.libsignal) && !f.includes('converse-omemo', _converse.blacklisted_plugins); return !_.isNil(window.libsignal) && !f.includes('converse-omemo', _converse.blacklisted_plugins);
...@@ -1049,5 +1045,5 @@ ...@@ -1049,5 +1045,5 @@
_converse.generateFingerprints(_converse.bare_jid).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR)); _converse.generateFingerprints(_converse.bare_jid).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
}); });
} }
}); });
}));
...@@ -6,35 +6,23 @@ ...@@ -6,35 +6,23 @@
// //
/*global define */ /*global define */
(function (root, factory) { import "@converse/headless/converse-vcard";
define(["@converse/headless/converse-core", import "converse-modal";
"bootstrap", import _FormData from "formdata-polyfill";
"formdata-polyfill", import bootstrap from "bootstrap";
"templates/alert.html", import converse from "@converse/headless/converse-core";
"templates/chat_status_modal.html", import tpl_alert from "templates/alert.html";
"templates/profile_modal.html", import tpl_chat_status_modal from "templates/chat_status_modal.html";
"templates/profile_view.html", import tpl_profile_modal from "templates/profile_modal.html";
"templates/status_option.html", import tpl_profile_view from "templates/profile_view.html";
"@converse/headless/converse-vcard", import tpl_status_option from "templates/status_option.html";
"converse-modal"
], factory);
}(this, function ( const { Strophe, Backbone, Promise, utils, _, moment } = converse.env;
converse, const u = converse.env.utils;
bootstrap,
_FormData,
tpl_alert, converse.plugins.add('converse-profile', {
tpl_chat_status_modal,
tpl_profile_modal,
tpl_profile_view,
tpl_status_option
) {
"use strict";
const { Strophe, Backbone, Promise, utils, _, moment } = converse.env;
const u = converse.env.utils;
converse.plugins.add('converse-profile', {
dependencies: ["converse-modal", "converse-vcard", "converse-chatboxviews"], dependencies: ["converse-modal", "converse-vcard", "converse-chatboxviews"],
...@@ -272,5 +260,5 @@ ...@@ -272,5 +260,5 @@
} }
}); });
} }
}); });
}));
...@@ -7,17 +7,16 @@ ...@@ -7,17 +7,16 @@
/* This is a Converse.js plugin which add support for registering /* This is a Converse.js plugin which add support for registering
* an "App Server" as defined in XEP-0357 * an "App Server" as defined in XEP-0357
*/ */
(function (root, factory) {
define(["@converse/headless/converse-core"], factory);
}(this, function (converse) {
"use strict";
const { Strophe, $iq, _ } = converse.env;
Strophe.addNamespace('PUSH', 'urn:xmpp:push:0'); import converse from "@converse/headless/converse-core";
const { Strophe, $iq, _ } = converse.env;
converse.plugins.add('converse-push', { Strophe.addNamespace('PUSH', 'urn:xmpp:push:0');
converse.plugins.add('converse-push', {
initialize () { initialize () {
/* The initialize function gets called as soon as the plugin is /* The initialize function gets called as soon as the plugin is
...@@ -131,5 +130,5 @@ ...@@ -131,5 +130,5 @@
_converse.api.listen.on('chatBoxesInitialized', () => _converse.chatboxes.on('add', onChatBoxAdded)); _converse.api.listen.on('chatBoxesInitialized', () => _converse.chatboxes.on('add', onChatBoxAdded));
} }
} }
}); });
}));
...@@ -9,49 +9,36 @@ ...@@ -9,49 +9,36 @@
/* This is a Converse.js plugin which add support for in-band registration /* This is a Converse.js plugin which add support for in-band registration
* as specified in XEP-0077. * as specified in XEP-0077.
*/ */
(function (root, factory) {
define(["utils/form", import "converse-controlbox";
"@converse/headless/converse-core", import converse from "@converse/headless/converse-core";
"templates/form_username.html", import tpl_form_input from "templates/form_input.html";
"templates/register_link.html", import tpl_form_username from "templates/form_username.html";
"templates/register_panel.html", import tpl_register_link from "templates/register_link.html";
"templates/registration_form.html", import tpl_register_panel from "templates/register_panel.html";
"templates/registration_request.html", import tpl_registration_form from "templates/registration_form.html";
"templates/form_input.html", import tpl_registration_request from "templates/registration_request.html";
"templates/spinner.html", import tpl_spinner from "templates/spinner.html";
"converse-controlbox" import utils from "utils/form";
], factory);
}(this, function ( // Strophe methods for building stanzas
utils, const { Strophe, Backbone, sizzle, $iq, _ } = converse.env;
converse,
tpl_form_username, // Add Strophe Namespaces
tpl_register_link, Strophe.addNamespace('REGISTER', 'jabber:iq:register');
tpl_register_panel,
tpl_registration_form, // Add Strophe Statuses
tpl_registration_request, let i = 0;
tpl_form_input, _.each(_.keys(Strophe.Status), function (key) {
tpl_spinner
) {
"use strict";
// Strophe methods for building stanzas
const { Strophe, Backbone, sizzle, $iq, _ } = converse.env;
// Add Strophe Namespaces
Strophe.addNamespace('REGISTER', 'jabber:iq:register');
// Add Strophe Statuses
let i = 0;
_.each(_.keys(Strophe.Status), function (key) {
i = Math.max(i, Strophe.Status[key]); i = Math.max(i, Strophe.Status[key]);
}); });
Strophe.Status.REGIFAIL = i + 1; Strophe.Status.REGIFAIL = i + 1;
Strophe.Status.REGISTERED = i + 2; Strophe.Status.REGISTERED = i + 2;
Strophe.Status.CONFLICT = i + 3; Strophe.Status.CONFLICT = i + 3;
Strophe.Status.NOTACCEPTABLE = i + 5; Strophe.Status.NOTACCEPTABLE = i + 5;
converse.plugins.add('converse-register', { converse.plugins.add('converse-register', {
'overrides': { 'overrides': {
// Overrides mentioned here will be picked up by converse.js's // Overrides mentioned here will be picked up by converse.js's
...@@ -698,5 +685,5 @@ ...@@ -698,5 +685,5 @@
} }
}); });
} }
}); });
}));
// Converse.js (A browser based XMPP chat client) // Converse.js (A browser based XMPP chat client)
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com> // Copyright (c) 2013-2018, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
//
/*global define */
/* This is a non-core Converse.js plugin which shows a list of currently open /* This is a non-core Converse.js plugin which shows a list of currently open
* rooms in the "Rooms Panel" of the ControlBox. * rooms in the "Rooms Panel" of the ControlBox.
*/ */
(function (root, factory) {
define(["@converse/headless/converse-core", import converse from "@converse/headless/converse-core";
"@converse/headless/converse-muc", import muc from "@converse/headless/converse-muc";
"templates/rooms_list.html", import tpl_rooms_list from "templates/rooms_list.html";
"templates/rooms_list_item.html" import tpl_rooms_list_item from "templates/rooms_list_item.html"
], factory);
}(this, function (converse, muc, tpl_rooms_list, tpl_rooms_list_item) { const { Backbone, Promise, Strophe, b64_sha1, sizzle, _ } = converse.env;
const { Backbone, Promise, Strophe, b64_sha1, sizzle, _ } = converse.env; const u = converse.env.utils;
const u = converse.env.utils;
converse.plugins.add('converse-roomslist', { converse.plugins.add('converse-roomslist', {
/* Optional dependencies are other plugins which might be /* Optional dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
...@@ -33,7 +31,7 @@ ...@@ -33,7 +31,7 @@
* *
* NB: These plugins need to have already been loaded via require.js. * NB: These plugins need to have already been loaded via require.js.
*/ */
dependencies: ["converse-singleton", "converse-controlbox", "@converse/headless/converse-muc", "converse-bookmarks"], dependencies: ["converse-singleton", "converse-controlbox", "converse-muc", "converse-bookmarks"],
initialize () { initialize () {
/* The initialize function gets called as soon as the plugin is /* The initialize function gets called as soon as the plugin is
...@@ -285,5 +283,5 @@ ...@@ -285,5 +283,5 @@
_converse.api.listen.on('reconnected', initRoomsListView); _converse.api.listen.on('reconnected', initRoomsListView);
} }
}); });
}));
// Converse.js // Converse.js
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2012-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import converse from "@converse/headless/converse-core";
define(["@converse/headless/converse-core"], factory);
}(this, function (converse) {
"use strict";
const { Backbone, Promise, Strophe, $iq, $pres, b64_sha1, moment, sizzle, _ } = converse.env;
const u = converse.env.utils;
converse.plugins.add('converse-roster', { const { Backbone, Promise, Strophe, $iq, $pres, b64_sha1, moment, sizzle, _ } = converse.env;
const u = converse.env.utils;
converse.plugins.add('converse-roster', {
dependencies: ["converse-vcard"], dependencies: ["converse-vcard"],
...@@ -933,5 +931,5 @@ ...@@ -933,5 +931,5 @@
} }
}); });
} }
}); });
}));
// Converse.js // Converse.js
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2012-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import "@converse/headless/converse-chatboxes";
define(["@converse/headless/converse-core", import "converse-modal";
"formdata-polyfill", import Awesomplete from "awesomplete";
"templates/add_contact_modal.html", import _FormData from "formdata-polyfill";
"templates/group_header.html", import converse from "@converse/headless/converse-core";
"templates/pending_contact.html", import tpl_add_contact_modal from "templates/add_contact_modal.html";
"templates/requesting_contact.html", import tpl_group_header from "templates/group_header.html";
"templates/roster.html", import tpl_pending_contact from "templates/pending_contact.html";
"templates/roster_filter.html", import tpl_requesting_contact from "templates/requesting_contact.html";
"templates/roster_item.html", import tpl_roster from "templates/roster.html";
"templates/search_contact.html", import tpl_roster_filter from "templates/roster_filter.html";
"awesomplete", import tpl_roster_item from "templates/roster_item.html";
"@converse/headless/converse-chatboxes", import tpl_search_contact from "templates/search_contact.html";
"converse-modal"
], factory); const { Backbone, Strophe, $iq, b64_sha1, sizzle, _ } = converse.env;
}(this, function ( const u = converse.env.utils;
converse,
_FormData,
tpl_add_contact_modal, converse.plugins.add('converse-rosterview', {
tpl_group_header,
tpl_pending_contact,
tpl_requesting_contact,
tpl_roster,
tpl_roster_filter,
tpl_roster_item,
tpl_search_contact,
Awesomplete
) {
"use strict";
const { Backbone, Strophe, $iq, b64_sha1, sizzle, _ } = converse.env;
const u = converse.env.utils;
converse.plugins.add('converse-rosterview', {
dependencies: ["converse-roster", "converse-modal"], dependencies: ["converse-roster", "converse-modal"],
...@@ -999,5 +984,5 @@ ...@@ -999,5 +984,5 @@
_converse.api.listen.on('rosterInitialized', initRoster); _converse.api.listen.on('rosterInitialized', initRoster);
_converse.api.listen.on('rosterReadyAfterReconnection', initRoster); _converse.api.listen.on('rosterReadyAfterReconnection', initRoster);
} }
}); });
}));
// Converse.js // Converse.js
// http://conversejs.org // http://conversejs.org
// //
// Copyright (c) 2012-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
/* converse-singleton /* converse-singleton
...@@ -13,26 +13,23 @@ ...@@ -13,26 +13,23 @@
* *
* This plugin makes sense in mobile or fullscreen chat environments (as * This plugin makes sense in mobile or fullscreen chat environments (as
* configured by the `view_mode` setting). * configured by the `view_mode` setting).
*
*/ */
(function (root, factory) {
define( import "converse-chatview";
["@converse/headless/converse-core", "converse-chatview"], import converse from "@converse/headless/converse-core";
factory);
}(this, function (converse) { const { _, Strophe } = converse.env;
"use strict"; const u = converse.env.utils;
const { _, Strophe } = converse.env;
const u = converse.env.utils;
function hideChat (view) { function hideChat (view) {
if (view.model.get('id') === 'controlbox') { return; } if (view.model.get('id') === 'controlbox') { return; }
u.safeSave(view.model, {'hidden': true}); u.safeSave(view.model, {'hidden': true});
view.hide(); view.hide();
} }
converse.plugins.add('converse-singleton', { converse.plugins.add('converse-singleton', {
// It's possible however to make optional dependencies non-optional. // It's possible however to make optional dependencies non-optional.
// If the setting "strict_plugin_dependencies" is set to true, // If the setting "strict_plugin_dependencies" is set to true,
// an error will be raised if the plugin is not found. // an error will be raised if the plugin is not found.
...@@ -114,5 +111,5 @@ ...@@ -114,5 +111,5 @@
} }
} }
} }
}); });
}));
...@@ -4,24 +4,19 @@ ...@@ -4,24 +4,19 @@
// Copyright (c) 2012-2018, the Converse.js developers // Copyright (c) 2012-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import "./utils/emoji";
define([ import "./utils/form";
"./converse-core", import converse from "./converse-core";
"filesize", import filesize from "filesize";
"./utils/form",
"./utils/emoji"
], factory);
}(this, function (converse, filesize) {
"use strict";
const { $msg, Backbone, Promise, Strophe, b64_sha1, moment, sizzle, utils, _ } = converse.env; const { $msg, Backbone, Promise, Strophe, b64_sha1, moment, sizzle, utils, _ } = converse.env;
const u = converse.env.utils; const u = converse.env.utils;
Strophe.addNamespace('MESSAGE_CORRECT', 'urn:xmpp:message-correct:0'); Strophe.addNamespace('MESSAGE_CORRECT', 'urn:xmpp:message-correct:0');
Strophe.addNamespace('REFERENCE', 'urn:xmpp:reference:0'); Strophe.addNamespace('REFERENCE', 'urn:xmpp:reference:0');
converse.plugins.add('converse-chatboxes', { converse.plugins.add('converse-chatboxes', {
dependencies: ["converse-roster", "converse-vcard"], dependencies: ["converse-roster", "converse-vcard"],
...@@ -953,6 +948,4 @@ ...@@ -953,6 +948,4 @@
}); });
/************************ END API ************************/ /************************ END API ************************/
} }
}); });
return converse;
}));
...@@ -4,76 +4,73 @@ ...@@ -4,76 +4,73 @@
// Copyright (c) 2013-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { "use strict";
define(["sizzle",
"es6-promise/dist/es6-promise.auto", import { $build, $iq, $msg, $pres, SHA1, Strophe } from "strophe.js";
"./lodash.noconflict", import Backbone from "./backbone.noconflict";
"./lodash.fp", import Promise from "es6-promise/dist/es6-promise.auto";
"./polyfill", import _ from "./lodash.noconflict";
"./i18n", import browserStorage from "backbone.browserStorage";
"./utils/core", import f from "./lodash.fp";
"moment", import i18n from "./i18n";
"strophe.js", import moment from "moment";
"pluggable.js/dist/pluggable", import pluggable from "pluggable.js/dist/pluggable";
"./backbone.noconflict", import polyfill from "./polyfill";
"backbone.browserStorage" import sizzle from "sizzle";
], factory); import u from "./utils/core";
}(this, function (sizzle, Promise, _, f, polyfill, i18n, u, moment, Strophe, pluggable, Backbone) {
"use strict";
// Strophe globals
// Strophe globals const b64_sha1 = SHA1.b64_sha1;
const { $build, $iq, $msg, $pres } = Strophe;
const b64_sha1 = Strophe.SHA1.b64_sha1; // Add Strophe Namespaces
Strophe = Strophe.Strophe; Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2');
Strophe.addNamespace('CHATSTATES', 'http://jabber.org/protocol/chatstates');
// Add Strophe Namespaces Strophe.addNamespace('CSI', 'urn:xmpp:csi:0');
Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2'); Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
Strophe.addNamespace('CHATSTATES', 'http://jabber.org/protocol/chatstates'); Strophe.addNamespace('FORWARD', 'urn:xmpp:forward:0');
Strophe.addNamespace('CSI', 'urn:xmpp:csi:0'); Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
Strophe.addNamespace('DELAY', 'urn:xmpp:delay'); Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
Strophe.addNamespace('FORWARD', 'urn:xmpp:forward:0'); Strophe.addNamespace('MAM', 'urn:xmpp:mam:2');
Strophe.addNamespace('HINTS', 'urn:xmpp:hints'); Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0'); Strophe.addNamespace('OMEMO', "eu.siacs.conversations.axolotl");
Strophe.addNamespace('MAM', 'urn:xmpp:mam:2'); Strophe.addNamespace('OUTOFBAND', 'jabber:x:oob');
Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick'); Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
Strophe.addNamespace('OMEMO', "eu.siacs.conversations.axolotl"); Strophe.addNamespace('REGISTER', 'jabber:iq:register');
Strophe.addNamespace('OUTOFBAND', 'jabber:x:oob'); Strophe.addNamespace('ROSTERX', 'http://jabber.org/protocol/rosterx');
Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub'); Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
Strophe.addNamespace('REGISTER', 'jabber:iq:register'); Strophe.addNamespace('SID', 'urn:xmpp:sid:0');
Strophe.addNamespace('ROSTERX', 'http://jabber.org/protocol/rosterx'); Strophe.addNamespace('SPOILER', 'urn:xmpp:spoiler:0');
Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm'); Strophe.addNamespace('VCARD', 'vcard-temp');
Strophe.addNamespace('SID', 'urn:xmpp:sid:0'); Strophe.addNamespace('VCARDUPDATE', 'vcard-temp:x:update');
Strophe.addNamespace('SPOILER', 'urn:xmpp:spoiler:0'); Strophe.addNamespace('XFORM', 'jabber:x:data');
Strophe.addNamespace('VCARD', 'vcard-temp');
Strophe.addNamespace('VCARDUPDATE', 'vcard-temp:x:update'); // Use Mustache style syntax for variable interpolation
Strophe.addNamespace('XFORM', 'jabber:x:data'); /* Configuration of Lodash templates (this config is distinct to the
// Use Mustache style syntax for variable interpolation
/* Configuration of Lodash templates (this config is distinct to the
* config of requirejs-tpl in main.js). This one is for normal inline templates. * config of requirejs-tpl in main.js). This one is for normal inline templates.
*/ */
_.templateSettings = { _.templateSettings = {
'escape': /\{\{\{([\s\S]+?)\}\}\}/g, 'escape': /\{\{\{([\s\S]+?)\}\}\}/g,
'evaluate': /\{\[([\s\S]+?)\]\}/g, 'evaluate': /\{\[([\s\S]+?)\]\}/g,
'interpolate': /\{\{([\s\S]+?)\}\}/g, 'interpolate': /\{\{([\s\S]+?)\}\}/g,
'imports': { '_': _ } 'imports': { '_': _ }
}; };
/** /**
* A private, closured object containing the private api (via `_converse.api`) * A private, closured object containing the private api (via `_converse.api`)
* as well as private methods and internal data-structures. * as well as private methods and internal data-structures.
* *
* @namespace _converse * @namespace _converse
*/ */
const _converse = { const _converse = {
'templates': {}, 'templates': {},
'promises': {} 'promises': {}
} }
_.extend(_converse, Backbone.Events); _.extend(_converse, Backbone.Events);
// Core plugins are whitelisted automatically // Core plugins are whitelisted automatically
_converse.core_plugins = [ _converse.core_plugins = [
'converse-autocomplete', 'converse-autocomplete',
'converse-bookmarks', 'converse-bookmarks',
'converse-caps', 'converse-caps',
...@@ -105,17 +102,17 @@ ...@@ -105,17 +102,17 @@
'converse-singleton', 'converse-singleton',
'converse-spoilers', 'converse-spoilers',
'converse-vcard' 'converse-vcard'
]; ];
// Setting wait to 59 instead of 60 to avoid timing conflicts with the // Setting wait to 59 instead of 60 to avoid timing conflicts with the
// webserver, which is often also set to 60 and might therefore sometimes // webserver, which is often also set to 60 and might therefore sometimes
// return a 504 error page instead of passing through to the BOSH proxy. // return a 504 error page instead of passing through to the BOSH proxy.
const BOSH_WAIT = 59; const BOSH_WAIT = 59;
// Make converse pluggable // Make converse pluggable
pluggable.enable(_converse, '_converse', 'pluggable'); pluggable.enable(_converse, '_converse', 'pluggable');
_converse.keycodes = { _converse.keycodes = {
TAB: 9, TAB: 9,
ENTER: 13, ENTER: 13,
SHIFT: 16, SHIFT: 16,
...@@ -128,11 +125,11 @@ ...@@ -128,11 +125,11 @@
AT: 50, AT: 50,
META: 91, META: 91,
META_RIGHT: 93 META_RIGHT: 93
}; };
// Module-level constants // Module-level constants
_converse.STATUS_WEIGHTS = { _converse.STATUS_WEIGHTS = {
'offline': 6, 'offline': 6,
'unavailable': 5, 'unavailable': 5,
'xa': 4, 'xa': 4,
...@@ -140,8 +137,8 @@ ...@@ -140,8 +137,8 @@
'dnd': 2, 'dnd': 2,
'chat': 1, // We currently don't differentiate between "chat" and "online" 'chat': 1, // We currently don't differentiate between "chat" and "online"
'online': 1 'online': 1
}; };
_converse.PRETTY_CHAT_STATUS = { _converse.PRETTY_CHAT_STATUS = {
'offline': 'Offline', 'offline': 'Offline',
'unavailable': 'Unavailable', 'unavailable': 'Unavailable',
'xa': 'Extended Away', 'xa': 'Extended Away',
...@@ -149,18 +146,18 @@ ...@@ -149,18 +146,18 @@
'dnd': 'Do not disturb', 'dnd': 'Do not disturb',
'chat': 'Chattty', 'chat': 'Chattty',
'online': 'Online' 'online': 'Online'
}; };
_converse.ANONYMOUS = "anonymous"; _converse.ANONYMOUS = "anonymous";
_converse.CLOSED = 'closed'; _converse.CLOSED = 'closed';
_converse.EXTERNAL = "external"; _converse.EXTERNAL = "external";
_converse.LOGIN = "login"; _converse.LOGIN = "login";
_converse.LOGOUT = "logout"; _converse.LOGOUT = "logout";
_converse.OPENED = 'opened'; _converse.OPENED = 'opened';
_converse.PREBIND = "prebind"; _converse.PREBIND = "prebind";
_converse.IQ_TIMEOUT = 20000; _converse.IQ_TIMEOUT = 20000;
_converse.CONNECTION_STATUS = { _converse.CONNECTION_STATUS = {
0: 'ERROR', 0: 'ERROR',
1: 'CONNECTING', 1: 'CONNECTING',
2: 'CONNFAIL', 2: 'CONNFAIL',
...@@ -172,38 +169,38 @@ ...@@ -172,38 +169,38 @@
8: 'ATTACHED', 8: 'ATTACHED',
9: 'REDIRECT', 9: 'REDIRECT',
10: 'RECONNECTING', 10: 'RECONNECTING',
}; };
_converse.SUCCESS = 'success'; _converse.SUCCESS = 'success';
_converse.FAILURE = 'failure'; _converse.FAILURE = 'failure';
_converse.DEFAULT_IMAGE_TYPE = 'image/png'; _converse.DEFAULT_IMAGE_TYPE = 'image/png';
_converse.DEFAULT_IMAGE = "iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gwHCy455JBsggAABkJJREFUeNrtnM1PE1sUwHvvTD8otWLHST/Gimi1CEgr6M6FEWuIBo2pujDVsNDEP8GN/4MbN7oxrlipG2OCgZgYlxAbkRYw1KqkIDRCSkM7nXvvW8x7vjyNeQ9m7p1p3z1LQk/v/Dhz7vkEXL161cHl9wI5Ag6IA+KAOCAOiAPigDggLhwQB2S+iNZ+PcYY/SWEEP2HAAAIoSAIoihCCP+ngDDGtVotGAz29/cfOXJEUZSOjg6n06lp2sbGRqlUWlhYyGazS0tLbrdbEASrzgksyeYJId3d3el0uqenRxRFAAAA4KdfIIRgjD9+/Pj8+fOpqSndslofEIQwHA6Pjo4mEon//qmFhYXHjx8vLi4ihBgDEnp7e9l8E0Jo165dQ0NDd+/eDYVC2/qsJElDQ0OEkKWlpa2tLZamxAhQo9EIBoOjo6MXL17csZLe3l5FUT59+lQul5l5JRaAVFWNRqN37tw5ceKEQVWRSOTw4cOFQuHbt2+iKLYCIISQLMu3b99OJpOmKAwEAgcPHszn8+vr6wzsiG6UQQhxuVyXLl0aGBgwUW0sFstkMl6v90fo1KyAMMYDAwPnzp0zXfPg4GAqlWo0Gk0MiBAiy/L58+edTqf5Aa4onj59OhaLYYybFRCEMBaL0fNxBw4cSCQStN0QRUBut3t4eJjq6U+dOiVJElVPRBFQIBDo6+ujCqirqyscDlONGykC2lYyYSR6pBoQQapHZwAoHo/TuARYAOrs7GQASFEUqn6aIiBJkhgA6ujooFpUo6iaTa7koFwnaoWadLNe81tbWwzoaJrWrICWl5cZAFpbW6OabVAEtLi4yABQsVjUNK0pAWWzWQaAcrlcswKanZ1VVZUqHYRQEwOq1Wpv3ryhCmh6erpcLjdrNl+v1ycnJ+l5UELI27dvv3//3qxxEADgy5cvExMT9Mznw4cPtFtAdAPFarU6Pj5eKpVM17yxsfHy5cvV1VXazXu62gVBKBQKT58+rdVqJqrFGL948eLdu3dU8/g/H4FBUaJYLAqC0NPTY9brMD4+PjY25mDSracOCABACJmZmXE6nUePHjWu8NWrV48ePSKEsGlAs7Agfd5nenq6Wq0mk0kjDzY2NvbkyRMIIbP2PLvhBUEQ8vl8NpuNx+M+n29bzhVjvLKycv/+/YmJCcazQuwA6YzW1tYmJyf1SY+2trZ/rRk1Go1SqfT69esHDx4UCgVmNaa/zZ/9ABUhRFXVYDB48uTJeDweiUQkSfL7/T9MA2NcqVTK5fLy8vL8/PzU1FSxWHS5XJaM4wGr9sUwxqqqer3eUCgkSZJuUBBCfTRvc3OzXC6vrKxUKhWn02nhCJ5lM4oQQo/HgxD6+vXr58+fHf8sDOp+HQDg8XgclorFU676dKLlo6yWRdItIBwQB8QBcUCtfosRQjRNQwhhjPUC4w46WXryBSHU1zgEQWBz99EFhDGu1+t+v//48ePxeFxRlD179ng8nh0Efgiher2+vr6ur3HMzMysrq7uTJVdACGEurq6Ll++nEgkPB7Pj9jPoDHqOxyqqubz+WfPnuVyuV9XPeyeagAAAoHArVu3BgcHab8CuVzu4cOHpVKJUnfA5GweY+xyuc6cOXPv3r1IJMLAR8iyPDw8XK/Xi8Wiqqqmm5KZgBBC7e3tN27cuHbtGuPVpf7+/lAoNDs7W61WzfVKpgHSSzw3b95MpVKW3MfRaDQSiczNzVUqFRMZmQOIEOL1eq9fv3727FlL1t50URRFluX5+flqtWpWEGAOIFEUU6nUlStXLKSjy759+xwOx9zcnKZpphzGHMzhcDiTydgk9r1w4YIp7RPTAAmCkMlk2FeLf/tIEKbTab/fbwtAhJBoNGrutpNx6e7uPnTokC1eMU3T0um0DZPMkZER6wERQnw+n/FFSxpy7Nix3bt3WwwIIcRgIWnHkkwmjecfRgGx7DtuV/r6+iwGhDHev3+/bQF1dnYaH6E2CkiWZdsC2rt3r8WAHA5HW1ubbQGZcjajgOwTH/4qNko1Wlg4IA6IA+KAOKBWBUQIsfNojyliKIoRRfH9+/dut9umf3wzpoUNNQ4BAJubmwz+ic+OxefzWWlBhJD29nbug7iT5sIBcUAcEAfEAXFAHBAHxOVn+QMrmWpuPZx12gAAAABJRU5ErkJggg=="; _converse.DEFAULT_IMAGE = "iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gwHCy455JBsggAABkJJREFUeNrtnM1PE1sUwHvvTD8otWLHST/Gimi1CEgr6M6FEWuIBo2pujDVsNDEP8GN/4MbN7oxrlipG2OCgZgYlxAbkRYw1KqkIDRCSkM7nXvvW8x7vjyNeQ9m7p1p3z1LQk/v/Dhz7vkEXL161cHl9wI5Ag6IA+KAOCAOiAPigDggLhwQB2S+iNZ+PcYY/SWEEP2HAAAIoSAIoihCCP+ngDDGtVotGAz29/cfOXJEUZSOjg6n06lp2sbGRqlUWlhYyGazS0tLbrdbEASrzgksyeYJId3d3el0uqenRxRFAAAA4KdfIIRgjD9+/Pj8+fOpqSndslofEIQwHA6Pjo4mEon//qmFhYXHjx8vLi4ihBgDEnp7e9l8E0Jo165dQ0NDd+/eDYVC2/qsJElDQ0OEkKWlpa2tLZamxAhQo9EIBoOjo6MXL17csZLe3l5FUT59+lQul5l5JRaAVFWNRqN37tw5ceKEQVWRSOTw4cOFQuHbt2+iKLYCIISQLMu3b99OJpOmKAwEAgcPHszn8+vr6wzsiG6UQQhxuVyXLl0aGBgwUW0sFstkMl6v90fo1KyAMMYDAwPnzp0zXfPg4GAqlWo0Gk0MiBAiy/L58+edTqf5Aa4onj59OhaLYYybFRCEMBaL0fNxBw4cSCQStN0QRUBut3t4eJjq6U+dOiVJElVPRBFQIBDo6+ujCqirqyscDlONGykC2lYyYSR6pBoQQapHZwAoHo/TuARYAOrs7GQASFEUqn6aIiBJkhgA6ujooFpUo6iaTa7koFwnaoWadLNe81tbWwzoaJrWrICWl5cZAFpbW6OabVAEtLi4yABQsVjUNK0pAWWzWQaAcrlcswKanZ1VVZUqHYRQEwOq1Wpv3ryhCmh6erpcLjdrNl+v1ycnJ+l5UELI27dvv3//3qxxEADgy5cvExMT9Mznw4cPtFtAdAPFarU6Pj5eKpVM17yxsfHy5cvV1VXazXu62gVBKBQKT58+rdVqJqrFGL948eLdu3dU8/g/H4FBUaJYLAqC0NPTY9brMD4+PjY25mDSracOCABACJmZmXE6nUePHjWu8NWrV48ePSKEsGlAs7Agfd5nenq6Wq0mk0kjDzY2NvbkyRMIIbP2PLvhBUEQ8vl8NpuNx+M+n29bzhVjvLKycv/+/YmJCcazQuwA6YzW1tYmJyf1SY+2trZ/rRk1Go1SqfT69esHDx4UCgVmNaa/zZ/9ABUhRFXVYDB48uTJeDweiUQkSfL7/T9MA2NcqVTK5fLy8vL8/PzU1FSxWHS5XJaM4wGr9sUwxqqqer3eUCgkSZJuUBBCfTRvc3OzXC6vrKxUKhWn02nhCJ5lM4oQQo/HgxD6+vXr58+fHf8sDOp+HQDg8XgclorFU676dKLlo6yWRdItIBwQB8QBcUCtfosRQjRNQwhhjPUC4w46WXryBSHU1zgEQWBz99EFhDGu1+t+v//48ePxeFxRlD179ng8nh0Efgiher2+vr6ur3HMzMysrq7uTJVdACGEurq6Ll++nEgkPB7Pj9jPoDHqOxyqqubz+WfPnuVyuV9XPeyeagAAAoHArVu3BgcHab8CuVzu4cOHpVKJUnfA5GweY+xyuc6cOXPv3r1IJMLAR8iyPDw8XK/Xi8Wiqqqmm5KZgBBC7e3tN27cuHbtGuPVpf7+/lAoNDs7W61WzfVKpgHSSzw3b95MpVKW3MfRaDQSiczNzVUqFRMZmQOIEOL1eq9fv3727FlL1t50URRFluX5+flqtWpWEGAOIFEUU6nUlStXLKSjy759+xwOx9zcnKZpphzGHMzhcDiTydgk9r1w4YIp7RPTAAmCkMlk2FeLf/tIEKbTab/fbwtAhJBoNGrutpNx6e7uPnTokC1eMU3T0um0DZPMkZER6wERQnw+n/FFSxpy7Nix3bt3WwwIIcRgIWnHkkwmjecfRgGx7DtuV/r6+iwGhDHev3+/bQF1dnYaH6E2CkiWZdsC2rt3r8WAHA5HW1ubbQGZcjajgOwTH/4qNko1Wlg4IA6IA+KAOKBWBUQIsfNojyliKIoRRfH9+/dut9umf3wzpoUNNQ4BAJubmwz+ic+OxefzWWlBhJD29nbug7iT5sIBcUAcEAfEAXFAHBAHxOVn+QMrmWpuPZx12gAAAABJRU5ErkJggg==";
_converse.TIMEOUTS = { // Set as module attr so that we can override in tests. _converse.TIMEOUTS = { // Set as module attr so that we can override in tests.
'PAUSED': 10000, 'PAUSED': 10000,
'INACTIVE': 90000 'INACTIVE': 90000
}; };
// XEP-0085 Chat states // XEP-0085 Chat states
// http://xmpp.org/extensions/xep-0085.html // http://xmpp.org/extensions/xep-0085.html
_converse.INACTIVE = 'inactive'; _converse.INACTIVE = 'inactive';
_converse.ACTIVE = 'active'; _converse.ACTIVE = 'active';
_converse.COMPOSING = 'composing'; _converse.COMPOSING = 'composing';
_converse.PAUSED = 'paused'; _converse.PAUSED = 'paused';
_converse.GONE = 'gone'; _converse.GONE = 'gone';
// Chat types // Chat types
_converse.PRIVATE_CHAT_TYPE = 'chatbox'; _converse.PRIVATE_CHAT_TYPE = 'chatbox';
_converse.CHATROOMS_TYPE = 'chatroom'; _converse.CHATROOMS_TYPE = 'chatroom';
_converse.HEADLINES_TYPE = 'headline'; _converse.HEADLINES_TYPE = 'headline';
_converse.CONTROLBOX_TYPE = 'controlbox'; _converse.CONTROLBOX_TYPE = 'controlbox';
// Default configuration values // Default configuration values
// ---------------------------- // ----------------------------
_converse.default_settings = { _converse.default_settings = {
allow_non_roster_messaging: false, allow_non_roster_messaging: false,
animate: true, animate: true,
authentication: 'login', // Available values are "login", "prebind", "anonymous" and "external". authentication: 'login', // Available values are "login", "prebind", "anonymous" and "external".
...@@ -242,10 +239,10 @@ ...@@ -242,10 +239,10 @@
view_mode: 'overlayed', // Choices are 'overlayed', 'fullscreen', 'mobile' view_mode: 'overlayed', // Choices are 'overlayed', 'fullscreen', 'mobile'
websocket_url: undefined, websocket_url: undefined,
whitelisted_plugins: [] whitelisted_plugins: []
}; };
_converse.log = function (message, level, style='') { _converse.log = function (message, level, style='') {
/* Logs messages to the browser's developer console. /* Logs messages to the browser's developer console.
* *
* Parameters: * Parameters:
...@@ -289,13 +286,13 @@ ...@@ -289,13 +286,13 @@
logger.info(`${prefix} ${moment().format()} INFO: ${message}`, style); logger.info(`${prefix} ${moment().format()} INFO: ${message}`, style);
} }
} }
}; };
Strophe.log = function (level, msg) { _converse.log(level+' '+msg, level); }; Strophe.log = function (level, msg) { _converse.log(level+' '+msg, level); };
Strophe.error = function (msg) { _converse.log(msg, Strophe.LogLevel.ERROR); }; Strophe.error = function (msg) { _converse.log(msg, Strophe.LogLevel.ERROR); };
_converse.__ = function (str) { _converse.__ = function (str) {
/* Translate the given string based on the current locale. /* Translate the given string based on the current locale.
* *
* Parameters: * Parameters:
...@@ -305,41 +302,41 @@ ...@@ -305,41 +302,41 @@
return str; return str;
} }
return i18n.translate.apply(i18n, arguments); return i18n.translate.apply(i18n, arguments);
} }
const __ = _converse.__; const __ = _converse.__;
const PROMISES = [ const PROMISES = [
'initialized', 'initialized',
'connectionInitialized', 'connectionInitialized',
'pluginsInitialized', 'pluginsInitialized',
'statusInitialized' 'statusInitialized'
]; ];
function addPromise (promise) { function addPromise (promise) {
/* Private function, used to add a new promise to the ones already /* Private function, used to add a new promise to the ones already
* available via the `waitUntil` api method. * available via the `waitUntil` api method.
*/ */
_converse.promises[promise] = u.getResolveablePromise(); _converse.promises[promise] = u.getResolveablePromise();
} }
_converse.emit = function (name) { _converse.emit = function (name) {
/* Event emitter and promise resolver */ /* Event emitter and promise resolver */
_converse.trigger.apply(this, arguments); _converse.trigger.apply(this, arguments);
const promise = _converse.promises[name]; const promise = _converse.promises[name];
if (!_.isUndefined(promise)) { if (!_.isUndefined(promise)) {
promise.resolve(); promise.resolve();
} }
}; };
_converse.isSingleton = function () { _converse.isSingleton = function () {
return _.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode); return _.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode);
} }
_converse.router = new Backbone.Router(); _converse.router = new Backbone.Router();
_converse.initialize = function (settings, callback) { _converse.initialize = function (settings, callback) {
settings = !_.isUndefined(settings) ? settings : {}; settings = !_.isUndefined(settings) ? settings : {};
const init_promise = u.getResolveablePromise(); const init_promise = u.getResolveablePromise();
...@@ -1229,9 +1226,9 @@ ...@@ -1229,9 +1226,9 @@
.catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); .catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
return init_promise; return init_promise;
}; };
/** /**
* ### The private API * ### The private API
* *
* The private API methods are only accessible via the closured {@link _converse} * The private API methods are only accessible via the closured {@link _converse}
...@@ -1244,7 +1241,7 @@ ...@@ -1244,7 +1241,7 @@
* @namespace _converse.api * @namespace _converse.api
* @memberOf _converse * @memberOf _converse
*/ */
_converse.api = { _converse.api = {
/** /**
* This grouping collects API functions related to the XMPP connection. * This grouping collects API functions related to the XMPP connection.
* *
...@@ -1658,9 +1655,9 @@ ...@@ -1658,9 +1655,9 @@
_converse.connection.sendIQ(stanza, resolve, reject, _converse.IQ_TIMEOUT); _converse.connection.sendIQ(stanza, resolve, reject, _converse.IQ_TIMEOUT);
}); });
} }
}; };
/** /**
* ### The Public API * ### The Public API
* *
* This namespace contains public API methods which are are * This namespace contains public API methods which are are
...@@ -1672,7 +1669,7 @@ ...@@ -1672,7 +1669,7 @@
* *
* @namespace converse * @namespace converse
*/ */
const converse = { const converse = {
/** /**
* Public API method which initializes Converse. * Public API method which initializes Converse.
* This method must always be called when using Converse. * This method must always be called when using Converse.
...@@ -1776,8 +1773,7 @@ ...@@ -1776,8 +1773,7 @@
'sizzle': sizzle, 'sizzle': sizzle,
'utils': u 'utils': u
} }
}; };
window.converse = converse; window.converse = converse;
window.dispatchEvent(new CustomEvent('converse-loaded')); window.dispatchEvent(new CustomEvent('converse-loaded'));
return converse; export default converse;
}));
...@@ -6,13 +6,12 @@ ...@@ -6,13 +6,12 @@
/* This is a Converse plugin which add support for XEP-0030: Service Discovery */ /* This is a Converse plugin which add support for XEP-0030: Service Discovery */
(function (root, factory) { import converse from "./converse-core";
define(["./converse-core", "sizzle"], factory); import sizzle from "sizzle";
}(this, function (converse, sizzle) {
const { Backbone, Promise, Strophe, $iq, b64_sha1, utils, _, f } = converse.env; const { Backbone, Promise, Strophe, $iq, b64_sha1, utils, _, f } = converse.env;
converse.plugins.add('converse-disco', { converse.plugins.add('converse-disco', {
initialize () { initialize () {
/* The initialize function gets called as soon as the plugin is /* The initialize function gets called as soon as the plugin is
...@@ -682,5 +681,4 @@ ...@@ -682,5 +681,4 @@
} }
}); });
} }
}); });
}));
...@@ -8,24 +8,22 @@ ...@@ -8,24 +8,22 @@
// XEP-0059 Result Set Management // XEP-0059 Result Set Management
(function (root, factory) { import "./converse-disco";
define(["sizzle", import "strophejs-plugin-rsm";
"./converse-core", import converse from "./converse-core";
"./converse-disco", import sizzle from "sizzle";
"strophejs-plugin-rsm"
], factory);
}(this, function (sizzle, converse) { const CHATROOMS_TYPE = 'chatroom';
"use strict"; const { Promise, Strophe, $iq, _, moment } = converse.env;
const CHATROOMS_TYPE = 'chatroom'; const u = converse.env.utils;
const { Promise, Strophe, $iq, _, moment } = converse.env;
const u = converse.env.utils; const RSM_ATTRIBUTES = ['max', 'first', 'last', 'after', 'before', 'index', 'count'];
// XEP-0313 Message Archive Management
const RSM_ATTRIBUTES = ['max', 'first', 'last', 'after', 'before', 'index', 'count']; const MAM_ATTRIBUTES = ['with', 'start', 'end'];
// XEP-0313 Message Archive Management
const MAM_ATTRIBUTES = ['with', 'start', 'end'];
function getMessageArchiveID (stanza) {
function getMessageArchiveID (stanza) {
// See https://xmpp.org/extensions/xep-0313.html#results // See https://xmpp.org/extensions/xep-0313.html#results
// //
// The result messages MUST contain a <result/> element with an 'id' // The result messages MUST contain a <result/> element with an 'id'
...@@ -39,9 +37,9 @@ ...@@ -39,9 +37,9 @@
if (!_.isUndefined(stanza_id)) { if (!_.isUndefined(stanza_id)) {
return stanza_id.getAttribute('id'); return stanza_id.getAttribute('id');
} }
} }
function queryForArchivedMessages (_converse, options, callback, errback) { function queryForArchivedMessages (_converse, options, callback, errback) {
/* Internal function, called by the "archive.query" API method. /* Internal function, called by the "archive.query" API method.
*/ */
let date; let date;
...@@ -121,10 +119,10 @@ ...@@ -121,10 +119,10 @@
}, },
_converse.message_archiving_timeout _converse.message_archiving_timeout
); );
} }
converse.plugins.add('converse-mam', { converse.plugins.add('converse-mam', {
dependencies: ['converse-chatview', 'converse-muc', 'converse-muc-views'], dependencies: ['converse-chatview', 'converse-muc', 'converse-muc-views'],
...@@ -592,5 +590,4 @@ ...@@ -592,5 +590,4 @@
} }
}); });
} }
}); });
}));
...@@ -4,56 +4,51 @@ ...@@ -4,56 +4,51 @@
// Copyright (c) 2013-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) { import "./converse-disco";
define([ import "./utils/emoji";
"./utils/form", import "./utils/muc";
"./converse-core", import "backbone.overview/backbone.orderedlistview";
"./converse-disco", import "backbone.overview/backbone.overview";
"backbone.overview/backbone.overview", import "backbone.vdomview";
"backbone.overview/backbone.orderedlistview", import converse from "./converse-core";
"backbone.vdomview", import u from "./utils/form";
"./utils/muc",
"./utils/emoji" const MUC_ROLE_WEIGHTS = {
], factory);
}(this, function (u, converse) {
"use strict";
const MUC_ROLE_WEIGHTS = {
'moderator': 1, 'moderator': 1,
'participant': 2, 'participant': 2,
'visitor': 3, 'visitor': 3,
'none': 2, 'none': 2,
}; };
const { Strophe, Backbone, Promise, $iq, $build, $msg, $pres, b64_sha1, sizzle, f, moment, _ } = converse.env; const { Strophe, Backbone, Promise, $iq, $build, $msg, $pres, b64_sha1, sizzle, f, moment, _ } = converse.env;
// Add Strophe Namespaces // Add Strophe Namespaces
Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + "#admin"); Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + "#admin");
Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + "#owner"); Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + "#owner");
Strophe.addNamespace('MUC_REGISTER', "jabber:iq:register"); Strophe.addNamespace('MUC_REGISTER', "jabber:iq:register");
Strophe.addNamespace('MUC_ROOMCONF', Strophe.NS.MUC + "#roomconfig"); Strophe.addNamespace('MUC_ROOMCONF', Strophe.NS.MUC + "#roomconfig");
Strophe.addNamespace('MUC_USER', Strophe.NS.MUC + "#user"); Strophe.addNamespace('MUC_USER', Strophe.NS.MUC + "#user");
converse.MUC_NICK_CHANGED_CODE = "303"; converse.MUC_NICK_CHANGED_CODE = "303";
converse.ROOM_FEATURES = [ converse.ROOM_FEATURES = [
'passwordprotected', 'unsecured', 'hidden', 'passwordprotected', 'unsecured', 'hidden',
'publicroom', 'membersonly', 'open', 'persistent', 'publicroom', 'membersonly', 'open', 'persistent',
'temporary', 'nonanonymous', 'semianonymous', 'temporary', 'nonanonymous', 'semianonymous',
'moderated', 'unmoderated', 'mam_enabled' 'moderated', 'unmoderated', 'mam_enabled'
]; ];
converse.ROOMSTATUS = { converse.ROOMSTATUS = {
CONNECTED: 0, CONNECTED: 0,
CONNECTING: 1, CONNECTING: 1,
NICKNAME_REQUIRED: 2, NICKNAME_REQUIRED: 2,
PASSWORD_REQUIRED: 3, PASSWORD_REQUIRED: 3,
DISCONNECTED: 4, DISCONNECTED: 4,
ENTERED: 5 ENTERED: 5
}; };
converse.plugins.add('converse-muc', { converse.plugins.add('converse-muc', {
/* Optional dependencies are other plugins which might be /* Optional dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before * overridden or relied upon, and therefore need to be loaded before
* this plugin. They are called "optional" because they might not be * this plugin. They are called "optional" because they might not be
...@@ -1458,20 +1453,17 @@ ...@@ -1458,20 +1453,17 @@
* true * true
* ); * );
*/ */
'open' (jids, attrs) { 'open': async function (jids, attrs) {
return new Promise((resolve, reject) => { await _converse.api.waitUntil('chatBoxesFetched');
_converse.api.waitUntil('chatBoxesFetched').then(() => {
if (_.isUndefined(jids)) { if (_.isUndefined(jids)) {
const err_msg = 'rooms.open: You need to provide at least one JID'; const err_msg = 'rooms.open: You need to provide at least one JID';
_converse.log(err_msg, Strophe.LogLevel.ERROR); _converse.log(err_msg, Strophe.LogLevel.ERROR);
reject(new TypeError(err_msg)); throw(new TypeError(err_msg));
} else if (_.isString(jids)) { } else if (_.isString(jids)) {
resolve(_converse.api.rooms.create(jids, attrs).trigger('show')); return _converse.api.rooms.create(jids, attrs).trigger('show');
} else { } else {
resolve(_.map(jids, (jid) => _converse.api.rooms.create(jid, attrs).trigger('show'))); return _.map(jids, (jid) => _converse.api.rooms.create(jid, attrs).trigger('show'));
} }
});
});
}, },
/** /**
...@@ -1524,5 +1516,4 @@ ...@@ -1524,5 +1516,4 @@
}); });
/************************ END API ************************/ /************************ END API ************************/
} }
}); });
}));
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
/* This is a Converse.js plugin which add support for application-level pings /* This is a Converse.js plugin which add support for application-level pings
* as specified in XEP-0199 XMPP Ping. * as specified in XEP-0199 XMPP Ping.
*/ */
(function (root, factory) {
define(["./converse-core", "strophejs-plugin-ping"], factory);
}(this, function (converse) {
"use strict";
// Strophe methods for building stanzas
const { Strophe, _ } = converse.env;
converse.plugins.add('converse-ping', { import "strophejs-plugin-ping";
import converse from "./converse-core";
// Strophe methods for building stanzas
const { Strophe, _ } = converse.env;
converse.plugins.add('converse-ping', {
initialize () { initialize () {
/* The initialize function gets called as soon as the plugin is /* The initialize function gets called as soon as the plugin is
...@@ -90,5 +90,4 @@ ...@@ -90,5 +90,4 @@
_converse.on('connected', onConnected); _converse.on('connected', onConnected);
_converse.on('reconnected', onConnected); _converse.on('reconnected', onConnected);
} }
}); });
}));
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
// Copyright (c) 2013-2018, the Converse.js developers // Copyright (c) 2013-2018, the Converse.js developers
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
(function (root, factory) {
define(["./converse-core", "./templates/vcard.html"], factory);
}(this, function (converse, tpl_vcard) {
"use strict";
const { Backbone, Promise, Strophe, _, $iq, $build, b64_sha1, moment, sizzle } = converse.env;
const u = converse.env.utils;
import converse from "./converse-core";
import tpl_vcard from "./templates/vcard.html";
converse.plugins.add('converse-vcard', { const { Backbone, Promise, Strophe, _, $iq, $build, b64_sha1, moment, sizzle } = converse.env;
const u = converse.env.utils;
converse.plugins.add('converse-vcard', {
initialize () { initialize () {
/* The initialize function gets called as soon as the plugin is /* The initialize function gets called as soon as the plugin is
...@@ -239,5 +239,4 @@ ...@@ -239,5 +239,4 @@
} }
}); });
} }
}); });
}));
...@@ -3,56 +3,20 @@ ...@@ -3,56 +3,20 @@
// //
// This is the utilities module. // This is the utilities module.
// //
// Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com> // Copyright (c) 2013-2018, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
// //
/*global define, escape, window, Uint8Array */ /*global escape, Uint8Array */
(function (root, factory) {
if (typeof define === 'function' && define.amd) { import Backbone from "backbone";
define([ import Promise from "es6-promise/dist/es6-promise.auto";
"sizzle", import { Strophe } from "strophe.js";
"es6-promise/dist/es6-promise.auto", import _ from "../lodash.noconflict";
"../lodash.noconflict", import sizzle from "sizzle";
"backbone",
"strophe.js", const u = {};
], factory);
} else { u.getLongestSubstring = function (string, candidates) {
// Used by the mockups
const Strophe = {
'Strophe': root.Strophe,
'$build': root.$build,
'$iq': root.$iq,
'$msg': root.$msg,
'$pres': root.$pres,
'SHA1': root.SHA1,
'MD5': root.MD5,
'b64_hmac_sha1': root.b64_hmac_sha1,
'b64_sha1': root.b64_sha1,
'str_hmac_sha1': root.str_hmac_sha1,
'str_sha1': root.str_sha1
};
root.converse_utils = factory(
root.sizzle,
root.Promise,
null,
root._,
root.Backbone,
Strophe
);
}
}(this, function (
sizzle,
Promise,
_,
Backbone,
Strophe
) {
"use strict";
Strophe = Strophe.Strophe;
const u = {};
u.getLongestSubstring = function (string, candidates) {
function reducer (accumulator, current_value) { function reducer (accumulator, current_value) {
if (string.startsWith(current_value)) { if (string.startsWith(current_value)) {
if (current_value.length > accumulator.length) { if (current_value.length > accumulator.length) {
...@@ -65,9 +29,9 @@ ...@@ -65,9 +29,9 @@
} }
} }
return candidates.reduce(reducer, ''); return candidates.reduce(reducer, '');
} }
u.prefixMentions = function (message) { u.prefixMentions = function (message) {
/* Given a message object, return its text with @ chars /* Given a message object, return its text with @ chars
* inserted before the mentioned nicknames. * inserted before the mentioned nicknames.
*/ */
...@@ -78,27 +42,27 @@ ...@@ -78,27 +42,27 @@
text = `${text.slice(0, ref.begin)}@${text.slice(ref.begin)}` text = `${text.slice(0, ref.begin)}@${text.slice(ref.begin)}`
}); });
return text; return text;
}; };
u.isValidJID = function (jid) { u.isValidJID = function (jid) {
return _.compact(jid.split('@')).length === 2 && !jid.startsWith('@') && !jid.endsWith('@'); return _.compact(jid.split('@')).length === 2 && !jid.startsWith('@') && !jid.endsWith('@');
}; };
u.isValidMUCJID = function (jid) { u.isValidMUCJID = function (jid) {
return !jid.startsWith('@') && !jid.endsWith('@'); return !jid.startsWith('@') && !jid.endsWith('@');
}; };
u.isSameBareJID = function (jid1, jid2) { u.isSameBareJID = function (jid1, jid2) {
return Strophe.getBareJidFromJid(jid1).toLowerCase() === return Strophe.getBareJidFromJid(jid1).toLowerCase() ===
Strophe.getBareJidFromJid(jid2).toLowerCase(); Strophe.getBareJidFromJid(jid2).toLowerCase();
}; };
u.getMostRecentMessage = function (model) { u.getMostRecentMessage = function (model) {
const messages = model.messages.filter('message'); const messages = model.messages.filter('message');
return messages[messages.length-1]; return messages[messages.length-1];
} }
u.isNewMessage = function (message) { u.isNewMessage = function (message) {
/* Given a stanza, determine whether it's a new /* Given a stanza, determine whether it's a new
* message, i.e. not a MAM archived one. * message, i.e. not a MAM archived one.
*/ */
...@@ -110,9 +74,9 @@ ...@@ -110,9 +74,9 @@
} else { } else {
return !(message.get('is_delayed') && message.get('is_archived')); return !(message.get('is_delayed') && message.get('is_archived'));
} }
}; };
u.isOnlyChatStateNotification = function (attrs) { u.isOnlyChatStateNotification = function (attrs) {
if (attrs instanceof Backbone.Model) { if (attrs instanceof Backbone.Model) {
attrs = attrs.attributes; attrs = attrs.attributes;
} }
...@@ -121,9 +85,9 @@ ...@@ -121,9 +85,9 @@
!attrs['file'] && !attrs['file'] &&
!(attrs['is_encrypted'] && attrs['plaintext']) && !(attrs['is_encrypted'] && attrs['plaintext']) &&
!attrs['message']; !attrs['message'];
}; };
u.isHeadlineMessage = function (_converse, message) { u.isHeadlineMessage = function (_converse, message) {
var from_jid = message.getAttribute('from'); var from_jid = message.getAttribute('from');
if (message.getAttribute('type') === 'headline') { if (message.getAttribute('type') === 'headline') {
return true; return true;
...@@ -142,9 +106,9 @@ ...@@ -142,9 +106,9 @@
return true; return true;
} }
return false; return false;
}; };
u.merge = function merge (first, second) { u.merge = function merge (first, second) {
/* Merge the second object into the first one. /* Merge the second object into the first one.
*/ */
for (var k in second) { for (var k in second) {
...@@ -154,9 +118,9 @@ ...@@ -154,9 +118,9 @@
first[k] = second[k]; first[k] = second[k];
} }
} }
}; };
u.applyUserSettings = function applyUserSettings (context, settings, user_settings) { u.applyUserSettings = function applyUserSettings (context, settings, user_settings) {
/* Configuration settings might be nested objects. We only want to /* Configuration settings might be nested objects. We only want to
* add settings which are whitelisted. * add settings which are whitelisted.
*/ */
...@@ -170,9 +134,9 @@ ...@@ -170,9 +134,9 @@
context[k] = user_settings[k]; context[k] = user_settings[k];
} }
} }
}; };
u.stringToNode = function (s) { u.stringToNode = function (s) {
/* Converts an HTML string into a DOM Node. /* Converts an HTML string into a DOM Node.
* Expects that the HTML string has only one top-level element, * Expects that the HTML string has only one top-level element,
* i.e. not multiple ones. * i.e. not multiple ones.
...@@ -183,9 +147,9 @@ ...@@ -183,9 +147,9 @@
var div = document.createElement('div'); var div = document.createElement('div');
div.innerHTML = s; div.innerHTML = s;
return div.firstElementChild; return div.firstElementChild;
}; };
u.getOuterWidth = function (el, include_margin=false) { u.getOuterWidth = function (el, include_margin=false) {
var width = el.offsetWidth; var width = el.offsetWidth;
if (!include_margin) { if (!include_margin) {
return width; return width;
...@@ -193,9 +157,9 @@ ...@@ -193,9 +157,9 @@
var style = window.getComputedStyle(el); var style = window.getComputedStyle(el);
width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10); width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
return width; return width;
}; };
u.stringToElement = function (s) { u.stringToElement = function (s) {
/* Converts an HTML string into a DOM element. /* Converts an HTML string into a DOM element.
* Expects that the HTML string has only one top-level element, * Expects that the HTML string has only one top-level element,
* i.e. not multiple ones. * i.e. not multiple ones.
...@@ -206,9 +170,9 @@ ...@@ -206,9 +170,9 @@
var div = document.createElement('div'); var div = document.createElement('div');
div.innerHTML = s; div.innerHTML = s;
return div.firstElementChild; return div.firstElementChild;
}; };
u.matchesSelector = function (el, selector) { u.matchesSelector = function (el, selector) {
/* Checks whether the DOM element matches the given selector. /* Checks whether the DOM element matches the given selector.
* *
* Parameters: * Parameters:
...@@ -223,9 +187,9 @@ ...@@ -223,9 +187,9 @@
el.webkitMatchesSelector || el.webkitMatchesSelector ||
el.oMatchesSelector el.oMatchesSelector
).call(el, selector); ).call(el, selector);
}; };
u.queryChildren = function (el, selector) { u.queryChildren = function (el, selector) {
/* Returns a list of children of the DOM element that match the /* Returns a list of children of the DOM element that match the
* selector. * selector.
* *
...@@ -235,9 +199,9 @@ ...@@ -235,9 +199,9 @@
* against. * against.
*/ */
return _.filter(el.childNodes, _.partial(u.matchesSelector, _, selector)); return _.filter(el.childNodes, _.partial(u.matchesSelector, _, selector));
}; };
u.contains = function (attr, query) { u.contains = function (attr, query) {
return function (item) { return function (item) {
if (typeof attr === 'object') { if (typeof attr === 'object') {
var value = false; var value = false;
...@@ -251,35 +215,35 @@ ...@@ -251,35 +215,35 @@
throw new TypeError('contains: wrong attribute type. Must be string or array.'); throw new TypeError('contains: wrong attribute type. Must be string or array.');
} }
}; };
}; };
u.isOfType = function (type, item) { u.isOfType = function (type, item) {
return item.get('type') == type; return item.get('type') == type;
}; };
u.isInstance = function (type, item) { u.isInstance = function (type, item) {
return item instanceof type; return item instanceof type;
}; };
u.getAttribute = function (key, item) { u.getAttribute = function (key, item) {
return item.get(key); return item.get(key);
}; };
u.contains.not = function (attr, query) { u.contains.not = function (attr, query) {
return function (item) { return function (item) {
return !(u.contains(attr, query)(item)); return !(u.contains(attr, query)(item));
}; };
}; };
u.rootContains = function (root, el) { u.rootContains = function (root, el) {
// The document element does not have the contains method in IE. // The document element does not have the contains method in IE.
if (root === document && !root.contains) { if (root === document && !root.contains) {
return document.head.contains(el) || document.body.contains(el); return document.head.contains(el) || document.body.contains(el);
} }
return root.contains ? root.contains(el) : window.HTMLElement.prototype.contains.call(root, el); return root.contains ? root.contains(el) : window.HTMLElement.prototype.contains.call(root, el);
}; };
u.createFragmentFromText = function (markup) { u.createFragmentFromText = function (markup) {
/* Returns a DocumentFragment containing DOM nodes based on the /* Returns a DocumentFragment containing DOM nodes based on the
* passed-in markup text. * passed-in markup text.
*/ */
...@@ -293,13 +257,13 @@ ...@@ -293,13 +257,13 @@
frag.appendChild(child); frag.appendChild(child);
} }
return frag return frag
}; };
u.isPersistableModel = function (model) { u.isPersistableModel = function (model) {
return model.collection && model.collection.browserStorage; return model.collection && model.collection.browserStorage;
}; };
u.getResolveablePromise = function () { u.getResolveablePromise = function () {
/* Returns a promise object on which `resolve` or `reject` can be /* Returns a promise object on which `resolve` or `reject` can be
* called. * called.
*/ */
...@@ -310,17 +274,17 @@ ...@@ -310,17 +274,17 @@
}) })
_.assign(promise, wrapper); _.assign(promise, wrapper);
return promise; return promise;
}; };
u.interpolate = function (string, o) { u.interpolate = function (string, o) {
return string.replace(/{{{([^{}]*)}}}/g, return string.replace(/{{{([^{}]*)}}}/g,
(a, b) => { (a, b) => {
var r = o[b]; var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a; return typeof r === 'string' || typeof r === 'number' ? r : a;
}); });
}; };
u.onMultipleEvents = function (events=[], callback) { u.onMultipleEvents = function (events=[], callback) {
/* Call the callback once all the events have been triggered /* Call the callback once all the events have been triggered
* *
* Parameters: * Parameters:
...@@ -340,60 +304,60 @@ ...@@ -340,60 +304,60 @@
} }
} }
_.each(events, (map) => map.object.on(map.event, handler)); _.each(events, (map) => map.object.on(map.event, handler));
}; };
u.safeSave = function (model, attributes) { u.safeSave = function (model, attributes) {
if (u.isPersistableModel(model)) { if (u.isPersistableModel(model)) {
model.save(attributes); model.save(attributes);
} else { } else {
model.set(attributes); model.set(attributes);
} }
}; };
u.siblingIndex = function (el) { u.siblingIndex = function (el) {
/* eslint-disable no-cond-assign */ /* eslint-disable no-cond-assign */
for (var i = 0; el = el.previousElementSibling; i++); for (var i = 0; el = el.previousElementSibling; i++);
return i; return i;
}; };
u.getCurrentWord = function (input) { u.getCurrentWord = function (input) {
const cursor = input.selectionEnd || undefined; const cursor = input.selectionEnd || undefined;
return _.last(input.value.slice(0, cursor).split(' ')); return _.last(input.value.slice(0, cursor).split(' '));
}; };
u.replaceCurrentWord = function (input, new_value) { u.replaceCurrentWord = function (input, new_value) {
const cursor = input.selectionEnd || undefined, const cursor = input.selectionEnd || undefined,
current_word = _.last(input.value.slice(0, cursor).split(' ')), current_word = _.last(input.value.slice(0, cursor).split(' ')),
value = input.value; value = input.value;
input.value = value.slice(0, cursor - current_word.length) + `${new_value} ` + value.slice(cursor); input.value = value.slice(0, cursor - current_word.length) + `${new_value} ` + value.slice(cursor);
input.selectionEnd = cursor - current_word.length + new_value.length + 1; input.selectionEnd = cursor - current_word.length + new_value.length + 1;
}; };
u.isVisible = function (el) { u.isVisible = function (el) {
if (u.hasClass('hidden', el)) { if (u.hasClass('hidden', el)) {
return false; return false;
} }
// XXX: Taken from jQuery's "visible" implementation // XXX: Taken from jQuery's "visible" implementation
return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0; return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
}; };
u.triggerEvent = function (el, name, type="Event", bubbles=true, cancelable=true) { u.triggerEvent = function (el, name, type="Event", bubbles=true, cancelable=true) {
const evt = document.createEvent(type); const evt = document.createEvent(type);
evt.initEvent(name, bubbles, cancelable); evt.initEvent(name, bubbles, cancelable);
el.dispatchEvent(evt); el.dispatchEvent(evt);
}; };
u.geoUriToHttp = function(text, geouri_replacement) { u.geoUriToHttp = function(text, geouri_replacement) {
const regex = /geo:([\-0-9.]+),([\-0-9.]+)(?:,([\-0-9.]+))?(?:\?(.*))?/g; const regex = /geo:([\-0-9.]+),([\-0-9.]+)(?:,([\-0-9.]+))?(?:\?(.*))?/g;
return text.replace(regex, geouri_replacement); return text.replace(regex, geouri_replacement);
}; };
u.httpToGeoUri = function(text, _converse) { u.httpToGeoUri = function(text, _converse) {
const replacement = 'geo:$1,$2'; const replacement = 'geo:$1,$2';
return text.replace(_converse.geouri_regex, replacement); return text.replace(_converse.geouri_regex, replacement);
}; };
u.getSelectValues = function (select) { u.getSelectValues = function (select) {
const result = []; const result = [];
const options = select && select.options; const options = select && select.options;
for (var i=0, iLen=options.length; i<iLen; i++) { for (var i=0, iLen=options.length; i<iLen; i++) {
...@@ -403,9 +367,9 @@ ...@@ -403,9 +367,9 @@
} }
} }
return result; return result;
}; };
u.formatFingerprint = function (fp) { u.formatFingerprint = function (fp) {
fp = fp.replace(/^05/, ''); fp = fp.replace(/^05/, '');
const arr = []; const arr = [];
for (let i=1; i<8; i++) { for (let i=1; i<8; i++) {
...@@ -413,34 +377,34 @@ ...@@ -413,34 +377,34 @@
fp = fp.slice(0, idx) + ' ' + fp.slice(idx); fp = fp.slice(0, idx) + ' ' + fp.slice(idx);
} }
return fp; return fp;
}; };
u.appendArrayBuffer = function (buffer1, buffer2) { u.appendArrayBuffer = function (buffer1, buffer2) {
const tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength); const tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
tmp.set(new Uint8Array(buffer1), 0); tmp.set(new Uint8Array(buffer1), 0);
tmp.set(new Uint8Array(buffer2), buffer1.byteLength); tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
return tmp.buffer; return tmp.buffer;
}; };
u.arrayBufferToHex = function (ab) { u.arrayBufferToHex = function (ab) {
// https://stackoverflow.com/questions/40031688/javascript-arraybuffer-to-hex#40031979 // https://stackoverflow.com/questions/40031688/javascript-arraybuffer-to-hex#40031979
return Array.prototype.map.call(new Uint8Array(ab), x => ('00' + x.toString(16)).slice(-2)).join(''); return Array.prototype.map.call(new Uint8Array(ab), x => ('00' + x.toString(16)).slice(-2)).join('');
}; };
u.arrayBufferToString = function (ab) { u.arrayBufferToString = function (ab) {
return new TextDecoder("utf-8").decode(ab); return new TextDecoder("utf-8").decode(ab);
}; };
u.stringToArrayBuffer = function (string) { u.stringToArrayBuffer = function (string) {
const bytes = new TextEncoder("utf-8").encode(string); const bytes = new TextEncoder("utf-8").encode(string);
return bytes.buffer; return bytes.buffer;
}; };
u.arrayBufferToBase64 = function (ab) { u.arrayBufferToBase64 = function (ab) {
return btoa((new Uint8Array(ab)).reduce((data, byte) => data + String.fromCharCode(byte), '')); return btoa((new Uint8Array(ab)).reduce((data, byte) => data + String.fromCharCode(byte), ''));
}; };
u.base64ToArrayBuffer = function (b64) { u.base64ToArrayBuffer = function (b64) {
const binary_string = window.atob(b64), const binary_string = window.atob(b64),
len = binary_string.length, len = binary_string.length,
bytes = new Uint8Array(len); bytes = new Uint8Array(len);
...@@ -449,13 +413,13 @@ ...@@ -449,13 +413,13 @@
bytes[i] = binary_string.charCodeAt(i) bytes[i] = binary_string.charCodeAt(i)
} }
return bytes.buffer return bytes.buffer
}; };
u.getRandomInt = function (max) { u.getRandomInt = function (max) {
return Math.floor(Math.random() * Math.floor(max)); return Math.floor(Math.random() * Math.floor(max));
}; };
u.putCurserAtEnd = function (textarea) { u.putCurserAtEnd = function (textarea) {
if (textarea !== document.activeElement) { if (textarea !== document.activeElement) {
textarea.focus(); textarea.focus();
} }
...@@ -466,14 +430,14 @@ ...@@ -466,14 +430,14 @@
// Scroll to the bottom, in case we're in a tall textarea // Scroll to the bottom, in case we're in a tall textarea
// (Necessary for Firefox and Chrome) // (Necessary for Firefox and Chrome)
this.scrollTop = 999999; this.scrollTop = 999999;
}; };
u.getUniqueId = function () { u.getUniqueId = function () {
return 'xxxxxxxx-xxxx'.replace(/[x]/g, function(c) { return 'xxxxxxxx-xxxx'.replace(/[x]/g, function(c) {
var r = Math.random() * 16 | 0, var r = Math.random() * 16 | 0,
v = c === 'x' ? r : r & 0x3 | 0x8; v = c === 'x' ? r : r & 0x3 | 0x8;
return v.toString(16); return v.toString(16);
}); });
}; };
return u;
})); export default u;
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,18 +5,12 @@ ...@@ -5,18 +5,12 @@
// //
// Copyright (c) 2013-2018, Jan-Carel Brand <jc@opkode.com> // Copyright (c) 2013-2018, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
//
/*global define */
(function (root, factory) {
define([
"../lodash.noconflict",
"./core",
"../templates/field.html"
], factory);
}(this, function (_, u, tpl_field) {
"use strict";
u.webForm2xForm = function (field) { import _ from "../lodash.noconflict";
import tpl_field from "../templates/field.html";
import u from "./core";
u.webForm2xForm = function (field) {
/* Takes an HTML DOM and turns it into an XForm field. /* Takes an HTML DOM and turns it into an XForm field.
* *
* Parameters: * Parameters:
...@@ -38,6 +32,5 @@ ...@@ -38,6 +32,5 @@
'value': value 'value': value
}) })
); );
}; };
return u; export default u;
}));
...@@ -3,18 +3,19 @@ ...@@ -3,18 +3,19 @@
// //
// This is the utilities module. // This is the utilities module.
// //
// Copyright (c) 2012-2017, Jan-Carel Brand <jc@opkode.com> // Copyright (c) 2013-2018, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
// //
/*global define, escape, Jed */ /*global escape, Jed */
(function (root, factory) {
define(["../converse-core", "./core"], factory);
}(this, function (converse, u) {
"use strict";
const { Strophe, sizzle, _ } = converse.env;
u.computeAffiliationsDelta = function computeAffiliationsDelta (exclude_existing, remove_absentees, new_list, old_list) { import converse from "@converse/headless/converse-core";
import u from "./core";
const { Strophe, sizzle, _ } = converse.env;
u.computeAffiliationsDelta = function computeAffiliationsDelta (exclude_existing, remove_absentees, new_list, old_list) {
/* Given two lists of objects with 'jid', 'affiliation' and /* Given two lists of objects with 'jid', 'affiliation' and
* 'reason' properties, return a new list containing * 'reason' properties, return a new list containing
* those objects that are new, changed or removed * those objects that are new, changed or removed
...@@ -69,9 +70,9 @@ ...@@ -69,9 +70,9 @@
); );
} }
return delta; return delta;
}; };
u.parseMemberListIQ = function parseMemberListIQ (iq) { u.parseMemberListIQ = function parseMemberListIQ (iq) {
/* Given an IQ stanza with a member list, create an array of member objects. /* Given an IQ stanza with a member list, create an array of member objects.
*/ */
return _.map( return _.map(
...@@ -99,5 +100,5 @@ ...@@ -99,5 +100,5 @@
return data; return data;
} }
); );
}; };
}));
...@@ -5,59 +5,35 @@ ...@@ -5,59 +5,35 @@
// //
// Copyright (c) 2013-2018, Jan-Carel Brand <jc@opkode.com> // Copyright (c) 2013-2018, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2) // Licensed under the Mozilla Public License (MPLv2)
//
/*global define */ import URI from "urijs";
(function (root, factory) { import _ from "../headless/lodash.noconflict";
define([ import sizzle from "sizzle";
"sizzle", import tpl_audio from "../templates/audio.html";
"../headless/lodash.noconflict", import tpl_field from "@converse/headless/templates/field.html";
"../headless/utils/core", import tpl_file from "../templates/file.html";
"urijs", import tpl_form_captcha from "../templates/form_captcha.html";
"../templates/audio.html", import tpl_form_checkbox from "../templates/form_checkbox.html";
"../headless/templates/field.html", import tpl_form_input from "../templates/form_input.html";
"../templates/file.html", import tpl_form_select from "../templates/form_select.html";
"../templates/form_captcha.html", import tpl_form_textarea from "../templates/form_textarea.html";
"../templates/form_checkbox.html", import tpl_form_url from "../templates/form_url.html";
"../templates/form_input.html", import tpl_form_username from "../templates/form_username.html";
"../templates/form_select.html", import tpl_image from "../templates/image.html";
"../templates/form_textarea.html", import tpl_select_option from "../templates/select_option.html";
"../templates/form_url.html", import tpl_video from "../templates/video.html";
"../templates/form_username.html", import u from "../headless/utils/core";
"../templates/image.html",
"../templates/select_option.html", const URL_REGEX = /\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b\/?/g;
"../templates/video.html"
], factory); const logger = _.assign({
}(this, function (
sizzle,
_,
u,
URI,
tpl_audio,
tpl_field,
tpl_file,
tpl_form_captcha,
tpl_form_checkbox,
tpl_form_input,
tpl_form_select,
tpl_form_textarea,
tpl_form_url,
tpl_form_username,
tpl_image,
tpl_select_option,
tpl_video
) {
"use strict";
const URL_REGEX = /\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b\/?/g;
const logger = _.assign({
'debug': _.get(console, 'log') ? console.log.bind(console) : _.noop, 'debug': _.get(console, 'log') ? console.log.bind(console) : _.noop,
'error': _.get(console, 'log') ? console.log.bind(console) : _.noop, 'error': _.get(console, 'log') ? console.log.bind(console) : _.noop,
'info': _.get(console, 'log') ? console.log.bind(console) : _.noop, 'info': _.get(console, 'log') ? console.log.bind(console) : _.noop,
'warn': _.get(console, 'log') ? console.log.bind(console) : _.noop 'warn': _.get(console, 'log') ? console.log.bind(console) : _.noop
}, console); }, console);
const XFORM_TYPE_MAP = { const XFORM_TYPE_MAP = {
'text-private': 'password', 'text-private': 'password',
'text-single': 'text', 'text-single': 'text',
'fixed': 'label', 'fixed': 'label',
...@@ -66,18 +42,18 @@ ...@@ -66,18 +42,18 @@
'jid-multi': 'textarea', 'jid-multi': 'textarea',
'list-single': 'dropdown', 'list-single': 'dropdown',
'list-multi': 'dropdown' 'list-multi': 'dropdown'
}; };
function slideOutWrapup (el) { function slideOutWrapup (el) {
/* Wrapup function for slideOut. */ /* Wrapup function for slideOut. */
el.removeAttribute('data-slider-marker'); el.removeAttribute('data-slider-marker');
el.classList.remove('collapsed'); el.classList.remove('collapsed');
el.style.overflow = ""; el.style.overflow = "";
el.style.height = ""; el.style.height = "";
} }
const isImage = function (url) { const isImage = function (url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var img = new Image(); var img = new Image();
var timer = window.setTimeout(function () { var timer = window.setTimeout(function () {
...@@ -94,10 +70,10 @@ ...@@ -94,10 +70,10 @@
}; };
img.src = url; img.src = url;
}); });
}; };
u.isAudioURL = function (url) { u.isAudioURL = function (url) {
if (!(url instanceof URI)) { if (!(url instanceof URI)) {
url = new URI(url); url = new URI(url);
} }
...@@ -106,10 +82,10 @@ ...@@ -106,10 +82,10 @@
return false; return false;
} }
return filename.endsWith('.ogg') || filename.endsWith('.mp3') || filename.endsWith('.m4a'); return filename.endsWith('.ogg') || filename.endsWith('.mp3') || filename.endsWith('.m4a');
} }
u.isImageURL = function (url) { u.isImageURL = function (url) {
if (!(url instanceof URI)) { if (!(url instanceof URI)) {
url = new URI(url); url = new URI(url);
} }
...@@ -121,10 +97,10 @@ ...@@ -121,10 +97,10 @@
filename.endsWith('.png') || filename.endsWith('.gif') || filename.endsWith('.png') || filename.endsWith('.gif') ||
filename.endsWith('.bmp') || filename.endsWith('.tiff') || filename.endsWith('.bmp') || filename.endsWith('.tiff') ||
filename.endsWith('.svg'); filename.endsWith('.svg');
}; };
u.isVideoURL = function (url) { u.isVideoURL = function (url) {
if (!(url instanceof URI)) { if (!(url instanceof URI)) {
url = new URI(url); url = new URI(url);
} }
...@@ -133,10 +109,10 @@ ...@@ -133,10 +109,10 @@
return false; return false;
} }
return filename.endsWith('.mp4') || filename.endsWith('.webm'); return filename.endsWith('.mp4') || filename.endsWith('.webm');
} }
u.renderAudioURL = function (_converse, url) { u.renderAudioURL = function (_converse, url) {
const uri = new URI(url); const uri = new URI(url);
if (u.isAudioURL(uri)) { if (u.isAudioURL(uri)) {
const { __ } = _converse; const { __ } = _converse;
...@@ -146,10 +122,10 @@ ...@@ -146,10 +122,10 @@
}) })
} }
return url; return url;
}; };
u.renderFileURL = function (_converse, url) { u.renderFileURL = function (_converse, url) {
const uri = new URI(url); const uri = new URI(url);
if (u.isImageURL(uri) || u.isVideoURL(uri) || u.isAudioURL(uri)) { if (u.isImageURL(uri) || u.isVideoURL(uri) || u.isAudioURL(uri)) {
return url; return url;
...@@ -160,10 +136,10 @@ ...@@ -160,10 +136,10 @@
'url': url, 'url': url,
'label_download': __('Download file "%1$s"', decodeURI(filename)) 'label_download': __('Download file "%1$s"', decodeURI(filename))
}) })
}; };
u.renderImageURL = function (_converse, url) { u.renderImageURL = function (_converse, url) {
if (!_converse.show_images_inline) { if (!_converse.show_images_inline) {
return u.addHyperlinks(url); return u.addHyperlinks(url);
} }
...@@ -176,10 +152,10 @@ ...@@ -176,10 +152,10 @@
}) })
} }
return url; return url;
}; };
u.renderImageURLs = function (_converse, el) { u.renderImageURLs = function (_converse, el) {
/* Returns a Promise which resolves once all images have been loaded. /* Returns a Promise which resolves once all images have been loaded.
*/ */
if (!_converse.show_images_inline) { if (!_converse.show_images_inline) {
...@@ -213,10 +189,10 @@ ...@@ -213,10 +189,10 @@
}) })
) )
) )
}; };
u.renderMovieURL = function (_converse, url) { u.renderMovieURL = function (_converse, url) {
const uri = new URI(url); const uri = new URI(url);
if (u.isVideoURL(uri)) { if (u.isVideoURL(uri)) {
const { __ } = _converse; const { __ } = _converse;
...@@ -226,14 +202,14 @@ ...@@ -226,14 +202,14 @@
}) })
} }
return url; return url;
}; };
u.renderNewLines = function (text) { u.renderNewLines = function (text) {
return text.replace(/\n\n+/g, '<br/><br/>').replace(/\n/g, '<br/>'); return text.replace(/\n\n+/g, '<br/><br/>').replace(/\n/g, '<br/>');
}; };
u.calculateElementHeight = function (el) { u.calculateElementHeight = function (el) {
/* Return the height of the passed in DOM element, /* Return the height of the passed in DOM element,
* based on the heights of its children. * based on the heights of its children.
*/ */
...@@ -241,84 +217,84 @@ ...@@ -241,84 +217,84 @@
el.children, el.children,
(result, child) => result + child.offsetHeight, 0 (result, child) => result + child.offsetHeight, 0
); );
} }
u.getNextElement = function (el, selector='*') { u.getNextElement = function (el, selector='*') {
let next_el = el.nextElementSibling; let next_el = el.nextElementSibling;
while (!_.isNull(next_el) && !sizzle.matchesSelector(next_el, selector)) { while (!_.isNull(next_el) && !sizzle.matchesSelector(next_el, selector)) {
next_el = next_el.nextElementSibling; next_el = next_el.nextElementSibling;
} }
return next_el; return next_el;
} }
u.getPreviousElement = function (el, selector='*') { u.getPreviousElement = function (el, selector='*') {
let prev_el = el.previousSibling; let prev_el = el.previousSibling;
while (!_.isNull(prev_el) && !sizzle.matchesSelector(prev_el, selector)) { while (!_.isNull(prev_el) && !sizzle.matchesSelector(prev_el, selector)) {
prev_el = prev_el.previousSibling prev_el = prev_el.previousSibling
} }
return prev_el; return prev_el;
} }
u.getFirstChildElement = function (el, selector='*') { u.getFirstChildElement = function (el, selector='*') {
let first_el = el.firstElementChild; let first_el = el.firstElementChild;
while (!_.isNull(first_el) && !sizzle.matchesSelector(first_el, selector)) { while (!_.isNull(first_el) && !sizzle.matchesSelector(first_el, selector)) {
first_el = first_el.nextSibling first_el = first_el.nextSibling
} }
return first_el; return first_el;
} }
u.getLastChildElement = function (el, selector='*') { u.getLastChildElement = function (el, selector='*') {
let last_el = el.lastElementChild; let last_el = el.lastElementChild;
while (!_.isNull(last_el) && !sizzle.matchesSelector(last_el, selector)) { while (!_.isNull(last_el) && !sizzle.matchesSelector(last_el, selector)) {
last_el = last_el.previousSibling last_el = last_el.previousSibling
} }
return last_el; return last_el;
} }
u.hasClass = function (className, el) { u.hasClass = function (className, el) {
return _.includes(el.classList, className); return _.includes(el.classList, className);
}; };
u.addClass = function (className, el) { u.addClass = function (className, el) {
if (el instanceof Element) { if (el instanceof Element) {
el.classList.add(className); el.classList.add(className);
} }
} }
u.removeClass = function (className, el) { u.removeClass = function (className, el) {
if (el instanceof Element) { if (el instanceof Element) {
el.classList.remove(className); el.classList.remove(className);
} }
return el; return el;
} }
u.removeElement = function (el) { u.removeElement = function (el) {
if (!_.isNil(el) && !_.isNil(el.parentNode)) { if (!_.isNil(el) && !_.isNil(el.parentNode)) {
el.parentNode.removeChild(el); el.parentNode.removeChild(el);
} }
} }
u.showElement = _.flow( u.showElement = _.flow(
_.partial(u.removeClass, 'collapsed'), _.partial(u.removeClass, 'collapsed'),
_.partial(u.removeClass, 'hidden') _.partial(u.removeClass, 'hidden')
) )
u.hideElement = function (el) { u.hideElement = function (el) {
if (!_.isNil(el)) { if (!_.isNil(el)) {
el.classList.add('hidden'); el.classList.add('hidden');
} }
return el; return el;
} }
u.ancestor = function (el, selector) { u.ancestor = function (el, selector) {
let parent = el; let parent = el;
while (!_.isNil(parent) && !sizzle.matchesSelector(parent, selector)) { while (!_.isNil(parent) && !sizzle.matchesSelector(parent, selector)) {
parent = parent.parentElement; parent = parent.parentElement;
} }
return parent; return parent;
} }
u.nextUntil = function (el, selector, include_self=false) { u.nextUntil = function (el, selector, include_self=false) {
/* Return the element's siblings until one matches the selector. */ /* Return the element's siblings until one matches the selector. */
const matches = []; const matches = [];
let sibling_el = el.nextElementSibling; let sibling_el = el.nextElementSibling;
...@@ -327,9 +303,9 @@ ...@@ -327,9 +303,9 @@
sibling_el = sibling_el.nextElementSibling; sibling_el = sibling_el.nextElementSibling;
} }
return matches; return matches;
} }
u.unescapeHTML = function (string) { u.unescapeHTML = function (string) {
/* Helper method that replace HTML-escaped symbols with equivalent characters /* Helper method that replace HTML-escaped symbols with equivalent characters
* (e.g. transform occurrences of '&amp;' to '&') * (e.g. transform occurrences of '&amp;' to '&')
* *
...@@ -339,18 +315,18 @@ ...@@ -339,18 +315,18 @@
var div = document.createElement('div'); var div = document.createElement('div');
div.innerHTML = string; div.innerHTML = string;
return div.innerText; return div.innerText;
}; };
u.escapeHTML = function (string) { u.escapeHTML = function (string) {
return string return string
.replace(/&/g, "&amp;") .replace(/&/g, "&amp;")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
.replace(/>/g, "&gt;") .replace(/>/g, "&gt;")
.replace(/"/g, "&quot;"); .replace(/"/g, "&quot;");
}; };
u.addMentionsMarkup = function (text, references, chatbox) { u.addMentionsMarkup = function (text, references, chatbox) {
if (chatbox.get('message_type') !== 'groupchat') { if (chatbox.get('message_type') !== 'groupchat') {
return text; return text;
} }
...@@ -367,10 +343,10 @@ ...@@ -367,10 +343,10 @@
} }
}); });
return text; return text;
}; };
u.addHyperlinks = function (text) { u.addHyperlinks = function (text) {
return URI.withinString(text, url => { return URI.withinString(text, url => {
const uri = new URI(url); const uri = new URI(url);
url = uri.normalize()._string; url = uri.normalize()._string;
...@@ -385,28 +361,28 @@ ...@@ -385,28 +361,28 @@
}, { }, {
'start': /\b(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi 'start': /\b(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi
}); });
}; };
u.slideInAllElements = function (elements, duration=300) { u.slideInAllElements = function (elements, duration=300) {
return Promise.all( return Promise.all(
_.map( _.map(
elements, elements,
_.partial(u.slideIn, _, duration) _.partial(u.slideIn, _, duration)
)); ));
}; };
u.slideToggleElement = function (el, duration) { u.slideToggleElement = function (el, duration) {
if (_.includes(el.classList, 'collapsed') || if (_.includes(el.classList, 'collapsed') ||
_.includes(el.classList, 'hidden')) { _.includes(el.classList, 'hidden')) {
return u.slideOut(el, duration); return u.slideOut(el, duration);
} else { } else {
return u.slideIn(el, duration); return u.slideIn(el, duration);
} }
}; };
u.slideOut = function (el, duration=200) { u.slideOut = function (el, duration=200) {
/* Shows/expands an element by sliding it out of itself /* Shows/expands an element by sliding it out of itself
* *
* Parameters: * Parameters:
...@@ -468,9 +444,9 @@ ...@@ -468,9 +444,9 @@
window.requestAnimationFrame(draw) window.requestAnimationFrame(draw)
); );
}); });
}; };
u.slideIn = function (el, duration=200) { u.slideIn = function (el, duration=200) {
/* Hides/collapses an element by sliding it into itself. */ /* Hides/collapses an element by sliding it into itself. */
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (_.isNil(el)) { if (_.isNil(el)) {
...@@ -515,16 +491,16 @@ ...@@ -515,16 +491,16 @@
window.requestAnimationFrame(draw) window.requestAnimationFrame(draw)
); );
}); });
}; };
function afterAnimationEnds (el, callback) { function afterAnimationEnds (el, callback) {
el.classList.remove('visible'); el.classList.remove('visible');
if (_.isFunction(callback)) { if (_.isFunction(callback)) {
callback(); callback();
} }
} }
u.fadeIn = function (el, callback) { u.fadeIn = function (el, callback) {
if (_.isNil(el)) { if (_.isNil(el)) {
logger.warn("Undefined or null element passed into fadeIn"); logger.warn("Undefined or null element passed into fadeIn");
} }
...@@ -541,10 +517,10 @@ ...@@ -541,10 +517,10 @@
} else { } else {
afterAnimationEnds(el, callback); afterAnimationEnds(el, callback);
} }
}; };
u.xForm2webForm = function (field, stanza, domain) { u.xForm2webForm = function (field, stanza, domain) {
/* Takes a field in XMPP XForm (XEP-004: Data Forms) format /* Takes a field in XMPP XForm (XEP-004: Data Forms) format
* and turns it into an HTML field. * and turns it into an HTML field.
* *
...@@ -638,6 +614,5 @@ ...@@ -638,6 +614,5 @@
}); });
} }
} }
} }
return u; export default u;
}));
...@@ -112,6 +112,8 @@ ...@@ -112,6 +112,8 @@
modal.el.querySelector('input[name="chatroom"]').value = jid; modal.el.querySelector('input[name="chatroom"]').value = jid;
modal.el.querySelector('input[name="nickname"]').value = nick; modal.el.querySelector('input[name="nickname"]').value = nick;
modal.el.querySelector('form input[type="submit"]').click(); modal.el.querySelector('form input[type="submit"]').click();
await utils.waitUntil(() => _converse.chatboxviews.get(jid), 1000);
return _converse.chatboxviews.get(jid);
}; };
utils.openChatRoom = function (_converse, room, server, nick) { utils.openChatRoom = function (_converse, room, server, nick) {
......
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