Replace knownEvents modules with static strings.

This commit is contained in:
Nedyalko Nikolov
2015-04-23 15:47:56 +03:00
parent 8023390692
commit 95ca8d9c8c
101 changed files with 520 additions and 471 deletions

View File

@@ -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();

View File

@@ -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,

View File

@@ -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

View File

@@ -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);
}
/**

View File

@@ -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