1 | /**
|
2 | * Contains the WebView class, which represents a standard browser widget.
|
3 | */
|
4 |
|
5 | import { View } from '../core/view';
|
6 | import { Property } from '../core/properties';
|
7 | import { EventData } from '../../data/observable';
|
8 |
|
9 | /**
|
10 | * Represents the observable property backing the Url property of each WebView instance.
|
11 | */
|
12 | export const urlProperty: Property<WebView, string>;
|
13 |
|
14 | /**
|
15 | * Represents navigation type
|
16 | */
|
17 | export type WebViewNavigationType = 'linkClicked' | 'formSubmitted' | 'backForward' | 'reload' | 'formResubmitted' | 'other' | undefined;
|
18 |
|
19 | /**
|
20 | * Represents a standard WebView widget.
|
21 | */
|
22 | export class WebView extends View {
|
23 | /**
|
24 | * String value used when hooking to loadStarted event.
|
25 | */
|
26 | public static loadStartedEvent: string;
|
27 |
|
28 | /**
|
29 | * String value used when hooking to loadFinished event.
|
30 | */
|
31 | public static loadFinishedEvent: string;
|
32 |
|
33 | /**
|
34 | * Gets the native [android widget](http://developer.android.com/reference/android/webkit/WebView.html) that represents the user interface for this component. Valid only when running on Android OS.
|
35 | */
|
36 | android: any /* android.webkit.WebView */;
|
37 |
|
38 | /**
|
39 | * Gets the native [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview/) that represents the user interface for this component. Valid only when running on iOS.
|
40 | */
|
41 | ios: any /* WKWebView */;
|
42 |
|
43 | /**
|
44 | * Gets or sets the url, local file path or HTML string.
|
45 | */
|
46 | src: string;
|
47 |
|
48 | /**
|
49 | * Gets a value indicating whether the WebView can navigate back.
|
50 | */
|
51 | canGoBack: boolean;
|
52 |
|
53 | /**
|
54 | * Gets a value indicating whether the WebView can navigate forward.
|
55 | */
|
56 | canGoForward: boolean;
|
57 |
|
58 | /**
|
59 | * Disable scrolling in the WebView
|
60 | */
|
61 | disableZoom: boolean;
|
62 |
|
63 | /**
|
64 | * Enables inline media playback on iOS.
|
65 | * By default, webview forces iPhone into fullscreen media playback.
|
66 | */
|
67 | iosAllowInlineMediaPlayback: boolean;
|
68 |
|
69 | /**
|
70 | * Stops loading the current content (if any).
|
71 | */
|
72 | stopLoading(): void;
|
73 |
|
74 | /**
|
75 | * Navigates back.
|
76 | */
|
77 | goBack();
|
78 |
|
79 | /**
|
80 | * Navigates forward.
|
81 | */
|
82 | goForward();
|
83 |
|
84 | /**
|
85 | * Reloads the current url.
|
86 | */
|
87 | reload();
|
88 |
|
89 | /**
|
90 | * A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
|
91 | * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
|
92 | * @param callback - Callback function which will be executed when event is raised.
|
93 | * @param thisArg - An optional parameter which will be used as `this` context for callback execution.
|
94 | */
|
95 | on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
|
96 |
|
97 | /**
|
98 | * Raised when a loadFinished event occurs.
|
99 | */
|
100 | on(event: 'loadFinished', callback: (args: LoadEventData) => void, thisArg?: any): void;
|
101 |
|
102 | /**
|
103 | * Raised when a loadStarted event occurs.
|
104 | */
|
105 | on(event: 'loadStarted', callback: (args: LoadEventData) => void, thisArg?: any): void;
|
106 | }
|
107 |
|
108 | /**
|
109 | * Event data containing information for the loading events of a WebView.
|
110 | */
|
111 | export interface LoadEventData extends EventData {
|
112 | /**
|
113 | * Gets the url of the web-view.
|
114 | */
|
115 | url: string;
|
116 |
|
117 | /**
|
118 | * Gets the navigation type of the web-view.
|
119 | */
|
120 | navigationType: NavigationType;
|
121 |
|
122 | /**
|
123 | * Gets the error (if any).
|
124 | */
|
125 | error: string;
|
126 | }
|