in src/EmbeddableObject.js [72:160]
constructor(options: EmbeddingOptions) {
if (!options) {
throw new Error('options is required');
}
if (!options.url) {
throw new Error('url is required');
}
const {
url,
container,
parameters,
defaultEmbeddingVisualType,
errorCallback,
loadCallback,
parametersChangeCallback,
selectedSheetChangeCallback,
isQEmbedded
} = options;
this.url = url;
if (container instanceof HTMLElement) {
this.container = container;
} else if (typeof container === 'string') {
this.container = document.querySelector(container);
}
if (!this.container) {
throw new Error('can\'t find valid container');
}
this.parameters = parameters;
this.defaultEmbeddingVisualType = defaultEmbeddingVisualType;
this.iframe = createIframe(options);
eventify(this);
if (typeof errorCallback === 'function') {
this.on(CLIENT_FACING_EVENT_NAMES.error, errorCallback);
}
if (typeof loadCallback === 'function') {
this.on(CLIENT_FACING_EVENT_NAMES.load, loadCallback);
}
if (typeof parametersChangeCallback === 'function') {
this.on(CLIENT_FACING_EVENT_NAMES.parametersChange, parametersChangeCallback);
}
if (typeof selectedSheetChangeCallback === 'function') {
this.on(CLIENT_FACING_EVENT_NAMES.selectedSheetChange, selectedSheetChangeCallback);
}
window.addEventListener('message', (function(event) {
if (!event) {
return;
}
if (event.source === (this.iframe && this.iframe.contentWindow)) {
this.handleMessageEvent(event, options);
}
}).bind(this), false);
if (isQEmbedded) {
this.qBarOpen = false;
this.isQEmbedded = isQEmbedded;
this.qOptions = options.qSearchBarOptions;
window.addEventListener('click', (function(event) {
const isClickInside = this.container ? this.container.contains(event.target) : true;
if (!isClickInside) {
const hideQBarEvent = constructEvent(OUT_GOING_POST_MESSAGE_EVENT_NAMES.HIDE_Q_BAR, {});
this.iframe.contentWindow.postMessage(hideQBarEvent, this.url);
}
}).bind(this), false);
}
(this: any).getContainer = this.getContainer.bind(this);
(this: any).getParameters = this.getParameters.bind(this);
(this: any).getActiveParameterValues = this.getActiveParameterValues.bind(this);
(this: any).getSheets = this.getSheets.bind(this);
(this: any).getDefaultEmbeddingVisualType = this.getDefaultEmbeddingVisualType.bind(this);
(this: any).getUrl = this.getUrl.bind(this);
(this: any).handleMessageEvent = this.handleMessageEvent.bind(this);
(this: any).setParameters = this.setParameters.bind(this);
(this: any).setDefaultEmbeddingVisualType = this.setDefaultEmbeddingVisualType.bind(this);
}