From 2478176f23cf3be22a5adef2e393c09e8f8953d6 Mon Sep 17 00:00:00 2001 From: damencho Date: Mon, 22 Jan 2018 17:47:18 -0600 Subject: [PATCH] Adds uiLoaded event in iframe API, fired when all resources are loaded. --- doc/api.md | 1 + modules/API/external/external_api.js | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/api.md b/doc/api.md index b811ab3ed..c5361e13d 100644 --- a/doc/api.md +++ b/doc/api.md @@ -27,6 +27,7 @@ Its constructor gets a number of options: * **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. * **jwt**: (optional) [JWT](https://jwt.io/) token. + * **onload**: (optional) handler for the iframe onload event. Example: diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index 9408effb2..33568d57d 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -123,7 +123,8 @@ function parseArguments(args) { configOverwrite, interfaceConfigOverwrite, noSSL, - jwt + jwt, + onload ] = args; return { @@ -134,7 +135,8 @@ function parseArguments(args) { configOverwrite, interfaceConfigOverwrite, noSSL, - jwt + jwt, + onload }; case 'object': // new arguments format return args[0]; @@ -196,6 +198,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter { * used. * @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for * authentication. + * @param {string} [options.onload] - The onload function that will listen + * for iframe onload event. */ constructor(domain, ...args) { super(); @@ -207,7 +211,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter { configOverwrite = {}, interfaceConfigOverwrite = {}, noSSL = false, - jwt = undefined + jwt = undefined, + onload = undefined } = parseArguments(args); this._parentNode = parentNode; @@ -218,7 +223,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter { noSSL, roomName }); - this._createIFrame(height, width); + this._createIFrame(height, width, onload); this._transport = new Transport({ backend: new PostMessageTransportBackend({ postisOptions: { @@ -243,11 +248,13 @@ export default class JitsiMeetExternalAPI extends EventEmitter { * parseSizeParam for format details. * @param {number|string} width - The with of the iframe. Check * parseSizeParam for format details. + * @param {Function} onload - The function that will listen + * for onload event. * @returns {void} * * @private */ - _createIFrame(height, width) { + _createIFrame(height, width, onload) { const frameName = `jitsiConferenceFrame${id}`; this._frame = document.createElement('iframe'); @@ -258,6 +265,13 @@ export default class JitsiMeetExternalAPI extends EventEmitter { this._setSize(height, width); this._frame.setAttribute('allowFullScreen', 'true'); 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); }