Skip to content

Commit

Permalink
Adds uiLoaded event in iframe API, fired when all resources are loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho authored and hristoterezov committed Jan 23, 2018
1 parent 12ec982 commit 2478176
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
24 changes: 19 additions & 5 deletions modules/API/external/external_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ function parseArguments(args) {
configOverwrite,
interfaceConfigOverwrite,
noSSL,
jwt
jwt,
onload
] = args;

return {
Expand All @@ -134,7 +135,8 @@ function parseArguments(args) {
configOverwrite,
interfaceConfigOverwrite,
noSSL,
jwt
jwt,
onload
};
case 'object': // new arguments format
return args[0];
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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: {
Expand All @@ -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');
Expand All @@ -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);
}

Expand Down

0 comments on commit 2478176

Please sign in to comment.