From d952faa3c255fd4858e792a62ae0629c4af70b24 Mon Sep 17 00:00:00 2001 From: Nedyalko Nikolov Date: Mon, 30 Mar 2015 13:44:37 +0300 Subject: [PATCH] Added application resources (used for binding converters), also some bug fixes (binding related). --- application/application-common.ts | 2 + application/application.d.ts | 5 ++ apps/tests/ui/list-view/list-view-tests.ts | 45 ++++++++++ apps/tests/ui/tab-view/tab-view-tests.ts | 41 +++++++++ .../polymer-expressions.d.ts | 3 +- .../polymer-expressions.js | 4 +- ui/core/bindable.ts | 86 ++++++++++++------- ui/list-view/list-view-common.ts | 2 +- 8 files changed, 151 insertions(+), 37 deletions(-) diff --git a/application/application-common.ts b/application/application-common.ts index 621b285e2..b1e97ef97 100644 --- a/application/application-common.ts +++ b/application/application-common.ts @@ -6,6 +6,8 @@ import styleScope = require("ui/styling/style-scope"); export var cssFile: string = "app.css" +export var resources: any = {}; + export var onUncaughtError: (error: definition.NativeScriptError) => void = undefined; export var onLaunch: (context: any) => any = undefined; diff --git a/application/application.d.ts b/application/application.d.ts index d3bc21a27..5f736b23d 100644 --- a/application/application.d.ts +++ b/application/application.d.ts @@ -23,6 +23,11 @@ declare module "application" { */ export var mainModule: string; + /** + * An application level static resources. + */ + export var resources: any; + /** * The application level css file name (starting from the application root). Used to set css across all pages. * Css will be applied for every page and page css will be applied after. diff --git a/apps/tests/ui/list-view/list-view-tests.ts b/apps/tests/ui/list-view/list-view-tests.ts index b804ce587..23b65a6de 100644 --- a/apps/tests/ui/list-view/list-view-tests.ts +++ b/apps/tests/ui/list-view/list-view-tests.ts @@ -429,6 +429,38 @@ export function test_loadMoreItems_not_raised_when_showing_many_items() { helper.buildUIAndRunTest(listView, testAction); } +export function test_usingAppLevelConvertersInListViewItems() { + var listView = new listViewModule.ListView(); + + var dateConverter = function (value, format) { + var result = format; + var day = value.getDate(); + result = result.replace("DD", month < 10 ? "0" + day : day); + var month = value.getMonth() + 1; + result = result.replace("MM", month < 10 ? "0" + month : month); + result = result.replace("YYYY", value.getFullYear()); + return result; + }; + + app.resources["dateConverter"] = dateConverter; + + var data = new observableArray.ObservableArray(); + + data.push({date: new Date()}); + + function testAction(views: Array) { + listView.itemTemplate = "