/* * Copyright (c) 2010, 2025 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 {BrowserFieldEventMap, BrowserFieldLayout, BrowserFieldModel, EnumObject, FormField, IFrame, InitModelOf, numbers, PopupBlockerHandler, PropertyChangeEvent, Rectangle, scout, strings} from '../../../index'; import $ from 'jquery'; import TriggeredEvent = JQuery.TriggeredEvent; export type BrowserFieldWindowStates = EnumObject; export class BrowserField extends FormField implements BrowserFieldModel { declare model: BrowserFieldModel; declare eventMap: BrowserFieldEventMap; declare self: BrowserField; autoCloseExternalWindow: boolean; externalWindowButtonText: string; externalWindowFieldText: string; location: string; trackLocation: boolean; sandboxEnabled: boolean; sandboxPermissions: string; trustedMessageOrigins: string[]; scrollBarEnabled: boolean; showInExternalWindow: boolean; iframe: IFrame; myWindow: Window; protected _messageListener: (event: MessageEvent) => any; protected _popupWindow: Window; protected _externalWindowTextField: JQuery; protected _externalWindowButton: JQuery; constructor() { super(); this.autoCloseExternalWindow = false; this.externalWindowButtonText = null; this.externalWindowFieldText = null; this.location = null; this.trackLocation = false; this.sandboxEnabled = true; this.sandboxPermissions = null; this.trustedMessageOrigins = []; this.scrollBarEnabled = true; this.showInExternalWindow = false; this._messageListener = null; this._popupWindow = null; this._externalWindowTextField = null; this._externalWindowButton = null; } static WindowStates = { WINDOW_OPEN: 'true', WINDOW_CLOSED: 'false' }; protected override _init(model: InitModelOf) { super._init(model); this.iframe = scout.create(IFrame, { parent: this, location: this.location, sandboxEnabled: this.sandboxEnabled, sandboxPermissions: this.sandboxPermissions, scrollBarEnabled: this.scrollBarEnabled, trackLocation: this.trackLocation }); this.iframe.on('propertyChange', this._onIFramePropertyChange.bind(this)); } protected override _render() { this.addContainer(this.$parent, 'browser-field', new BrowserFieldLayout(this)); this.addLabel(); if (!this.showInExternalWindow) { // mode 1: