2022-08-30 08:47:55 +00:00
|
|
|
/* global APP, interfaceConfig */
|
|
|
|
|
|
|
|
import $ from 'jquery';
|
2018-03-07 00:28:19 +00:00
|
|
|
|
2019-10-08 12:27:35 +00:00
|
|
|
import { getSharedDocumentUrl, setDocumentEditingState } from '../../../react/features/etherpad';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { getToolboxHeight } from '../../../react/features/toolbox/functions.web';
|
2017-04-10 17:59:44 +00:00
|
|
|
import Filmstrip from '../videolayout/Filmstrip';
|
2020-05-20 10:57:03 +00:00
|
|
|
import LargeContainer from '../videolayout/LargeContainer';
|
|
|
|
import VideoLayout from '../videolayout/VideoLayout';
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Default Etherpad frame width.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
const DEFAULT_WIDTH = 640;
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Default Etherpad frame height.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
const DEFAULT_HEIGHT = 480;
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const ETHERPAD_CONTAINER_TYPE = 'etherpad';
|
2015-12-25 16:55:45 +00:00
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Container for Etherpad iframe.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
class Etherpad extends LargeContainer {
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
* Creates new Etherpad object
|
|
|
|
*/
|
2019-10-08 12:27:35 +00:00
|
|
|
constructor(url) {
|
2015-12-25 16:55:45 +00:00
|
|
|
super();
|
|
|
|
|
|
|
|
const iframe = document.createElement('iframe');
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
iframe.id = 'etherpadIFrame';
|
2019-10-08 12:27:35 +00:00
|
|
|
iframe.src = url;
|
2023-02-03 08:28:51 +00:00
|
|
|
iframe.style.border = 0;
|
2017-10-12 23:02:29 +00:00
|
|
|
iframe.scrolling = 'no';
|
2015-12-25 16:55:45 +00:00
|
|
|
iframe.width = DEFAULT_WIDTH;
|
|
|
|
iframe.height = DEFAULT_HEIGHT;
|
|
|
|
iframe.setAttribute('style', 'visibility: hidden;');
|
|
|
|
|
|
|
|
this.container.appendChild(iframe);
|
|
|
|
|
|
|
|
this.iframe = iframe;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
get isOpen() {
|
|
|
|
return Boolean(this.iframe);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
get container() {
|
2015-12-25 16:55:45 +00:00
|
|
|
return document.getElementById('etherpad');
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
resize(containerWidth, containerHeight) {
|
2017-06-14 23:52:59 +00:00
|
|
|
let height, width;
|
|
|
|
|
|
|
|
if (interfaceConfig.VERTICAL_FILMSTRIP) {
|
2018-04-09 05:03:26 +00:00
|
|
|
height = containerHeight - getToolboxHeight();
|
2020-02-10 15:27:43 +00:00
|
|
|
width = containerWidth - Filmstrip.getVerticalFilmstripWidth();
|
2017-06-14 23:52:59 +00:00
|
|
|
} else {
|
|
|
|
height = containerHeight - Filmstrip.getFilmstripHeight();
|
|
|
|
width = containerWidth;
|
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
$(this.iframe)
|
|
|
|
.width(width)
|
|
|
|
.height(height);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
show() {
|
2015-12-25 16:55:45 +00:00
|
|
|
const $iframe = $(this.iframe);
|
|
|
|
const $container = $(this.container);
|
2017-10-12 23:02:29 +00:00
|
|
|
const self = this;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
return new Promise(resolve => {
|
2017-10-12 23:02:29 +00:00
|
|
|
$iframe.fadeIn(300, () => {
|
2016-03-18 20:00:55 +00:00
|
|
|
self.bodyBackground = document.body.style.background;
|
2015-12-25 16:55:45 +00:00
|
|
|
document.body.style.background = '#eeeeee';
|
2017-10-12 23:02:29 +00:00
|
|
|
$iframe.css({ visibility: 'visible' });
|
|
|
|
$container.css({ zIndex: 2 });
|
2018-04-09 18:02:21 +00:00
|
|
|
|
|
|
|
APP.store.dispatch(setDocumentEditingState(true));
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
hide() {
|
2015-12-25 16:55:45 +00:00
|
|
|
const $iframe = $(this.iframe);
|
|
|
|
const $container = $(this.container);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
document.body.style.background = this.bodyBackground;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
return new Promise(resolve => {
|
2017-10-12 23:02:29 +00:00
|
|
|
$iframe.fadeOut(300, () => {
|
|
|
|
$iframe.css({ visibility: 'hidden' });
|
|
|
|
$container.css({ zIndex: 0 });
|
2018-04-09 18:02:21 +00:00
|
|
|
|
|
|
|
APP.store.dispatch(setDocumentEditingState(false));
|
|
|
|
|
2015-12-25 16:55:45 +00:00
|
|
|
resolve();
|
2015-01-07 14:54:03 +00:00
|
|
|
});
|
2015-12-25 16:55:45 +00:00
|
|
|
});
|
|
|
|
}
|
2016-03-18 03:19:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {boolean} do not switch on dominant speaker event if on stage.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
stayOnStage() {
|
2016-03-18 03:19:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Manager of the Etherpad frame.
|
|
|
|
*/
|
2015-12-25 16:55:45 +00:00
|
|
|
export default class EtherpadManager {
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2019-10-08 12:27:35 +00:00
|
|
|
constructor(eventEmitter) {
|
2016-03-24 01:43:29 +00:00
|
|
|
this.eventEmitter = eventEmitter;
|
2015-12-25 16:55:45 +00:00
|
|
|
this.etherpad = null;
|
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
get isOpen() {
|
|
|
|
return Boolean(this.etherpad);
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
2017-11-16 18:26:14 +00:00
|
|
|
*
|
2017-10-12 23:02:29 +00:00
|
|
|
*/
|
2016-03-24 01:43:29 +00:00
|
|
|
isVisible() {
|
|
|
|
return VideoLayout.isLargeContainerTypeVisible(ETHERPAD_CONTAINER_TYPE);
|
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Create new Etherpad frame.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
openEtherpad() {
|
2019-10-08 12:27:35 +00:00
|
|
|
this.etherpad = new Etherpad(getSharedDocumentUrl(APP.store.getState));
|
2015-12-25 16:55:45 +00:00
|
|
|
VideoLayout.addLargeVideoContainer(
|
2016-03-18 02:58:40 +00:00
|
|
|
ETHERPAD_CONTAINER_TYPE,
|
2015-12-25 16:55:45 +00:00
|
|
|
this.etherpad
|
|
|
|
);
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 14:59:35 +00:00
|
|
|
/**
|
|
|
|
* Toggle Etherpad frame visibility.
|
|
|
|
* Open new Etherpad frame if there is no Etherpad frame yet.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
toggleEtherpad() {
|
2015-12-25 16:55:45 +00:00
|
|
|
if (!this.isOpen) {
|
|
|
|
this.openEtherpad();
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const isVisible = this.isVisible();
|
2015-12-25 16:55:45 +00:00
|
|
|
|
2016-03-18 02:58:40 +00:00
|
|
|
VideoLayout.showLargeVideoContainer(
|
|
|
|
ETHERPAD_CONTAINER_TYPE, !isVisible);
|
2016-03-24 01:43:29 +00:00
|
|
|
|
2018-03-07 00:28:19 +00:00
|
|
|
APP.store.dispatch(setDocumentEditingState(!isVisible));
|
2015-12-25 16:55:45 +00:00
|
|
|
}
|
|
|
|
}
|