/* * Copyright (c) 2010, 2023 BSI Business Systems Integration AG * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 */ import {Device, events, HtmlComponent, IFrameEventMap, IFrameKeyStrokeContext, IFrameModel, KeyStrokeContext, scout, Widget} from '../index'; export class IFrame extends Widget implements IFrameModel { declare model: IFrameModel; declare eventMap: IFrameEventMap; declare self: IFrame; location: string; sandboxEnabled: boolean; sandboxPermissions: string; scrollBarEnabled: boolean; trackLocation: boolean; /** * Iframe on iOS is always as big as its content. Workaround it by using a wrapper div with overflow: auto * Don't wrap it when running in the chrome emulator (in that case isIosPlatform returns false) */ wrapIframe: boolean; $iframe: JQuery; constructor() { super(); this.location = null; this.sandboxEnabled = true; this.sandboxPermissions = null; this.scrollBarEnabled = true; this.trackLocation = false; this.wrapIframe = Device.get().isIosPlatform(); this.$iframe = null; } protected override _createKeyStrokeContext(): KeyStrokeContext { return new IFrameKeyStrokeContext(); } protected override _render() { let cssClass = 'iframe ' + Device.get().cssClassForIphone(); // Inserting an IFrame starts the processing of the micro task queue in Safari. // This must not happen during rendering because it could trigger render again for elements being rendered (some layouts render parts of the widget, e.g. widgets with virtual scrolling) this.session.layoutValidator.suppressValidate(); if (this.wrapIframe) { this.$container = this.$parent.appendDiv('iframe-wrapper'); this.$iframe = this.$container.appendElement('