From 37f3370c04575090f06d6a76d746d770aa4c6109 Mon Sep 17 00:00:00 2001 From: Timothy Jones Date: Wed, 4 Jul 2018 12:16:09 +1000 Subject: [PATCH 1/2] Fix typos --- README.md | 4 ++-- src/lex-web-ui-loader/css/lex-web-ui-iframe.css | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4392402a..4e04b3bf 100755 --- a/README.md +++ b/README.md @@ -314,7 +314,7 @@ page](#stand-alone-page) section. // as a JSON file or events. The configUrl variable in the // loaderOptions above can be used to put these config values in a file // instead of explicitly passing it as an argument. - var chatbotUiconfig = { + var chatbotUiConfig = { ui: { // origin of the parent site where you are including the chatbot UI // set to window.location.origin since hosting on same site @@ -337,7 +337,7 @@ page](#stand-alone-page) section. // Call the load function which returns a promise that is resolved // once the component is loaded or is rejected if there is an error - iframeLoader.load(chabotUiConfig) + iframeLoader.load(chatbotUiConfig) .then(function () { console.log('iframe loaded'); }) diff --git a/src/lex-web-ui-loader/css/lex-web-ui-iframe.css b/src/lex-web-ui-loader/css/lex-web-ui-iframe.css index b5e7ec57..4acc2f6e 100644 --- a/src/lex-web-ui-loader/css/lex-web-ui-iframe.css +++ b/src/lex-web-ui-loader/css/lex-web-ui-iframe.css @@ -44,7 +44,7 @@ and (max-width: 480px) { margin-right: 2vw; align-self: center; } - .lex-web-ui-ifame--minimize { + .lex-web-ui-iframe--minimize { min-width: 60vw; height: 48px; } From e85c3b3563b4eb3f7a93c3a2745ab864a45da94c Mon Sep 17 00:00:00 2001 From: potterve Date: Tue, 21 Aug 2018 11:29:08 -0500 Subject: [PATCH 2/2] Fixes which prevent configBase (default code specified config values) from overriding those specified in the json configuration file loaded via the deployed website. Remove "shouldLoadIframeMinizmied" from configBase. Validate existence of shouldLoadIframeMinimized in configuration and set to default to "true" if not configured. Re-ordered when a a default "iframeSrcPath" is merged to configuration so as to not override that specified in the web based json configuration file. --- .gitignore | 1 + src/lex-web-ui-loader/js/defaults/lex-web-ui.js | 1 - src/lex-web-ui-loader/js/index.js | 9 ++++++--- src/lex-web-ui-loader/js/lib/iframe-component-loader.js | 8 ++++++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index ed1bf778..4b93265d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ out/ node_modules/ +.idea/ diff --git a/src/lex-web-ui-loader/js/defaults/lex-web-ui.js b/src/lex-web-ui-loader/js/defaults/lex-web-ui.js index 4e0cb359..dad5f405 100644 --- a/src/lex-web-ui-loader/js/defaults/lex-web-ui.js +++ b/src/lex-web-ui-loader/js/defaults/lex-web-ui.js @@ -27,7 +27,6 @@ export const configBase = { iframe: { iframeOrigin: '', iframeSrcPath: '', - shouldLoadIframeMinimized: true, }, }; diff --git a/src/lex-web-ui-loader/js/index.js b/src/lex-web-ui-loader/js/index.js index 45a871ec..ae6992db 100644 --- a/src/lex-web-ui-loader/js/index.js +++ b/src/lex-web-ui-loader/js/index.js @@ -156,13 +156,16 @@ export class IframeLoader extends Loader { } load(configParam = {}) { - this.config.iframe = this.config.iframe || {}; - this.config.iframe.iframeSrcPath = this.mergeSrcPath(configParam); - return super.load(configParam) .then(() => { // assign API to this object to make calls more succint this.api = this.compLoader.api; + // make sure iframe and iframeSrcPath are set to values if not + // configured by standard mechanisms. At this point, default + // values from ./defaults/loader.js will be used. + this.config.iframe = this.config.iframe || {}; + this.config.iframe.iframeSrcPath = this.config.iframe.iframeSrcPath || + this.mergeSrcPath(configParam); }); } diff --git a/src/lex-web-ui-loader/js/lib/iframe-component-loader.js b/src/lex-web-ui-loader/js/lib/iframe-component-loader.js index 6e94fbd5..b6fbcaf8 100644 --- a/src/lex-web-ui-loader/js/lib/iframe-component-loader.js +++ b/src/lex-web-ui-loader/js/lib/iframe-component-loader.js @@ -61,6 +61,9 @@ export class IframeComponentLoader { this.config.iframe.iframeOrigin = this.config.parentOrigin || window.location.origin; } + if (iframeConfig.shouldLoadIframeMinimized === undefined) { + this.config.iframe.shouldLoadIframeMinimized = true; + } // assign parentOrigin if not found in config if (!(this.config.parentOrigin)) { this.config.parentOrigin = @@ -102,6 +105,11 @@ export class IframeComponentLoader { console.error('missing parentOrigin config field'); return false; } + if (!('shouldLoadIframeMinimized' in iframeConfig)) { + console.error('missing shouldLoadIframeMinimized config field'); + return false; + } + return true; }