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