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 | * Adds a listener for the specified event name.
|
91 | *
|
92 | * @param eventName The name of the event.
|
93 | * @param callback The event listener to add. Will be called when an event of
|
94 | * the given name is raised.
|
95 | * @param thisArg An optional parameter which, when set, will be bound as the
|
96 | * `this` context when the callback is called. Falsy values will be not be
|
97 | * bound.
|
98 | */
|
99 | on(eventName: string, callback: (data: EventData) => void, thisArg?: any): void;
|
100 |
|
101 | /**
|
102 | * Raised when a loadFinished event occurs.
|
103 | */
|
104 | on(event: 'loadFinished', callback: (args: LoadEventData) => void, thisArg?: any): void;
|
105 |
|
106 | /**
|
107 | * Raised when a loadStarted event occurs.
|
108 | */
|
109 | on(event: 'loadStarted', callback: (args: LoadEventData) => void, thisArg?: any): void;
|
110 | }
|
111 |
|
112 | /**
|
113 | * Event data containing information for the loading events of a WebView.
|
114 | */
|
115 | export interface LoadEventData extends EventData {
|
116 | /**
|
117 | * Gets the url of the web-view.
|
118 | */
|
119 | url: string;
|
120 |
|
121 | /**
|
122 | * Gets the navigation type of the web-view.
|
123 | */
|
124 | navigationType: NavigationType;
|
125 |
|
126 | /**
|
127 | * Gets the error (if any).
|
128 | */
|
129 | error: string;
|
130 | }
|