Adds uiLoaded event in iframe API, fired when all resources are loaded.

This commit is contained in:
damencho 2018-01-22 17:47:18 -06:00 committed by hristoterezov
parent 12ec982067
commit 2478176f23
2 changed files with 20 additions and 5 deletions

View File

@ -27,6 +27,7 @@ Its constructor gets a number of options:
* **interfaceConfigOverwrite**: (optional) JS object with overrides for options defined in [interface_config.js]. * **interfaceConfigOverwrite**: (optional) JS object with overrides for options defined in [interface_config.js].
* **noSSL**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS. * **noSSL**: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
* **jwt**: (optional) [JWT](https://jwt.io/) token. * **jwt**: (optional) [JWT](https://jwt.io/) token.
* **onload**: (optional) handler for the iframe onload event.
Example: Example:

View File

@ -123,7 +123,8 @@ function parseArguments(args) {
configOverwrite, configOverwrite,
interfaceConfigOverwrite, interfaceConfigOverwrite,
noSSL, noSSL,
jwt jwt,
onload
] = args; ] = args;
return { return {
@ -134,7 +135,8 @@ function parseArguments(args) {
configOverwrite, configOverwrite,
interfaceConfigOverwrite, interfaceConfigOverwrite,
noSSL, noSSL,
jwt jwt,
onload
}; };
case 'object': // new arguments format case 'object': // new arguments format
return args[0]; return args[0];
@ -196,6 +198,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
* used. * used.
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for * @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
* authentication. * authentication.
* @param {string} [options.onload] - The onload function that will listen
* for iframe onload event.
*/ */
constructor(domain, ...args) { constructor(domain, ...args) {
super(); super();
@ -207,7 +211,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
configOverwrite = {}, configOverwrite = {},
interfaceConfigOverwrite = {}, interfaceConfigOverwrite = {},
noSSL = false, noSSL = false,
jwt = undefined jwt = undefined,
onload = undefined
} = parseArguments(args); } = parseArguments(args);
this._parentNode = parentNode; this._parentNode = parentNode;
@ -218,7 +223,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
noSSL, noSSL,
roomName roomName
}); });
this._createIFrame(height, width); this._createIFrame(height, width, onload);
this._transport = new Transport({ this._transport = new Transport({
backend: new PostMessageTransportBackend({ backend: new PostMessageTransportBackend({
postisOptions: { postisOptions: {
@ -243,11 +248,13 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
* parseSizeParam for format details. * parseSizeParam for format details.
* @param {number|string} width - The with of the iframe. Check * @param {number|string} width - The with of the iframe. Check
* parseSizeParam for format details. * parseSizeParam for format details.
* @param {Function} onload - The function that will listen
* for onload event.
* @returns {void} * @returns {void}
* *
* @private * @private
*/ */
_createIFrame(height, width) { _createIFrame(height, width, onload) {
const frameName = `jitsiConferenceFrame${id}`; const frameName = `jitsiConferenceFrame${id}`;
this._frame = document.createElement('iframe'); this._frame = document.createElement('iframe');
@ -258,6 +265,13 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
this._setSize(height, width); this._setSize(height, width);
this._frame.setAttribute('allowFullScreen', 'true'); this._frame.setAttribute('allowFullScreen', 'true');
this._frame.style.border = 0; this._frame.style.border = 0;
if (onload) {
// waits for iframe resources to load
// and fires event when it is done
this._frame.onload = onload;
}
this._frame = this._parentNode.appendChild(this._frame); this._frame = this._parentNode.appendChild(this._frame);
} }