2016-11-02 14:58:43 +00:00
|
|
|
/* global APP, $ */
|
2015-12-11 14:48:16 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
import { processReplacements, linkify } from './Replacement';
|
2015-12-11 14:48:16 +00:00
|
|
|
import CommandsProcessor from './Commands';
|
2017-10-12 23:02:29 +00:00
|
|
|
import VideoLayout from '../../videolayout/VideoLayout';
|
2015-12-11 14:48:16 +00:00
|
|
|
|
|
|
|
import UIUtil from '../../util/UIUtil';
|
|
|
|
import UIEvents from '../../../../service/UI/UIEvents';
|
|
|
|
|
2016-09-19 17:48:38 +00:00
|
|
|
import { smileys } from './smileys';
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
import { dockToolbox, setSubject } from '../../../../react/features/toolbox';
|
2017-02-16 23:02:40 +00:00
|
|
|
|
2016-11-02 14:58:43 +00:00
|
|
|
let unreadMessages = 0;
|
|
|
|
const sidePanelsContainerId = 'sideToolbarContainer';
|
|
|
|
const htmlStr = `
|
2016-10-25 13:16:15 +00:00
|
|
|
<div id="chat_container" class="sideToolbarContainer__inner">
|
|
|
|
<div id="nickname">
|
|
|
|
<span data-i18n="chat.nickname.title"></span>
|
|
|
|
<form>
|
2016-11-09 16:46:58 +00:00
|
|
|
<input type='text'
|
|
|
|
class="input-control" id="nickinput" autofocus
|
2016-10-25 13:16:15 +00:00
|
|
|
data-i18n="[placeholder]chat.nickname.popover">
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="chatconversation"></div>
|
2017-04-01 05:52:40 +00:00
|
|
|
<textarea id="usermsg" autofocus
|
2016-10-25 13:16:15 +00:00
|
|
|
data-i18n="[placeholder]chat.messagebox"></textarea>
|
|
|
|
<div id="smileysarea">
|
2017-05-04 16:19:46 +00:00
|
|
|
<div id="smileys">
|
2016-10-25 13:16:15 +00:00
|
|
|
<img src="images/smile.svg"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-11-02 14:58:43 +00:00
|
|
|
</div>`;
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2016-10-25 13:16:15 +00:00
|
|
|
function initHTML() {
|
2016-11-02 14:58:43 +00:00
|
|
|
$(`#${sidePanelsContainerId}`)
|
|
|
|
.append(htmlStr);
|
2016-10-25 13:16:15 +00:00
|
|
|
}
|
|
|
|
|
2016-09-14 20:13:15 +00:00
|
|
|
/**
|
|
|
|
* The container id, which is and the element id.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
const CHAT_CONTAINER_ID = 'chat_container';
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
/**
|
2016-09-14 20:18:14 +00:00
|
|
|
* Updates visual notification, indicating that a message has arrived.
|
2015-01-07 14:54:03 +00:00
|
|
|
*/
|
2016-09-14 20:18:14 +00:00
|
|
|
function updateVisualNotification() {
|
2017-03-31 17:54:58 +00:00
|
|
|
// XXX The rewrite of the toolbar in React delayed the availability of the
|
|
|
|
// element unreadMessages. In order to work around the delay, I introduced
|
|
|
|
// and utilized unreadMsgSelector in addition to unreadMsgElement.
|
|
|
|
const unreadMsgSelector = $('#unreadMessages');
|
|
|
|
const unreadMsgElement
|
|
|
|
= unreadMsgSelector.length > 0 ? unreadMsgSelector[0] : undefined;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-05-25 19:10:56 +00:00
|
|
|
if (unreadMessages && unreadMsgElement) {
|
2015-01-07 14:54:03 +00:00
|
|
|
unreadMsgElement.innerHTML = unreadMessages.toString();
|
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
APP.store.dispatch(dockToolbox(true));
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-03-31 17:54:58 +00:00
|
|
|
const chatButtonElement
|
2015-08-05 21:56:08 +00:00
|
|
|
= document.getElementById('toolbar_button_chat');
|
2017-03-31 17:54:58 +00:00
|
|
|
const leftIndent
|
|
|
|
= (UIUtil.getTextWidth(chatButtonElement)
|
2017-10-12 23:02:29 +00:00
|
|
|
- UIUtil.getTextWidth(unreadMsgElement)) / 2;
|
2017-03-31 17:54:58 +00:00
|
|
|
const topIndent
|
2017-10-12 23:02:29 +00:00
|
|
|
= ((UIUtil.getTextHeight(chatButtonElement)
|
|
|
|
- UIUtil.getTextHeight(unreadMsgElement)) / 2) - 5;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
unreadMsgElement.setAttribute(
|
2017-03-31 17:54:58 +00:00
|
|
|
'style',
|
2017-10-12 23:02:29 +00:00
|
|
|
`top:${topIndent}; left:${leftIndent};`);
|
|
|
|
} else {
|
2017-03-31 17:54:58 +00:00
|
|
|
unreadMsgSelector.html('');
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
2016-09-20 02:22:41 +00:00
|
|
|
|
2017-03-31 17:54:58 +00:00
|
|
|
if (unreadMsgElement) {
|
|
|
|
unreadMsgSelector.parent()[unreadMessages > 0 ? 'show' : 'hide']();
|
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current time in the format it is shown to the user
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2015-06-12 21:14:31 +00:00
|
|
|
function getCurrentTime(stamp) {
|
2017-10-12 23:02:29 +00:00
|
|
|
const now = stamp ? new Date(stamp) : new Date();
|
|
|
|
let hour = now.getHours();
|
|
|
|
let minute = now.getMinutes();
|
|
|
|
let second = now.getSeconds();
|
|
|
|
|
|
|
|
if (hour.toString().length === 1) {
|
|
|
|
hour = `0${hour}`;
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
if (minute.toString().length === 1) {
|
|
|
|
minute = `0${minute}`;
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
if (second.toString().length === 1) {
|
|
|
|
second = `0${second}`;
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
|
|
|
|
return `${hour}:${minute}:${second}`;
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-07-28 21:52:32 +00:00
|
|
|
function toggleSmileys() {
|
2017-10-12 23:02:29 +00:00
|
|
|
const smileys = $('#smileysContainer'); // eslint-disable-line no-shadow
|
|
|
|
|
2017-11-17 19:08:46 +00:00
|
|
|
smileys.slideToggle();
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
$('#usermsg').focus();
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-01-07 14:54:03 +00:00
|
|
|
function addClickFunction(smiley, number) {
|
|
|
|
smiley.onclick = function addSmileyToMessage() {
|
2017-10-12 23:02:29 +00:00
|
|
|
const usermsg = $('#usermsg');
|
|
|
|
let message = usermsg.val();
|
|
|
|
|
|
|
|
message += smileys[`smiley${number}`];
|
2015-01-07 14:54:03 +00:00
|
|
|
usermsg.val(message);
|
|
|
|
usermsg.get(0).setSelectionRange(message.length, message.length);
|
|
|
|
toggleSmileys();
|
|
|
|
usermsg.focus();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the smileys container to the chat
|
|
|
|
*/
|
|
|
|
function addSmileys() {
|
2017-10-12 23:02:29 +00:00
|
|
|
const smileysContainer = document.createElement('div');
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
smileysContainer.id = 'smileysContainer';
|
2017-10-12 23:02:29 +00:00
|
|
|
for (let i = 1; i <= 21; i++) {
|
|
|
|
const smileyContainer = document.createElement('div');
|
|
|
|
|
|
|
|
smileyContainer.id = `smiley${i}`;
|
2015-01-07 14:54:03 +00:00
|
|
|
smileyContainer.className = 'smileyContainer';
|
2017-10-12 23:02:29 +00:00
|
|
|
const smiley = document.createElement('img');
|
|
|
|
|
|
|
|
smiley.src = `images/smileys/smiley${i}.svg`;
|
|
|
|
smiley.className = 'smiley';
|
2015-01-07 14:54:03 +00:00
|
|
|
addClickFunction(smiley, i);
|
|
|
|
smileyContainer.appendChild(smiley);
|
|
|
|
smileysContainer.appendChild(smileyContainer);
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
$('#chat_container').append(smileysContainer);
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resizes the chat conversation.
|
|
|
|
*/
|
|
|
|
function resizeChatConversation() {
|
2017-10-12 23:02:29 +00:00
|
|
|
const msgareaHeight = $('#usermsg').outerHeight();
|
|
|
|
const chatspace = $(`#${CHAT_CONTAINER_ID}`);
|
|
|
|
const width = chatspace.width();
|
|
|
|
const chat = $('#chatconversation');
|
|
|
|
const smileys = $('#smileysarea'); // eslint-disable-line no-shadow
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
smileys.height(msgareaHeight);
|
2017-10-12 23:02:29 +00:00
|
|
|
$('#smileys').css('bottom', (msgareaHeight - 26) / 2);
|
2015-01-07 14:54:03 +00:00
|
|
|
$('#smileysContainer').css('bottom', msgareaHeight);
|
|
|
|
chat.width(width - 10);
|
|
|
|
chat.height(window.innerHeight - 15 - msgareaHeight);
|
|
|
|
}
|
|
|
|
|
2016-11-16 12:09:22 +00:00
|
|
|
/**
|
|
|
|
* Focus input after 400 ms
|
|
|
|
* Found input by id
|
|
|
|
*
|
|
|
|
* @param id {string} input id
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
function deferredFocus(id) {
|
2017-02-28 04:33:27 +00:00
|
|
|
setTimeout(() => $(`#${id}`).focus(), 400);
|
2016-11-15 18:18:40 +00:00
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
/**
|
|
|
|
* Chat related user interface.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
const Chat = {
|
2015-01-07 14:54:03 +00:00
|
|
|
/**
|
|
|
|
* Initializes chat related interface.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
init(eventEmitter) {
|
2016-10-25 13:16:15 +00:00
|
|
|
initHTML();
|
2017-10-06 17:52:23 +00:00
|
|
|
if (APP.conference.getLocalDisplayName()) {
|
2015-01-07 14:54:03 +00:00
|
|
|
Chat.setChatConversationMode(true);
|
2015-12-01 12:53:01 +00:00
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
$('#smileys').click(() => {
|
2016-10-25 13:16:15 +00:00
|
|
|
Chat.toggleSmileys();
|
|
|
|
});
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
$('#nickinput').keydown(function(event) {
|
2015-01-07 14:54:03 +00:00
|
|
|
if (event.keyCode === 13) {
|
|
|
|
event.preventDefault();
|
2017-10-12 23:02:29 +00:00
|
|
|
const val = this.value; // eslint-disable-line no-invalid-this
|
|
|
|
|
|
|
|
this.value = '';// eslint-disable-line no-invalid-this
|
2015-12-14 16:54:08 +00:00
|
|
|
eventEmitter.emit(UIEvents.NICKNAME_CHANGED, val);
|
2016-11-15 18:18:40 +00:00
|
|
|
deferredFocus('usermsg');
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const usermsg = $('#usermsg');
|
|
|
|
|
|
|
|
usermsg.keydown(function(event) {
|
2015-01-07 14:54:03 +00:00
|
|
|
if (event.keyCode === 13) {
|
|
|
|
event.preventDefault();
|
2017-10-12 23:02:29 +00:00
|
|
|
const value = this.value; // eslint-disable-line no-invalid-this
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
usermsg.val('').trigger('autosize.resize');
|
2017-10-12 23:02:29 +00:00
|
|
|
this.focus();// eslint-disable-line no-invalid-this
|
|
|
|
const command = new CommandsProcessor(value, eventEmitter);
|
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
if (command.isCommand()) {
|
2015-01-07 14:54:03 +00:00
|
|
|
command.processCommand();
|
2015-12-11 14:48:16 +00:00
|
|
|
} else {
|
2017-10-12 23:02:29 +00:00
|
|
|
const message = UIUtil.escapeHtml(value);
|
|
|
|
|
2015-12-01 12:53:01 +00:00
|
|
|
eventEmitter.emit(UIEvents.MESSAGE_CREATED, message);
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const onTextAreaResize = function() {
|
2015-01-07 14:54:03 +00:00
|
|
|
resizeChatConversation();
|
|
|
|
Chat.scrollChatToBottom();
|
|
|
|
};
|
2017-10-12 23:02:29 +00:00
|
|
|
|
|
|
|
usermsg.autosize({ callback: onTextAreaResize });
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2016-09-14 20:22:36 +00:00
|
|
|
eventEmitter.on(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
|
2017-10-12 23:02:29 +00:00
|
|
|
(containerId, isVisible) => {
|
|
|
|
if (containerId !== CHAT_CONTAINER_ID || !isVisible) {
|
2016-09-14 20:22:36 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-09-14 20:22:36 +00:00
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
unreadMessages = 0;
|
2016-09-14 20:18:14 +00:00
|
|
|
updateVisualNotification();
|
2016-09-14 20:26:38 +00:00
|
|
|
|
2016-09-15 19:02:56 +00:00
|
|
|
// Undock the toolbar when the chat is shown and if we're in a
|
|
|
|
// video mode.
|
|
|
|
if (VideoLayout.isLargeVideoVisible()) {
|
2017-04-01 05:52:40 +00:00
|
|
|
APP.store.dispatch(dockToolbox(false));
|
2016-09-15 19:02:56 +00:00
|
|
|
}
|
|
|
|
|
2016-09-14 20:26:38 +00:00
|
|
|
// if we are in conversation mode focus on the text input
|
|
|
|
// if we are not, focus on the display name input
|
2017-10-13 19:31:05 +00:00
|
|
|
deferredFocus(
|
|
|
|
APP.conference.getLocalDisplayName()
|
|
|
|
? 'usermsg'
|
|
|
|
: 'nickinput');
|
2015-01-07 14:54:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
addSmileys();
|
2016-09-20 02:22:41 +00:00
|
|
|
updateVisualNotification();
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends the given message to the chat conversation.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line max-params
|
|
|
|
updateChatConversation(id, displayName, message, stamp) {
|
|
|
|
let divClassName = '';
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
if (APP.conference.isLocalId(id)) {
|
2017-10-12 23:02:29 +00:00
|
|
|
divClassName = 'localuser';
|
2015-12-11 14:48:16 +00:00
|
|
|
} else {
|
2017-10-12 23:02:29 +00:00
|
|
|
divClassName = 'remoteuser';
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
if (!Chat.isVisible()) {
|
|
|
|
unreadMessages++;
|
2016-09-14 20:18:14 +00:00
|
|
|
updateVisualNotification();
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// replace links and smileys
|
|
|
|
// Strophe already escapes special symbols on sending,
|
|
|
|
// so we escape here only tags to avoid double &
|
2017-10-12 23:02:29 +00:00
|
|
|
const escMessage = message.replace(/</g, '<')
|
|
|
|
.replace(/>/g, '>')
|
|
|
|
.replace(/\n/g, '<br/>');
|
|
|
|
const escDisplayName = UIUtil.escapeHtml(displayName);
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
2015-12-11 14:48:16 +00:00
|
|
|
message = processReplacements(escMessage);
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const messageContainer
|
|
|
|
= `${'<div class="chatmessage">'
|
|
|
|
+ '<img src="images/chatArrow.svg" class="chatArrow">'
|
|
|
|
+ '<div class="username '}${divClassName}">${escDisplayName
|
|
|
|
}</div><div class="timestamp">${getCurrentTime(stamp)
|
|
|
|
}</div><div class="usermessage">${message}</div>`
|
|
|
|
+ '</div>';
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
$('#chatconversation').append(messageContainer);
|
|
|
|
$('#chatconversation').animate(
|
2017-10-12 23:02:29 +00:00
|
|
|
{ scrollTop: $('#chatconversation')[0].scrollHeight }, 1000);
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends error message to the conversation
|
|
|
|
* @param errorMessage the received error message.
|
|
|
|
* @param originalText the original message.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
chatAddError(errorMessage, originalText) {
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
2015-01-23 12:01:44 +00:00
|
|
|
errorMessage = UIUtil.escapeHtml(errorMessage);
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line no-param-reassign
|
2015-01-23 12:01:44 +00:00
|
|
|
originalText = UIUtil.escapeHtml(originalText);
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
$('#chatconversation').append(
|
2017-10-12 23:02:29 +00:00
|
|
|
`${'<div class="errorMessage"><b>Error: </b>Your message'}${
|
|
|
|
originalText ? ` "${originalText}"` : ''
|
|
|
|
} was not sent.${
|
|
|
|
errorMessage ? ` Reason: ${errorMessage}` : ''}</div>`);
|
2015-01-07 14:54:03 +00:00
|
|
|
$('#chatconversation').animate(
|
2017-10-12 23:02:29 +00:00
|
|
|
{ scrollTop: $('#chatconversation')[0].scrollHeight }, 1000);
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the subject to the UI
|
|
|
|
* @param subject the subject
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
setSubject(subject) {
|
2015-12-11 14:48:16 +00:00
|
|
|
if (subject) {
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line no-param-reassign
|
2015-01-07 14:54:03 +00:00
|
|
|
subject = subject.trim();
|
|
|
|
}
|
2016-11-04 13:58:43 +00:00
|
|
|
|
2017-03-31 17:54:58 +00:00
|
|
|
const html = linkify(UIUtil.escapeHtml(subject));
|
2017-02-16 23:02:40 +00:00
|
|
|
|
|
|
|
APP.store.dispatch(setSubject(html));
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the chat conversation mode.
|
2016-09-14 20:26:38 +00:00
|
|
|
* Conversation mode is the normal chat mode, non conversation mode is
|
|
|
|
* where we ask user to input its display name.
|
2016-02-12 14:15:34 +00:00
|
|
|
* @param {boolean} isConversationMode if chat should be in
|
|
|
|
* conversation mode or not.
|
2015-01-07 14:54:03 +00:00
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
setChatConversationMode(isConversationMode) {
|
|
|
|
$(`#${CHAT_CONTAINER_ID}`)
|
2016-09-08 22:34:16 +00:00
|
|
|
.toggleClass('is-conversation-mode', isConversationMode);
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Resizes the chat area.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
resizeChat(width, height) {
|
|
|
|
$(`#${CHAT_CONTAINER_ID}`).width(width)
|
|
|
|
.height(height);
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
resizeChatConversation();
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the chat is currently visible.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
isVisible() {
|
2016-09-08 22:34:16 +00:00
|
|
|
return UIUtil.isVisible(
|
2016-09-14 20:13:15 +00:00
|
|
|
document.getElementById(CHAT_CONTAINER_ID));
|
2015-12-11 14:48:16 +00:00
|
|
|
},
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
/**
|
|
|
|
* Shows and hides the window with the smileys
|
|
|
|
*/
|
2015-12-11 14:48:16 +00:00
|
|
|
toggleSmileys,
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Scrolls chat to the bottom.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
scrollChatToBottom() {
|
2017-02-28 04:33:27 +00:00
|
|
|
setTimeout(
|
|
|
|
() => {
|
|
|
|
const chatconversation = $('#chatconversation');
|
|
|
|
|
|
|
|
// XXX Prevent TypeError: undefined is not an object when the
|
|
|
|
// Web browser does not support WebRTC (yet).
|
|
|
|
chatconversation.length > 0
|
|
|
|
&& chatconversation.scrollTop(
|
|
|
|
chatconversation[0].scrollHeight);
|
|
|
|
},
|
|
|
|
5);
|
2015-12-11 14:48:16 +00:00
|
|
|
}
|
|
|
|
};
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-12-11 14:48:16 +00:00
|
|
|
export default Chat;
|