mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Replace knownEvents modules with static strings.
This commit is contained in:
@@ -3,10 +3,6 @@ import view = require("ui/core/view");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import proxy = require("ui/core/proxy");
|
||||
|
||||
export module knownEvents {
|
||||
export var loadFinished: string = "loadFinished";
|
||||
export var loadStarted: string = "loadStarted";
|
||||
}
|
||||
var urlProperty = new dependencyObservable.Property(
|
||||
"url",
|
||||
"WebView",
|
||||
@@ -27,6 +23,8 @@ function onUrlPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
(<proxy.PropertyMetadata>urlProperty.metadata).onSetNativeValue = onUrlPropertyChanged;
|
||||
|
||||
export class WebView extends view.View implements definition.WebView {
|
||||
public static loadStartedEvent = "loadStarted";
|
||||
public static loadFinishedEvent = "loadFinished";
|
||||
|
||||
public static urlProperty = urlProperty;
|
||||
|
||||
@@ -51,7 +49,7 @@ export class WebView extends view.View implements definition.WebView {
|
||||
this._suspendLoading = false;
|
||||
|
||||
var args = <definition.LoadEventData>{
|
||||
eventName: knownEvents.loadFinished,
|
||||
eventName: WebView.loadFinishedEvent,
|
||||
object: this,
|
||||
url: url,
|
||||
error: error
|
||||
@@ -62,7 +60,7 @@ export class WebView extends view.View implements definition.WebView {
|
||||
|
||||
public _onLoadStarted(url: string) {
|
||||
var args = <definition.LoadEventData>{
|
||||
eventName: knownEvents.loadStarted,
|
||||
eventName: WebView.loadStartedEvent,
|
||||
object: this,
|
||||
url: url,
|
||||
error: undefined
|
||||
|
||||
46
ui/web-view/web-view.d.ts
vendored
46
ui/web-view/web-view.d.ts
vendored
@@ -6,25 +6,19 @@ declare module "ui/web-view" {
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import observable = require("data/observable");
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
export module knownEvents {
|
||||
/**
|
||||
* Raised when the web-view has completely loaded an url.
|
||||
*/
|
||||
export var loadFinished: string;
|
||||
|
||||
/**
|
||||
* Raised when the web-view starts loading an url.
|
||||
*/
|
||||
export var loadStarted: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a standard WebView widget.
|
||||
*/
|
||||
export class WebView extends view.View {
|
||||
/**
|
||||
* String value used when hooking to loadStarted event.
|
||||
*/
|
||||
public static loadStartedEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to loadFinished event.
|
||||
*/
|
||||
public static loadFinishedEvent: string;
|
||||
|
||||
/**
|
||||
* Represents the observable property backing the Url property of each WebView instance.
|
||||
@@ -71,9 +65,23 @@ declare module "ui/web-view" {
|
||||
*/
|
||||
reload();
|
||||
|
||||
on(event: string, callback: (data: observable.EventData) => void);
|
||||
on(event: "loadFinished", callback: (args: LoadEventData) => void);
|
||||
on(event: "loadStarted", callback: (args: LoadEventData) => void);
|
||||
/**
|
||||
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
|
||||
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
|
||||
* @param callback - Callback function which will be executed when event is raised.
|
||||
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
|
||||
*/
|
||||
on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when a loadFinished event occurs.
|
||||
*/
|
||||
on(event: "loadFinished", callback: (args: LoadEventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when a loadStarted event occurs.
|
||||
*/
|
||||
on(event: "loadStarted", callback: (args: LoadEventData) => void, thisArg?: any);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,4 +97,4 @@ declare module "ui/web-view" {
|
||||
*/
|
||||
error: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user