UNPKG

openfin-browser-adapter

Version:
129 lines (128 loc) 3.82 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var Base_1 = require("./Base"); var windowRegistry_1 = require("../helper/windowRegistry"); var Window = (function (_super) { __extends(Window, _super); function Window(data, callback) { var _this = _super.call(this) || this; var opened; if (data && data.url) { opened = window.open(data.url, '_blank'); } _this.contentWindow = opened || window; _this.name = data.name; if (callback) { setTimeout(callback, 0); } windowRegistry_1.default[data.name] = _this; return _this; } Window.wrap = function (appUuid, windowName) { if (!windowRegistry_1.default[windowName]) { windowRegistry_1.default[windowName] = new Window({ name: windowName }, function () { }); } return windowRegistry_1.default[windowName]; }; Window.getCurrent = function () { if (this._name) { return windowRegistry_1.default[this._name]; } else { Window._name = 'current-window-name'; return new Window({ name: Window._name }, function () { }); } }; Window.prototype.close = function (force, callback, errorCallback) { try { this.contentWindow.close(); if (callback) { callback(); } } catch (error) { if (errorCallback) { errorCallback(error); } } }; Window.prototype.getParentWindow = function () { if (window.location.pathname === '/') { return this; } return null; }; Window.prototype.getBounds = function (success) { var result = {}; if (success) { result.left = this.contentWindow.screenX; result.top = this.contentWindow.screenY; result.width = this.contentWindow.outerWidth; result.height = this.contentWindow.outerHeight; success(result); } }; Window._name = null; Window.staticMethods = []; Window.instanceMethods = [ 'getNativeWindow', 'getParentApplication', 'addEventListener', 'animate', 'authenticate', 'blur', 'bringToFront', 'disableFrame', 'enableFrame', 'executeJavaScript', 'flash', 'focus', 'getAllFrames', 'getGroup', 'getInfo', 'getOptions', 'getSnapshot', 'getState', 'getZoomLevel', 'hide', 'isShowing', 'joinGroup', 'leaveGroup', 'maximize', 'mergeGroups', 'minimize', 'moveBy', 'moveTo', 'navigate', 'navigateBack', 'navigateForward', 'reload', 'removeEventListener', 'resizeBy', 'resizeTo', 'restore', 'setAsForeground', 'setBounds', 'setZoomLevel', 'show', 'showAt', 'stopFlashing', 'stopNavigation', 'updateOptions', ]; return Window; }(Base_1.BaseApiClass)); exports.Window = Window;