goog.module('gep.components.InstallationFrame');
const AbstractLayer = goog.require('gep.components.AbstractLayer');
const {LayerType} = goog.require('gep.provider.LayerProvider');
const {createDom} = goog.require('goog.dom');
const TagName = goog.require('goog.dom.TagName');
/**
* Component that controls the display of an external installation in an iframe.
* @extends {AbstractLayer}
*/
class InstallationFrame extends AbstractLayer
{
constructor()
{
super(LayerType.INSTALLATION);
}
/**
* Component is ready and had loaded all dependencies (inherit method waitFor and sub components).
* @inheritDoc
*/
onInit()
{
super.onInit();
/**
* Dom element in which the (dynamically built) content is added.
* @type {Element}
* @private
*/
this.contentWrapper_ = this.getElement().querySelector('.layer-content-wrapper');
}
/**
* Dynamically creates the layer content/dom structure to display the external installation in an iframe
* @inheritDoc
*/
async initContent_(layer, data)
{
if(this.content_)
this.content_.remove();
await super.initContent_(layer, data);
this.content_ = createDom(TagName.IFRAME, {'src': data['url'], 'width': '100%', 'height': '100%', 'class': 'layer-content is-visible'});
this.contentWrapper_.append(this.content_);
}
/**
* Activates all interactive elements in the layer.
* Remove the iframe content to stop all processes of the installation.
* @inheritDoc
*/
deactivate_()
{
super.deactivate_();
if(this.content_)
this.content_.remove();
}
/**
* Checks whether a content change and thus an update of
* the content should take place when the layer is called up again.
* @inheritDoc
*/
checkLayerContentInitalisation_(event)
{
return true;
}
}
exports = InstallationFrame;