mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #316 from NativeScript/nnikolov/KnownEventRefactoring
Replace knownEvents modules with static strings.
This commit is contained in:
@@ -116,7 +116,7 @@ export class AppViewModel extends observable.Observable {
|
||||
set search(value: string) {
|
||||
if (this._search !== value) {
|
||||
this._search = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "search", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "search", value: value });
|
||||
|
||||
this.filter();
|
||||
}
|
||||
@@ -128,7 +128,7 @@ export class AppViewModel extends observable.Observable {
|
||||
set selectedIndex(value: number) {
|
||||
if (this._selectedIndex !== value) {
|
||||
this._selectedIndex = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "selectedIndex", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "selectedIndex", value: value });
|
||||
|
||||
this.set("dayHeader", conferenceDays[value].title);
|
||||
|
||||
@@ -150,7 +150,7 @@ export class AppViewModel extends observable.Observable {
|
||||
this._sessions = this._sessions.filter(i=> { return i.favorite });
|
||||
}
|
||||
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "sessions", value: this._sessions });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "sessions", value: this._sessions });
|
||||
}
|
||||
|
||||
public onDataLoaded() {
|
||||
@@ -171,7 +171,7 @@ export class AppViewModel extends observable.Observable {
|
||||
this.selectedViewIndex = 2;
|
||||
}
|
||||
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "selectedViewIndex", value: this.selectedViewIndex });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "selectedViewIndex", value: this.selectedViewIndex });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ export class SessionModel extends observable.Observable implements Session {
|
||||
set favorite(value: boolean) {
|
||||
if (this._favorite !== value) {
|
||||
this._favorite = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "favorite", value: this._favorite });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "favorite", value: this._favorite });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export class AppViewModel extends observable.Observable {
|
||||
if (!this._redditItems) {
|
||||
this._redditItems = new virtualArray.VirtualArray<redditViewModel.RedditViewModel>(1000);
|
||||
this._redditItems.loadSize = 50;
|
||||
this._redditItems.on(virtualArray.knownEvents.itemsLoading, (args: virtualArray.ItemsLoading) => {
|
||||
this._redditItems.on(virtualArray.VirtualArray.itemsLoadingEvent, (args: virtualArray.ItemsLoading) => {
|
||||
|
||||
http.getJSON<redditModel.Data>(redditUrl + args.count +
|
||||
(after ? "&after=" + after : "")).then(result => {
|
||||
@@ -69,7 +69,7 @@ export class AppViewModel extends observable.Observable {
|
||||
cache.enableDownload();
|
||||
}
|
||||
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: ISSCROLLING, value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: ISSCROLLING, value: value });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export class RedditViewModel extends observable.Observable {
|
||||
set isLoading(value: boolean) {
|
||||
if (this._isLoading !== value) {
|
||||
this._isLoading = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: ISLOADING, value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: ISLOADING, value: value });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ export class RedditViewModel extends observable.Observable {
|
||||
completed: (image: any, key: string) => {
|
||||
if (url === key) {
|
||||
this.isLoading = false;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: THUMBNAIL_IMAGE, value: image });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: THUMBNAIL_IMAGE, value: image });
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -87,7 +87,7 @@ export class RedditViewModel extends observable.Observable {
|
||||
|
||||
imageSource.fromUrl(url).then(result => {
|
||||
this.isLoading = false;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: IMAGE_SOURCE, value: result });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: IMAGE_SOURCE, value: result });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,6 @@ export class WebViewModel extends observable.Observable {
|
||||
set text(value: string) {
|
||||
console.log(value);
|
||||
this._text = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "text", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "text", value: value });
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ export function createPage() {
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.items = new Array(100);
|
||||
|
||||
listView.on(listViewModule.knownEvents.itemLoading, (args: listViewModule.ItemEventData) => {
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, (args: listViewModule.ItemEventData) => {
|
||||
var StackLayout = <stackLayoutModule.StackLayout>args.view;
|
||||
if (!StackLayout) {
|
||||
StackLayout = createListViewItemFunc();
|
||||
|
||||
@@ -36,7 +36,7 @@ export function createPage() {
|
||||
mainStackLayout.addChild(childStackLayout);
|
||||
for (var j = 0; j < buttonsPerRow; j++) {
|
||||
button = new buttonModule.Button();
|
||||
button.on(buttonModule.knownEvents.tap, function (data) {
|
||||
button.on(buttonModule.Button.tapEvent, function (data) {
|
||||
trace.write("eventName=" + data.eventName + " object=" + data.object, trace.categories.Test, trace.messageType.info);
|
||||
});
|
||||
button.text = "" + i + j;
|
||||
|
||||
@@ -27,7 +27,7 @@ export function createPage() {
|
||||
var button = new buttonModule.Button();
|
||||
button.text = text;
|
||||
button.width = 40;
|
||||
button.on(buttonModule.knownEvents.tap, function (eventData) {
|
||||
button.on(buttonModule.Button.tapEvent, function (eventData) {
|
||||
count = ((<any>eventData.object).text) * 1000;
|
||||
countLabel.text = "Create " + count + " objects of type:";
|
||||
});
|
||||
@@ -79,7 +79,7 @@ export function createPage() {
|
||||
var addControlButtonFunc = function (text) {
|
||||
var button = new buttonModule.Button();
|
||||
button.text = text;
|
||||
button.on(buttonModule.knownEvents.tap, onClickHandler);
|
||||
button.on(buttonModule.Button.tapEvent, onClickHandler);
|
||||
mainLayout.addChild(button);
|
||||
};
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export function createPage() {
|
||||
var startButtonClickHandler = function () {
|
||||
allocateMemory();
|
||||
};
|
||||
startButton.on(buttonModule.knownEvents.tap, startButtonClickHandler);
|
||||
startButton.on(buttonModule.Button.tapEvent, startButtonClickHandler);
|
||||
|
||||
var stopButton = new buttonModule.Button();
|
||||
stopButton.height = 50;
|
||||
@@ -34,7 +34,7 @@ export function createPage() {
|
||||
var stopButtonClickHandler = function () {
|
||||
nativeCallsWrapper.forceGarbageCollection();
|
||||
};
|
||||
stopButton.on(buttonModule.knownEvents.tap, stopButtonClickHandler);
|
||||
stopButton.on(buttonModule.Button.tapEvent, stopButtonClickHandler);
|
||||
|
||||
mainStackLayout.addChild(startButton);
|
||||
mainStackLayout.addChild(stopButton);
|
||||
|
||||
@@ -16,7 +16,7 @@ export function createPage() {
|
||||
var forwardIntervalId;
|
||||
var backIntervalId;
|
||||
|
||||
startButton.on(buttonModule.knownEvents.tap, function () {
|
||||
startButton.on(buttonModule.Button.tapEvent, function () {
|
||||
|
||||
forwardIntervalId = setInterval(function () {
|
||||
console.log("Navigating to controls page...");
|
||||
|
||||
@@ -13,13 +13,13 @@ export function createPage() {
|
||||
|
||||
var backButton = new buttonModule.Button();
|
||||
backButton.text = "< back";
|
||||
backButton.on(buttonModule.knownEvents.tap, () => { page.frame.goBack(); });
|
||||
backButton.on(buttonModule.Button.tapEvent, () => { page.frame.goBack(); });
|
||||
stackLayout.addChild(backButton);
|
||||
|
||||
var label = new labelModule.Label();
|
||||
stackLayout.addChild(label);
|
||||
|
||||
page.on(pagesModule.knownEvents.navigatedTo, () => {
|
||||
page.on(pagesModule.Page.navigatedToEvent, () => {
|
||||
var item = page.navigationContext;
|
||||
label.text = "I am detail for " + item;
|
||||
});
|
||||
@@ -30,7 +30,7 @@ export function createPage() {
|
||||
|
||||
var actionButton = new buttonModule.Button();
|
||||
actionButton.text = "Copy";
|
||||
actionButton.on(buttonModule.knownEvents.tap, () => {
|
||||
actionButton.on(buttonModule.Button.tapEvent, () => {
|
||||
label.text = textField.text;
|
||||
});
|
||||
stackLayout.addChild(actionButton);
|
||||
|
||||
@@ -14,7 +14,7 @@ export function createPage() {
|
||||
listView.height = 200;
|
||||
var itemsSource = [1, 2, 3];
|
||||
|
||||
listView.on(listViewModule.knownEvents.itemLoading, (args: listViewModule.ItemEventData) => {
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, (args: listViewModule.ItemEventData) => {
|
||||
var label = <labelModule.Label>args.view;
|
||||
if (!label) {
|
||||
label = new labelModule.Label();
|
||||
@@ -28,7 +28,7 @@ export function createPage() {
|
||||
}
|
||||
});
|
||||
|
||||
listView.on(listViewModule.knownEvents.itemTap, (args: listViewModule.ItemEventData) => {
|
||||
listView.on(listViewModule.ListView.itemTapEvent, (args: listViewModule.ItemEventData) => {
|
||||
var navigationEntry = {
|
||||
moduleName: "NavigationTest/details-page",
|
||||
context: itemsSource[args.index]
|
||||
@@ -49,7 +49,7 @@ export function createPage() {
|
||||
|
||||
var actionButton = new buttonModule.Button();
|
||||
actionButton.text = "Copy";
|
||||
actionButton.on(buttonModule.knownEvents.tap, () => {
|
||||
actionButton.on(buttonModule.Button.tapEvent, () => {
|
||||
label.text = textField.text;
|
||||
});
|
||||
stackLayout.addChild(actionButton);
|
||||
|
||||
@@ -14,14 +14,14 @@ export function createPage() {
|
||||
|
||||
var changeStateButton = new buttonModule.Button();
|
||||
changeStateButton.text = "CHANGE STATE";
|
||||
changeStateButton.on(buttonModule.knownEvents.tap, () => {
|
||||
changeStateButton.on(buttonModule.Button.tapEvent, () => {
|
||||
stateLabel.text = "CHANGED STATE";
|
||||
});
|
||||
stackLayout.addChild(changeStateButton);
|
||||
|
||||
var navigateButton = new buttonModule.Button();
|
||||
navigateButton.text = "->";
|
||||
navigateButton.on(buttonModule.knownEvents.tap, () => {
|
||||
navigateButton.on(buttonModule.Button.tapEvent, () => {
|
||||
page.frame.navigate("NavigationTest/page2");
|
||||
});
|
||||
stackLayout.addChild(navigateButton);
|
||||
|
||||
@@ -11,7 +11,7 @@ export function createPage() {
|
||||
|
||||
var backButton = new buttonModule.Button();
|
||||
backButton.text = "<-";
|
||||
backButton.on(buttonModule.knownEvents.tap, () => { page.frame.goBack(); });
|
||||
backButton.on(buttonModule.Button.tapEvent, () => { page.frame.goBack(); });
|
||||
stackLayout.addChild(backButton);
|
||||
|
||||
page.content = stackLayout;
|
||||
|
||||
@@ -18,13 +18,13 @@ export function createPage() {
|
||||
var startButton = new buttonModule.Button();
|
||||
startButton.text = "Start timer";
|
||||
var intervalId;
|
||||
startButton.addEventListener(buttonModule.knownEvents.tap, function () {
|
||||
startButton.addEventListener(buttonModule.Button.tapEvent, function () {
|
||||
intervalId = timer.setInterval(intervalCallback, 100);
|
||||
});
|
||||
|
||||
var stopButton = new buttonModule.Button();
|
||||
stopButton.text = "Stop timer";
|
||||
stopButton.addEventListener(buttonModule.knownEvents.tap, function () {
|
||||
stopButton.addEventListener(buttonModule.Button.tapEvent, function () {
|
||||
timer.clearInterval(intervalId);
|
||||
});
|
||||
|
||||
|
||||
@@ -23,21 +23,21 @@ export function createPage() {
|
||||
var dataMarshallingButton0 = new buttonModule.Button();
|
||||
dataMarshallingButton0.text = "Compare JavaScript dates 10000 times";
|
||||
mainLayout.addChild(dataMarshallingButton0);
|
||||
dataMarshallingButton0.on(buttonModule.knownEvents.tap, function () {
|
||||
dataMarshallingButton0.on(buttonModule.Button.tapEvent, function () {
|
||||
resultsLabel.text = testsModule.compareJavaScriptDates(10000);
|
||||
});
|
||||
|
||||
var dataMarshallingButton1 = new buttonModule.Button();
|
||||
dataMarshallingButton1.text = "Compare Native dates 10000 times";
|
||||
mainLayout.addChild(dataMarshallingButton1);
|
||||
dataMarshallingButton1.on(buttonModule.knownEvents.tap, function () {
|
||||
dataMarshallingButton1.on(buttonModule.Button.tapEvent, function () {
|
||||
resultsLabel.text = testsModule.compareNativeDates(10000);
|
||||
});
|
||||
|
||||
var dataMarshallingButton2 = new buttonModule.Button();
|
||||
dataMarshallingButton2.text = "Bitmap -> byte[] -> Bitmap 200 times";
|
||||
mainLayout.addChild(dataMarshallingButton2);
|
||||
dataMarshallingButton2.on(buttonModule.knownEvents.tap, function () {
|
||||
dataMarshallingButton2.on(buttonModule.Button.tapEvent, function () {
|
||||
testsModule.decodeAndEncodeBitmap(200, function (message) {
|
||||
resultsLabel.text = message;
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ export class ControlsPage extends pagesModule.Page implements definition.Control
|
||||
|
||||
var goBackButton = new buttonModule.Button();
|
||||
goBackButton.text = "Back";
|
||||
goBackButton.on(buttonModule.knownEvents.tap, function () {
|
||||
goBackButton.on(buttonModule.Button.tapEvent, function () {
|
||||
frameModule.topmost().goBack();
|
||||
});
|
||||
this._mainLayout.addChild(goBackButton);
|
||||
|
||||
@@ -16,7 +16,7 @@ export class NavPage extends pagesModule.Page implements definition.ControlsPage
|
||||
|
||||
var goBackButton = new buttonModule.Button();
|
||||
goBackButton.text = "<-";
|
||||
goBackButton.on(buttonModule.knownEvents.tap, function () {
|
||||
goBackButton.on(buttonModule.Button.tapEvent, function () {
|
||||
frameModule.topmost().goBack();
|
||||
});
|
||||
stackLayout.addChild(goBackButton);
|
||||
@@ -32,7 +32,7 @@ export class NavPage extends pagesModule.Page implements definition.ControlsPage
|
||||
var changeStateButton = new buttonModule.Button();
|
||||
changeStateButton.text = "Click me!"
|
||||
var clickCount = 0;
|
||||
changeStateButton.on(buttonModule.knownEvents.tap, () => {
|
||||
changeStateButton.on(buttonModule.Button.tapEvent, () => {
|
||||
//stateLabel.text = "<<<CHANGED STATE>>>";
|
||||
//textField.text = "<<<CHANGED STATE>>>";
|
||||
changeStateButton.text = (clickCount++).toString();
|
||||
@@ -41,7 +41,7 @@ export class NavPage extends pagesModule.Page implements definition.ControlsPage
|
||||
|
||||
var forwardButton = new buttonModule.Button();
|
||||
forwardButton.text = "->";
|
||||
forwardButton.on(buttonModule.knownEvents.tap, function () {
|
||||
forwardButton.on(buttonModule.Button.tapEvent, function () {
|
||||
var pageFactory = function () {
|
||||
return new NavPage(id + 1);
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ export class WebViewModel extends observable.Observable {
|
||||
set selectedIndex(value: number) {
|
||||
console.log("selectedIndex:" + value);
|
||||
this._selectedIndex = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "selectedIndex", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "selectedIndex", value: value });
|
||||
}
|
||||
|
||||
private _items: Array<string>
|
||||
@@ -22,7 +22,7 @@ export class WebViewModel extends observable.Observable {
|
||||
set items(value: Array<string>) {
|
||||
console.log("items:" + value);
|
||||
this._items = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "items", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "items", value: value });
|
||||
}
|
||||
|
||||
private _day: number;
|
||||
@@ -32,7 +32,7 @@ export class WebViewModel extends observable.Observable {
|
||||
set day(value: number) {
|
||||
console.log("day:" + value);
|
||||
this._day = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "day", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "day", value: value });
|
||||
}
|
||||
|
||||
private _month: number;
|
||||
@@ -42,7 +42,7 @@ export class WebViewModel extends observable.Observable {
|
||||
set month(value: number) {
|
||||
console.log("month:" + value);
|
||||
this._month = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "month", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "month", value: value });
|
||||
}
|
||||
|
||||
private _year: number;
|
||||
@@ -52,7 +52,7 @@ export class WebViewModel extends observable.Observable {
|
||||
set year(value: number) {
|
||||
console.log("year:" + value);
|
||||
this._year = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "year", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "year", value: value });
|
||||
}
|
||||
|
||||
private _hour: number;
|
||||
@@ -62,7 +62,7 @@ export class WebViewModel extends observable.Observable {
|
||||
set hour(value: number) {
|
||||
console.log("hour:" + value);
|
||||
this._hour = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "hour", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "hour", value: value });
|
||||
}
|
||||
|
||||
private _minute: number;
|
||||
@@ -72,6 +72,6 @@ export class WebViewModel extends observable.Observable {
|
||||
set minute(value: number) {
|
||||
console.log("minute:" + value);
|
||||
this._minute = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "minute", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "minute", value: value });
|
||||
}
|
||||
}
|
||||
@@ -37,13 +37,13 @@ export function createPage() {
|
||||
}
|
||||
}
|
||||
var clickHandler = clickHandlerFactory(nextIndex, length);
|
||||
goToNextTabButton.on(buttonModule.knownEvents.tap, clickHandler);
|
||||
goToNextTabButton.on(buttonModule.Button.tapEvent, clickHandler);
|
||||
|
||||
// Second button
|
||||
var navigateToAnotherPageButton = new buttonModule.Button();
|
||||
navigateToAnotherPageButton.text = "Navigate to another page";
|
||||
stackLayout.addChild(navigateToAnotherPageButton);
|
||||
navigateToAnotherPageButton.on(buttonModule.knownEvents.tap, function () {
|
||||
navigateToAnotherPageButton.on(buttonModule.Button.tapEvent, function () {
|
||||
var pageFactory = function () {
|
||||
return new navPageModule.NavPage(0);
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ textView.style.fontSize = 8;
|
||||
export function createPage() {
|
||||
var button = new bm.Button();
|
||||
button.text = "Run Tests";
|
||||
button.on(bm.knownEvents.tap, function () {
|
||||
button.on(bm.Button.tapEvent, function () {
|
||||
tests.runAll();
|
||||
});
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export function createPage() {
|
||||
|
||||
var button = new buttonModule.Button();
|
||||
button.text = "Test";
|
||||
button.on(buttonModule.knownEvents.tap, function () {
|
||||
button.on(buttonModule.Button.tapEvent, function () {
|
||||
var topFrame = frame.topmost();
|
||||
topFrame.goBack();
|
||||
});
|
||||
|
||||
@@ -14,10 +14,10 @@ export function createPage() {
|
||||
|
||||
var listView = new listViewDef.ListView();
|
||||
|
||||
listView.on(listViewDef.knownEvents.itemLoading, (args: listViewDef.ItemEventData) => {
|
||||
listView.on(listViewDef.ListView.itemLoadingEvent, (args: listViewDef.ItemEventData) => {
|
||||
var btn = <bm.Button> args.view;
|
||||
if (btn) {
|
||||
btn.off(bm.knownEvents.tap);
|
||||
btn.off(bm.Button.tapEvent);
|
||||
}
|
||||
else {
|
||||
btn = new bm.Button();
|
||||
@@ -26,13 +26,13 @@ export function createPage() {
|
||||
|
||||
if (!data[args.index]) {
|
||||
btn.text = "Run all";
|
||||
btn.on(bm.knownEvents.tap, function () {
|
||||
btn.on(bm.Button.tapEvent, function () {
|
||||
tests.runAll();
|
||||
});
|
||||
} else {
|
||||
var testModule = data[args.index];
|
||||
btn.text = testModule;
|
||||
btn.on(bm.knownEvents.tap, function () {
|
||||
btn.on(bm.Button.tapEvent, function () {
|
||||
tests.runAll(testModule);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ export var test_ObservableArray_popShouldRemoveTheLastElementAndRaiseChangeEvent
|
||||
var index = array.length - 1;
|
||||
// </hide>
|
||||
|
||||
array.on(observableArrayModule.knownEvents.change, (args: observableArrayModule.ChangedData<number>) => {
|
||||
array.on(observableArrayModule.ObservableArray.changeEvent, (args: observableArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "delete".
|
||||
@@ -148,7 +148,7 @@ export var test_ObservableArray_popShouldRemoveTheLastElementAndRaiseChangeEvent
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(result.eventName === observableArrayModule.knownEvents.change && result.action === observableArrayModule.ChangeType.Delete &&
|
||||
TKUnit.assert(result.eventName === observableArrayModule.ObservableArray.changeEvent && result.action === observableArrayModule.ChangeType.Delete &&
|
||||
result.removed.length === 1 && result.index === index && result.addedCount === 0, "ObservableArray pop() should raise 'change' event with correct args!");
|
||||
};
|
||||
|
||||
@@ -176,7 +176,7 @@ export var test_ObservableArray_pushShouldAppendNewElementAndRaiseChangeEventWit
|
||||
// ### Handle "change" event to know more info about the change after calling push() method with single element.
|
||||
// ``` JavaScript
|
||||
var array = new observableArrayModule.ObservableArray([1, 2, 3]);
|
||||
array.on(observableArrayModule.knownEvents.change, (args: observableArrayModule.ChangedData<number>) => {
|
||||
array.on(observableArrayModule.ObservableArray.changeEvent, (args: observableArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "add".
|
||||
@@ -193,7 +193,7 @@ export var test_ObservableArray_pushShouldAppendNewElementAndRaiseChangeEventWit
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(result.eventName === observableArrayModule.knownEvents.change && result.action === observableArrayModule.ChangeType.Add &&
|
||||
TKUnit.assert(result.eventName === observableArrayModule.ObservableArray.changeEvent && result.action === observableArrayModule.ChangeType.Add &&
|
||||
result.removed.length === 0 && result.index === 3 && result.addedCount === 1, "ObservableArray push() should raise 'change' event with correct args!");
|
||||
};
|
||||
|
||||
@@ -221,7 +221,7 @@ export var test_ObservableArray_pushShouldAppendNewElementsAndRaiseChangeEventWi
|
||||
// ### Handle "change" event to know more info about the change after calling push() method with multiple elements.
|
||||
// ``` JavaScript
|
||||
var array = new observableArrayModule.ObservableArray([1, 2, 3]);
|
||||
array.on(observableArrayModule.knownEvents.change, (args: observableArrayModule.ChangedData<number>) => {
|
||||
array.on(observableArrayModule.ObservableArray.changeEvent, (args: observableArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "add".
|
||||
@@ -238,7 +238,7 @@ export var test_ObservableArray_pushShouldAppendNewElementsAndRaiseChangeEventWi
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(result.eventName === observableArrayModule.knownEvents.change && result.action === observableArrayModule.ChangeType.Add &&
|
||||
TKUnit.assert(result.eventName === observableArrayModule.ObservableArray.changeEvent && result.action === observableArrayModule.ChangeType.Add &&
|
||||
result.removed.length === 0 && result.index === 3 && result.addedCount === 3, "ObservableArray push() should raise 'change' event with correct args!");
|
||||
};
|
||||
|
||||
@@ -266,7 +266,7 @@ export var test_ObservableArray_pushShouldAppendNewElementsFromSourceArrayAndRai
|
||||
// ### Handle "change" event to know more info about the change after calling push() method with multiple elements from source array.
|
||||
// ``` JavaScript
|
||||
var array = new observableArrayModule.ObservableArray([1, 2, 3]);
|
||||
array.on(observableArrayModule.knownEvents.change, (args: observableArrayModule.ChangedData<number>) => {
|
||||
array.on(observableArrayModule.ObservableArray.changeEvent, (args: observableArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "add".
|
||||
@@ -283,7 +283,7 @@ export var test_ObservableArray_pushShouldAppendNewElementsFromSourceArrayAndRai
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(result.eventName === observableArrayModule.knownEvents.change && result.action === observableArrayModule.ChangeType.Add &&
|
||||
TKUnit.assert(result.eventName === observableArrayModule.ObservableArray.changeEvent && result.action === observableArrayModule.ChangeType.Add &&
|
||||
result.removed.length === 0 && result.index === 3 && result.addedCount === 3, "ObservableArray push() should raise 'change' event with correct args!");
|
||||
};
|
||||
|
||||
@@ -323,7 +323,7 @@ export var test_ObservableArray_shiftShouldRemoveTheFirstElementAndRaiseChangeEv
|
||||
// ``` JavaScript
|
||||
var array = new observableArrayModule.ObservableArray([1, 2, 3]);
|
||||
|
||||
array.on(observableArrayModule.knownEvents.change, (args: observableArrayModule.ChangedData<number>) => {
|
||||
array.on(observableArrayModule.ObservableArray.changeEvent, (args: observableArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "delete".
|
||||
@@ -340,7 +340,7 @@ export var test_ObservableArray_shiftShouldRemoveTheFirstElementAndRaiseChangeEv
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(result.eventName === observableArrayModule.knownEvents.change && result.action === observableArrayModule.ChangeType.Delete &&
|
||||
TKUnit.assert(result.eventName === observableArrayModule.ObservableArray.changeEvent && result.action === observableArrayModule.ChangeType.Delete &&
|
||||
result.removed.length === 1 && result.index === 0 && result.addedCount === 0, "ObservableArray shift() should raise 'change' event with correct args!");
|
||||
};
|
||||
|
||||
@@ -414,7 +414,7 @@ export var test_ObservableArray_spliceShouldRemoveSpecifiedNumberOfElementsStart
|
||||
// ``` JavaScript
|
||||
var array = new observableArrayModule.ObservableArray([1, 2, 3]);
|
||||
|
||||
array.on(observableArrayModule.knownEvents.change, (args: observableArrayModule.ChangedData<number>) => {
|
||||
array.on(observableArrayModule.ObservableArray.changeEvent, (args: observableArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "splice".
|
||||
@@ -431,7 +431,7 @@ export var test_ObservableArray_spliceShouldRemoveSpecifiedNumberOfElementsStart
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(result.eventName === observableArrayModule.knownEvents.change && result.action === observableArrayModule.ChangeType.Splice &&
|
||||
TKUnit.assert(result.eventName === observableArrayModule.ObservableArray.changeEvent && result.action === observableArrayModule.ChangeType.Splice &&
|
||||
result.removed.length === 2 && result.index === 1 && result.addedCount === 0, "ObservableArray splice() should raise 'change' event with correct args!");
|
||||
};
|
||||
|
||||
@@ -455,7 +455,7 @@ export var test_ObservableArray_spliceShouldRemoveAndInertSpecifiedNumberOfEleme
|
||||
// ``` JavaScript
|
||||
var array = new observableArrayModule.ObservableArray(["one", "two", "three"]);
|
||||
|
||||
array.on(observableArrayModule.knownEvents.change, (args: observableArrayModule.ChangedData<number>) => {
|
||||
array.on(observableArrayModule.ObservableArray.changeEvent, (args: observableArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "splice".
|
||||
@@ -472,7 +472,7 @@ export var test_ObservableArray_spliceShouldRemoveAndInertSpecifiedNumberOfEleme
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(result.eventName === observableArrayModule.knownEvents.change && result.action === observableArrayModule.ChangeType.Splice &&
|
||||
TKUnit.assert(result.eventName === observableArrayModule.ObservableArray.changeEvent && result.action === observableArrayModule.ChangeType.Splice &&
|
||||
result.removed.length === 2 && result.index === 1 && result.addedCount === 1, "ObservableArray splice() should raise 'change' event with correct args!");
|
||||
};
|
||||
|
||||
@@ -501,7 +501,7 @@ export var test_ObservableArray_unshiftShouldInsertNewElementsFromTheStartAndRai
|
||||
// ### Handle "change" event to know more info about the change after calling unshift(item1, item2... itemN) method.
|
||||
// ``` JavaScript
|
||||
var array = new observableArrayModule.ObservableArray([1, 2, 3]);
|
||||
array.on(observableArrayModule.knownEvents.change, (args: observableArrayModule.ChangedData<number>) => {
|
||||
array.on(observableArrayModule.ObservableArray.changeEvent, (args: observableArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "add".
|
||||
@@ -518,7 +518,7 @@ export var test_ObservableArray_unshiftShouldInsertNewElementsFromTheStartAndRai
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(result.eventName === observableArrayModule.knownEvents.change && result.action === observableArrayModule.ChangeType.Add &&
|
||||
TKUnit.assert(result.eventName === observableArrayModule.ObservableArray.changeEvent && result.action === observableArrayModule.ChangeType.Add &&
|
||||
result.removed.length === 0 && result.index === 0 && result.addedCount === 2, "ObservableArray unshift() should raise 'change' event with correct args!");
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export function createPage() {
|
||||
|
||||
var btn = new button.Button();
|
||||
btn.text = "Page B new activity";
|
||||
btn.on(button.knownEvents.tap, function () {
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
var nextPage = "tests/pages/navigation/pageB-new-activity";
|
||||
frame.topmost().navigate(nextPage);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ export function createPage() {
|
||||
|
||||
var btn = new button.Button();
|
||||
btn.text = "Page B";
|
||||
btn.on(button.knownEvents.tap, function () {
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
var nextPage = "tests/pages/navigation/pageB";
|
||||
frame.topmost().navigate(nextPage);
|
||||
});
|
||||
@@ -24,7 +24,7 @@ export function createPage() {
|
||||
|
||||
var btnActivity = new button.Button();
|
||||
btnActivity.text = "start activity";
|
||||
btnActivity.on(button.knownEvents.tap, function () {
|
||||
btnActivity.on(button.Button.tapEvent, function () {
|
||||
var newPage = "tests/pages/navigation/pageA-new-activity";
|
||||
|
||||
var newFrame = new frame.Frame();
|
||||
@@ -43,7 +43,7 @@ export function createPage() {
|
||||
}
|
||||
lv.height = 200;
|
||||
lv.items = data;
|
||||
lv.on(list.knownEvents.itemLoading, (args: list.ItemEventData) => {
|
||||
lv.on(list.ListView.itemLoadingEvent, (args: list.ItemEventData) => {
|
||||
var btn = <button.Button> args.view;
|
||||
if (!btn) {
|
||||
btn = new button.Button();
|
||||
|
||||
@@ -10,7 +10,7 @@ export function createPage() {
|
||||
|
||||
var btn = new button.Button();
|
||||
btn.text = "Page C new activity";
|
||||
btn.on(button.knownEvents.tap, function () {
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
var nextPage = "tests/pages/navigation/pageC-new-activity";
|
||||
frame.topmost().navigate(nextPage);
|
||||
});
|
||||
@@ -18,7 +18,7 @@ export function createPage() {
|
||||
|
||||
var backBtn = new button.Button();
|
||||
backBtn.text = "BACK";
|
||||
backBtn.on(button.knownEvents.tap, function () {
|
||||
backBtn.on(button.Button.tapEvent, function () {
|
||||
frame.topmost().goBack();
|
||||
});
|
||||
stack.addChild(backBtn);
|
||||
|
||||
@@ -13,7 +13,7 @@ export function createPage() {
|
||||
|
||||
var btn = new button.Button();
|
||||
btn.text = "Page C";
|
||||
btn.on(button.knownEvents.tap, function () {
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
var nextPage = "tests/pages/navigation/pageC";
|
||||
frame.topmost().navigate(nextPage);
|
||||
});
|
||||
@@ -21,7 +21,7 @@ export function createPage() {
|
||||
|
||||
var btnActivity = new button.Button();
|
||||
btnActivity.text = "start activity";
|
||||
btnActivity.on(button.knownEvents.tap, function () {
|
||||
btnActivity.on(button.Button.tapEvent, function () {
|
||||
var newFrame = new frame.Frame();
|
||||
var newPage = "tests/pages/navigation/pageA-new-activity";
|
||||
newFrame.navigate(newPage);
|
||||
@@ -30,7 +30,7 @@ export function createPage() {
|
||||
|
||||
var backBtn = new button.Button();
|
||||
backBtn.text = "BACK";
|
||||
backBtn.on(button.knownEvents.tap, function () {
|
||||
backBtn.on(button.Button.tapEvent, function () {
|
||||
frame.topmost().goBack();
|
||||
});
|
||||
stack.addChild(backBtn);
|
||||
|
||||
@@ -10,7 +10,7 @@ export function createPage() {
|
||||
|
||||
var btn = new button.Button();
|
||||
btn.text = "Page A ???";
|
||||
btn.on(button.knownEvents.tap, function () {
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
var newPage = "tests/pages/navigation/pageA";
|
||||
frame.topmost().navigate(newPage);
|
||||
});
|
||||
@@ -18,7 +18,7 @@ export function createPage() {
|
||||
|
||||
var backBtn = new button.Button();
|
||||
backBtn.text = "BACK";
|
||||
backBtn.on(button.knownEvents.tap, function () {
|
||||
backBtn.on(button.Button.tapEvent, function () {
|
||||
frame.topmost().goBack();
|
||||
});
|
||||
stack.addChild(backBtn);
|
||||
|
||||
@@ -10,7 +10,7 @@ export function createPage() {
|
||||
|
||||
var newActivity = new button.Button();
|
||||
newActivity.text = "start activity";
|
||||
newActivity.on(button.knownEvents.tap, function () {
|
||||
newActivity.on(button.Button.tapEvent, function () {
|
||||
var newFrame = new frame.Frame();
|
||||
var newPage = "tests/pages/navigation/pageA-new-activity";
|
||||
newFrame.navigate(newPage);
|
||||
@@ -19,7 +19,7 @@ export function createPage() {
|
||||
|
||||
var btn = new button.Button();
|
||||
btn.text = "Page A ???";
|
||||
btn.on(button.knownEvents.tap, function () {
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
var nextPage = "tests/pages/navigation/pageA";
|
||||
frame.topmost().navigate(nextPage);
|
||||
});
|
||||
@@ -27,7 +27,7 @@ export function createPage() {
|
||||
|
||||
var backBtn = new button.Button();
|
||||
backBtn.text = "BACK";
|
||||
backBtn.on(button.knownEvents.tap, function () {
|
||||
backBtn.on(button.Button.tapEvent, function () {
|
||||
frame.topmost().goBack();
|
||||
});
|
||||
stack.addChild(backBtn);
|
||||
|
||||
@@ -52,7 +52,7 @@ export function createPage() {
|
||||
//page.content = GridLayout;
|
||||
page.content = StackLayout;
|
||||
var x = 1;
|
||||
btn1.on(button.knownEvents.tap, function () {
|
||||
btn1.on(button.Button.tapEvent, function () {
|
||||
x++;
|
||||
var gravity;
|
||||
//btn1.android.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT));
|
||||
|
||||
@@ -12,7 +12,7 @@ export function createPage() {
|
||||
var vAligns = ["stretch", "top", "center", "bottom"];
|
||||
//var hAligns = ["stretch", "left", "center", "right"];
|
||||
var count = 0;
|
||||
btn.on(buttons.knownEvents.tap, function () {
|
||||
btn.on(buttons.Button.tapEvent, function () {
|
||||
//page.css = "button { vertical-align:" + vAligns[(count++) % 4] + " }";
|
||||
btn.verticalAlignment = vAligns[(count++) % 4];
|
||||
})
|
||||
|
||||
@@ -39,7 +39,7 @@ export function createPage() {
|
||||
var counter = 0;
|
||||
var btn = new btns.Button();
|
||||
btn.text = "tap";
|
||||
btn.on(btns.knownEvents.tap, function () {
|
||||
btn.on(btns.Button.tapEvent, function () {
|
||||
btn.text = "hi: " + counter++;
|
||||
});
|
||||
btn.isEnabled = false;
|
||||
@@ -50,7 +50,7 @@ export function createPage() {
|
||||
var info = new btns.Button();
|
||||
info.text = "info";
|
||||
info.cssClass = "info";
|
||||
info.on(btns.knownEvents.tap, function () {
|
||||
info.on(btns.Button.tapEvent, function () {
|
||||
info.text = "hi: " + counter++;
|
||||
btn.isEnabled = true;
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ export function createPage() {
|
||||
var count = 0;
|
||||
var control = new btns.Button();
|
||||
control.text = "test control";
|
||||
control.on(btns.knownEvents.tap, (data) => { control.text = "count: " + count++; });
|
||||
control.on(btns.Button.tapEvent, (data) => { control.text = "count: " + count++; });
|
||||
grid.addChild(control);
|
||||
|
||||
var scrollView = new scroll.ScrollView();
|
||||
|
||||
@@ -26,15 +26,15 @@ export var test_FormattedString_RemovesEventListeners_for_spans = function () {
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assert(formattedString.spans.getItem(0).hasListeners(observable.knownEvents.propertyChange) === true, "Listener for spans collection change event is not attached!");
|
||||
TKUnit.assert(formattedString.spans.getItem(0).hasListeners(observable.Observable.propertyChangeEvent) === true, "Listener for spans collection change event is not attached!");
|
||||
var removedSpan = formattedString.spans.pop();
|
||||
TKUnit.assert(removedSpan.hasListeners(observable.knownEvents.propertyChange) === false, "Listener for spans collection change event is not removed!");
|
||||
TKUnit.assert(removedSpan.hasListeners(observable.Observable.propertyChangeEvent) === false, "Listener for spans collection change event is not removed!");
|
||||
}
|
||||
|
||||
export var test_FormattedTextProperty_IsChanged_When_SpanIsAdded = function () {
|
||||
var formattedString = new formattedStringModule.FormattedString();
|
||||
var formattedTextChanged = false;
|
||||
formattedString.addEventListener(observable.knownEvents.propertyChange, () => {
|
||||
formattedString.addEventListener(observable.Observable.propertyChangeEvent, () => {
|
||||
formattedTextChanged = true;
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ export var test_FormattedTextProperty_IsChanged_When_SpanIsChanged = function ()
|
||||
formattedString.spans.push(firstSpan);
|
||||
|
||||
var formattedTextChanged = false;
|
||||
formattedString.addEventListener(observable.knownEvents.propertyChange, () => {
|
||||
formattedString.addEventListener(observable.Observable.propertyChangeEvent, () => {
|
||||
formattedTextChanged = true;
|
||||
});
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ export var test_WhenBindingIsSetToAnElement_AndElementIsRemoved_ShouldBeCollecte
|
||||
var sourcePropertyName = "testProperty";
|
||||
var targetPropertyName = "text";
|
||||
|
||||
page.on(viewModule.knownEvents.loaded, () => {
|
||||
page.on(viewModule.View.loadedEvent, () => {
|
||||
var model = new observable.Observable();
|
||||
model.set(sourcePropertyName, expectedValue);
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ var _testOnClick = function (views: Array<viewModule.View>) {
|
||||
// <snippet module="ui/button" title="button">
|
||||
// ### Responding to the tap event
|
||||
// ``` JavaScript
|
||||
button.on(buttonModule.knownEvents.tap, function (args: observable.EventData) {
|
||||
button.on(buttonModule.Button.tapEvent, function (args: observable.EventData) {
|
||||
//// Do something
|
||||
// <hide>
|
||||
actualValue = true;
|
||||
|
||||
@@ -31,7 +31,7 @@ function validateDOChangeData(obj: TestDO, property: dependencyObservableModule.
|
||||
TKUnit.assert(currentChangeData.property === property, "metadata.onValueChanged method called with wrong property member");
|
||||
TKUnit.assert(currentChangeData.newValue === newValue, "metadata.onValueChanged method called with wrong newValue member");
|
||||
TKUnit.assert(currentChangeData.oldValue === oldValue, "metadata.onValueChanged method called with wrong oldValue member");
|
||||
TKUnit.assert(currentChangeData.eventName === observableModule.knownEvents.propertyChange, "metadata.onValueChanged method called with wrong eventName member");
|
||||
TKUnit.assert(currentChangeData.eventName === observableModule.Observable.propertyChangeEvent, "metadata.onValueChanged method called with wrong eventName member");
|
||||
}
|
||||
|
||||
function validateChangeData(data: observableModule.PropertyChangeData, obj: observableModule.Observable, propertyName: string, newValue: any) {
|
||||
@@ -39,7 +39,7 @@ function validateChangeData(data: observableModule.PropertyChangeData, obj: obse
|
||||
TKUnit.assert(data.object === obj, "DependencyObservable.on called with wrong object member.");
|
||||
TKUnit.assert(data.propertyName === propertyName, "DependencyObservable.on called with wrong propertyName member");
|
||||
TKUnit.assert(data.value === newValue, "DependencyObservable.on called with wrong value member");
|
||||
TKUnit.assert(data.eventName === observableModule.knownEvents.propertyChange, "DependencyObservable.on method called with wrong eventName member");
|
||||
TKUnit.assert(data.eventName === observableModule.Observable.propertyChangeEvent, "DependencyObservable.on method called with wrong eventName member");
|
||||
}
|
||||
|
||||
// <snippet module="ui/core/dependency-observable" title="dependency-observable">
|
||||
@@ -342,7 +342,7 @@ export function test_Observable_on_propertyChange_IsRaised() {
|
||||
var dO1 = new TestDO();
|
||||
|
||||
var changeData: observableModule.PropertyChangeData;
|
||||
dO1.on(observableModule.knownEvents.propertyChange, function (data: observableModule.PropertyChangeData) {
|
||||
dO1.on(observableModule.Observable.propertyChangeEvent, function (data: observableModule.PropertyChangeData) {
|
||||
changeData = data;
|
||||
});
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ export function test_set_items_to_array_loads_all_items() {
|
||||
// ``` JavaScript
|
||||
var colors = ["red", "green", "blue"];
|
||||
listView.items = colors;
|
||||
listView.on(listViewModule.knownEvents.itemLoading, function (args: listViewModule.ItemEventData) {
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, function (args: listViewModule.ItemEventData) {
|
||||
if (!args.view) {
|
||||
//// Create label if it is not already created.
|
||||
args.view = new labelModule.Label();
|
||||
@@ -130,7 +130,7 @@ export function test_set_items_to_array_loads_all_items() {
|
||||
|
||||
export function test_set_items_to_array_creates_native_views() {
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
listView.items = FEW_ITEMS;
|
||||
@@ -145,7 +145,7 @@ export function test_set_items_to_array_creates_native_views() {
|
||||
export function test_refresh_after_adding_items_to_array_loads_new_items() {
|
||||
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var colors = ["red", "green", "blue"];
|
||||
@@ -176,7 +176,7 @@ export function test_refresh_reloads_all_items() {
|
||||
var indexes = {};
|
||||
var testStarted = false;
|
||||
listView.items = FEW_ITEMS;
|
||||
listView.on(listViewModule.knownEvents.itemLoading, function (args: listViewModule.ItemEventData) {
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, function (args: listViewModule.ItemEventData) {
|
||||
if (!args.view) {
|
||||
args.view = new labelModule.Label();
|
||||
}
|
||||
@@ -202,7 +202,7 @@ export function test_refresh_reloads_all_items() {
|
||||
|
||||
export function test_set_itmes_to_null_clears_native_items() {
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
listView.items = FEW_ITEMS;
|
||||
@@ -219,7 +219,7 @@ export function test_set_itmes_to_null_clears_native_items() {
|
||||
|
||||
export function test_set_itmes_to_undefiend_clears_native_items() {
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
listView.items = FEW_ITEMS;
|
||||
@@ -236,7 +236,7 @@ export function test_set_itmes_to_undefiend_clears_native_items() {
|
||||
|
||||
export function test_set_itmes_to_different_source_loads_new_items() {
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
listView.items = [1, 2, 3];
|
||||
@@ -261,7 +261,7 @@ export function test_set_items_to_observable_array_loads_all_items() {
|
||||
// ``` JavaScript
|
||||
var colors = new observableArray.ObservableArray(["red", "green", "blue"]);
|
||||
listView.items = colors;
|
||||
listView.on(listViewModule.knownEvents.itemLoading, function (args: listViewModule.ItemEventData) {
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, function (args: listViewModule.ItemEventData) {
|
||||
if (!args.view) {
|
||||
//// Create label if it is not already created.
|
||||
args.view = new labelModule.Label();
|
||||
@@ -284,7 +284,7 @@ export function test_set_items_to_observable_array_loads_all_items() {
|
||||
|
||||
export function test_add_to_observable_array_refreshes_the_listview() {
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var colors = new observableArray.ObservableArray(["red", "green", "blue"]);
|
||||
@@ -314,7 +314,7 @@ export function test_remove_from_observable_array_refreshes_the_listview() {
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
listView.items = data;
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
TKUnit.wait(ASYNC);
|
||||
TKUnit.assertEqual(getNativeViewCount(listView), 3, "getNativeViewCount");
|
||||
@@ -334,7 +334,7 @@ export function test_splice_observable_array_refreshes_the_listview() {
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
listView.items = data;
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
TKUnit.wait(ASYNC);
|
||||
TKUnit.assertEqual(getNativeViewCount(listView), 3, "getNativeViewCount");
|
||||
@@ -350,7 +350,7 @@ export function test_splice_observable_array_refreshes_the_listview() {
|
||||
}
|
||||
export function test_nativeTap_is_raised() {
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
listView.items = FEW_ITEMS;
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
@@ -362,7 +362,7 @@ export function test_nativeTap_is_raised() {
|
||||
// ### ItemTap event
|
||||
// The event will be raise when an item inside the ListView is tapped.
|
||||
// ``` JavaScript
|
||||
listView.on(listViewModule.knownEvents.itemTap, function (args: listViewModule.ItemEventData) {
|
||||
listView.on(listViewModule.ListView.itemTapEvent, function (args: listViewModule.ItemEventData) {
|
||||
var tappedItemIndex = args.index;
|
||||
var tappedItemView = args.view;
|
||||
//// Do someting
|
||||
@@ -390,13 +390,13 @@ export function test_loadMoreItems_raised_when_showing_few_items() {
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var loadMoreItemsCount = 0;
|
||||
listView.items = FEW_ITEMS;
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
// <snippet module="ui/list-view" title="list-view">
|
||||
// ### LoadMoreItems event
|
||||
// The event will be raised when the ListView is scrolled so that the last item is visible.
|
||||
// This even is intended to be used to add additional data in the ListView.
|
||||
// ``` JavaScript
|
||||
listView.on(listViewModule.knownEvents.loadMoreItems, function (data: observable.EventData) {
|
||||
listView.on(listViewModule.ListView.loadMoreItemsEvent, function (data: observable.EventData) {
|
||||
//// Do something.
|
||||
//<hide>
|
||||
loadMoreItemsCount++;
|
||||
@@ -413,12 +413,12 @@ export function test_loadMoreItems_raised_when_showing_few_items() {
|
||||
|
||||
export function test_loadMoreItems_not_raised_when_showing_many_items() {
|
||||
var listView = new listViewModule.ListView();
|
||||
listView.on(listViewModule.knownEvents.itemLoading, loadViewWithItemNumber);
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, loadViewWithItemNumber);
|
||||
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var loadMoreItemsCount = 0;
|
||||
listView.items = MANY_ITEMS;
|
||||
listView.on(listViewModule.knownEvents.loadMoreItems, function (data: observable.EventData) {
|
||||
listView.on(listViewModule.ListView.loadMoreItemsEvent, function (data: observable.EventData) {
|
||||
loadMoreItemsCount++;
|
||||
});
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export var tests_DummyTestForCodeSnippet = function () {
|
||||
person.set("Name", "John");
|
||||
person.set("Age", 34);
|
||||
person.set("Married", true);
|
||||
person.addEventListener(observable.knownEvents.propertyChange, function (pcd: observable.PropertyChangeData) {
|
||||
person.addEventListener(observable.Observable.propertyChangeEvent, function (pcd: observable.PropertyChangeData) {
|
||||
//console.log(pcd.eventName.toString() + " " + pcd.propertyName.toString() + " " + pcd.value.toString());
|
||||
});
|
||||
person.set("Age", 35);
|
||||
@@ -83,7 +83,7 @@ export var test_Observable_UpdateAnotherPropertyWithinChangedCallback = function
|
||||
}
|
||||
}
|
||||
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, changedCallback);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, changedCallback);
|
||||
|
||||
obj.set("name", "Initial name");
|
||||
obj.set("test", "Initial test");
|
||||
@@ -143,13 +143,13 @@ export var test_Observable_addEventListener_SingleEvent = function () {
|
||||
var receivedCount = 0;
|
||||
var callback = function (data: observable.PropertyChangeData) {
|
||||
receivedCount++;
|
||||
TKUnit.assert(data.eventName === observable.knownEvents.propertyChange, "Expected event name " + observable.knownEvents.propertyChange);
|
||||
TKUnit.assert(data.eventName === observable.Observable.propertyChangeEvent, "Expected event name " + observable.Observable.propertyChangeEvent);
|
||||
TKUnit.assert(data.object === obj, "PropertyChangeData.object value not valid.");
|
||||
TKUnit.assert(data.propertyName === "testName", "PropertyChangeData.propertyName value not valid.");
|
||||
TKUnit.assert(data.value === 1, "PropertyChangeData.value value not valid.");
|
||||
}
|
||||
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, callback);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, callback);
|
||||
obj.set("testName", 1);
|
||||
TKUnit.assert(receivedCount === 1, "PropertyChanged event not raised properly.");
|
||||
}
|
||||
@@ -162,9 +162,9 @@ export var test_Observable_addEventListener_MultipleEvents = function () {
|
||||
receivedCount++;
|
||||
TKUnit.assert(data.object === obj, "EventData.object value not valid.");
|
||||
|
||||
if (data.eventName === observable.knownEvents.propertyChange) {
|
||||
if (data.eventName === observable.Observable.propertyChangeEvent) {
|
||||
var propertyData = <observable.PropertyChangeData>data;
|
||||
TKUnit.assert(propertyData.eventName === observable.knownEvents.propertyChange, "Expected event name " + observable.knownEvents.propertyChange);
|
||||
TKUnit.assert(propertyData.eventName === observable.Observable.propertyChangeEvent, "Expected event name " + observable.Observable.propertyChangeEvent);
|
||||
TKUnit.assert(propertyData.propertyName === "testName", "PropertyChangeData.propertyName value not valid.");
|
||||
TKUnit.assert(propertyData.value === 1, "PropertyChangeData.value value not valid.");
|
||||
} else {
|
||||
@@ -172,7 +172,7 @@ export var test_Observable_addEventListener_MultipleEvents = function () {
|
||||
}
|
||||
}
|
||||
|
||||
var events = observable.knownEvents.propertyChange + "," + TESTED_NAME;
|
||||
var events = observable.Observable.propertyChangeEvent + "," + TESTED_NAME;
|
||||
obj.addEventListener(events, callback);
|
||||
obj.set("testName", 1);
|
||||
obj.test();
|
||||
@@ -187,9 +187,9 @@ export var test_Observable_addEventListener_MultipleEvents_ShouldTrim = function
|
||||
receivedCount++;
|
||||
}
|
||||
|
||||
var events = observable.knownEvents.propertyChange + " , " + TESTED_NAME;
|
||||
var events = observable.Observable.propertyChangeEvent + " , " + TESTED_NAME;
|
||||
obj.addEventListener(events, callback);
|
||||
TKUnit.assert(obj.hasListeners(observable.knownEvents.propertyChange), "Observable.addEventListener for multiple events should trim each event name.");
|
||||
TKUnit.assert(obj.hasListeners(observable.Observable.propertyChangeEvent), "Observable.addEventListener for multiple events should trim each event name.");
|
||||
TKUnit.assert(obj.hasListeners(TESTED_NAME), "Observable.addEventListener for multiple events should trim each event name.");
|
||||
|
||||
obj.set("testName", 1);
|
||||
@@ -210,8 +210,8 @@ export var test_Observable_addEventListener_MultipleCallbacks = function () {
|
||||
receivedCount++;
|
||||
}
|
||||
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, callback1);
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, callback2);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, callback1);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, callback2);
|
||||
|
||||
obj.set("testName", 1);
|
||||
TKUnit.assert(receivedCount === 2, "The propertyChanged notification should be raised twice.");
|
||||
@@ -229,7 +229,7 @@ export var test_Observable_addEventListener_MultipleCallbacks_MultipleEvents = f
|
||||
receivedCount++;
|
||||
}
|
||||
|
||||
var events = observable.knownEvents.propertyChange + " , " + TESTED_NAME;
|
||||
var events = observable.Observable.propertyChangeEvent + " , " + TESTED_NAME;
|
||||
obj.addEventListener(events, callback1);
|
||||
obj.addEventListener(events, callback2);
|
||||
|
||||
@@ -247,11 +247,11 @@ export var test_Observable_removeEventListener_SingleEvent_SingleCallback = func
|
||||
receivedCount++;
|
||||
}
|
||||
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, callback);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, callback);
|
||||
obj.set("testName", 1);
|
||||
|
||||
obj.removeEventListener(observable.knownEvents.propertyChange, callback);
|
||||
TKUnit.assert(!obj.hasListeners(observable.knownEvents.propertyChange), "Observable.removeEventListener not working properly.");
|
||||
obj.removeEventListener(observable.Observable.propertyChangeEvent, callback);
|
||||
TKUnit.assert(!obj.hasListeners(observable.Observable.propertyChangeEvent), "Observable.removeEventListener not working properly.");
|
||||
|
||||
obj.set("testName", 2);
|
||||
TKUnit.assert(receivedCount === 1, "Observable.removeEventListener not working properly.");
|
||||
@@ -269,18 +269,18 @@ export var test_Observable_removeEventListener_SingleEvent_MultipleCallbacks = f
|
||||
receivedCount++;
|
||||
}
|
||||
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, callback1);
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, callback2);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, callback1);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, callback2);
|
||||
obj.set("testName", 1);
|
||||
|
||||
obj.removeEventListener(observable.knownEvents.propertyChange, callback1);
|
||||
TKUnit.assert(obj.hasListeners(observable.knownEvents.propertyChange), "Observable.removeEventListener not working properly with multiple listeners.");
|
||||
obj.removeEventListener(observable.Observable.propertyChangeEvent, callback1);
|
||||
TKUnit.assert(obj.hasListeners(observable.Observable.propertyChangeEvent), "Observable.removeEventListener not working properly with multiple listeners.");
|
||||
|
||||
obj.set("testName", 2);
|
||||
TKUnit.assert(receivedCount === 3, "Observable.removeEventListener not working properly with multiple listeners.");
|
||||
|
||||
obj.removeEventListener(observable.knownEvents.propertyChange, callback2);
|
||||
TKUnit.assert(!obj.hasListeners(observable.knownEvents.propertyChange), "Observable.removeEventListener not working properly with multiple listeners.");
|
||||
obj.removeEventListener(observable.Observable.propertyChangeEvent, callback2);
|
||||
TKUnit.assert(!obj.hasListeners(observable.Observable.propertyChangeEvent), "Observable.removeEventListener not working properly with multiple listeners.");
|
||||
|
||||
obj.set("testName", 3);
|
||||
TKUnit.assert(receivedCount === 3, "Observable.removeEventListener not working properly with multiple listeners.");
|
||||
@@ -294,7 +294,7 @@ export var test_Observable_removeEventListener_MutlipleEvents_SingleCallback = f
|
||||
receivedCount++;
|
||||
}
|
||||
|
||||
var events = observable.knownEvents.propertyChange + " , " + TESTED_NAME;
|
||||
var events = observable.Observable.propertyChangeEvent + " , " + TESTED_NAME;
|
||||
obj.addEventListener(events, callback);
|
||||
|
||||
obj.set("testName", 1);
|
||||
@@ -302,7 +302,7 @@ export var test_Observable_removeEventListener_MutlipleEvents_SingleCallback = f
|
||||
|
||||
obj.removeEventListener(events, callback);
|
||||
|
||||
TKUnit.assert(!obj.hasListeners(observable.knownEvents.propertyChange), "Expected result for hasObservers is false");
|
||||
TKUnit.assert(!obj.hasListeners(observable.Observable.propertyChangeEvent), "Expected result for hasObservers is false");
|
||||
TKUnit.assert(!obj.hasListeners(TESTED_NAME), "Expected result for hasObservers is false.");
|
||||
|
||||
obj.set("testName", 2);
|
||||
@@ -323,13 +323,13 @@ export var test_Observable_removeEventListener_SingleEvent_NoCallbackSpecified =
|
||||
receivedCount++;
|
||||
}
|
||||
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, callback1);
|
||||
obj.addEventListener(observable.knownEvents.propertyChange, callback2);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, callback1);
|
||||
obj.addEventListener(observable.Observable.propertyChangeEvent, callback2);
|
||||
|
||||
obj.set("testName", 1);
|
||||
obj.removeEventListener(observable.knownEvents.propertyChange);
|
||||
obj.removeEventListener(observable.Observable.propertyChangeEvent);
|
||||
|
||||
TKUnit.assert(!obj.hasListeners(observable.knownEvents.propertyChange), "Expected result for hasObservers is false.");
|
||||
TKUnit.assert(!obj.hasListeners(observable.Observable.propertyChangeEvent), "Expected result for hasObservers is false.");
|
||||
|
||||
obj.set("testName", 2);
|
||||
TKUnit.assert(receivedCount === 2, "Expected receive count is 2");
|
||||
|
||||
@@ -125,7 +125,7 @@ export function test_AfterPageLoaded_is_called_NativeInstance_is_created() {
|
||||
|
||||
var pageFactory = function (): PageModule.Page {
|
||||
page = new PageModule.Page();
|
||||
page.on(view.knownEvents.loaded, handler);
|
||||
page.on(view.View.loadedEvent, handler);
|
||||
|
||||
label = new LabelModule.Label();
|
||||
label.text = "Text";
|
||||
@@ -139,7 +139,7 @@ export function test_AfterPageLoaded_is_called_NativeInstance_is_created() {
|
||||
TKUnit.assert(nativeInstanceCreated, "Expected: true, Actual: " + nativeInstanceCreated);
|
||||
}
|
||||
finally {
|
||||
page.off(view.knownEvents.loaded, handler);
|
||||
page.off(view.View.loadedEvent, handler);
|
||||
helper.goBack();
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ export function test_PageLoaded_is_called_once() {
|
||||
var pageFactory2 = function (): PageModule.Page {
|
||||
page2 = new PageModule.Page();
|
||||
addLabelToPage(page2, "Page 2");
|
||||
page2.on(view.knownEvents.loaded, handler);
|
||||
page2.on(view.View.loadedEvent, handler);
|
||||
return page2;
|
||||
};
|
||||
|
||||
@@ -176,7 +176,7 @@ export function test_PageLoaded_is_called_once() {
|
||||
TKUnit.assert(loaded === 1, "Expected: 1, Actual: " + loaded);
|
||||
}
|
||||
finally {
|
||||
page2.off(view.knownEvents.loaded, handler);
|
||||
page2.off(view.View.loadedEvent, handler);
|
||||
helper.goBack();
|
||||
helper.goBack();
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ export function test_NavBar_isVisible_when_MenuItems_areSet() {
|
||||
var navBarIsVisible = false;
|
||||
|
||||
var handler = function (data) {
|
||||
page.off(view.knownEvents.loaded, handler);
|
||||
page.off(view.View.loadedEvent, handler);
|
||||
navBarIsVisible = (<any>page.frame.ios).showNavigationBar;
|
||||
}
|
||||
|
||||
var pageFactory = function (): PageModule.Page {
|
||||
page = new PageModule.Page();
|
||||
page.on(view.knownEvents.loaded, handler);
|
||||
page.on(view.View.loadedEvent, handler);
|
||||
|
||||
var mi = new PageModule.MenuItem();
|
||||
mi.text = "B";
|
||||
@@ -56,7 +56,7 @@ export function test_NavBar_isVisible_when_MenuItems_areSet() {
|
||||
TKUnit.assert(navBarIsVisible, "Expected: true, Actual: " + navBarIsVisible);
|
||||
}
|
||||
finally {
|
||||
page.off(view.knownEvents.loaded, handler);
|
||||
page.off(view.View.loadedEvent, handler);
|
||||
helper.goBack();
|
||||
}
|
||||
}
|
||||
@@ -99,14 +99,14 @@ export function test_property_changed_event_when_setting_maxValue_with_adjust()
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var changedProperties = {};
|
||||
var allChanges = 0;
|
||||
progress.on(observable.knownEvents.propertyChange, function (data: observable.EventData) {
|
||||
progress.on(observable.Observable.propertyChangeEvent, function (data: observable.EventData) {
|
||||
allChanges++;
|
||||
changedProperties[(<observable.PropertyChangeData>data).propertyName] = true;
|
||||
});
|
||||
|
||||
// Act
|
||||
progress.maxValue = 40;
|
||||
progress.off(observable.knownEvents.propertyChange);
|
||||
progress.off(observable.Observable.propertyChangeEvent);
|
||||
|
||||
// Assert
|
||||
TKUnit.assert(changedProperties["value"], "Property changed for 'value' not called.");
|
||||
|
||||
@@ -20,10 +20,10 @@ export function test_DummyTestForSnippetOnly() {
|
||||
// ### Searching
|
||||
// ``` JavaScript
|
||||
var searchBar = new searchBarModule.SearchBar();
|
||||
searchBar.on(searchBarModule.knownEvents.submit, function (args: observable.EventData) {
|
||||
searchBar.on(searchBarModule.SearchBar.submitEvent, function (args: observable.EventData) {
|
||||
console.log("Search for " + (<searchBarModule.SearchBar>args.object).text);
|
||||
});
|
||||
searchBar.on(searchBarModule.knownEvents.clear, function (args: observable.EventData) {
|
||||
searchBar.on(searchBarModule.SearchBar.clearEvent, function (args: observable.EventData) {
|
||||
console.log("Clear");
|
||||
});
|
||||
// ```
|
||||
|
||||
@@ -65,7 +65,7 @@ export function test_set_native_value_triggers_propertyChanged() {
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var valueChanged = false;
|
||||
var allChanges = 0;
|
||||
slider.on(observable.knownEvents.propertyChange, function (data: observable.EventData) {
|
||||
slider.on(observable.Observable.propertyChangeEvent, function (data: observable.EventData) {
|
||||
allChanges++;
|
||||
var propertyData = <observable.PropertyChangeData>data;
|
||||
if (propertyData && propertyData.propertyName === "value" && propertyData.value === TEST_VALUE) {
|
||||
@@ -75,7 +75,7 @@ export function test_set_native_value_triggers_propertyChanged() {
|
||||
|
||||
setNativeValue(slider, TEST_VALUE);
|
||||
|
||||
slider.off(observable.knownEvents.propertyChange);
|
||||
slider.off(observable.Observable.propertyChangeEvent);
|
||||
|
||||
TKUnit.assert(valueChanged, "Property changed for value not called.");
|
||||
TKUnit.assertEqual(allChanges, 1, "Property changed callbacks.");
|
||||
@@ -206,14 +206,14 @@ export function test_property_changed_event_when_setting_minValue_no_adjust() {
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var changedProperties = {};
|
||||
var allChanges = 0;
|
||||
slider.on(observable.knownEvents.propertyChange, function (data: observable.EventData) {
|
||||
slider.on(observable.Observable.propertyChangeEvent, function (data: observable.EventData) {
|
||||
allChanges++;
|
||||
changedProperties[(<observable.PropertyChangeData>data).propertyName] = true;
|
||||
});
|
||||
|
||||
// Act
|
||||
slider.minValue = 10;
|
||||
slider.off(observable.knownEvents.propertyChange);
|
||||
slider.off(observable.Observable.propertyChangeEvent);
|
||||
|
||||
// Assert
|
||||
TKUnit.assert(changedProperties["minValue"], "Property changed for minValue not called.");
|
||||
@@ -232,14 +232,14 @@ export function test_property_changed_event_when_setting_minValue_with_adjust()
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var changedProperties = {};
|
||||
var allChanges = 0;
|
||||
slider.on(observable.knownEvents.propertyChange, function (data: observable.EventData) {
|
||||
slider.on(observable.Observable.propertyChangeEvent, function (data: observable.EventData) {
|
||||
allChanges++;
|
||||
changedProperties[(<observable.PropertyChangeData>data).propertyName] = true;
|
||||
});
|
||||
|
||||
// Act
|
||||
slider.minValue = 60;
|
||||
slider.off(observable.knownEvents.propertyChange);
|
||||
slider.off(observable.Observable.propertyChangeEvent);
|
||||
|
||||
// Assert
|
||||
TKUnit.assert(changedProperties["value"], "Property changed for 'value' not called.");
|
||||
@@ -259,14 +259,14 @@ export function test_property_changed_event_when_setting_maxValue_no_adjust() {
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var changedProperties = {};
|
||||
var allChanges = 0;
|
||||
slider.on(observable.knownEvents.propertyChange, function (data: observable.EventData) {
|
||||
slider.on(observable.Observable.propertyChangeEvent, function (data: observable.EventData) {
|
||||
allChanges++;
|
||||
changedProperties[(<observable.PropertyChangeData>data).propertyName] = true;
|
||||
});
|
||||
|
||||
// Act
|
||||
slider.maxValue = 200;
|
||||
slider.off(observable.knownEvents.propertyChange);
|
||||
slider.off(observable.Observable.propertyChangeEvent);
|
||||
|
||||
// Assert
|
||||
TKUnit.assert(changedProperties["maxValue"], "Property changed for maxValue not called.");
|
||||
@@ -285,14 +285,14 @@ export function test_property_changed_event_when_setting_maxValue_with_adjust()
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var changedProperties = {};
|
||||
var allChanges = 0;
|
||||
slider.on(observable.knownEvents.propertyChange, function (data: observable.EventData) {
|
||||
slider.on(observable.Observable.propertyChangeEvent, function (data: observable.EventData) {
|
||||
allChanges++;
|
||||
changedProperties[(<observable.PropertyChangeData>data).propertyName] = true;
|
||||
});
|
||||
|
||||
// Act
|
||||
slider.maxValue = 40;
|
||||
slider.off(observable.knownEvents.propertyChange);
|
||||
slider.off(observable.Observable.propertyChangeEvent);
|
||||
|
||||
// Assert
|
||||
TKUnit.assert(changedProperties["value"], "Property changed for 'value' not called.");
|
||||
|
||||
@@ -178,7 +178,7 @@ export function test_setting_same_color_does_not_trigger_property_change() {
|
||||
testView.style.color = new color.Color("#FF0000");
|
||||
|
||||
var changed = false;
|
||||
testView.style.on(observable.knownEvents.propertyChange, (data) => {
|
||||
testView.style.on(observable.Observable.propertyChangeEvent, (data) => {
|
||||
changed = true;
|
||||
});
|
||||
|
||||
@@ -191,7 +191,7 @@ export function test_setting_different_color_triggers_property_change() {
|
||||
testView.style.color = new color.Color("#FF0000");
|
||||
|
||||
var changed = false;
|
||||
testView.style.on(observable.knownEvents.propertyChange, (data) => {
|
||||
testView.style.on(observable.Observable.propertyChangeEvent, (data) => {
|
||||
changed = true;
|
||||
});
|
||||
|
||||
@@ -204,7 +204,7 @@ export function test_setting_same_backgroundColor_does_not_trigger_property_chan
|
||||
testView.style.backgroundColor = new color.Color("#FF0000");
|
||||
|
||||
var changed = false;
|
||||
testView.style.on(observable.knownEvents.propertyChange, (data) => {
|
||||
testView.style.on(observable.Observable.propertyChangeEvent, (data) => {
|
||||
changed = true;
|
||||
});
|
||||
|
||||
@@ -217,7 +217,7 @@ export function test_setting_different_backgroundColor_triggers_property_change(
|
||||
testView.style.backgroundColor = new color.Color("#FF0000");
|
||||
|
||||
var changed = false;
|
||||
testView.style.on(observable.knownEvents.propertyChange, (data) => {
|
||||
testView.style.on(observable.Observable.propertyChangeEvent, (data) => {
|
||||
changed = true;
|
||||
});
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ export function test_set_native_checked_triggers_propertyChanged() {
|
||||
function testAction(views: Array<viewModule.View>) {
|
||||
var checkedChanged = false;
|
||||
var allChanges = 0;
|
||||
mySwitch.on(observable.knownEvents.propertyChange, function (data: observable.EventData) {
|
||||
mySwitch.on(observable.Observable.propertyChangeEvent, function (data: observable.EventData) {
|
||||
allChanges++;
|
||||
var propertyData = <observable.PropertyChangeData>data;
|
||||
if (propertyData && propertyData.propertyName === "checked" && propertyData.value === true) {
|
||||
@@ -91,7 +91,7 @@ export function test_set_native_checked_triggers_propertyChanged() {
|
||||
|
||||
setNativeValue(mySwitch, true);
|
||||
|
||||
mySwitch.off(observable.knownEvents.propertyChange);
|
||||
mySwitch.off(observable.Observable.propertyChangeEvent);
|
||||
|
||||
TKUnit.assert(checkedChanged, "Property changed for checked not called.");
|
||||
TKUnit.assertEqual(allChanges, 1, "Property changed callbacks.");
|
||||
|
||||
@@ -71,7 +71,7 @@ function _createListView(): listViewModule.ListView {
|
||||
listView.id = "ListView";
|
||||
var items = Array.apply(null, Array(10)).map(function (_, i) { return i; });
|
||||
|
||||
listView.on(listViewModule.knownEvents.itemLoading, function (args: listViewModule.ItemEventData) {
|
||||
listView.on(listViewModule.ListView.itemLoadingEvent, function (args: listViewModule.ItemEventData) {
|
||||
var button = <buttonModule.Button>args.view;
|
||||
if (!button) {
|
||||
button = new buttonModule.Button();
|
||||
@@ -80,7 +80,7 @@ function _createListView(): listViewModule.ListView {
|
||||
|
||||
button.text = "Button" + args.index;
|
||||
button.id = button.text;
|
||||
button.on(buttonModule.knownEvents.tap, _clickHandlerFactory(args.index));
|
||||
button.on(buttonModule.Button.tapEvent, _clickHandlerFactory(args.index));
|
||||
});
|
||||
|
||||
listView.items = items;
|
||||
|
||||
@@ -123,18 +123,18 @@ export var test_event_LoadedUnloaded_IsRaised = function () {
|
||||
var layoutUnloaded = false,
|
||||
buttonUnloaded = false;
|
||||
|
||||
views[1].on(viewModule.knownEvents.unloaded, (data) => {
|
||||
views[1].on(viewModule.View.unloadedEvent, (data) => {
|
||||
layoutUnloaded = true;
|
||||
});
|
||||
|
||||
views[2].on(viewModule.knownEvents.unloaded, (data) => {
|
||||
views[2].on(viewModule.View.unloadedEvent, (data) => {
|
||||
buttonUnloaded = true;
|
||||
});
|
||||
|
||||
var newButton = new button.Button(),
|
||||
buttonLoaded = false;
|
||||
|
||||
newButton.on(viewModule.knownEvents.loaded, (data) => {
|
||||
newButton.on(viewModule.View.loadedEvent, (data) => {
|
||||
buttonLoaded = true;
|
||||
});
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ export var testLoadExistingUrl = function () {
|
||||
// <snippet module="ui/web-view" title="WebView">
|
||||
// ### Using WebView
|
||||
// ``` JavaScript
|
||||
webView.on(webViewModule.knownEvents.loadFinished, function (args: webViewModule.LoadEventData) {
|
||||
webView.on(webViewModule.WebView.loadFinishedEvent, function (args: webViewModule.LoadEventData) {
|
||||
// <hide>
|
||||
actualUrl = args.url;
|
||||
actualError = args.error;
|
||||
@@ -89,7 +89,7 @@ export var testLoadInvalidUrl = function () {
|
||||
|
||||
var testFinished = false;
|
||||
var actualError;
|
||||
webView.on(webViewModule.knownEvents.loadFinished, function (args: webViewModule.LoadEventData) {
|
||||
webView.on(webViewModule.WebView.loadFinishedEvent, function (args: webViewModule.LoadEventData) {
|
||||
if (actualError) {
|
||||
// Android call this twice -- the second time args.error is undefined.
|
||||
return;
|
||||
|
||||
@@ -38,7 +38,7 @@ export var test_VirtualArray_setItemShouldRaiseChangeEventWhenYouSetDifferentIte
|
||||
var result: virtualArrayModule.ChangedData<number>;
|
||||
var index = 0;
|
||||
|
||||
array.on(virtualArrayModule.knownEvents.change, (args: virtualArrayModule.ChangedData<number>) => {
|
||||
array.on(virtualArrayModule.VirtualArray.changeEvent, (args: virtualArrayModule.ChangedData<number>) => {
|
||||
result = args;
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ export var test_VirtualArray_setItemShouldRaiseChangeEventWhenYouSetDifferentIte
|
||||
result.removed.length === 1 && result.index === index && result.addedCount === 1, "VirtualArray<T> setItem() should raise 'change' event with correct args!");
|
||||
// </hide>
|
||||
|
||||
array.on(virtualArrayModule.knownEvents.itemsLoading, (args: virtualArrayModule.ItemsLoading) => {
|
||||
array.on(virtualArrayModule.VirtualArray.itemsLoadingEvent, (args: virtualArrayModule.ItemsLoading) => {
|
||||
//// Argument (args) is ItemsLoading.
|
||||
//// args.index is start index of the page where the requested index is located.
|
||||
//// args.count number of requested items.
|
||||
@@ -90,7 +90,7 @@ export var test_VirtualArray_loadShouldRaiseChangeEventWithCorrectArgs = functio
|
||||
var index = 0;
|
||||
// </hide>
|
||||
|
||||
array.on(virtualArrayModule.knownEvents.change, (args: virtualArrayModule.ChangedData<number>) => {
|
||||
array.on(virtualArrayModule.VirtualArray.changeEvent, (args: virtualArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "update".
|
||||
@@ -124,7 +124,7 @@ export var test_VirtualArray_lengthIncreaseShouldRaiseChangeEventWithCorrectArgs
|
||||
var index = array.length;
|
||||
// </hide>
|
||||
|
||||
array.on(virtualArrayModule.knownEvents.change, (args: virtualArrayModule.ChangedData<number>) => {
|
||||
array.on(virtualArrayModule.VirtualArray.changeEvent, (args: virtualArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "add".
|
||||
@@ -156,7 +156,7 @@ export var test_VirtualArray_lengthDecreaseShouldRaiseChangeEventWithCorrectArgs
|
||||
var index = array.length;
|
||||
// </hide>
|
||||
|
||||
array.on(virtualArrayModule.knownEvents.change, (args: virtualArrayModule.ChangedData<number>) => {
|
||||
array.on(virtualArrayModule.VirtualArray.changeEvent, (args: virtualArrayModule.ChangedData<number>) => {
|
||||
//// Argument (args) is ChangedData<T>.
|
||||
//// args.eventName is "change".
|
||||
//// args.action is "remove".
|
||||
@@ -180,13 +180,13 @@ export var test_VirtualArray_shouldRaiseItemsLoadingIfIndexIsNotLoadedAndGetItem
|
||||
|
||||
var result: virtualArrayModule.ItemsLoading;
|
||||
|
||||
array.on(virtualArrayModule.knownEvents.itemsLoading, (args: virtualArrayModule.ItemsLoading) => {
|
||||
array.on(virtualArrayModule.VirtualArray.itemsLoadingEvent, (args: virtualArrayModule.ItemsLoading) => {
|
||||
result = args;
|
||||
});
|
||||
|
||||
array.getItem(0);
|
||||
|
||||
TKUnit.assert(result.eventName === virtualArrayModule.knownEvents.itemsLoading && result.index === 0 &&
|
||||
TKUnit.assert(result.eventName === virtualArrayModule.VirtualArray.itemsLoadingEvent && result.index === 0 &&
|
||||
result.count === array.loadSize, "VirtualArray<T> getItem() should raise 'itemsLoading' event with correct args if item is not loaded!");
|
||||
};
|
||||
|
||||
@@ -197,7 +197,7 @@ export var test_VirtualArray_shouldNotRaiseItemsLoadingIfIndexIsLoadedAndGetItem
|
||||
|
||||
var result: virtualArrayModule.ItemsLoading;
|
||||
|
||||
array.on(virtualArrayModule.knownEvents.itemsLoading, (args: virtualArrayModule.ItemsLoading) => {
|
||||
array.on(virtualArrayModule.VirtualArray.itemsLoadingEvent, (args: virtualArrayModule.ItemsLoading) => {
|
||||
result = args;
|
||||
});
|
||||
|
||||
@@ -216,14 +216,14 @@ export var test_VirtualArray_shouldRaiseItemsLoadingIfIndexIsNotLoadedAndGetItem
|
||||
|
||||
var result = new Array<virtualArrayModule.ItemsLoading>();
|
||||
|
||||
array.on(virtualArrayModule.knownEvents.itemsLoading, (args: virtualArrayModule.ItemsLoading) => {
|
||||
array.on(virtualArrayModule.VirtualArray.itemsLoadingEvent, (args: virtualArrayModule.ItemsLoading) => {
|
||||
result.push(args);
|
||||
});
|
||||
|
||||
array.getItem(1);
|
||||
|
||||
TKUnit.assert(result.length === 2 &&
|
||||
result[0].eventName === virtualArrayModule.knownEvents.itemsLoading && result[0].index === 1 && result[0].count === 4 &&
|
||||
result[1].eventName === virtualArrayModule.knownEvents.itemsLoading && result[1].index === 6 && result[1].count === 9,
|
||||
result[0].eventName === virtualArrayModule.VirtualArray.itemsLoadingEvent && result[0].index === 1 && result[0].count === 4 &&
|
||||
result[1].eventName === virtualArrayModule.VirtualArray.itemsLoadingEvent && result[1].index === 6 && result[1].count === 9,
|
||||
"VirtualArray<T> getItem() should raise 'itemsLoading' event with correct args!");
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ export class MyControl extends stackLayoutModule.StackLayout {
|
||||
var lbl = new label.Label();
|
||||
var btn = new button.Button();
|
||||
btn.text = "Tap me!";
|
||||
btn.on(button.knownEvents.tap, (args: observable.EventData) => {
|
||||
btn.on(button.Button.tapEvent, (args: observable.EventData) => {
|
||||
lbl.text = "Tap " + counter++;
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export function createPage() {
|
||||
|
||||
var btn = new button.Button();
|
||||
btn.text = "Run";
|
||||
btn.on(button.knownEvents.tap, function () {
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
var pagePath = basePath + txtInput.text;
|
||||
var fileName = fs.path.join(__dirname, "pages", txtInput.text);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export function createPage() {
|
||||
rotaionLabel.text = "Rotate here";
|
||||
stack.addChild(rotaionLabel);
|
||||
|
||||
stopButton.on(button.knownEvents.tap, function () {
|
||||
stopButton.on(button.Button.tapEvent, function () {
|
||||
observer1.disconnect();
|
||||
observer2.disconnect();
|
||||
observer3.disconnect();
|
||||
|
||||
@@ -8,7 +8,7 @@ export function createPage() {
|
||||
|
||||
var btn = new button.Button();
|
||||
btn.text = "Alert";
|
||||
btn.on(button.knownEvents.tap, function () {
|
||||
btn.on(button.Button.tapEvent, function () {
|
||||
alert("Alert is global");
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export class WebViewModel extends observable.Observable {
|
||||
}
|
||||
set url(value: string) {
|
||||
this._url = value;
|
||||
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "url", value: value });
|
||||
this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "url", value: value });
|
||||
}
|
||||
|
||||
//private _text: string;
|
||||
@@ -25,7 +25,7 @@ export class WebViewModel extends observable.Observable {
|
||||
//}
|
||||
//set text(value: string) {
|
||||
// this._text = value;
|
||||
// this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "text", value: value });
|
||||
// this.notify({ object: this, eventName: observable.Observable.propertyChangeEvent, propertyName: "text", value: value });
|
||||
|
||||
// if (application.ios) {
|
||||
// this.url = this.text;
|
||||
|
||||
@@ -18,7 +18,7 @@ export function createPage() {
|
||||
};
|
||||
|
||||
var button = new bm.Button();
|
||||
button.on(bm.knownEvents.tap, function () {
|
||||
button.on(bm.Button.tapEvent, function () {
|
||||
fs.File.fromPath(__dirname + "/xml.xml").readText().then(input => {
|
||||
// I am a change made in master.
|
||||
console.log("EasySax JavaScript XmlParser (without namespace processing) running...");
|
||||
|
||||
22
data/observable-array/observable-array.d.ts
vendored
22
data/observable-array/observable-array.d.ts
vendored
@@ -6,13 +6,6 @@
|
||||
declare module "data/observable-array" {
|
||||
import observable = require("data/observable");
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
module knownEvents {
|
||||
export var change: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event args for "changed" event.
|
||||
*/
|
||||
@@ -52,12 +45,23 @@ declare module "data/observable-array" {
|
||||
* Advanced array like class used when you want to be notified when a change occurs.
|
||||
*/
|
||||
class ObservableArray<T> extends observable.Observable {
|
||||
on(event: string, callback: (data: observable.EventData) => void);
|
||||
/**
|
||||
* String value used when hooking to change event.
|
||||
*/
|
||||
public static changeEvent: 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: (data: observable.EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when a change occurs.
|
||||
*/
|
||||
on(event: "change", callback: (args: ChangedData<T>) => void);
|
||||
on(event: "change", callback: (args: ChangedData<T>) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Create ObservableArray<T> with specified length.
|
||||
|
||||
@@ -10,13 +10,9 @@ export class ChangeType implements observableArrayDef.ChangeType {
|
||||
|
||||
var CHANGE = "change";
|
||||
|
||||
export module knownEvents {
|
||||
export var change = CHANGE;
|
||||
}
|
||||
|
||||
export class ObservableArray<T> extends observable.Observable implements observableArrayDef.ObservableArray<T> { // implements Array<T> {
|
||||
|
||||
//[n: number]: T;
|
||||
public static changeEvent = CHANGE;
|
||||
|
||||
private _array: Array<any>;
|
||||
private _addArgs: observableArrayDef.ChangedData<T>;
|
||||
|
||||
26
data/observable/observable.d.ts
vendored
26
data/observable/observable.d.ts
vendored
@@ -30,20 +30,14 @@ declare module "data/observable" {
|
||||
value: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
module knownEvents {
|
||||
/**
|
||||
* The name of the property changed event.
|
||||
*/
|
||||
export var propertyChange: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Observable is used when you want to be notified when a change occurs. Use on/off methods to add/remove listener.
|
||||
*/
|
||||
class Observable {
|
||||
/**
|
||||
* String value used when hooking to propertyChange event.
|
||||
*/
|
||||
public static propertyChangeEvent: string;
|
||||
|
||||
/**
|
||||
* Creates an Observable instance and sets its properties accroding to the supplied JSON object.
|
||||
@@ -56,14 +50,22 @@ declare module "data/observable" {
|
||||
typeName: string;
|
||||
|
||||
/**
|
||||
* Shortcut alias to the addEventListener method.
|
||||
* 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: EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when a propertyChange occurs.
|
||||
*/
|
||||
on(event: "propertyChange", callback: (data: EventData) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Shortcut alias to the removeEventListener method.
|
||||
*/
|
||||
off(eventNames: string, callback?: any);
|
||||
off(eventNames: string, callback?: any, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Adds a listener for the specified event name.
|
||||
|
||||
@@ -6,11 +6,9 @@ interface ListenerEntry {
|
||||
thisArg: any;
|
||||
}
|
||||
|
||||
export module knownEvents {
|
||||
export var propertyChange = "propertyChange";
|
||||
}
|
||||
|
||||
export class Observable implements definition.Observable {
|
||||
public static propertyChangeEvent = "propertyChange";
|
||||
|
||||
private _observers = {};
|
||||
|
||||
constructor(json?: any) {
|
||||
@@ -31,8 +29,8 @@ export class Observable implements definition.Observable {
|
||||
this.addEventListener(eventNames, callback, thisArg);
|
||||
}
|
||||
|
||||
public off(eventNames: string, callback?: any) {
|
||||
this.removeEventListener(eventNames, callback);
|
||||
public off(eventNames: string, callback?: any, thisArg?: any) {
|
||||
this.removeEventListener(eventNames, callback, thisArg);
|
||||
}
|
||||
|
||||
public addEventListener(eventNames: string, callback: (data: definition.EventData) => void, thisArg?: any) {
|
||||
@@ -122,7 +120,7 @@ export class Observable implements definition.Observable {
|
||||
|
||||
public _createPropertyChangeData(name: string, value: any): definition.PropertyChangeData {
|
||||
return {
|
||||
eventName: knownEvents.propertyChange,
|
||||
eventName: Observable.propertyChangeEvent,
|
||||
propertyName: name,
|
||||
object: this,
|
||||
value: value
|
||||
|
||||
30
data/virtual-array/virtual-array.d.ts
vendored
30
data/virtual-array/virtual-array.d.ts
vendored
@@ -5,14 +5,6 @@ declare module "data/virtual-array" {
|
||||
import observable = require("data/observable");
|
||||
import observableArray = require("data/observable-array");
|
||||
|
||||
/**
|
||||
* Known event names.
|
||||
*/
|
||||
module knownEvents {
|
||||
export var itemsLoading: string;
|
||||
export var change: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides event args for "changed" event.
|
||||
*/
|
||||
@@ -31,6 +23,16 @@ declare module "data/virtual-array" {
|
||||
* Advanced array like class that helps loading items on demand.
|
||||
*/
|
||||
export class VirtualArray<T> extends observable.Observable {
|
||||
/**
|
||||
* String value used when hooking to change event.
|
||||
*/
|
||||
public static changeEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to itemsLoading event.
|
||||
*/
|
||||
public static itemsLoadingEvent: string;
|
||||
|
||||
constructor(arrayLength?: number);
|
||||
|
||||
/**
|
||||
@@ -58,17 +60,23 @@ declare module "data/virtual-array" {
|
||||
*/
|
||||
load(index: number, items: T[]): void;
|
||||
|
||||
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 still not loaded items are requested.
|
||||
*/
|
||||
on(event: "itemsLoading", callback: (args: ItemsLoading) => void);
|
||||
on(event: "itemsLoading", callback: (args: ItemsLoading) => void, thisArg?: any);
|
||||
|
||||
/**
|
||||
* Raised when a change occurs.
|
||||
*/
|
||||
on(event: "change", callback: (args: ChangedData<T>) => void);
|
||||
on(event: "change", callback: (args: ChangedData<T>) => void, thisArg?: any);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,11 +4,6 @@ import virtualArrayDef = require("data/virtual-array");
|
||||
|
||||
var CHANGE = "change", UPDATE = "update", DELETE = "delete", ADD = "add";
|
||||
|
||||
export module knownEvents {
|
||||
export var itemsLoading = "itemsLoading";
|
||||
export var change = "change";
|
||||
}
|
||||
|
||||
export class ChangeType implements virtualArrayDef.ChangeType {
|
||||
static Add = "add";
|
||||
static Delete = "delete";
|
||||
@@ -17,6 +12,9 @@ export class ChangeType implements virtualArrayDef.ChangeType {
|
||||
}
|
||||
|
||||
export class VirtualArray<T> extends observable.Observable {
|
||||
public static changeEvent = CHANGE;
|
||||
public static itemsLoadingEvent = "itemsLoading";
|
||||
|
||||
private _requestedIndexes: Array<number>;
|
||||
private _loadedIndexes: Array<number>;
|
||||
private _length: number;
|
||||
@@ -139,7 +137,7 @@ export class VirtualArray<T> extends observable.Observable {
|
||||
} else {
|
||||
if (count > 0) {
|
||||
this.notify({
|
||||
eventName: knownEvents.itemsLoading, object: this,
|
||||
eventName: VirtualArray.itemsLoadingEvent, object: this,
|
||||
index: start,
|
||||
count: count
|
||||
});
|
||||
@@ -152,7 +150,7 @@ export class VirtualArray<T> extends observable.Observable {
|
||||
|
||||
if (start >= 0 && count > 0) {
|
||||
this.notify({
|
||||
eventName: knownEvents.itemsLoading, object: this,
|
||||
eventName: VirtualArray.itemsLoadingEvent, object: this,
|
||||
index: start,
|
||||
count: count
|
||||
});
|
||||
|
||||
@@ -138,7 +138,7 @@ export class FormattedString extends observable.Observable implements definition
|
||||
constructor() {
|
||||
super();
|
||||
this._spans = new observableArray.ObservableArray<spanModule.Span>();
|
||||
this._spans.addEventListener(observableArray.knownEvents.change, this.onSpansCollectionChanged, this);
|
||||
this._spans.addEventListener(observableArray.ObservableArray.changeEvent, this.onSpansCollectionChanged, this);
|
||||
this._isDirty = true;
|
||||
}
|
||||
|
||||
@@ -155,14 +155,14 @@ export class FormattedString extends observable.Observable implements definition
|
||||
for (i = 0; i < eventData.addedCount; i++) {
|
||||
var addedSpan: spanModule.Span = (<observableArray.ObservableArray<spanModule.Span>>eventData.object).getItem(eventData.index + i);
|
||||
addedSpan.parentFormattedString = this;
|
||||
addedSpan.addEventListener(observable.knownEvents.propertyChange, this.onSpanChanged, this);
|
||||
addedSpan.addEventListener(observable.Observable.propertyChangeEvent, this.onSpanChanged, this);
|
||||
}
|
||||
}
|
||||
if (eventData.removed && eventData.removed.length > 0) {
|
||||
var p;
|
||||
for (p = 0; p < eventData.removed.length; p++) {
|
||||
var removedSpan = eventData.removed[p];
|
||||
removedSpan.removeEventListener(observable.knownEvents.propertyChange, this.onSpanChanged, this);
|
||||
removedSpan.removeEventListener(observable.Observable.propertyChangeEvent, this.onSpanChanged, this);
|
||||
}
|
||||
}
|
||||
this.updateFormattedText(true);
|
||||
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user