projects/wms-framework/src/lib/baseframework/HtmlWindow.ts
Replacement for HTML Window
Properties |
|
Methods |
Private window |
Type : WindowProxy | null
|
Default value : null
|
Save the current window |
Invoke | ||||||
Invoke(...args: any)
|
||||||
Invoke a method for the current window
Parameters :
Returns :
any
|
Navigate | ||||||||||||||||
Navigate(targetUri: Uri, target: string, features: string)
|
||||||||||||||||
Moves the browser to the given location
Parameters :
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);
}
}
}