Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
127f4589
Commit
127f4589
authored
May 08, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update dist files
parent
b6692b17
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
592 additions
and
277 deletions
+592
-277
dist/converse-no-dependencies.js
dist/converse-no-dependencies.js
+298
-102
dist/converse.js
dist/converse.js
+294
-169
package-lock.json
package-lock.json
+0
-6
No files found.
dist/converse-no-dependencies.js
View file @
127f4589
...
@@ -9647,12 +9647,11 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
...
@@ -9647,12 +9647,11 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
'str_hmac_sha1': root.str_hmac_sha1,
'str_hmac_sha1': root.str_hmac_sha1,
'str_sha1': root.str_sha1
'str_sha1': root.str_sha1
};
};
root.converse_utils = factory(root.sizzle, root.Promise, root._, Strophe);
root.converse_utils = factory(root.sizzle, root.Promise, root._,
root.Backbone,
Strophe);
}
}
})(this, function (sizzle, Promise, _, Backbone, Strophe, URI, tpl_audio, tpl_file, tpl_image, tpl_video) {
})(this, function (sizzle, Promise, _, Backbone, Strophe, URI, tpl_audio, tpl_file, tpl_image, tpl_video) {
"use strict";
"use strict";
var b64_sha1 = Strophe.SHA1.b64_sha1;
Strophe = Strophe.Strophe;
Strophe = Strophe.Strophe;
var URL_REGEX = /\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b\/?/g;
var URL_REGEX = /\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b\/?/g;
...
@@ -10770,8 +10769,9 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
...
@@ -10770,8 +10769,9 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
Strophe.addNamespace('SID', 'urn:xmpp:sid:0');
Strophe.addNamespace('SID', 'urn:xmpp:sid:0');
Strophe.addNamespace('SPOILER', 'urn:xmpp:spoiler:0');
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('VCARDUPDATE', 'vcard-temp:x:update');
Strophe.addNamespace('XFORM', 'jabber:x:data'); // Use Mustache style syntax for variable interpolation
/* Configuration of Lodash templates (this config is distinct to the
/* 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.
...
@@ -11609,16 +11609,22 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
...
@@ -11609,16 +11609,22 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
defaults: function defaults() {
defaults: function defaults() {
return {
return {
"jid": _converse.bare_jid,
"jid": _converse.bare_jid,
"nickname": _converse.nickname,
"status": _converse.default_state
"status": _converse.default_state,
"vcard_updated": null,
'image': _converse.DEFAULT_IMAGE,
'image_type': _converse.DEFAULT_IMAGE_TYPE
};
};
},
},
initialize: function initialize() {
initialize: function initialize() {
var _this3 = this;
var _this3 = this;
this.vcard = _converse.vcards.findWhere({
'jid': this.get('jid')
});
if (_.isNil(this.vcard)) {
this.vcard = _converse.vcards.create({
'jid': this.get('jid')
});
}
this.on('change:status', function (item) {
this.on('change:status', function (item) {
var status = _this3.get('status');
var status = _this3.get('status');
...
@@ -20689,6 +20695,9 @@ return __p
...
@@ -20689,6 +20695,9 @@ return __p
};
};
},
},
initialize: function initialize() {
initialize: function initialize() {
if (this.get('type') === 'groupchat' && this.collection.chatbox.get('nick') === Strophe.getResourceFromJid(this.get('from'))) {
this.vcard = _converse.xmppstatus.vcard;
} else {
this.vcard = _converse.vcards.findWhere({
this.vcard = _converse.vcards.findWhere({
'jid': this.get('from')
'jid': this.get('from')
});
});
...
@@ -20698,6 +20707,7 @@ return __p
...
@@ -20698,6 +20707,7 @@ return __p
'jid': this.get('from')
'jid': this.get('from')
});
});
}
}
}
if (this.get('file')) {
if (this.get('file')) {
this.on('change:put', this.uploadFile, this);
this.on('change:put', this.uploadFile, this);
...
@@ -21548,7 +21558,13 @@ __p += '\n <canvas class="avatar" height="36" width="36"></canvas>\n ';
...
@@ -21548,7 +21558,13 @@ __p += '\n <canvas class="avatar" height="36" width="36"></canvas>\n ';
} ;
} ;
__p += '\n <div class="chat-msg-content">\n <span class="chat-msg-heading">\n <span class="chat-msg-author">' +
__p += '\n <div class="chat-msg-content">\n <span class="chat-msg-heading">\n <span class="chat-msg-author">' +
__e(o.username) +
__e(o.username) +
'</span>\n <span class="chat-msg-time">' +
'\n ';
_.each(o.roles, function (role) { ;
__p += ' <span class="badge badge-secondary">' +
__e(role) +
'</span> ';
}); ;
__p += '\n </span>\n <span class="chat-msg-time">' +
__e(o.pretty_time) +
__e(o.pretty_time) +
'</span>\n </span>\n <span class="chat-msg-text"></span>\n <div class="chat-msg-media"></div>\n </div>\n</div>\n';
'</span>\n </span>\n <span class="chat-msg-text"></span>\n <div class="chat-msg-media"></div>\n </div>\n</div>\n';
return __p
return __p
...
@@ -21685,10 +21701,14 @@ return __p
...
@@ -21685,10 +21701,14 @@ return __p
} else {
} else {
template = this.model.get('is_spoiler') ? tpl_spoiler_message : tpl_message;
template = this.model.get('is_spoiler') ? tpl_spoiler_message : tpl_message;
}
}
const moment_time = moment(this.model.get('time')),
role = this.model.vcard.get('role'),
roles = role ? role.split(',') : [];
const moment_time = moment(this.model.get('time'));
const msg = u.stringToElement(template(
const msg = u.stringToElement(template(
_.extend(this.model.toJSON(), {
_.extend(
this.model.toJSON(), {
'roles': roles,
'pretty_time': moment_time.format(_converse.time_format),
'pretty_time': moment_time.format(_converse.time_format),
'time': moment_time.format(),
'time': moment_time.format(),
'extra_classes': this.getExtraMessageClasses(),
'extra_classes': this.getExtraMessageClasses(),
...
@@ -24312,6 +24332,17 @@ return __p
...
@@ -24312,6 +24332,17 @@ return __p
});
});
//# sourceMappingURL=converse-rosterview.js.map;
//# sourceMappingURL=converse-rosterview.js.map;
define('tpl!alert', ['lodash'], function(_) {return function(o) {
var __t, __p = '', __e = _.escape;
__p += '<div class="alert ' +
__e(o.type) +
'" role="alert">' +
__e(o.message) +
'</div>\n';
return __p
};});
define('tpl!chat_status_modal', ['lodash'], function(_) {return function(o) {
define('tpl!chat_status_modal', ['lodash'], function(_) {return function(o) {
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
function print() { __p += __j.call(arguments, '') }
...
@@ -24365,19 +24396,51 @@ __p += '<div class="modal fade" id="user-profile-modal" tabindex="-1" role="dial
...
@@ -24365,19 +24396,51 @@ __p += '<div class="modal fade" id="user-profile-modal" tabindex="-1" role="dial
__e(o.heading_profile) +
__e(o.heading_profile) +
'</h5>\n <button type="button" class="close" data-dismiss="modal" aria-label="' +
'</h5>\n <button type="button" class="close" data-dismiss="modal" aria-label="' +
__e(o.label_close) +
__e(o.label_close) +
'"><span aria-hidden="true">×</span></button>\n </div>\n <
div class="modal-body">\n <div class="row">\n <div class="col-auto">\n
';
'"><span aria-hidden="true">×</span></button>\n </div>\n <
form class="converse-form">\n <div class="modal-body">\n <div class="row">\n <div class="col-auto">\n <a class="change-avatar" href="#">\n
';
if (o.image) { ;
if (o.image) { ;
__p += '\n <a class="show-profile" href="#">\n <img alt="User Avatar" class="img-thumbnail avatar align-self-center" height="100px" width="100px" src="data:' +
__p += '\n <img alt="' +
__e(o.alt_avatar) +
'" class="img-thumbnail avatar align-self-center" height="100px" width="100px" src="data:' +
__e(o.image_type) +
__e(o.image_type) +
';base64,' +
';base64,' +
__e(o.image) +
__e(o.image) +
'"/>\n
</a>\n
';
'"/>\n ';
} ;
} ;
__p += '\n </div>\n <div class="col-auto">\n <div classs="row w-100">\n <label>Fullname:</label>\n <span class="username">' +
__p += '\n ';
__e(o.fullname) +
if (!o.image) { ;
'</span>\n </div>\n <div classs="row w-100">\n <label>XMPP Address:</label>\n <span class="username">' +
__p += '\n <canvas class="avatar" height="100px" width="100px"/>\n ';
} ;
__p += '\n </a>\n <input class="hidden" name="image" type="file">\n </div>\n <div class="col">\n <div class="form-group">\n <label class="col-form-label">' +
__e(o.label_jid) +
':</label>\n <div>' +
__e(o.jid) +
__e(o.jid) +
'</span>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</div>\n';
'</div>\n </div>\n </div>\n </div>\n <div class="form-group">\n <label for="vcard-fullname" class="col-form-label">' +
__e(o.label_fullname) +
':</label>\n <input id="vcard-fullname" type="text" class="form-control" name="fn" value="' +
__e(o.fullname) +
'">\n </div>\n <div class="form-group">\n <label for="vcard-nickname" class="col-form-label">' +
__e(o.label_nickname) +
':</label>\n <input id="vcard-nickname" type="text" class="form-control" name="nickname" value="' +
__e(o.nickname) +
'">\n </div>\n <div class="form-group">\n <label for="vcard-url" class="col-form-label">' +
__e(o.label_url) +
':</label>\n <input id="vcard-url" type="url" class="form-control" name="url" value="' +
__e(o.url) +
'">\n </div>\n <div class="form-group">\n <label for="vcard-email" class="col-form-label">' +
__e(o.label_email) +
':</label>\n <input id="vcard-email" type="email" class="form-control" name="email" value="' +
__e(o.email) +
'">\n </div>\n <div class="form-group">\n <label for="vcard-role" class="col-form-label">' +
__e(o.label_role) +
':</label>\n <input id="vcard-role" type="text" class="form-control" name="role" value="' +
__e(o.role) +
'" aria-describedby="vcard-role-help">\n <small id="vcard-role-help" class="form-text text-muted">' +
__e(o.label_role_help) +
'</small>\n </div>\n </div>\n <div class="modal-footer">\n <button type="submit" class="save-form btn btn-primary">' +
__e(o.label_save) +
'</button>\n <button type="button" class="btn btn-secondary" data-dismiss="modal">' +
__e(o.label_close) +
'</button>\n </div>\n </form>\n </div>\n </div>\n</div>\n';
return __p
return __p
};});
};});
...
@@ -24385,15 +24448,11 @@ return __p
...
@@ -24385,15 +24448,11 @@ return __p
define('tpl!profile_view', ['lodash'], function(_) {return function(o) {
define('tpl!profile_view', ['lodash'], function(_) {return function(o) {
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
function print() { __p += __j.call(arguments, '') }
__p += '<div class="userinfo">\n<div class="profile d-flex">\n ';
__p += '<div class="userinfo">\n<div class="profile d-flex">\n <a class="show-profile" href="#">\n <img alt="User Avatar" class="avatar align-self-center" height="40px" width="40px" src="data:' +
if (o.image) { ;
__p += '\n <a class="show-profile" href="#">\n <img alt="User Avatar" class="avatar align-self-center" height="40px" width="40px" src="data:' +
__e(o.image_type) +
__e(o.image_type) +
';base64,' +
';base64,' +
__e(o.image) +
__e(o.image) +
'"/>\n </a>\n ';
'"/>\n </a>\n <span class="username w-100 align-self-center">' +
} ;
__p += '\n <span class="username w-100 align-self-center">' +
__e(o.fullname) +
__e(o.fullname) +
'</span>\n <!-- <a class="chatbox-btn fa fa-vcard align-self-center" title="' +
'</span>\n <!-- <a class="chatbox-btn fa fa-vcard align-self-center" title="' +
__e(o.title_your_profile) +
__e(o.title_your_profile) +
...
@@ -24452,14 +24511,35 @@ __e( o.text ) +
...
@@ -24452,14 +24511,35 @@ __e( o.text ) +
return __p
return __p
};});
};});
define('tpl!vcard', ['lodash'], function(_) {return function(o) {
var __t, __p = '', __e = _.escape;
__p += '<vCard xmlns="vcard-temp">\n <FN>' +
__e(o.fn) +
'</FN>\n <NICKNAME>' +
__e(o.fn) +
'</NICKNAME>\n <URL>' +
__e(o.url) +
'</URL>\n <ROLE>' +
__e(o.role) +
'</ROLE>\n <EMAIL><INTERNET/><PREF/><USERID>' +
__e(o.email) +
'</USERID></EMAIL>\n <PHOTO>\n <TYPE>' +
__e(o.image_type) +
'</TYPE>\n <BINVAL>' +
__e(o.image) +
'</BINVAL>\n </PHOTO>\n</vCard>\n';
return __p
};});
// Converse.js
// Converse.js
// http://conversejs.org
// http://conversejs.org
//
//
// 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) {
(function (root, factory) {
define('converse-vcard',["converse-core", "crypto", "
strophe.
vcard"], factory);
define('converse-vcard',["converse-core", "crypto", "
tpl!
vcard"], factory);
})(this, function (converse, CryptoJS) {
})(this, function (converse, CryptoJS
, tpl_vcard
) {
"use strict";
"use strict";
var _converse$env = converse.env,
var _converse$env = converse.env,
...
@@ -24468,10 +24548,26 @@ return __p
...
@@ -24468,10 +24548,26 @@ return __p
Strophe = _converse$env.Strophe,
Strophe = _converse$env.Strophe,
SHA1 = _converse$env.SHA1,
SHA1 = _converse$env.SHA1,
_ = _converse$env._,
_ = _converse$env._,
$iq = _converse$env.$iq,
$build = _converse$env.$build,
b64_sha1 = _converse$env.b64_sha1,
b64_sha1 = _converse$env.b64_sha1,
moment = _converse$env.moment,
moment = _converse$env.moment,
sizzle = _converse$env.sizzle;
sizzle = _converse$env.sizzle;
var u = converse.env.utils;
var u = converse.env.utils;
converse.plugins.add('converse-vcard', {
initialize: function initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
var _converse = this._converse;
_converse.VCards = Backbone.Collection.extend({
model: _converse.ModelWithDefaultAvatar,
initialize: function initialize() {
this.on('add', function (vcard) {
return _converse.api.vcard.update(vcard);
});
}
});
function onVCardData(_converse, jid, iq, callback) {
function onVCardData(_converse, jid, iq, callback) {
var vcard = iq.querySelector('vCard');
var vcard = iq.querySelector('vCard');
...
@@ -24481,9 +24577,12 @@ return __p
...
@@ -24481,9 +24577,12 @@ return __p
result = {
result = {
'stanza': iq,
'stanza': iq,
'fullname': _.get(vcard.querySelector('FN'), 'textContent'),
'fullname': _.get(vcard.querySelector('FN'), 'textContent'),
'nickname': _.get(vcard.querySelector('NICKNAME'), 'textContent'),
'image': _.get(vcard.querySelector('PHOTO BINVAL'), 'textContent'),
'image': _.get(vcard.querySelector('PHOTO BINVAL'), 'textContent'),
'image_type': _.get(vcard.querySelector('PHOTO TYPE'), 'textContent'),
'image_type': _.get(vcard.querySelector('PHOTO TYPE'), 'textContent'),
'url': _.get(vcard.querySelector('URL'), 'textContent')
'url': _.get(vcard.querySelector('URL'), 'textContent'),
'role': _.get(vcard.querySelector('ROLE'), 'textContent'),
'email': _.get(vcard.querySelector('EMAIL USERID'), 'textContent')
};
};
}
}
...
@@ -24506,6 +24605,33 @@ return __p
...
@@ -24506,6 +24605,33 @@ return __p
}
}
}
}
function createStanza(type, jid, vcard_el) {
var iq = $iq(jid ? {
'type': type,
'to': jid
} : {
'type': type
});
if (!vcard_el) {
iq.c("vCard", {
'xmlns': Strophe.NS.VCARD
});
} else {
iq.cnode(vcard_el);
}
return iq;
}
function setVCard(data) {
return new Promise(function (resolve, reject) {
var vcard_el = Strophe.xmlHtmlNode(tpl_vcard(data)).firstElementChild;
_converse.connection.sendIQ(createStanza("set", data.jid, vcard_el), resolve, reject);
});
}
function getVCard(_converse, jid) {
function getVCard(_converse, jid) {
/* Request the VCard of another user. Returns a promise.
/* Request the VCard of another user. Returns a promise.
*
*
...
@@ -24513,28 +24639,14 @@ return __p
...
@@ -24513,28 +24639,14 @@ return __p
* (String) jid - The Jabber ID of the user whose VCard
* (String) jid - The Jabber ID of the user whose VCard
* is being requested.
* is being requested.
*/
*/
var to
= Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid;
jid
= Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid;
return new Promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
_converse.connection.vcard.get(_.partial(onVCardData, _converse, jid, _, resolve), to, _.partial(onVCardError, _converse, jid, _, resolve)
);
_converse.connection.sendIQ(createStanza("get", jid), _.partial(onVCardData, _converse, jid, _, resolve), _.partial(onVCardError, _converse, jid, _, resolve), 5000
);
});
});
}
}
converse.plugins.add('converse-vcard', {
initialize: function initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
var _converse = this._converse;
_converse.VCards = Backbone.Collection.extend({
model: _converse.ModelWithDefaultAvatar,
initialize: function initialize() {
this.on('add', function (vcard) {
return _converse.api.vcard.update(vcard);
});
}
});
/* Event handlers */
/* Event handlers */
_converse.initVCardCollection = function () {
_converse.initVCardCollection = function () {
_converse.vcards = new _converse.VCards();
_converse.vcards = new _converse.VCards();
_converse.vcards.browserStorage = new Backbone.BrowserStorage.local(b64_sha1("converse.vcards"));
_converse.vcards.browserStorage = new Backbone.BrowserStorage.local(b64_sha1("converse.vcards"));
...
@@ -24548,16 +24660,9 @@ return __p
...
@@ -24548,16 +24660,9 @@ return __p
_converse.api.disco.addFeature(Strophe.NS.VCARD);
_converse.api.disco.addFeature(Strophe.NS.VCARD);
});
});
_converse.on('statusInitialized', function fetchOwnVCard() {
_converse.api.disco.supports(Strophe.NS.VCARD, _converse.domain).then(function (result) {
if (result.length) {
_converse.api.vcard.update(_converse.xmppstatus);
}
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
});
_.extend(_converse.api, {
_.extend(_converse.api, {
'vcard': {
'vcard': {
'set': setVCard,
'get': function get(model, force) {
'get': function get(model, force) {
if (_.isString(model)) {
if (_.isString(model)) {
return getVCard(_converse, model);
return getVCard(_converse, model);
...
@@ -24578,7 +24683,7 @@ return __p
...
@@ -24578,7 +24683,7 @@ return __p
return new Promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
_this.get(model, force).then(function (vcard) {
_this.get(model, force).then(function (vcard) {
model.save(_.extend(_.pick(vcard, ['fullname', '
url
', 'image_type', 'image', 'image_hash']), {
model.save(_.extend(_.pick(vcard, ['fullname', '
nickname', 'email', 'url', 'role
', 'image_type', 'image', 'image_hash']), {
'vcard_updated': moment().format()
'vcard_updated': moment().format()
}));
}));
resolve();
resolve();
...
@@ -24600,8 +24705,8 @@ return __p
...
@@ -24600,8 +24705,8 @@ return __p
/*global define */
/*global define */
(function (root, factory) {
(function (root, factory) {
define('converse-profile',["converse-core", "bootstrap", "tpl!chat_status_modal", "tpl!profile_modal", "tpl!profile_view", "tpl!status_option", "converse-vcard", "converse-modal"], factory);
define('converse-profile',["converse-core", "bootstrap", "tpl!
alert", "tpl!
chat_status_modal", "tpl!profile_modal", "tpl!profile_view", "tpl!status_option", "converse-vcard", "converse-modal"], factory);
})(this, function (converse, bootstrap, tpl_chat_status_modal, tpl_profile_modal, tpl_profile_view, tpl_status_option) {
})(this, function (converse, bootstrap, tpl_
alert, tpl_
chat_status_modal, tpl_profile_modal, tpl_profile_view, tpl_status_option) {
"use strict";
"use strict";
var _converse$env = converse.env,
var _converse$env = converse.env,
...
@@ -24613,7 +24718,7 @@ return __p
...
@@ -24613,7 +24718,7 @@ return __p
moment = _converse$env.moment;
moment = _converse$env.moment;
var u = converse.env.utils;
var u = converse.env.utils;
converse.plugins.add('converse-profile', {
converse.plugins.add('converse-profile', {
dependencies: ["converse-modal"],
dependencies: ["converse-modal"
, "converse-vcard"
],
initialize: function initialize() {
initialize: function initialize() {
/* The initialize function gets called as soon as the plugin is
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
* loaded by converse.js's plugin machinery.
...
@@ -24621,11 +24726,102 @@ return __p
...
@@ -24621,11 +24726,102 @@ return __p
var _converse = this._converse,
var _converse = this._converse,
__ = _converse.__;
__ = _converse.__;
_converse.ProfileModal = _converse.BootstrapModal.extend({
_converse.ProfileModal = _converse.BootstrapModal.extend({
events: {
'click .change-avatar': "openFileSelection",
'change input[type="file"': "updateFilePreview",
'submit form': 'onFormSubmitted'
},
initialize: function initialize() {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change', this.render, this);
},
toHTML: function toHTML() {
toHTML: function toHTML() {
return tpl_profile_modal(_.extend(this.model.toJSON(), {
return tpl_profile_modal(_.extend(this.model.toJSON(),
this.model.vcard.toJSON(),
{
'heading_profile': __('Your Profile'),
'heading_profile': __('Your Profile'),
'label_close': __('Close')
'label_close': __('Close'),
'label_email': __('Email'),
'label_fullname': __('Full Name'),
'label_nickname': __('Nickname'),
'label_jid': __('XMPP Address (JID)'),
'label_role': __('Role'),
'label_role_help': __('Use commas to separate multiple roles. Your roles are shown next to your name on your chat messages.'),
'label_save': __('Save'),
'label_url': __('URL'),
'alt_avatar': __('Your avatar image')
}));
}));
},
openFileSelection: function openFileSelection(ev) {
ev.preventDefault();
this.el.querySelector('input[type="file"]').click();
},
updateFilePreview: function updateFilePreview(ev) {
var _this = this;
var file = ev.target.files[0],
reader = new FileReader();
reader.onloadend = function () {
_this.el.querySelector('.avatar').setAttribute('src', reader.result);
};
reader.readAsDataURL(file);
},
setVCard: function setVCard(body, data) {
var _this2 = this;
_converse.api.vcard.set(data).then(function () {
_converse.api.vcard.update(_this2.model.vcard, true);
var html = tpl_alert({
'message': __('Profile data succesfully saved'),
'type': 'alert-primary'
});
body.insertAdjacentHTML('afterBegin', html);
}).catch(function (err) {
_converse.log(err, Strophe.LogLevel.FATAL);
var html = tpl_alert({
'message': __('An error happened while trying to save your profile data'),
'type': 'alert-danger'
});
body.insertAdjacentHTML('afterBegin', html);
});
},
onFormSubmitted: function onFormSubmitted(ev) {
var _this3 = this;
ev.preventDefault();
var reader = new FileReader(),
form_data = new FormData(ev.target),
body = this.el.querySelector('.modal-body'),
image_file = form_data.get('image');
var data = {
'fn': form_data.get('fn'),
'role': form_data.get('role'),
'email': form_data.get('email'),
'url': form_data.get('url')
};
if (!image_file.size) {
_.extend(data, {
'image': this.model.get('image'),
'image_type': this.model.get('image_type')
});
this.setVCard(body, data);
} else {
reader.onloadend = function () {
_.extend(data, {
'image': btoa(reader.result),
'image_type': image_file.type
});
_this3.setVCard(body, data);
};
reader.readAsBinaryString(image_file);
}
}
}
});
});
_converse.ChatStatusModal = _converse.BootstrapModal.extend({
_converse.ChatStatusModal = _converse.BootstrapModal.extend({
...
@@ -24634,7 +24830,7 @@ return __p
...
@@ -24634,7 +24830,7 @@ return __p
"click .clear-input": "clearStatusMessage"
"click .clear-input": "clearStatusMessage"
},
},
toHTML: function toHTML() {
toHTML: function toHTML() {
return tpl_chat_status_modal(_.extend(this.model.toJSON(), {
return tpl_chat_status_modal(_.extend(this.model.toJSON(),
this.model.vcard.toJSON(),
{
'label_away': __('Away'),
'label_away': __('Away'),
'label_close': __('Close'),
'label_close': __('Close'),
'label_busy': __('Busy'),
'label_busy': __('Busy'),
...
@@ -24649,10 +24845,10 @@ return __p
...
@@ -24649,10 +24845,10 @@ return __p
}));
}));
},
},
afterRender: function afterRender() {
afterRender: function afterRender() {
var _this = this;
var _this
4
= this;
this.el.addEventListener('shown.bs.modal', function () {
this.el.addEventListener('shown.bs.modal', function () {
_this.el.querySelector('input[name="status_message"]').focus();
_this
4
.el.querySelector('input[name="status_message"]').focus();
}, false);
}, false);
},
},
clearStatusMessage: function clearStatusMessage(ev) {
clearStatusMessage: function clearStatusMessage(ev) {
...
@@ -24683,11 +24879,12 @@ return __p
...
@@ -24683,11 +24879,12 @@ return __p
},
},
initialize: function initialize() {
initialize: function initialize() {
this.model.on("change", this.render, this);
this.model.on("change", this.render, this);
this.model.vcard.on("change", this.render, this);
},
},
toHTML: function toHTML() {
toHTML: function toHTML() {
var chat_status = this.model.get('status') || 'offline';
var chat_status = this.model.get('status') || 'offline';
return tpl_profile_view(_.extend(this.model.toJSON(), {
return tpl_profile_view(_.extend(this.model.toJSON(),
this.model.vcard.toJSON(),
{
'fullname': this.model.get('fullname') || _converse.bare_jid,
'fullname': this.model.
vcard.
get('fullname') || _converse.bare_jid,
'status_message': this.model.get('status_message') || __("I am %1$s", this.getPrettyStatus(chat_status)),
'status_message': this.model.get('status_message') || __("I am %1$s", this.getPrettyStatus(chat_status)),
'chat_status': chat_status,
'chat_status': chat_status,
'_converse': _converse,
'_converse': _converse,
...
@@ -30689,7 +30886,7 @@ return __p
...
@@ -30689,7 +30886,7 @@ return __p
if (message && message !== "") {
if (message && message !== "") {
pres.c("status").t(message).up();
pres.c("status").t(message).up();
}
}
const nick = _converse.xmppstatus.
get('nickname') || _converse.xmppstatus
.get('fullname');
const nick = _converse.xmppstatus.
vcard.get('nickname') || _converse.xmppstatus.vcard
.get('fullname');
if (nick) {
if (nick) {
pres.c('nick', {'xmlns': Strophe.NS.NICK}).t(nick).up();
pres.c('nick', {'xmlns': Strophe.NS.NICK}).t(nick).up();
}
}
...
@@ -30918,7 +31115,7 @@ return __p
...
@@ -30918,7 +31115,7 @@ return __p
if (item.getAttribute('action') === 'add') {
if (item.getAttribute('action') === 'add') {
_converse.roster.addAndSubscribe(
_converse.roster.addAndSubscribe(
item.getAttribute('jid'),
item.getAttribute('jid'),
_converse.xmppstatus.
get('nickname') || _converse.xmppstatus
.get('fullname')
_converse.xmppstatus.
vcard.get('nickname') || _converse.xmppstatus.vcard
.get('fullname')
);
);
}
}
});
});
...
@@ -32556,7 +32753,6 @@ if (typeof define !== 'undefined') {
...
@@ -32556,7 +32753,6 @@ if (typeof define !== 'undefined') {
var emptyFunction = function () { };
var emptyFunction = function () { };
define('strophe.ping', ['strophe'], strophePlugin);
define('strophe.ping', ['strophe'], strophePlugin);
define('strophe.rsm', ['strophe'], strophePlugin);
define('strophe.rsm', ['strophe'], strophePlugin);
define('strophe.vcard', ['strophe'], strophePlugin);
define('backbone', [], function () { return Backbone; });
define('backbone', [], function () { return Backbone; });
define('backbone.noconflict', [], function () { return Backbone; });
define('backbone.noconflict', [], function () { return Backbone; });
define('backbone.browserStorage', ['backbone'], emptyFunction);
define('backbone.browserStorage', ['backbone'], emptyFunction);
dist/converse.js
View file @
127f4589
...
@@ -41775,12 +41775,11 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
...
@@ -41775,12 +41775,11 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
'str_hmac_sha1': root.str_hmac_sha1,
'str_hmac_sha1': root.str_hmac_sha1,
'str_sha1': root.str_sha1
'str_sha1': root.str_sha1
};
};
root.converse_utils = factory(root.sizzle, root.Promise, root._, Strophe);
root.converse_utils = factory(root.sizzle, root.Promise, root._,
root.Backbone,
Strophe);
}
}
})(this, function (sizzle, Promise, _, Backbone, Strophe, URI, tpl_audio, tpl_file, tpl_image, tpl_video) {
})(this, function (sizzle, Promise, _, Backbone, Strophe, URI, tpl_audio, tpl_file, tpl_image, tpl_video) {
"use strict";
"use strict";
var b64_sha1 = Strophe.SHA1.b64_sha1;
Strophe = Strophe.Strophe;
Strophe = Strophe.Strophe;
var URL_REGEX = /\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b\/?/g;
var URL_REGEX = /\b(https?:\/\/|www\.|https?:\/\/www\.)[^\s<>]{2,200}\b\/?/g;
...
@@ -43345,8 +43344,9 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
...
@@ -43345,8 +43344,9 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
Strophe.addNamespace('SID', 'urn:xmpp:sid:0');
Strophe.addNamespace('SID', 'urn:xmpp:sid:0');
Strophe.addNamespace('SPOILER', 'urn:xmpp:spoiler:0');
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('VCARDUPDATE', 'vcard-temp:x:update');
Strophe.addNamespace('XFORM', 'jabber:x:data'); // Use Mustache style syntax for variable interpolation
/* Configuration of Lodash templates (this config is distinct to the
/* 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.
...
@@ -44184,16 +44184,22 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
...
@@ -44184,16 +44184,22 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
defaults: function defaults() {
defaults: function defaults() {
return {
return {
"jid": _converse.bare_jid,
"jid": _converse.bare_jid,
"nickname": _converse.nickname,
"status": _converse.default_state
"status": _converse.default_state,
"vcard_updated": null,
'image': _converse.DEFAULT_IMAGE,
'image_type': _converse.DEFAULT_IMAGE_TYPE
};
};
},
},
initialize: function initialize() {
initialize: function initialize() {
var _this3 = this;
var _this3 = this;
this.vcard = _converse.vcards.findWhere({
'jid': this.get('jid')
});
if (_.isNil(this.vcard)) {
this.vcard = _converse.vcards.create({
'jid': this.get('jid')
});
}
this.on('change:status', function (item) {
this.on('change:status', function (item) {
var status = _this3.get('status');
var status = _this3.get('status');
...
@@ -53426,6 +53432,9 @@ return __p
...
@@ -53426,6 +53432,9 @@ return __p
};
};
},
},
initialize: function initialize() {
initialize: function initialize() {
if (this.get('type') === 'groupchat' && this.collection.chatbox.get('nick') === Strophe.getResourceFromJid(this.get('from'))) {
this.vcard = _converse.xmppstatus.vcard;
} else {
this.vcard = _converse.vcards.findWhere({
this.vcard = _converse.vcards.findWhere({
'jid': this.get('from')
'jid': this.get('from')
});
});
...
@@ -53435,6 +53444,7 @@ return __p
...
@@ -53435,6 +53444,7 @@ return __p
'jid': this.get('from')
'jid': this.get('from')
});
});
}
}
}
if (this.get('file')) {
if (this.get('file')) {
this.on('change:put', this.uploadFile, this);
this.on('change:put', this.uploadFile, this);
...
@@ -54285,7 +54295,13 @@ __p += '\n <canvas class="avatar" height="36" width="36"></canvas>\n ';
...
@@ -54285,7 +54295,13 @@ __p += '\n <canvas class="avatar" height="36" width="36"></canvas>\n ';
} ;
} ;
__p += '\n <div class="chat-msg-content">\n <span class="chat-msg-heading">\n <span class="chat-msg-author">' +
__p += '\n <div class="chat-msg-content">\n <span class="chat-msg-heading">\n <span class="chat-msg-author">' +
__e(o.username) +
__e(o.username) +
'</span>\n <span class="chat-msg-time">' +
'\n ';
_.each(o.roles, function (role) { ;
__p += ' <span class="badge badge-secondary">' +
__e(role) +
'</span> ';
}); ;
__p += '\n </span>\n <span class="chat-msg-time">' +
__e(o.pretty_time) +
__e(o.pretty_time) +
'</span>\n </span>\n <span class="chat-msg-text"></span>\n <div class="chat-msg-media"></div>\n </div>\n</div>\n';
'</span>\n </span>\n <span class="chat-msg-text"></span>\n <div class="chat-msg-media"></div>\n </div>\n</div>\n';
return __p
return __p
...
@@ -54403,8 +54419,11 @@ return __p
...
@@ -54403,8 +54419,11 @@ return __p
template = this.model.get('is_spoiler') ? tpl_spoiler_message : tpl_message;
template = this.model.get('is_spoiler') ? tpl_spoiler_message : tpl_message;
}
}
var moment_time = moment(this.model.get('time'));
var moment_time = moment(this.model.get('time')),
role = this.model.vcard.get('role'),
roles = role ? role.split(',') : [];
var msg = u.stringToElement(template(_.extend(this.model.toJSON(), {
var msg = u.stringToElement(template(_.extend(this.model.toJSON(), {
'roles': roles,
'pretty_time': moment_time.format(_converse.time_format),
'pretty_time': moment_time.format(_converse.time_format),
'time': moment_time.format(),
'time': moment_time.format(),
'extra_classes': this.getExtraMessageClasses(),
'extra_classes': this.getExtraMessageClasses(),
...
@@ -57524,6 +57543,17 @@ define("awesomplete", (function (global) {
...
@@ -57524,6 +57543,17 @@ define("awesomplete", (function (global) {
});
});
//# sourceMappingURL=converse-rosterview.js.map;
//# sourceMappingURL=converse-rosterview.js.map;
define('tpl!alert', ['lodash'], function(_) {return function(o) {
var __t, __p = '', __e = _.escape;
__p += '<div class="alert ' +
__e(o.type) +
'" role="alert">' +
__e(o.message) +
'</div>\n';
return __p
};});
define('tpl!chat_status_modal', ['lodash'], function(_) {return function(o) {
define('tpl!chat_status_modal', ['lodash'], function(_) {return function(o) {
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
function print() { __p += __j.call(arguments, '') }
...
@@ -57577,19 +57607,51 @@ __p += '<div class="modal fade" id="user-profile-modal" tabindex="-1" role="dial
...
@@ -57577,19 +57607,51 @@ __p += '<div class="modal fade" id="user-profile-modal" tabindex="-1" role="dial
__e(o.heading_profile) +
__e(o.heading_profile) +
'</h5>\n <button type="button" class="close" data-dismiss="modal" aria-label="' +
'</h5>\n <button type="button" class="close" data-dismiss="modal" aria-label="' +
__e(o.label_close) +
__e(o.label_close) +
'"><span aria-hidden="true">×</span></button>\n </div>\n <
div class="modal-body">\n <div class="row">\n <div class="col-auto">\n
';
'"><span aria-hidden="true">×</span></button>\n </div>\n <
form class="converse-form">\n <div class="modal-body">\n <div class="row">\n <div class="col-auto">\n <a class="change-avatar" href="#">\n
';
if (o.image) { ;
if (o.image) { ;
__p += '\n <a class="show-profile" href="#">\n <img alt="User Avatar" class="img-thumbnail avatar align-self-center" height="100px" width="100px" src="data:' +
__p += '\n <img alt="' +
__e(o.alt_avatar) +
'" class="img-thumbnail avatar align-self-center" height="100px" width="100px" src="data:' +
__e(o.image_type) +
__e(o.image_type) +
';base64,' +
';base64,' +
__e(o.image) +
__e(o.image) +
'"/>\n
</a>\n
';
'"/>\n ';
} ;
} ;
__p += '\n </div>\n <div class="col-auto">\n <div classs="row w-100">\n <label>Fullname:</label>\n <span class="username">' +
__p += '\n ';
__e(o.fullname) +
if (!o.image) { ;
'</span>\n </div>\n <div classs="row w-100">\n <label>XMPP Address:</label>\n <span class="username">' +
__p += '\n <canvas class="avatar" height="100px" width="100px"/>\n ';
} ;
__p += '\n </a>\n <input class="hidden" name="image" type="file">\n </div>\n <div class="col">\n <div class="form-group">\n <label class="col-form-label">' +
__e(o.label_jid) +
':</label>\n <div>' +
__e(o.jid) +
__e(o.jid) +
'</span>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</div>\n';
'</div>\n </div>\n </div>\n </div>\n <div class="form-group">\n <label for="vcard-fullname" class="col-form-label">' +
__e(o.label_fullname) +
':</label>\n <input id="vcard-fullname" type="text" class="form-control" name="fn" value="' +
__e(o.fullname) +
'">\n </div>\n <div class="form-group">\n <label for="vcard-nickname" class="col-form-label">' +
__e(o.label_nickname) +
':</label>\n <input id="vcard-nickname" type="text" class="form-control" name="nickname" value="' +
__e(o.nickname) +
'">\n </div>\n <div class="form-group">\n <label for="vcard-url" class="col-form-label">' +
__e(o.label_url) +
':</label>\n <input id="vcard-url" type="url" class="form-control" name="url" value="' +
__e(o.url) +
'">\n </div>\n <div class="form-group">\n <label for="vcard-email" class="col-form-label">' +
__e(o.label_email) +
':</label>\n <input id="vcard-email" type="email" class="form-control" name="email" value="' +
__e(o.email) +
'">\n </div>\n <div class="form-group">\n <label for="vcard-role" class="col-form-label">' +
__e(o.label_role) +
':</label>\n <input id="vcard-role" type="text" class="form-control" name="role" value="' +
__e(o.role) +
'" aria-describedby="vcard-role-help">\n <small id="vcard-role-help" class="form-text text-muted">' +
__e(o.label_role_help) +
'</small>\n </div>\n </div>\n <div class="modal-footer">\n <button type="submit" class="save-form btn btn-primary">' +
__e(o.label_save) +
'</button>\n <button type="button" class="btn btn-secondary" data-dismiss="modal">' +
__e(o.label_close) +
'</button>\n </div>\n </form>\n </div>\n </div>\n</div>\n';
return __p
return __p
};});
};});
...
@@ -57597,15 +57659,11 @@ return __p
...
@@ -57597,15 +57659,11 @@ return __p
define('tpl!profile_view', ['lodash'], function(_) {return function(o) {
define('tpl!profile_view', ['lodash'], function(_) {return function(o) {
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
function print() { __p += __j.call(arguments, '') }
__p += '<div class="userinfo">\n<div class="profile d-flex">\n ';
__p += '<div class="userinfo">\n<div class="profile d-flex">\n <a class="show-profile" href="#">\n <img alt="User Avatar" class="avatar align-self-center" height="40px" width="40px" src="data:' +
if (o.image) { ;
__p += '\n <a class="show-profile" href="#">\n <img alt="User Avatar" class="avatar align-self-center" height="40px" width="40px" src="data:' +
__e(o.image_type) +
__e(o.image_type) +
';base64,' +
';base64,' +
__e(o.image) +
__e(o.image) +
'"/>\n </a>\n ';
'"/>\n </a>\n <span class="username w-100 align-self-center">' +
} ;
__p += '\n <span class="username w-100 align-self-center">' +
__e(o.fullname) +
__e(o.fullname) +
'</span>\n <!-- <a class="chatbox-btn fa fa-vcard align-self-center" title="' +
'</span>\n <!-- <a class="chatbox-btn fa fa-vcard align-self-center" title="' +
__e(o.title_your_profile) +
__e(o.title_your_profile) +
...
@@ -60098,76 +60156,26 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60098,76 +60156,26 @@ CryptoJS.mode.CTR = (function () {
return CryptoJS
return CryptoJS
}));
}));
/* Plugin to implement the vCard extension.
* http://xmpp.org/extensions/xep-0054.html
*
* Author: Nathan Zorn (nathan.zorn@gmail.com)
* AMD support by JC Brand
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define('strophe.vcard',[
"strophe"
], function (Strophe) {
factory(
Strophe.Strophe,
Strophe.$build,
Strophe.$iq ,
Strophe.$msg,
Strophe.$pres
);
return Strophe;
});
} else {
// Browser globals
factory(
root.Strophe,
root.$build,
root.$iq ,
root.$msg,
root.$pres
);
}
}(this, function (Strophe, $build, $iq, $msg, $pres) {
var buildIq = function(type, jid, vCardEl) {
var iq = $iq(jid ? {type: type, to: jid} : {type: type});
iq.c("vCard", {xmlns: Strophe.NS.VCARD});
if (vCardEl) {
iq.cnode(vCardEl);
}
return iq;
};
Strophe.addConnectionPlugin('vcard', {
_connection: null,
init: function(conn) {
this._connection = conn;
return Strophe.addNamespace('VCARD', 'vcard-temp');
},
/* Function
define('tpl!vcard', ['lodash'], function(_) {return function(o) {
* Retrieve a vCard for a JID/Entity
var __t, __p = '', __e = _.escape;
* Parameters:
__p += '<vCard xmlns="vcard-temp">\n <FN>' +
* (Function) handler_cb - The callback function used to handle the request.
__e(o.fn) +
* (String) jid - optional - The name of the entity to request the vCard
'</FN>\n <NICKNAME>' +
* If no jid is given, this function retrieves the current user's vcard.
__e(o.fn) +
* */
'</NICKNAME>\n <URL>' +
get: function(handler_cb, jid, error_cb) {
__e(o.url) +
var iq = buildIq("get", jid);
'</URL>\n <ROLE>' +
return this._connection.sendIQ(iq, handler_cb, error_cb);
__e(o.role) +
},
'</ROLE>\n <EMAIL><INTERNET/><PREF/><USERID>' +
__e(o.email) +
/* Function
'</USERID></EMAIL>\n <PHOTO>\n <TYPE>' +
* Set an entity's vCard.
__e(o.image_type) +
*/
'</TYPE>\n <BINVAL>' +
set: function(handler_cb, vCardEl, jid, error_cb) {
__e(o.image) +
var iq = buildIq("set", jid, vCardEl);
'</BINVAL>\n </PHOTO>\n</vCard>\n';
return this._connection.sendIQ(iq, handler_cb, error_cb);
return __p
}
};});
});
}));
// Converse.js
// Converse.js
// http://conversejs.org
// http://conversejs.org
...
@@ -60175,8 +60183,8 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60175,8 +60183,8 @@ CryptoJS.mode.CTR = (function () {
// 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) {
(function (root, factory) {
define('converse-vcard',["converse-core", "crypto", "
strophe.
vcard"], factory);
define('converse-vcard',["converse-core", "crypto", "
tpl!
vcard"], factory);
})(this, function (converse, CryptoJS) {
})(this, function (converse, CryptoJS
, tpl_vcard
) {
"use strict";
"use strict";
var _converse$env = converse.env,
var _converse$env = converse.env,
...
@@ -60185,10 +60193,26 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60185,10 +60193,26 @@ CryptoJS.mode.CTR = (function () {
Strophe = _converse$env.Strophe,
Strophe = _converse$env.Strophe,
SHA1 = _converse$env.SHA1,
SHA1 = _converse$env.SHA1,
_ = _converse$env._,
_ = _converse$env._,
$iq = _converse$env.$iq,
$build = _converse$env.$build,
b64_sha1 = _converse$env.b64_sha1,
b64_sha1 = _converse$env.b64_sha1,
moment = _converse$env.moment,
moment = _converse$env.moment,
sizzle = _converse$env.sizzle;
sizzle = _converse$env.sizzle;
var u = converse.env.utils;
var u = converse.env.utils;
converse.plugins.add('converse-vcard', {
initialize: function initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
var _converse = this._converse;
_converse.VCards = Backbone.Collection.extend({
model: _converse.ModelWithDefaultAvatar,
initialize: function initialize() {
this.on('add', function (vcard) {
return _converse.api.vcard.update(vcard);
});
}
});
function onVCardData(_converse, jid, iq, callback) {
function onVCardData(_converse, jid, iq, callback) {
var vcard = iq.querySelector('vCard');
var vcard = iq.querySelector('vCard');
...
@@ -60198,9 +60222,12 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60198,9 +60222,12 @@ CryptoJS.mode.CTR = (function () {
result = {
result = {
'stanza': iq,
'stanza': iq,
'fullname': _.get(vcard.querySelector('FN'), 'textContent'),
'fullname': _.get(vcard.querySelector('FN'), 'textContent'),
'nickname': _.get(vcard.querySelector('NICKNAME'), 'textContent'),
'image': _.get(vcard.querySelector('PHOTO BINVAL'), 'textContent'),
'image': _.get(vcard.querySelector('PHOTO BINVAL'), 'textContent'),
'image_type': _.get(vcard.querySelector('PHOTO TYPE'), 'textContent'),
'image_type': _.get(vcard.querySelector('PHOTO TYPE'), 'textContent'),
'url': _.get(vcard.querySelector('URL'), 'textContent')
'url': _.get(vcard.querySelector('URL'), 'textContent'),
'role': _.get(vcard.querySelector('ROLE'), 'textContent'),
'email': _.get(vcard.querySelector('EMAIL USERID'), 'textContent')
};
};
}
}
...
@@ -60223,6 +60250,33 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60223,6 +60250,33 @@ CryptoJS.mode.CTR = (function () {
}
}
}
}
function createStanza(type, jid, vcard_el) {
var iq = $iq(jid ? {
'type': type,
'to': jid
} : {
'type': type
});
if (!vcard_el) {
iq.c("vCard", {
'xmlns': Strophe.NS.VCARD
});
} else {
iq.cnode(vcard_el);
}
return iq;
}
function setVCard(data) {
return new Promise(function (resolve, reject) {
var vcard_el = Strophe.xmlHtmlNode(tpl_vcard(data)).firstElementChild;
_converse.connection.sendIQ(createStanza("set", data.jid, vcard_el), resolve, reject);
});
}
function getVCard(_converse, jid) {
function getVCard(_converse, jid) {
/* Request the VCard of another user. Returns a promise.
/* Request the VCard of another user. Returns a promise.
*
*
...
@@ -60230,28 +60284,14 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60230,28 +60284,14 @@ CryptoJS.mode.CTR = (function () {
* (String) jid - The Jabber ID of the user whose VCard
* (String) jid - The Jabber ID of the user whose VCard
* is being requested.
* is being requested.
*/
*/
var to
= Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid;
jid
= Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid;
return new Promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
_converse.connection.vcard.get(_.partial(onVCardData, _converse, jid, _, resolve), to, _.partial(onVCardError, _converse, jid, _, resolve)
);
_converse.connection.sendIQ(createStanza("get", jid), _.partial(onVCardData, _converse, jid, _, resolve), _.partial(onVCardError, _converse, jid, _, resolve), 5000
);
});
});
}
}
converse.plugins.add('converse-vcard', {
initialize: function initialize() {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
var _converse = this._converse;
_converse.VCards = Backbone.Collection.extend({
model: _converse.ModelWithDefaultAvatar,
initialize: function initialize() {
this.on('add', function (vcard) {
return _converse.api.vcard.update(vcard);
});
}
});
/* Event handlers */
/* Event handlers */
_converse.initVCardCollection = function () {
_converse.initVCardCollection = function () {
_converse.vcards = new _converse.VCards();
_converse.vcards = new _converse.VCards();
_converse.vcards.browserStorage = new Backbone.BrowserStorage.local(b64_sha1("converse.vcards"));
_converse.vcards.browserStorage = new Backbone.BrowserStorage.local(b64_sha1("converse.vcards"));
...
@@ -60265,16 +60305,9 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60265,16 +60305,9 @@ CryptoJS.mode.CTR = (function () {
_converse.api.disco.addFeature(Strophe.NS.VCARD);
_converse.api.disco.addFeature(Strophe.NS.VCARD);
});
});
_converse.on('statusInitialized', function fetchOwnVCard() {
_converse.api.disco.supports(Strophe.NS.VCARD, _converse.domain).then(function (result) {
if (result.length) {
_converse.api.vcard.update(_converse.xmppstatus);
}
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
});
_.extend(_converse.api, {
_.extend(_converse.api, {
'vcard': {
'vcard': {
'set': setVCard,
'get': function get(model, force) {
'get': function get(model, force) {
if (_.isString(model)) {
if (_.isString(model)) {
return getVCard(_converse, model);
return getVCard(_converse, model);
...
@@ -60295,7 +60328,7 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60295,7 +60328,7 @@ CryptoJS.mode.CTR = (function () {
return new Promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
_this.get(model, force).then(function (vcard) {
_this.get(model, force).then(function (vcard) {
model.save(_.extend(_.pick(vcard, ['fullname', '
url
', 'image_type', 'image', 'image_hash']), {
model.save(_.extend(_.pick(vcard, ['fullname', '
nickname', 'email', 'url', 'role
', 'image_type', 'image', 'image_hash']), {
'vcard_updated': moment().format()
'vcard_updated': moment().format()
}));
}));
resolve();
resolve();
...
@@ -60317,8 +60350,8 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60317,8 +60350,8 @@ CryptoJS.mode.CTR = (function () {
/*global define */
/*global define */
(function (root, factory) {
(function (root, factory) {
define('converse-profile',["converse-core", "bootstrap", "tpl!chat_status_modal", "tpl!profile_modal", "tpl!profile_view", "tpl!status_option", "converse-vcard", "converse-modal"], factory);
define('converse-profile',["converse-core", "bootstrap", "tpl!
alert", "tpl!
chat_status_modal", "tpl!profile_modal", "tpl!profile_view", "tpl!status_option", "converse-vcard", "converse-modal"], factory);
})(this, function (converse, bootstrap, tpl_chat_status_modal, tpl_profile_modal, tpl_profile_view, tpl_status_option) {
})(this, function (converse, bootstrap, tpl_
alert, tpl_
chat_status_modal, tpl_profile_modal, tpl_profile_view, tpl_status_option) {
"use strict";
"use strict";
var _converse$env = converse.env,
var _converse$env = converse.env,
...
@@ -60330,7 +60363,7 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60330,7 +60363,7 @@ CryptoJS.mode.CTR = (function () {
moment = _converse$env.moment;
moment = _converse$env.moment;
var u = converse.env.utils;
var u = converse.env.utils;
converse.plugins.add('converse-profile', {
converse.plugins.add('converse-profile', {
dependencies: ["converse-modal"],
dependencies: ["converse-modal"
, "converse-vcard"
],
initialize: function initialize() {
initialize: function initialize() {
/* The initialize function gets called as soon as the plugin is
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
* loaded by converse.js's plugin machinery.
...
@@ -60338,11 +60371,102 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60338,11 +60371,102 @@ CryptoJS.mode.CTR = (function () {
var _converse = this._converse,
var _converse = this._converse,
__ = _converse.__;
__ = _converse.__;
_converse.ProfileModal = _converse.BootstrapModal.extend({
_converse.ProfileModal = _converse.BootstrapModal.extend({
events: {
'click .change-avatar': "openFileSelection",
'change input[type="file"': "updateFilePreview",
'submit form': 'onFormSubmitted'
},
initialize: function initialize() {
_converse.BootstrapModal.prototype.initialize.apply(this, arguments);
this.model.on('change', this.render, this);
},
toHTML: function toHTML() {
toHTML: function toHTML() {
return tpl_profile_modal(_.extend(this.model.toJSON(), {
return tpl_profile_modal(_.extend(this.model.toJSON(),
this.model.vcard.toJSON(),
{
'heading_profile': __('Your Profile'),
'heading_profile': __('Your Profile'),
'label_close': __('Close')
'label_close': __('Close'),
'label_email': __('Email'),
'label_fullname': __('Full Name'),
'label_nickname': __('Nickname'),
'label_jid': __('XMPP Address (JID)'),
'label_role': __('Role'),
'label_role_help': __('Use commas to separate multiple roles. Your roles are shown next to your name on your chat messages.'),
'label_save': __('Save'),
'label_url': __('URL'),
'alt_avatar': __('Your avatar image')
}));
}));
},
openFileSelection: function openFileSelection(ev) {
ev.preventDefault();
this.el.querySelector('input[type="file"]').click();
},
updateFilePreview: function updateFilePreview(ev) {
var _this = this;
var file = ev.target.files[0],
reader = new FileReader();
reader.onloadend = function () {
_this.el.querySelector('.avatar').setAttribute('src', reader.result);
};
reader.readAsDataURL(file);
},
setVCard: function setVCard(body, data) {
var _this2 = this;
_converse.api.vcard.set(data).then(function () {
_converse.api.vcard.update(_this2.model.vcard, true);
var html = tpl_alert({
'message': __('Profile data succesfully saved'),
'type': 'alert-primary'
});
body.insertAdjacentHTML('afterBegin', html);
}).catch(function (err) {
_converse.log(err, Strophe.LogLevel.FATAL);
var html = tpl_alert({
'message': __('An error happened while trying to save your profile data'),
'type': 'alert-danger'
});
body.insertAdjacentHTML('afterBegin', html);
});
},
onFormSubmitted: function onFormSubmitted(ev) {
var _this3 = this;
ev.preventDefault();
var reader = new FileReader(),
form_data = new FormData(ev.target),
body = this.el.querySelector('.modal-body'),
image_file = form_data.get('image');
var data = {
'fn': form_data.get('fn'),
'role': form_data.get('role'),
'email': form_data.get('email'),
'url': form_data.get('url')
};
if (!image_file.size) {
_.extend(data, {
'image': this.model.get('image'),
'image_type': this.model.get('image_type')
});
this.setVCard(body, data);
} else {
reader.onloadend = function () {
_.extend(data, {
'image': btoa(reader.result),
'image_type': image_file.type
});
_this3.setVCard(body, data);
};
reader.readAsBinaryString(image_file);
}
}
}
});
});
_converse.ChatStatusModal = _converse.BootstrapModal.extend({
_converse.ChatStatusModal = _converse.BootstrapModal.extend({
...
@@ -60351,7 +60475,7 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60351,7 +60475,7 @@ CryptoJS.mode.CTR = (function () {
"click .clear-input": "clearStatusMessage"
"click .clear-input": "clearStatusMessage"
},
},
toHTML: function toHTML() {
toHTML: function toHTML() {
return tpl_chat_status_modal(_.extend(this.model.toJSON(), {
return tpl_chat_status_modal(_.extend(this.model.toJSON(),
this.model.vcard.toJSON(),
{
'label_away': __('Away'),
'label_away': __('Away'),
'label_close': __('Close'),
'label_close': __('Close'),
'label_busy': __('Busy'),
'label_busy': __('Busy'),
...
@@ -60366,10 +60490,10 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60366,10 +60490,10 @@ CryptoJS.mode.CTR = (function () {
}));
}));
},
},
afterRender: function afterRender() {
afterRender: function afterRender() {
var _this = this;
var _this
4
= this;
this.el.addEventListener('shown.bs.modal', function () {
this.el.addEventListener('shown.bs.modal', function () {
_this.el.querySelector('input[name="status_message"]').focus();
_this
4
.el.querySelector('input[name="status_message"]').focus();
}, false);
}, false);
},
},
clearStatusMessage: function clearStatusMessage(ev) {
clearStatusMessage: function clearStatusMessage(ev) {
...
@@ -60400,11 +60524,12 @@ CryptoJS.mode.CTR = (function () {
...
@@ -60400,11 +60524,12 @@ CryptoJS.mode.CTR = (function () {
},
},
initialize: function initialize() {
initialize: function initialize() {
this.model.on("change", this.render, this);
this.model.on("change", this.render, this);
this.model.vcard.on("change", this.render, this);
},
},
toHTML: function toHTML() {
toHTML: function toHTML() {
var chat_status = this.model.get('status') || 'offline';
var chat_status = this.model.get('status') || 'offline';
return tpl_profile_view(_.extend(this.model.toJSON(), {
return tpl_profile_view(_.extend(this.model.toJSON(),
this.model.vcard.toJSON(),
{
'fullname': this.model.get('fullname') || _converse.bare_jid,
'fullname': this.model.
vcard.
get('fullname') || _converse.bare_jid,
'status_message': this.model.get('status_message') || __("I am %1$s", this.getPrettyStatus(chat_status)),
'status_message': this.model.get('status_message') || __("I am %1$s", this.getPrettyStatus(chat_status)),
'chat_status': chat_status,
'chat_status': chat_status,
'_converse': _converse,
'_converse': _converse,
...
@@ -71359,7 +71484,7 @@ return __p
...
@@ -71359,7 +71484,7 @@ return __p
pres.c("status").t(message).up();
pres.c("status").t(message).up();
}
}
var nick = _converse.xmppstatus.
get('nickname') || _converse.xmppstatus
.get('fullname');
var nick = _converse.xmppstatus.
vcard.get('nickname') || _converse.xmppstatus.vcard
.get('fullname');
if (nick) {
if (nick) {
pres.c('nick', {
pres.c('nick', {
...
@@ -71593,7 +71718,7 @@ return __p
...
@@ -71593,7 +71718,7 @@ return __p
subscribeToSuggestedItems: function subscribeToSuggestedItems(msg) {
subscribeToSuggestedItems: function subscribeToSuggestedItems(msg) {
_.each(msg.querySelectorAll('item'), function (item) {
_.each(msg.querySelectorAll('item'), function (item) {
if (item.getAttribute('action') === 'add') {
if (item.getAttribute('action') === 'add') {
_converse.roster.addAndSubscribe(item.getAttribute('jid'), _converse.xmppstatus.
get('nickname') || _converse.xmppstatus
.get('fullname'));
_converse.roster.addAndSubscribe(item.getAttribute('jid'), _converse.xmppstatus.
vcard.get('nickname') || _converse.xmppstatus.vcard
.get('fullname'));
}
}
});
});
package-lock.json
View file @
127f4589
...
@@ -9346,12 +9346,6 @@
...
@@ -9346,12 +9346,6 @@
"integrity"
:
"sha1-zBPqgHWmbJ2rdt04G37d/bG64Hs="
,
"integrity"
:
"sha1-zBPqgHWmbJ2rdt04G37d/bG64Hs="
,
"dev"
:
true
"dev"
:
true
},
},
"strophejs-plugin-vcard"
:
{
"version"
:
"0.0.1"
,
"resolved"
:
"https://registry.npmjs.org/strophejs-plugin-vcard/-/strophejs-plugin-vcard-0.0.1.tgz"
,
"integrity"
:
"sha1-BDfoyYdZr5fKJ07GuAC1W52IciM="
,
"dev"
:
true
},
"supports-color"
:
{
"supports-color"
:
{
"version"
:
"5.3.0"
,
"version"
:
"5.3.0"
,
"resolved"
:
"https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz"
,
"resolved"
:
"https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment