2018-03-28 18:38:22 +02:00
|
|
|
(function (root, factory) {
|
2018-03-29 16:12:19 +02:00
|
|
|
define(["converse-core"], factory);
|
2018-03-28 18:38:22 +02:00
|
|
|
}(this, function (converse) {
|
|
|
|
"use strict";
|
|
|
|
|
2018-03-29 16:12:19 +02:00
|
|
|
const { Promise, Strophe, _ } = converse.env;
|
|
|
|
const u = converse.env.utils;
|
|
|
|
|
|
|
|
Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
|
|
|
|
|
2018-03-28 18:38:22 +02:00
|
|
|
converse.plugins.add('converse-http-file-upload', {
|
2018-03-29 16:12:19 +02:00
|
|
|
/* Plugin dependencies are other plugins which might be
|
|
|
|
* overridden or relied upon, and therefore need to be loaded before
|
|
|
|
* this plugin.
|
|
|
|
*
|
|
|
|
* If the setting "strict_plugin_dependencies" is set to true,
|
|
|
|
* an error will be raised if the plugin is not found. By default it's
|
|
|
|
* false, which means these plugins are only loaded opportunistically.
|
|
|
|
*
|
|
|
|
* NB: These plugins need to have already been loaded via require.js.
|
|
|
|
*/
|
|
|
|
dependencies: ["converse-chatview"],
|
|
|
|
|
|
|
|
overrides: {
|
|
|
|
|
|
|
|
ChatBoxView: {
|
|
|
|
addFileUploadButton (options) {
|
|
|
|
},
|
|
|
|
|
|
|
|
renderToolbar (toolbar, options) {
|
|
|
|
const { _converse } = this.__super__;
|
|
|
|
const result = this.__super__.renderToolbar.apply(this, arguments);
|
|
|
|
// TODO: check results.length
|
|
|
|
_converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain)
|
|
|
|
.then(this.addFileUploadButton.bind(this));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-03-28 18:38:22 +02:00
|
|
|
|
|
|
|
initialize () {
|
|
|
|
/* The initialize function gets called as soon as the plugin is
|
|
|
|
* loaded by converse.js's plugin machinery.
|
|
|
|
*/
|
|
|
|
const { _converse } = this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}));
|