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:
@@ -10,7 +10,7 @@ import fs = require("file-system");
|
||||
import gestures = require("ui/gestures");
|
||||
import bindingBuilder = require("ui/builder/binding-builder");
|
||||
|
||||
var KNOWNEVENTS = "knownEvents";
|
||||
var EVENT = "Event";
|
||||
var UI_PATH = "ui/";
|
||||
var MODULES = {
|
||||
"ActivityIndicator": "ui/activity-indicator",
|
||||
@@ -104,7 +104,7 @@ export function getComponentModule(elementName: string, namespace: string, attri
|
||||
|
||||
export function setPropertyValue(instance: view.View, instanceModule: Object, exports: Object, propertyName: string, propertyValue: string) {
|
||||
if (isBinding(propertyValue) && instance.bind) {
|
||||
if (isKnownEvent(propertyName, instanceModule)) {
|
||||
if (isKnownEvent(propertyName, instanceModule[instance.typeName])) {
|
||||
attachEventBinding(instance, propertyName, propertyValue);
|
||||
} else {
|
||||
var bindOptions = bindingBuilder.getBindingOptions(propertyName, getBindingExpressionFromAttribute(propertyValue));
|
||||
@@ -115,7 +115,7 @@ export function setPropertyValue(instance: view.View, instanceModule: Object, ex
|
||||
twoWay: bindOptions[bindingBuilder.bindingConstants.twoWay]
|
||||
}, bindOptions[bindingBuilder.bindingConstants.source]);
|
||||
}
|
||||
} else if (isKnownEvent(propertyName, instanceModule)) {
|
||||
} else if (isKnownEvent(propertyName, instanceModule[instance.typeName])) {
|
||||
// Get the event handler from page module exports.
|
||||
var handler = exports && exports[propertyValue];
|
||||
|
||||
@@ -175,11 +175,11 @@ function attachEventBinding(instance: view.View, eventName: string, value: strin
|
||||
if (types.isFunction(handler)) {
|
||||
instance.on(eventName, handler, instance.bindingContext);
|
||||
}
|
||||
instance.off(observable.knownEvents.propertyChange, propertyChangeHandler);
|
||||
instance.off(observable.Observable.propertyChangeEvent, propertyChangeHandler);
|
||||
}
|
||||
};
|
||||
|
||||
instance.on(observable.knownEvents.propertyChange, propertyChangeHandler);
|
||||
instance.on(observable.Observable.propertyChangeEvent, propertyChangeHandler);
|
||||
}
|
||||
|
||||
function isGesture(name: string, instance: any): boolean {
|
||||
@@ -187,8 +187,9 @@ function isGesture(name: string, instance: any): boolean {
|
||||
}
|
||||
|
||||
function isKnownEvent(name: string, exports: any): boolean {
|
||||
return (KNOWNEVENTS in exports && name in exports[KNOWNEVENTS]) ||
|
||||
(KNOWNEVENTS in view && name in view[KNOWNEVENTS]);
|
||||
var nameEvent = name + EVENT;
|
||||
var result = !types.isNullOrUndefined(exports) ? nameEvent in exports : false;
|
||||
return result;
|
||||
}
|
||||
|
||||
function getBindingExpressionFromAttribute(value: string): string {
|
||||
|
||||
@@ -6,9 +6,6 @@ import formattedString = require("text/formatted-string");
|
||||
import observable = require("data/observable");
|
||||
import weakEventListener = require("ui/core/weak-event-listener");
|
||||
|
||||
export module knownEvents {
|
||||
export var tap = "tap";
|
||||
}
|
||||
var textProperty = new dependencyObservable.Property(
|
||||
"text",
|
||||
"Button",
|
||||
@@ -37,6 +34,8 @@ function onFormattedTextPropertyChanged(data: dependencyObservable.PropertyChang
|
||||
|
||||
export class Button extends view.View implements definition.Button {
|
||||
|
||||
public static tapEvent = "tap";
|
||||
|
||||
public static textProperty = textProperty;
|
||||
public static formattedTextProperty = formattedTextProperty;
|
||||
|
||||
@@ -63,7 +62,7 @@ export class Button extends view.View implements definition.Button {
|
||||
if (this.formattedText !== value) {
|
||||
var weakEventOptions: weakEventListener.WeakEventListenerOptions = {
|
||||
targetWeakRef: new WeakRef(this),
|
||||
eventName: observable.knownEvents.propertyChange,
|
||||
eventName: observable.Observable.propertyChangeEvent,
|
||||
sourceWeakRef: new WeakRef(value),
|
||||
handler: this.onFormattedTextChanged,
|
||||
handlerContext: this,
|
||||
|
||||
@@ -33,7 +33,7 @@ export class Button extends common.Button {
|
||||
|
||||
onClick: function (v) {
|
||||
if (this.owner) {
|
||||
this.owner._emit(common.knownEvents.tap);
|
||||
this.owner._emit(common.Button.tapEvent);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
26
ui/button/button.d.ts
vendored
26
ui/button/button.d.ts
vendored
@@ -7,13 +7,6 @@ declare module "ui/button" {
|
||||
import view = require("ui/core/view");
|
||||
import formattedString = require("text/formatted-string");
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
export module knownEvents {
|
||||
export var tap: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a standard Button widget.
|
||||
*/
|
||||
@@ -23,6 +16,11 @@ declare module "ui/button" {
|
||||
*/
|
||||
public static textProperty: dependencyObservable.Property;
|
||||
|
||||
/**
|
||||
* String value used when hooking to tap event.
|
||||
*/
|
||||
public static tapEvent: string;
|
||||
|
||||
/**
|
||||
* Gets the native [android widget](http://developer.android.com/reference/android/widget/Button.html) that represents the user interface for this component. Valid only when running on Android OS.
|
||||
*/
|
||||
@@ -43,7 +41,17 @@ declare module "ui/button" {
|
||||
*/
|
||||
formattedText: formattedString.FormattedString;
|
||||
|
||||
on(event: string, callback: (data: observable.EventData) => void);
|
||||
on(event: "tap", callback: (args: observable.EventData) => 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 tap event occurs.
|
||||
*/
|
||||
on(event: "tap", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class TapHandlerImpl extends NSObject {
|
||||
}
|
||||
|
||||
public tap(args) {
|
||||
this._owner._emit(common.knownEvents.tap);
|
||||
this._owner._emit(common.Button.tapEvent);
|
||||
}
|
||||
|
||||
public static ObjCExposedMethods = {
|
||||
|
||||
@@ -164,7 +164,7 @@ export class Binding {
|
||||
this.weakEventListenerOptions = {
|
||||
targetWeakRef: this.target,
|
||||
sourceWeakRef: this.sourceOptions.instance,
|
||||
eventName: observable.knownEvents.propertyChange,
|
||||
eventName: observable.Observable.propertyChangeEvent,
|
||||
handler: this.onSourcePropertyChanged,
|
||||
handlerContext: this,
|
||||
key: this.options.targetProperty
|
||||
|
||||
@@ -332,13 +332,13 @@ export class DependencyObservable extends observable.Observable {
|
||||
property.metadata.onValueChanged({
|
||||
object: this,
|
||||
property: property,
|
||||
eventName: observable.knownEvents.propertyChange,
|
||||
eventName: observable.Observable.propertyChangeEvent,
|
||||
newValue: newValue,
|
||||
oldValue: oldValue
|
||||
});
|
||||
}
|
||||
|
||||
if (this.hasListeners(observable.knownEvents.propertyChange)) {
|
||||
if (this.hasListeners(observable.Observable.propertyChangeEvent)) {
|
||||
var changeData = super._createPropertyChangeData(property.name, newValue);
|
||||
this.notify(changeData);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ export class ProxyObject extends bindable.Bindable implements definition.ProxyOb
|
||||
proxyMetadata.onSetNativeValue({
|
||||
object: this,
|
||||
property: property,
|
||||
eventName: observable.knownEvents.propertyChange,
|
||||
eventName: observable.Observable.propertyChangeEvent,
|
||||
newValue: newValue,
|
||||
oldValue: oldValue
|
||||
});
|
||||
|
||||
@@ -64,11 +64,6 @@ export function getAncestor(view: View, typeName: string): definition.View {
|
||||
return parent;
|
||||
}
|
||||
|
||||
export module knownEvents {
|
||||
export var loaded = "loaded";
|
||||
export var unloaded = "unloaded";
|
||||
}
|
||||
|
||||
var viewIdCounter = 0;
|
||||
|
||||
function onCssClassPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
@@ -107,6 +102,8 @@ function onCssClassPropertyChanged(data: dependencyObservable.PropertyChangeData
|
||||
);
|
||||
|
||||
export class View extends proxy.ProxyObject implements definition.View {
|
||||
public static loadedEvent = "loaded";
|
||||
public static unloadedEvent = "unloaded";
|
||||
|
||||
public static idProperty = idProperty;
|
||||
public static cssClassProperty = cssClassProperty;
|
||||
|
||||
52
ui/core/view.d.ts
vendored
52
ui/core/view.d.ts
vendored
@@ -4,6 +4,7 @@ declare module "ui/core/view" {
|
||||
import proxy = require("ui/core/proxy");
|
||||
import gestures = require("ui/gestures");
|
||||
import color = require("color");
|
||||
import observable = require("data/observable");
|
||||
|
||||
/**
|
||||
* Gets a child view by id.
|
||||
@@ -28,21 +29,6 @@ declare module "ui/core/view" {
|
||||
*/
|
||||
export function getAncestor(view: View, typeName: string): View;
|
||||
|
||||
/**
|
||||
* Defines an enum with events for view class.
|
||||
*/
|
||||
module knownEvents {
|
||||
/**
|
||||
* Raised when the view is added to visual tree and loaded (shown).
|
||||
*/
|
||||
export var loaded: string;
|
||||
|
||||
/**
|
||||
* Raised when the view is unloaded.
|
||||
*/
|
||||
export var unloaded: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines interface for an optional parameter used to create a view.
|
||||
*/
|
||||
@@ -109,6 +95,16 @@ declare module "ui/core/view" {
|
||||
* A View occupies a rectangular area on the screen and is responsible for drawing and layouting of all UI components within.
|
||||
*/
|
||||
export class View extends proxy.ProxyObject {
|
||||
/**
|
||||
* String value used when hooking to loaded event.
|
||||
*/
|
||||
public static loadedEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to unloaded event.
|
||||
*/
|
||||
public static unloadedEvent: string;
|
||||
|
||||
/**
|
||||
* Represents the observable property backing the id property of each View.
|
||||
*/
|
||||
@@ -118,7 +114,15 @@ declare module "ui/core/view" {
|
||||
* Represents the observable property backing the cssClass property of each View.
|
||||
*/
|
||||
public static cssClassProperty: dependencyObservable.Property;
|
||||
|
||||
/**
|
||||
* Represents the observable property backing the isEnabled property of each View.
|
||||
*/
|
||||
public static isEnabledProperty: dependencyObservable.Property;
|
||||
|
||||
/**
|
||||
* Represents the observable property backing the isUserInteractionEnabled property of each View.
|
||||
*/
|
||||
public static isUserInteractionEnabledProperty: dependencyObservable.Property;
|
||||
|
||||
constructor(options?: Options);
|
||||
@@ -353,6 +357,24 @@ declare module "ui/core/view" {
|
||||
|
||||
observe(type: number, callback: (args: gestures.GestureEventData) => void): gestures.GesturesObserver;
|
||||
|
||||
/**
|
||||
* 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 loaded event occurs.
|
||||
*/
|
||||
on(event: "loaded", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when an unloaded event occurs.
|
||||
*/
|
||||
on(event: "unloaded", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
// Lifecycle events
|
||||
onLoaded(): void;
|
||||
onUnloaded(): void;
|
||||
|
||||
@@ -110,18 +110,14 @@ function pageFromBuilder(moduleNamePath: string, moduleExports: any): pages.Page
|
||||
return page;
|
||||
}
|
||||
|
||||
export module knownEvents {
|
||||
export module android {
|
||||
export var optionSelected = "optionSelected";
|
||||
}
|
||||
}
|
||||
|
||||
interface NavigationContext {
|
||||
entry: definition.BackstackEntry;
|
||||
isBackNavigation: boolean;
|
||||
}
|
||||
|
||||
export class Frame extends view.CustomLayoutView implements definition.Frame {
|
||||
public static androidOptionSelectedEvent = "optionSelected";
|
||||
|
||||
private _navigationQueue: Array<NavigationContext>;
|
||||
private _backStack: Array<definition.BackstackEntry>;
|
||||
public _currentEntry: definition.BackstackEntry;
|
||||
|
||||
@@ -481,13 +481,13 @@ class NativeActivity extends com.tns.NativeScriptActivity {
|
||||
}
|
||||
|
||||
onOptionsItemSelected(menuItem: android.view.IMenuItem) {
|
||||
if (!this.androidFrame.hasListeners(frameCommon.knownEvents.android.optionSelected)) {
|
||||
if (!this.androidFrame.hasListeners(frameCommon.Frame.androidOptionSelectedEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var data: definition.AndroidOptionEventData = {
|
||||
handled: false,
|
||||
eventName: frameCommon.knownEvents.android.optionSelected,
|
||||
eventName: frameCommon.Frame.androidOptionSelectedEvent,
|
||||
item: menuItem,
|
||||
object: this.androidFrame
|
||||
}
|
||||
|
||||
33
ui/frame/frame.d.ts
vendored
33
ui/frame/frame.d.ts
vendored
@@ -12,6 +12,11 @@ declare module "ui/frame" {
|
||||
* Nested frames are supported, enabling hierarchical navigation scenarios.
|
||||
*/
|
||||
export class Frame extends view.View {
|
||||
/**
|
||||
* String value used when hooking to androidOptionSelected event (prefix `android` states that this event is available only in Android).
|
||||
*/
|
||||
public static androidOptionSelectedEvent: string;
|
||||
|
||||
/**
|
||||
* Navigates to the previous entry (if any) in the back stack.
|
||||
*/
|
||||
@@ -86,6 +91,19 @@ declare module "ui/frame" {
|
||||
_processNavigationQueue(page: pages.Page);
|
||||
_invalidateOptionsMenu();
|
||||
//@endprivate
|
||||
|
||||
/**
|
||||
* 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: (args: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when native android [onOptionsItemSelected method](http://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)) is called.
|
||||
*/
|
||||
on(event: "optionSelected", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,19 +232,4 @@ declare module "ui/frame" {
|
||||
*/
|
||||
navBarVisibility: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates the events raised by the Frame object.
|
||||
*/
|
||||
module knownEvents {
|
||||
/**
|
||||
* Encapsulates the events raised by the android part of the Frame.
|
||||
*/
|
||||
module android {
|
||||
/**
|
||||
* Raised when the native [onOptionsItemSelected method](http://developer.android.com/reference/android/app/Activity.html#onOptionsItemSelected(android.view.MenuItem)) is called.
|
||||
*/
|
||||
export var optionSelected: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,8 @@ export class GesturesObserver implements definition.GesturesObserver {
|
||||
this._dettach();
|
||||
};
|
||||
|
||||
target.on(view.knownEvents.loaded, this._onTargetLoaded);
|
||||
target.on(view.knownEvents.unloaded, this._onTargetUnloaded);
|
||||
target.on(view.View.loadedEvent, this._onTargetLoaded);
|
||||
target.on(view.View.unloadedEvent, this._onTargetUnloaded);
|
||||
|
||||
if (target.isLoaded) {
|
||||
this._attach(target, type);
|
||||
@@ -57,8 +57,8 @@ export class GesturesObserver implements definition.GesturesObserver {
|
||||
this._dettach();
|
||||
|
||||
if (this._target) {
|
||||
this._target.off(view.knownEvents.loaded, this._onTargetLoaded);
|
||||
this._target.off(view.knownEvents.unloaded, this._onTargetUnloaded);
|
||||
this._target.off(view.View.loadedEvent, this._onTargetLoaded);
|
||||
this._target.off(view.View.unloadedEvent, this._onTargetUnloaded);
|
||||
|
||||
this._onTargetLoaded = null;
|
||||
this._onTargetUnloaded = null;
|
||||
|
||||
@@ -74,8 +74,8 @@ export class GesturesObserver implements definition.GesturesObserver {
|
||||
this._dettach();
|
||||
};
|
||||
|
||||
target.on(view.knownEvents.loaded, this._onTargetLoaded);
|
||||
target.on(view.knownEvents.unloaded, this._onTargetUnloaded);
|
||||
target.on(view.View.loadedEvent, this._onTargetLoaded);
|
||||
target.on(view.View.unloadedEvent, this._onTargetUnloaded);
|
||||
|
||||
if (target.isLoaded) {
|
||||
this._attach(target, type);
|
||||
@@ -164,8 +164,8 @@ export class GesturesObserver implements definition.GesturesObserver {
|
||||
this._dettach();
|
||||
|
||||
if (this._target) {
|
||||
this._target.off(view.knownEvents.loaded, this._onTargetLoaded);
|
||||
this._target.off(view.knownEvents.unloaded, this._onTargetUnloaded);
|
||||
this._target.off(view.View.loadedEvent, this._onTargetLoaded);
|
||||
this._target.off(view.View.unloadedEvent, this._onTargetUnloaded);
|
||||
|
||||
this._onTargetLoaded = null;
|
||||
this._onTargetUnloaded = null;
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
import observable = require("data/observable");
|
||||
import imageSource = require("image-source");
|
||||
|
||||
export module knownEvents {
|
||||
export var downloaded = "downloaded";
|
||||
}
|
||||
|
||||
export interface DownloadRequest {
|
||||
url: string;
|
||||
key: string;
|
||||
@@ -13,6 +9,8 @@ export interface DownloadRequest {
|
||||
}
|
||||
|
||||
export class Cache extends observable.Observable implements definition.Cache {
|
||||
public static downloadedEvent = "downloaded";
|
||||
|
||||
public placeholder: imageSource.ImageSource;
|
||||
public maxRequests = 5;
|
||||
private _enabled = true;
|
||||
@@ -135,9 +133,9 @@ export class Cache extends observable.Observable implements definition.Cache {
|
||||
request.completed(image, request.key);
|
||||
}
|
||||
|
||||
if (this.hasListeners(knownEvents.downloaded)) {
|
||||
if (this.hasListeners(Cache.downloadedEvent)) {
|
||||
this.notify({
|
||||
eventName: knownEvents.downloaded,
|
||||
eventName: Cache.downloadedEvent,
|
||||
object: this,
|
||||
key: key,
|
||||
image: image
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import common = require("ui/image-cache/image-cache-common");
|
||||
|
||||
module.exports.knownEvents = common.knownEvents;
|
||||
|
||||
class LruBitmapCache extends android.util.LruCache<string, android.graphics.Bitmap> {
|
||||
constructor(cacheSize: number) {
|
||||
super(cacheSize);
|
||||
|
||||
27
ui/image-cache/image-cache.d.ts
vendored
27
ui/image-cache/image-cache.d.ts
vendored
@@ -27,6 +27,10 @@ declare module "ui/image-cache" {
|
||||
* Represents a class that stores handles image download requests and caches the already downloaded images.
|
||||
*/
|
||||
export class Cache extends observable.Observable {
|
||||
/**
|
||||
* String value used when hooking to downloaded event.
|
||||
*/
|
||||
public static downloadedEvent: string;
|
||||
/**
|
||||
* The image to be used to notify for a pending download request - e.g. loading indicator.
|
||||
*/
|
||||
@@ -71,22 +75,25 @@ declare module "ui/image-cache" {
|
||||
*/
|
||||
clear(): 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: (args: observable.EventData) => void , thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when the image has been downloaded.
|
||||
*/
|
||||
on(event: "downloaded", callback: (args: DownloadedData) => void , thisArg?: any);
|
||||
|
||||
//@private
|
||||
_downloadCore(request: DownloadRequest);
|
||||
_onDownloadCompleted(key: string, image: any);
|
||||
//@endprivate
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines an enum with events specific for image-cache class.
|
||||
*/
|
||||
export module knownEvents {
|
||||
/**
|
||||
* Raised when the image has been downloaded.
|
||||
*/
|
||||
export var downloaded: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data for downloaded event.
|
||||
*/
|
||||
|
||||
@@ -3,8 +3,6 @@ import httpRequest = require("http/http-request");
|
||||
import utils = require("utils/utils");
|
||||
import trace = require("trace");
|
||||
|
||||
module.exports.knownEvents = common.knownEvents;
|
||||
|
||||
//class NSCacheDelegateImpl extends NSObject implements NSCacheDelegate {
|
||||
// public static ObjCProtocols = [NSCacheDelegate];
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
var lv = new lvm.ListView();
|
||||
lv.items = data;
|
||||
lv.on(lvm.knownEvents.itemLoading, function(args){
|
||||
lv.on(lvm.ListView.itemLoadingEvent, function(args){
|
||||
var label = args.view;
|
||||
if(!label) {
|
||||
label = new lm.Label();
|
||||
|
||||
@@ -15,12 +15,6 @@ var ITEMSCHANGED = "_itemsChanged";
|
||||
var CHANGE = "change";
|
||||
var SEPARATORCOLOR = "separatorColor";
|
||||
|
||||
export module knownEvents {
|
||||
export var itemLoading = "itemLoading";
|
||||
export var itemTap = "itemTap";
|
||||
export var loadMoreItems = "loadMoreItems";
|
||||
}
|
||||
|
||||
export module knownTemplates {
|
||||
export var itemTemplate = "itemTemplate";
|
||||
}
|
||||
@@ -46,6 +40,9 @@ function onItemTemplatePropertyChanged(data: dependencyObservable.PropertyChange
|
||||
}
|
||||
|
||||
export class ListView extends view.View implements definition.ListView {
|
||||
public static itemLoadingEvent = "itemLoading";
|
||||
public static itemTapEvent = "itemTap";
|
||||
public static loadMoreItemsEvent = "loadMoreItems";
|
||||
|
||||
public static separatorColorProperty = new dependencyObservable.Property(
|
||||
SEPARATORCOLOR,
|
||||
|
||||
@@ -7,9 +7,9 @@ import proxy = require("ui/core/proxy");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import color = require("color");
|
||||
|
||||
var ITEMLOADING = common.knownEvents.itemLoading;
|
||||
var LOADMOREITEMS = common.knownEvents.loadMoreItems;
|
||||
var ITEMTAP = common.knownEvents.itemTap;
|
||||
var ITEMLOADING = common.ListView.itemLoadingEvent;
|
||||
var LOADMOREITEMS = common.ListView.loadMoreItemsEvent;
|
||||
var ITEMTAP = common.ListView.itemTapEvent;
|
||||
var REALIZED_INDEX = "realizedIndex";
|
||||
|
||||
// merge the exports of the common file with the exports of this file
|
||||
|
||||
47
ui/list-view/list-view.d.ts
vendored
47
ui/list-view/list-view.d.ts
vendored
@@ -7,26 +7,6 @@ declare module "ui/list-view" {
|
||||
import view = require("ui/core/view");
|
||||
import color = require("color");
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
export module knownEvents {
|
||||
/**
|
||||
* The name of event raised when item is loading inside the ListView.
|
||||
*/
|
||||
export var itemLoading: string;
|
||||
|
||||
/**
|
||||
* The name of event raised when ListView item is tapped.
|
||||
*/
|
||||
export var itemTap: string;
|
||||
|
||||
/**
|
||||
* The name of event raised when the ListView is scrolled so that its last item is visible.
|
||||
*/
|
||||
export var loadMoreItems: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Known template names.
|
||||
*/
|
||||
@@ -41,6 +21,19 @@ declare module "ui/list-view" {
|
||||
* Represents a view that shows items in a vertically scrolling list.
|
||||
*/
|
||||
export class ListView extends view.View {
|
||||
/**
|
||||
* String value used when hooking to itemLoading event.
|
||||
*/
|
||||
public static itemLoadingEvent: string;
|
||||
/**
|
||||
* String value used when hooking to itemTap event.
|
||||
*/
|
||||
public static itemTapEvent: string;
|
||||
/**
|
||||
* String value used when hooking to loadMoreItems event.
|
||||
*/
|
||||
public static loadMoreItemsEvent: string;
|
||||
|
||||
/**
|
||||
* Represents the observable property backing the items property of each ListView instance.
|
||||
*/
|
||||
@@ -92,7 +85,13 @@ declare module "ui/list-view" {
|
||||
*/
|
||||
refresh();
|
||||
|
||||
on(event: string, callback: (data: observable.EventData) => 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 View for the data at the specified index should be created.
|
||||
@@ -100,17 +99,17 @@ declare module "ui/list-view" {
|
||||
* Note, that the view property of the event data can be pre-initialized with
|
||||
* an old instance of a view, so that it can be reused.
|
||||
*/
|
||||
on(event: "itemLoading", callback: (args: ItemEventData) => void);
|
||||
on(event: "itemLoading", callback: (args: ItemEventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when an item inside the ListView is tapped.
|
||||
*/
|
||||
on(event: "itemTap", callback: (args: ItemEventData) => void);
|
||||
on(event: "itemTap", callback: (args: ItemEventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when the ListView is scrolled so that its last item is visible.
|
||||
*/
|
||||
on(event: "loadMoreItems", callback: (args: observable.EventData) => void);
|
||||
on(event: "loadMoreItems", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,9 +8,9 @@ import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import color = require("color");
|
||||
|
||||
var CELLIDENTIFIER = "cell";
|
||||
var ITEMLOADING = common.knownEvents.itemLoading;
|
||||
var LOADMOREITEMS = common.knownEvents.loadMoreItems;
|
||||
var ITEMTAP = common.knownEvents.itemTap;
|
||||
var ITEMLOADING = common.ListView.itemLoadingEvent;
|
||||
var LOADMOREITEMS = common.ListView.loadMoreItemsEvent;
|
||||
var ITEMTAP = common.ListView.itemTapEvent;
|
||||
var DEFAULT_HEIGHT = 80;
|
||||
|
||||
// merge the exports of the common file with the exports of this file
|
||||
|
||||
@@ -11,16 +11,13 @@ import enums = require("ui/enums");
|
||||
|
||||
var OPTIONS_MENU = "optionsMenu";
|
||||
|
||||
export module knownEvents {
|
||||
export var navigatedTo = "navigatedTo";
|
||||
export var tap = "tap";
|
||||
}
|
||||
|
||||
export module knownCollections {
|
||||
export var optionsMenu = "optionsMenu";
|
||||
}
|
||||
|
||||
export class Page extends contentView.ContentView implements dts.Page, view.AddArrayFromBuilder {
|
||||
public static navigatedToEvent = "navigatedTo";
|
||||
|
||||
private _navigationContext: any;
|
||||
|
||||
private _cssApplied: boolean;
|
||||
@@ -102,7 +99,7 @@ export class Page extends contentView.ContentView implements dts.Page, view.AddA
|
||||
public onNavigatedTo(context: any) {
|
||||
this._navigationContext = context;
|
||||
this.notify({
|
||||
eventName: knownEvents.navigatedTo,
|
||||
eventName: Page.navigatedToEvent,
|
||||
object: this,
|
||||
context: context
|
||||
});
|
||||
@@ -227,6 +224,7 @@ export class OptionsMenu implements dts.OptionsMenu {
|
||||
}
|
||||
|
||||
export class MenuItem extends bindable.Bindable implements dts.MenuItem {
|
||||
public static tapEvent = "tap";
|
||||
|
||||
public static textProperty = new dependencyObservable.Property(
|
||||
"text", "MenuItem", new dependencyObservable.PropertyMetadata("", null, MenuItem.onItemChanged));
|
||||
@@ -271,7 +269,7 @@ export class MenuItem extends bindable.Bindable implements dts.MenuItem {
|
||||
}
|
||||
|
||||
public _raiseTap() {
|
||||
this._emit(knownEvents.tap);
|
||||
this._emit(MenuItem.tapEvent);
|
||||
}
|
||||
|
||||
menu: OptionsMenu;
|
||||
|
||||
40
ui/page/page.d.ts
vendored
40
ui/page/page.d.ts
vendored
@@ -23,16 +23,6 @@ declare module "ui/page" {
|
||||
context: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates the known event names for the page module.
|
||||
*/
|
||||
export module knownEvents {
|
||||
/**
|
||||
* The event raised when the Page.onNavigatedTo method is called.
|
||||
*/
|
||||
export var navigatedTo: string;
|
||||
}
|
||||
|
||||
export module knownCollections {
|
||||
export var optionsMenu: string;
|
||||
}
|
||||
@@ -41,6 +31,10 @@ declare module "ui/page" {
|
||||
* Represents a logical unit for navigation (inside Frame).
|
||||
*/
|
||||
export class Page extends contentView.ContentView implements view.AddArrayFromBuilder {
|
||||
/**
|
||||
* String value used when hooking to navigatedTo event.
|
||||
*/
|
||||
public static navigatedToEvent: string;
|
||||
|
||||
constructor(options?: Options)
|
||||
|
||||
@@ -100,14 +94,17 @@ declare module "ui/page" {
|
||||
onNavigatedFrom(isBackNavigation: boolean): void;
|
||||
|
||||
/**
|
||||
* Raised when navigation to the page is finished.
|
||||
* 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(event: string, callback: (data: observable.EventData) => void);
|
||||
on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when navigation to the page is finished.
|
||||
*/
|
||||
on(event: "navigatedTo", callback: (args: NavigatedData) => void);
|
||||
on(event: "navigatedTo", callback: (args: NavigatedData) => void, thisArg?: any);
|
||||
|
||||
_addArrayFromBuilder(name: string, value: Array<any>): void;
|
||||
|
||||
@@ -144,6 +141,10 @@ declare module "ui/page" {
|
||||
}
|
||||
|
||||
export class MenuItem extends bindable.Bindable {
|
||||
/**
|
||||
* String value used when hooking to tap event.
|
||||
*/
|
||||
public static tapEvent: string;
|
||||
|
||||
/**
|
||||
* Represents the observable property backing the text property.
|
||||
@@ -158,7 +159,18 @@ declare module "ui/page" {
|
||||
text: string;
|
||||
icon: string;
|
||||
android: AndroidMenuItemOptions;
|
||||
on(event: string, callback: (data: observable.EventData) => 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);
|
||||
|
||||
/**
|
||||
* Raised when a tap event occurs.
|
||||
*/
|
||||
on(event: "tap", callback: (args: observable.EventData) => void);
|
||||
|
||||
//@private
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import definition = require("ui/placeholder");
|
||||
import view = require("ui/core/view");
|
||||
|
||||
export module knownEvents {
|
||||
export var creatingView = "creatingView";
|
||||
}
|
||||
|
||||
export class Placeholder extends view.View implements definition.Placeholder {
|
||||
public static creatingViewEvent = "creatingView";
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export class Placeholder extends common.Placeholder {
|
||||
private _android: android.view.View;
|
||||
|
||||
public _createUI() {
|
||||
var args = <definition.CreateViewEventData>{ eventName: common.knownEvents.creatingView, object: this, view: undefined, context: this._context };
|
||||
var args = <definition.CreateViewEventData>{ eventName: common.Placeholder.creatingViewEvent, object: this, view: undefined, context: this._context };
|
||||
this.notify(args);
|
||||
this._android = <android.view.View>args.view;
|
||||
}
|
||||
|
||||
24
ui/placeholder/placeholder.d.ts
vendored
24
ui/placeholder/placeholder.d.ts
vendored
@@ -5,18 +5,26 @@ declare module "ui/placeholder" {
|
||||
import view = require("ui/core/view");
|
||||
import observable = require("data/observable");
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
export module knownEvents {
|
||||
export var creatingView: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Placeholder, which is used to add a native view to the visual tree.
|
||||
*/
|
||||
export class Placeholder extends view.View {
|
||||
on(event: string, callback: (args: CreateViewEventData) => void);
|
||||
/**
|
||||
* String value used when hooking to creatingView event.
|
||||
*/
|
||||
public static creatingViewEvent: string;
|
||||
|
||||
/**
|
||||
* 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: (args: observable.EventData) => void);
|
||||
|
||||
/**
|
||||
* Raised when a creatingView event occurs.
|
||||
*/
|
||||
on(event: "creatingView", callback: (args: CreateViewEventData) => void);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export class Placeholder extends common.Placeholder {
|
||||
get ios(): UIView {
|
||||
if (!this._ios) {
|
||||
console.trace();
|
||||
var args = <definition.CreateViewEventData>{ eventName: common.knownEvents.creatingView, object: this, view: undefined, context: undefined };
|
||||
var args = <definition.CreateViewEventData>{ eventName: common.Placeholder.creatingViewEvent, object: this, view: undefined, context: undefined };
|
||||
super.notify(args);
|
||||
this._ios = args.view;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,10 @@ import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import proxy = require("ui/core/proxy");
|
||||
import color = require("color");
|
||||
|
||||
export module knownEvents {
|
||||
export var submit = "submit";
|
||||
export var clear = "clear";
|
||||
}
|
||||
|
||||
export class SearchBar extends view.View implements definition.SearchBar {
|
||||
public static submitEvent = "submit";
|
||||
public static clearEvent = "clear";
|
||||
|
||||
public static textFieldBackgroundColorProperty = new dependencyObservable.Property("textFieldBackgroundColor", "SearchBar", new proxy.PropertyMetadata(undefined))
|
||||
public static hintProperty = new dependencyObservable.Property("hint", "SearchBar", new proxy.PropertyMetadata(""))
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ export class SearchBar extends common.SearchBar {
|
||||
|
||||
// This code is needed since sometimes OnCloseListener is not called!
|
||||
if (newText === EMPTY && this[SEARCHTEXT] !== newText) {
|
||||
this.owner._emit(common.knownEvents.clear);
|
||||
this.owner._emit(common.SearchBar.clearEvent);
|
||||
}
|
||||
|
||||
this[SEARCHTEXT] = newText;
|
||||
@@ -104,7 +104,7 @@ export class SearchBar extends common.SearchBar {
|
||||
if (this.owner) {
|
||||
// This code is needed since onQueryTextSubmit is called twice with same query!
|
||||
if (query !== EMPTY && this[QUERY] !== query) {
|
||||
this.owner._emit(common.knownEvents.submit);
|
||||
this.owner._emit(common.SearchBar.submitEvent);
|
||||
}
|
||||
this[QUERY] = query;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ export class SearchBar extends common.SearchBar {
|
||||
|
||||
onClose: function () {
|
||||
if (this.owner) {
|
||||
this.owner._emit(common.knownEvents.clear);
|
||||
this.owner._emit(common.SearchBar.clearEvent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
37
ui/search-bar/search-bar.d.ts
vendored
37
ui/search-bar/search-bar.d.ts
vendored
@@ -7,25 +7,20 @@ declare module "ui/search-bar" {
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import color = require("color");
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
module knownEvents {
|
||||
/**
|
||||
* Raised when search request has been submitted.
|
||||
*/
|
||||
export var submit: string;
|
||||
|
||||
/**
|
||||
* Raised when search critea has been cleared.
|
||||
*/
|
||||
export var clear: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a search bar component.
|
||||
*/
|
||||
export class SearchBar extends view.View {
|
||||
/**
|
||||
* String value used when hooking to submit event.
|
||||
*/
|
||||
public static submitEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to clear event.
|
||||
*/
|
||||
public static clearEvent: string;
|
||||
|
||||
/**
|
||||
* Dependency property used to support binding operations related to search-bar text.
|
||||
*/
|
||||
@@ -61,16 +56,22 @@ declare module "ui/search-bar" {
|
||||
*/
|
||||
textFieldBackgroundColor: color.Color;
|
||||
|
||||
on(event: string, callback: (data: observable.EventData) => 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 search bar search is submitted.
|
||||
*/
|
||||
on(event: "submit", callback: (args: observable.EventData) => void);
|
||||
on(event: "submit", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when a search bar search is closed.
|
||||
*/
|
||||
on(event: "close", callback: (args: observable.EventData) => void);
|
||||
on(event: "close", callback: (args: observable.EventData) => void, thisArg?: any);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
|
||||
|
||||
// This code is needed since sometimes searchBarCancelButtonClicked is not called!
|
||||
if (searchText === "" && this._searchText !== searchText) {
|
||||
this._owner._emit(common.knownEvents.clear);
|
||||
this._owner._emit(common.SearchBar.clearEvent);
|
||||
}
|
||||
|
||||
this._searchText = searchText;
|
||||
@@ -78,12 +78,12 @@ class UISearchBarDelegateImpl extends NSObject implements UISearchBarDelegate {
|
||||
|
||||
public searchBarCancelButtonClicked(searchBar: UISearchBar) {
|
||||
searchBar.resignFirstResponder();
|
||||
this._owner._emit(common.knownEvents.clear);
|
||||
this._owner._emit(common.SearchBar.clearEvent);
|
||||
}
|
||||
|
||||
public searchBarSearchButtonClicked(searchBar: UISearchBar) {
|
||||
searchBar.resignFirstResponder();
|
||||
this._owner._emit(common.knownEvents.submit);
|
||||
this._owner._emit(common.SearchBar.submitEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ export class SlideOutControl extends common.SlideOutControl {
|
||||
|
||||
var owningFrame: frame.Frame = <frame.Frame>view.getAncestor(this, "Frame");
|
||||
if (owningFrame) {
|
||||
owningFrame.android.removeEventListener(frame.knownEvents.android.optionSelected, this._optionSelectedCallback);
|
||||
owningFrame.android.removeEventListener(frame.Frame.androidOptionSelectedEvent, this._optionSelectedCallback);
|
||||
this._optionsCallbackAdded = false;
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ export class SlideOutControl extends common.SlideOutControl {
|
||||
|
||||
var owningFrame: frame.Frame = <frame.Frame>view.getAncestor(this, "Frame");
|
||||
if (owningFrame) {
|
||||
owningFrame.android.addEventListener(frame.knownEvents.android.optionSelected, this._optionSelectedCallback);
|
||||
owningFrame.android.addEventListener(frame.Frame.androidOptionSelectedEvent, this._optionSelectedCallback);
|
||||
this._optionsCallbackAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export class TextBase extends view.View implements definition.TextBase {
|
||||
if (this.formattedText !== value) {
|
||||
var weakEventOptions: weakEventListener.WeakEventListenerOptions = {
|
||||
targetWeakRef: new WeakRef(this),
|
||||
eventName: observable.knownEvents.propertyChange,
|
||||
eventName: observable.Observable.propertyChangeEvent,
|
||||
sourceWeakRef: new WeakRef(value),
|
||||
handler: this.onFormattedTextChanged,
|
||||
handlerContext: this,
|
||||
|
||||
@@ -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