Commit 9a9eae3f authored by JC Brand's avatar JC Brand

Use esnext to auto-generate es2015 syntax

parent ac1475ed
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
], factory); ], factory);
}(this, function (converse, tpl_chatbox) { }(this, function (converse, tpl_chatbox) {
"use strict"; "use strict";
const _ = converse.env._, const { _, utils } = converse.env;
utils = converse.env.utils;
converse.plugins.add('converse-headline', { converse.plugins.add('converse-headline', {
...@@ -27,8 +26,8 @@ ...@@ -27,8 +26,8 @@
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
ChatBoxViews: { ChatBoxViews: {
onChatBoxAdded: function (item) { onChatBoxAdded (item) {
const _converse = this.__super__._converse; const { _converse } = this.__super__;
let view = this.get(item.get('id')); let view = this.get(item.get('id'));
if (!view && item.get('type') === 'headline') { if (!view && item.get('type') === 'headline') {
view = new _converse.HeadlinesBoxView({model: item}); view = new _converse.HeadlinesBoxView({model: item});
...@@ -41,12 +40,12 @@ ...@@ -41,12 +40,12 @@
} }
}, },
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.
*/ */
const _converse = this._converse, const { _converse } = this,
__ = _converse.__; { __ } = _converse;
_converse.HeadlinesBoxView = _converse.ChatBoxView.extend({ _converse.HeadlinesBoxView = _converse.ChatBoxView.extend({
className: 'chatbox headlines', className: 'chatbox headlines',
...@@ -57,7 +56,7 @@ ...@@ -57,7 +56,7 @@
'keypress textarea.chat-textarea': 'keyPressed' 'keypress textarea.chat-textarea': 'keyPressed'
}, },
initialize: function () { initialize () {
this.disable_mam = true; // Don't do MAM queries for this box this.disable_mam = true; // Don't do MAM queries for this box
this.model.messages.on('add', this.onMessageAdded, this); this.model.messages.on('add', this.onMessageAdded, this);
this.model.on('show', this.show, this); this.model.on('show', this.show, this);
...@@ -67,7 +66,7 @@ ...@@ -67,7 +66,7 @@
_converse.emit('chatBoxInitialized', this); _converse.emit('chatBoxInitialized', this);
}, },
render: function () { render () {
this.$el.attr('id', this.model.get('box_id')) this.$el.attr('id', this.model.get('box_id'))
.html(tpl_chatbox( .html(tpl_chatbox(
_.extend(this.model.toJSON(), { _.extend(this.model.toJSON(), {
......
...@@ -16,19 +16,18 @@ ...@@ -16,19 +16,18 @@
], factory); ], factory);
}(this, function (converse, tpl_brand_heading) { }(this, function (converse, tpl_brand_heading) {
"use strict"; "use strict";
var $ = converse.env.jQuery, const $ = converse.env.jQuery,
Strophe = converse.env.Strophe, { Strophe, _ } = converse.env;
_ = converse.env._;
function createBrandHeadingElement () { function createBrandHeadingElement () {
var div = document.createElement('div'); const div = document.createElement('div');
div.innerHTML = tpl_brand_heading(); div.innerHTML = tpl_brand_heading();
return div.firstChild; return div.firstChild;
} }
function isMessageToHiddenChat (_converse, message) { function isMessageToHiddenChat (_converse, message) {
var jid = Strophe.getBareJidFromJid(message.getAttribute('from')); const jid = Strophe.getBareJidFromJid(message.getAttribute('from'));
var model = _converse.chatboxes.get(jid); const model = _converse.chatboxes.get(jid);
if (!_.isNil(model)) { if (!_.isNil(model)) {
return model.get('hidden'); return model.get('hidden');
} }
...@@ -46,45 +45,45 @@ ...@@ -46,45 +45,45 @@
// //
// new functions which don't exist yet can also be added. // new functions which don't exist yet can also be added.
areDesktopNotificationsEnabled: function () { areDesktopNotificationsEnabled () {
// Call with "ignore_hidden" as true, so that it doesn't check // Call with "ignore_hidden" as true, so that it doesn't check
// if the windowState is hidden. // if the windowState is hidden.
return this.__super__.areDesktopNotificationsEnabled.call(this, true); return this.__super__.areDesktopNotificationsEnabled.call(this, true);
}, },
shouldNotifyOfMessage: function (message) { shouldNotifyOfMessage (message) {
var _converse = this.__super__._converse; const { _converse } = this.__super__;
var result = this.__super__.shouldNotifyOfMessage.apply(this, arguments); const result = this.__super__.shouldNotifyOfMessage.apply(this, arguments);
return result && isMessageToHiddenChat(_converse, message); return result && isMessageToHiddenChat(_converse, message);
}, },
ControlBoxView: { ControlBoxView: {
renderContactsPanel: function () { renderContactsPanel () {
this.__super__.renderContactsPanel.apply(this, arguments); this.__super__.renderContactsPanel.apply(this, arguments);
this.el.classList.remove("fullscreen"); this.el.classList.remove("fullscreen");
return this; return this;
}, },
renderRegistrationPanel: function () { renderRegistrationPanel () {
this.__super__.renderRegistrationPanel.apply(this, arguments); this.__super__.renderRegistrationPanel.apply(this, arguments);
var el = document.getElementById('converse-register'); const el = document.getElementById('converse-register');
el.parentNode.insertBefore(createBrandHeadingElement(), el); el.parentNode.insertBefore(createBrandHeadingElement(), el);
return this; return this;
}, },
renderLoginPanel: function () { renderLoginPanel () {
this.__super__.renderLoginPanel.apply(this, arguments); this.__super__.renderLoginPanel.apply(this, arguments);
this.el.classList.add("fullscreen"); this.el.classList.add("fullscreen");
var el = document.getElementById('converse-login'); const el = document.getElementById('converse-login');
el.parentNode.insertBefore(createBrandHeadingElement(), el); el.parentNode.insertBefore(createBrandHeadingElement(), el);
return this; return this;
} }
}, },
ChatRoomView: { ChatRoomView: {
afterShown: function (focus) { afterShown (focus) {
/* Make sure chat rooms are scrolled down when opened /* Make sure chat rooms are scrolled down when opened
*/ */
this.scrollDown(); this.scrollDown();
...@@ -96,7 +95,7 @@ ...@@ -96,7 +95,7 @@
} }
}, },
initialize: function () { initialize () {
this._converse.api.settings.update({ this._converse.api.settings.update({
chatview_avatar_height: 44, chatview_avatar_height: 44,
chatview_avatar_width: 44, chatview_avatar_width: 44,
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
define(["converse-core", "converse-muc"], factory); define(["converse-core", "converse-muc"], factory);
}(this, function (converse) { }(this, function (converse) {
"use strict"; "use strict";
const Backbone = converse.env.Backbone, const { Backbone, _ } = converse.env;
_ = converse.env._;
converse.plugins.add('converse-muc-embedded', { converse.plugins.add('converse-muc-embedded', {
overrides: { overrides: {
...@@ -20,12 +19,12 @@ ...@@ -20,12 +19,12 @@
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
ChatBoxes: { ChatBoxes: {
onConnected: function () { onConnected () {
// Override to avoid storing or fetching chat boxes from session // Override to avoid storing or fetching chat boxes from session
// storage. // storage.
const _converse = this.__super__._converse; const { _converse } = this.__super__;
this.browserStorage = new Backbone.BrowserStorage[_converse.storage]( this.browserStorage = new Backbone.BrowserStorage[_converse.storage](
converse.env.b64_sha1('converse.chatboxes-'+_converse.bare_jid)); converse.env.b64_sha1(`converse.chatboxes-${_converse.bare_jid}`));
this.registerMessageHandler(); this.registerMessageHandler();
/* This is disabled: /* This is disabled:
* *
...@@ -39,7 +38,7 @@ ...@@ -39,7 +38,7 @@
}, },
ChatRoomView: { ChatRoomView: {
insertIntoDOM: function () { insertIntoDOM () {
if (!document.body.contains(this.el)) { if (!document.body.contains(this.el)) {
const container = document.querySelector('#converse-embedded-chat'); const container = document.querySelector('#converse-embedded-chat');
container.innerHTML = ''; container.innerHTML = '';
...@@ -50,11 +49,11 @@ ...@@ -50,11 +49,11 @@
} }
}, },
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.
*/ */
const _converse = this._converse; const { _converse } = this;
if (!_.isArray(_converse.auto_join_rooms)) { if (!_.isArray(_converse.auto_join_rooms)) {
throw new Error("converse-muc-embedded: auto_join_rooms must be an Array"); throw new Error("converse-muc-embedded: auto_join_rooms must be an Array");
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -14,16 +14,15 @@ ...@@ -14,16 +14,15 @@
}(this, function (converse) { }(this, function (converse) {
"use strict"; "use strict";
// Strophe methods for building stanzas // Strophe methods for building stanzas
const Strophe = converse.env.Strophe, const { Strophe, _ } = converse.env;
_ = converse.env._;
converse.plugins.add('converse-ping', { converse.plugins.add('converse-ping', {
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.
*/ */
const _converse = this._converse; const { _converse } = this;
_converse.api.settings.update({ _converse.api.settings.update({
ping_interval: 180 //in seconds ping_interval: 180 //in seconds
...@@ -72,7 +71,7 @@ ...@@ -72,7 +71,7 @@
return true; return true;
}); });
_converse.connection.addTimedHandler(1000, function () { _converse.connection.addTimedHandler(1000, function () {
var now = new Date(); const now = new Date();
if (!_converse.lastStanzaDate) { if (!_converse.lastStanzaDate) {
_converse.lastStanzaDate = now; _converse.lastStanzaDate = now;
} }
...@@ -84,7 +83,7 @@ ...@@ -84,7 +83,7 @@
} }
}; };
var onConnected = function () { const onConnected = function () {
// Wrapper so that we can spy on registerPingHandler in tests // Wrapper so that we can spy on registerPingHandler in tests
_converse.registerPingHandler(); _converse.registerPingHandler();
}; };
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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