2017-06-13 21:07:42 +02:00
|
|
|
// Converse.js (A browser based XMPP chat client)
|
|
|
|
// http://conversejs.org
|
|
|
|
//
|
|
|
|
// Copyright (c) 2012-2016, Jan-Carel Brand <jc@opkode.com>
|
|
|
|
// Licensed under the Mozilla Public License (MPLv2)
|
|
|
|
//
|
2017-06-15 15:09:34 +02:00
|
|
|
/*global define */
|
2017-06-13 21:07:42 +02:00
|
|
|
|
|
|
|
(function (root, factory) {
|
|
|
|
define(["converse-core",
|
2017-06-15 15:09:34 +02:00
|
|
|
"tpl!brand_heading",
|
2017-06-13 21:07:42 +02:00
|
|
|
"converse-chatview",
|
|
|
|
"converse-controlbox",
|
|
|
|
"converse-muc",
|
|
|
|
"converse-singleton"
|
|
|
|
], factory);
|
2017-06-15 15:09:34 +02:00
|
|
|
}(this, function (converse, tpl_brand_heading) {
|
2017-06-13 21:07:42 +02:00
|
|
|
"use strict";
|
2017-07-10 21:14:48 +02:00
|
|
|
const { Strophe, _ } = converse.env;
|
2017-06-13 21:07:42 +02:00
|
|
|
|
2017-06-15 15:09:34 +02:00
|
|
|
function createBrandHeadingElement () {
|
2017-07-10 17:46:22 +02:00
|
|
|
const div = document.createElement('div');
|
2017-06-15 15:09:34 +02:00
|
|
|
div.innerHTML = tpl_brand_heading();
|
|
|
|
return div.firstChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isMessageToHiddenChat (_converse, message) {
|
2017-07-10 17:46:22 +02:00
|
|
|
const jid = Strophe.getBareJidFromJid(message.getAttribute('from'));
|
|
|
|
const model = _converse.chatboxes.get(jid);
|
2017-06-15 15:09:34 +02:00
|
|
|
if (!_.isNil(model)) {
|
|
|
|
return model.get('hidden');
|
|
|
|
}
|
|
|
|
// Not having a chat box is assume to be practically the same
|
|
|
|
// as it being hidden.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-06-13 21:07:42 +02:00
|
|
|
converse.plugins.add('converse-inverse', {
|
|
|
|
|
|
|
|
overrides: {
|
|
|
|
// overrides mentioned here will be picked up by converse.js's
|
|
|
|
// plugin architecture they will replace existing methods on the
|
|
|
|
// relevant objects or classes.
|
|
|
|
//
|
|
|
|
// new functions which don't exist yet can also be added.
|
|
|
|
|
2017-07-10 17:46:22 +02:00
|
|
|
areDesktopNotificationsEnabled () {
|
2017-06-13 21:07:42 +02:00
|
|
|
// Call with "ignore_hidden" as true, so that it doesn't check
|
|
|
|
// if the windowState is hidden.
|
|
|
|
return this.__super__.areDesktopNotificationsEnabled.call(this, true);
|
|
|
|
},
|
|
|
|
|
2017-07-10 17:46:22 +02:00
|
|
|
shouldNotifyOfMessage (message) {
|
|
|
|
const { _converse } = this.__super__;
|
|
|
|
const result = this.__super__.shouldNotifyOfMessage.apply(this, arguments);
|
2017-06-15 15:09:34 +02:00
|
|
|
return result && isMessageToHiddenChat(_converse, message);
|
2017-06-13 21:07:42 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
ControlBoxView: {
|
2017-07-10 17:46:22 +02:00
|
|
|
renderContactsPanel () {
|
2017-06-13 21:07:42 +02:00
|
|
|
this.__super__.renderContactsPanel.apply(this, arguments);
|
|
|
|
this.el.classList.remove("fullscreen");
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-07-10 17:46:22 +02:00
|
|
|
renderRegistrationPanel () {
|
2017-06-13 21:07:42 +02:00
|
|
|
this.__super__.renderRegistrationPanel.apply(this, arguments);
|
|
|
|
|
2017-07-10 17:46:22 +02:00
|
|
|
const el = document.getElementById('converse-register');
|
2017-06-15 15:09:34 +02:00
|
|
|
el.parentNode.insertBefore(createBrandHeadingElement(), el);
|
2017-06-13 21:07:42 +02:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-07-10 17:46:22 +02:00
|
|
|
renderLoginPanel () {
|
2017-06-13 21:07:42 +02:00
|
|
|
this.__super__.renderLoginPanel.apply(this, arguments);
|
|
|
|
this.el.classList.add("fullscreen");
|
|
|
|
|
2017-07-10 17:46:22 +02:00
|
|
|
const el = document.getElementById('converse-login');
|
2017-06-15 15:09:34 +02:00
|
|
|
el.parentNode.insertBefore(createBrandHeadingElement(), el);
|
2017-06-13 21:07:42 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
ChatRoomView: {
|
2017-07-10 17:46:22 +02:00
|
|
|
afterShown (focus) {
|
2017-06-13 21:07:42 +02:00
|
|
|
/* Make sure chat rooms are scrolled down when opened
|
|
|
|
*/
|
|
|
|
this.scrollDown();
|
|
|
|
if (focus) {
|
|
|
|
this.focus();
|
|
|
|
}
|
|
|
|
return this.__super__.afterShown.apply(this, arguments);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-07-10 17:46:22 +02:00
|
|
|
initialize () {
|
2017-07-05 11:03:13 +02:00
|
|
|
this._converse.api.settings.update({
|
2017-06-14 11:14:42 +02:00
|
|
|
chatview_avatar_height: 44,
|
|
|
|
chatview_avatar_width: 44,
|
2017-06-13 21:40:06 +02:00
|
|
|
hide_open_bookmarks: true,
|
|
|
|
show_controlbox_by_default: true,
|
|
|
|
sticky_controlbox: true,
|
2017-06-13 21:07:42 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}));
|