File

projects/wms-framework/src/lib/baseframework/HtmlWindow.ts

Description

Replacement for HTML Window

Index

Properties
Methods

Properties

Private window
Type : WindowProxy | null
Default value : null

Save the current window

Methods

Invoke
Invoke(...args: any)

Invoke a method for the current window

Parameters :
Name Type Optional
args any No
Returns : any
Navigate
Navigate(targetUri: Uri, target: string, features: string)

Moves the browser to the given location

Parameters :
Name Type Optional Description
targetUri Uri No

target URI

target string No
features string No
Returns : HtmlWindow
import {
  ArgumentException,
  ArgumentNullException,
  InvalidOperationException,
} from './Exceptions';
import { Uri } from './Uri';

/**
 * Replacement for HTML Window
 *
 * @export
 * @class HtmlWindow
 * @wType System.Windows.Browser.HtmlWindow
 */
export class HtmlWindow {
  /**
   * Save the current window
   *
   * @private
   * @type {(WindowProxy | null)}
   * @memberof HtmlWindow
   */
  private window: WindowProxy | null = null;

  /**
   * Moves the browser to the given location
   *
   * @param {Uri} targetUri target URI
   * @memberof HtmlWindow
   */
  Navigate(targetUri: Uri, target: string, features: string): HtmlWindow {
    this.window = window;
    this.window = this.window.open(targetUri.AbsoluteUri, target, features);
    return this;
  }

  /**
   * Invoke a method for the current window
   *
   * @param {...any} args
   * @memberof HtmlWindow
   */
  Invoke(...args: any): any {
    this.window = this.window || window;
    const func: string = args[0];
    if (func.trimEnd().length === 0) {
      throw new ArgumentException('the method name should be a valid method');
    }
    if (this.window[func] === undefined) {
      throw new ArgumentNullException(`Method ${func} not found`);
    }
    try {
      return this.window[func].apply(
        this.window,
        Array.isArray(args.slice(1)) && args.slice(1).length === 0
          ? undefined
          : args.slice(1)
      );
    } catch (error) {
      throw new InvalidOperationException(error);
    }
  }
}

result-matching ""

    No results matching ""