definitions fixed

This commit is contained in:
Erjan Gavalji
2015-03-03 10:34:40 +02:00
parent a03ce4ca1d
commit cc829e0152
705 changed files with 321431 additions and 148812 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

17
.gitignore vendored
View File

@@ -1,3 +1,20 @@
# generated files
*.map
.baseDir.ts
.sublime-grunt.cache
tscommand*.tmp.txt
.tscache
*.js
node_modules/
dist/
!gruntfile.js
!js-libs/**/*.*
CrossPlatformModules.sln.ide/
*.suo
CrossPlatformModules.suo
CrossPlatformModules.v14.suo
CrossPlatformModules.csproj.user
bin/
obj/

View File

@@ -1,417 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ProjectGuid>{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<OutputPath>bin</OutputPath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<TypeScriptToolsVersion>1.0</TypeScriptToolsVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>BCL</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Full'">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'iOS'">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Android'">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'iOS_Deploy'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\</OutputPath>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Android_Deploy'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\</OutputPath>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'iOS_Tests'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\</OutputPath>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Android_Tests'">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>63708</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:63708/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<ItemGroup>
<TypeScriptCompile Include="application\application.android.ts">
<DependentUpon>application.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="application\application.d.ts" />
<TypeScriptCompile Include="application\application.ios.ts">
<DependentUpon>application.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="console\console-native.android.ts">
<DependentUpon>console-native.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="console\console-native.ios.ts">
<DependentUpon>console-native.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="console\console.ts">
<DependentUpon>console.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="console\console-native.d.ts" />
<TypeScriptCompile Include="declarations.d.ts" />
<TypeScriptCompile Include="declarations.android.d.ts">
<DependentUpon>declarations.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="declarations.ios.d.ts">
<DependentUpon>declarations.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="file-system\file-system.d.ts" />
<TypeScriptCompile Include="file-system\file-system-access.d.ts" />
<TypeScriptCompile Include="file-system\file-system.impl.ts">
<DependentUpon>file-system.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="http\http-request.d.ts" />
<TypeScriptCompile Include="http\http-request.android.ts">
<DependentUpon>http-request.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="http\http-request.ios.ts">
<DependentUpon>http-request.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="image-source\image-source-native.android.ts">
<DependentUpon>image-source-native.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="image-source\image-source-native.ios.ts">
<DependentUpon>image-source-native.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="image-source\image-source.d.ts" />
<TypeScriptCompile Include="image-source\image-source-native.d.ts" />
<TypeScriptCompile Include="image-source\image-source.impl.ts">
<DependentUpon>image-source.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="image-source\index.ts" />
<TypeScriptCompile Include="location\location.d.ts" />
<TypeScriptCompile Include="promises\promises.d.ts" />
<TypeScriptCompile Include="Tests\application-tests-common.ts" />
<TypeScriptCompile Include="Tests\application-tests.ios.ts">
<DependentUpon>application-tests-common.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="Tests\application-tests.android.ts">
<DependentUpon>application-tests-common.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="Tests\file-system-tests.ts" />
<TypeScriptCompile Include="Tests\http-tests.ts" />
<TypeScriptCompile Include="Tests\image-source-tests.ts" />
<TypeScriptCompile Include="Tests\index.ts" />
<TypeScriptCompile Include="Tests\location-tests.ts" />
<TypeScriptCompile Include="Tests\testRunner.ts" />
<TypeScriptCompile Include="Tests\TKUnit.ts" />
<TypeScriptCompile Include="text\index.ts" />
<TypeScriptCompile Include="text\text.android.ts">
<DependentUpon>text.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="text\text.d.ts" />
<TypeScriptCompile Include="text\text.ios.ts">
<DependentUpon>text.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\core\bindable.ts" />
<TypeScriptCompile Include="ui\core\proxy.ts" />
<TypeScriptCompile Include="ui\frame\frame-common.ts">
<DependentUpon>frame.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\frame\frame.android.ts">
<DependentUpon>frame.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\frame\frame.d.ts" />
<TypeScriptCompile Include="ui\frame\frame.ios.ts">
<DependentUpon>frame.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\frame\index.ts" />
<TypeScriptCompile Include="ui\image\image.android.ts">
<DependentUpon>image.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\image\image.d.ts" />
<TypeScriptCompile Include="ui\image\image.ios.ts">
<DependentUpon>image.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\image\index.ts" />
<TypeScriptCompile Include="ui\label\index.ts" />
<TypeScriptCompile Include="ui\label\label.d.ts" />
<TypeScriptCompile Include="ui\label\label.android.ts">
<DependentUpon>label.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\label\label.ios.ts">
<DependentUpon>label.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\pages\index.ts" />
<TypeScriptCompile Include="ui\pages\page-common.ts">
<DependentUpon>page.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\pages\page.android.ts">
<DependentUpon>page.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\pages\page.d.ts" />
<TypeScriptCompile Include="ui\text-field\index.ts" />
<TypeScriptCompile Include="ui\text-field\text-field.android.ts">
<DependentUpon>text-field.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\text-field\text-field.d.ts" />
<TypeScriptCompile Include="ui\text-field\text-field.ios.ts">
<DependentUpon>text-field.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="utils\module-merge.ts" />
<TypeScriptCompile Include="utils\utils_android.ts" />
<TypeScriptCompile Include="utils\utils_ios.ts" />
<TypeScriptCompile Include="http\index.ts" />
<TypeScriptCompile Include="location\index.ts" />
<TypeScriptCompile Include="file-system\index.ts" />
<TypeScriptCompile Include="console\index.ts" />
<TypeScriptCompile Include="application\index.ts" />
<TypeScriptCompile Include="android17.d.ts" />
<TypeScriptCompile Include="promises\promises.ts" />
<TypeScriptCompile Include="promises\index.ts" />
<TypeScriptCompile Include="ios7.d.ts" />
<TypeScriptCompile Include="globals\index.ts" />
<TypeScriptCompile Include="timer\index.ts" />
<TypeScriptCompile Include="timer\timer.android.ts">
<DependentUpon>timer.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="console\console.d.ts" />
<TypeScriptCompile Include="timer\timer.d.ts" />
<TypeScriptCompile Include="timer\timer.ios.ts">
<DependentUpon>timer.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="Tests\local-settings-tests.ts" />
<TypeScriptCompile Include="file-system\file-system-access.android.ts">
<DependentUpon>file-system-access.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="file-system\file-system-access.ios.ts">
<DependentUpon>file-system-access.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="application\application-common.ts" />
<TypeScriptCompile Include="http\http.impl.ts">
<DependentUpon>http.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="http\http.d.ts" />
<TypeScriptCompile Include="local-settings\index.ts" />
<TypeScriptCompile Include="local-settings\local-settings.d.ts" />
<TypeScriptCompile Include="local-settings\local-settings.android.ts">
<DependentUpon>local-settings.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="local-settings\local-settings.ios.ts">
<DependentUpon>local-settings.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="local-settings\local-settings-common.ts" />
<TypeScriptCompile Include="Tests\timer-tests.ts" />
<TypeScriptCompile Include="location\location-types.ts">
<DependentUpon>location.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="location\location-manager.android.ts">
<DependentUpon>location-manager.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="location\location-manager.d.ts" />
<TypeScriptCompile Include="location\location-manager.ios.ts">
<DependentUpon>location-manager.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="location\location.impl.ts">
<DependentUpon>location.d.ts</DependentUpon>
</TypeScriptCompile>
</ItemGroup>
<ItemGroup>
<TypeScriptCompile Include="libjs.d.ts" />
</ItemGroup>
<ItemGroup>
<TypeScriptCompile Include="ui\core\view.ts" />
<TypeScriptCompile Include="ui\core\observable.ts" />
<TypeScriptCompile Include="ui\dialogs\dialogs.android.ts">
<DependentUpon>dialogs.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\dialogs\dialogs.d.ts" />
<TypeScriptCompile Include="ui\dialogs\dialogs.ios.ts">
<DependentUpon>dialogs.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\dialogs\index.ts" />
<TypeScriptCompile Include="ui\dialogs\dialogs-common.ts" />
<TypeScriptCompile Include="ui\core\event-manager.ts" />
<TypeScriptCompile Include="ui\button\index.ts" />
<TypeScriptCompile Include="ui\button\button.d.ts" />
<TypeScriptCompile Include="ui\button\button.android.ts">
<DependentUpon>button.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\button\button.ios.ts">
<DependentUpon>button.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\slider\index.ts" />
<TypeScriptCompile Include="ui\slider\slider.android.ts" />
<TypeScriptCompile Include="ui\slider\slider.d.ts" />
<TypeScriptCompile Include="ui\slider\slider.ios.ts" />
<TypeScriptCompile Include="ui\switch\switch.d.ts" />
<TypeScriptCompile Include="ui\switch\index.ts" />
<TypeScriptCompile Include="ui\switch\switch.android.ts">
<DependentUpon>switch.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\switch\switch.ios.ts">
<DependentUpon>switch.d.ts</DependentUpon>
</TypeScriptCompile>
<Content Include="_references.ts" />
<Content Include="image-source\Readme.md" />
<Content Include="http\Readme.md" />
<Content Include="Readme.md" />
<Content Include="console\Readme.md" />
<Content Include="location\Readme.md" />
<Content Include="application\Readme.md" />
<Content Include="globals\Readme.md" />
<Content Include="timer\Readme.md" />
<Content Include="Deploy\Readme.md" />
<Content Include="Tests\Readme.md" />
<Content Include="local-settings\Readme.md" />
</ItemGroup>
<ItemGroup>
<Folder Include="Deploy\Eclipse\" />
<Folder Include="Deploy\Full\" />
<Folder Include="Deploy\xCode\" />
</ItemGroup>
<ItemGroup>
<Content Include="ui\dialogs\Readme.md" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Full'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<TypeScriptRemoveComments>True</TypeScriptRemoveComments>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptTarget>ES5</TypeScriptTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'iOS'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<TypeScriptRemoveComments>True</TypeScriptRemoveComments>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptTarget>ES5</TypeScriptTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Android'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<TypeScriptRemoveComments>True</TypeScriptRemoveComments>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptTarget>ES5</TypeScriptTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'iOS_Deploy'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<TypeScriptRemoveComments>True</TypeScriptRemoveComments>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptTarget>ES5</TypeScriptTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Android_Deploy'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<TypeScriptRemoveComments>True</TypeScriptRemoveComments>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptTarget>ES5</TypeScriptTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Android_Tests'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptRemoveComments>True</TypeScriptRemoveComments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'iOS_Tests'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<TypeScriptRemoveComments>True</TypeScriptRemoveComments>
<TypeScriptTarget>ES5</TypeScriptTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Documentation'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<TypeScriptRemoveComments>False</TypeScriptRemoveComments>
<TypeScriptTarget>ES5</TypeScriptTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
</PropertyGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets')" />
<!--
Custom build tasks
-->
<PropertyGroup Condition=" '$(Configuration)' == 'Full'">
<TargetOS>Full</TargetOS>
<JSConfig>Deploy\Full\Configuration.xml</JSConfig>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'iOS'">
<TargetOS>iOS</TargetOS>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'iOS_Deploy'">
<TargetOS>iOS</TargetOS>
<JSConfig>Deploy\xCode\Configuration.xml</JSConfig>
<JSMainFile>bootstrap.js</JSMainFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'iOS_Tests'">
<TargetOS>iOS</TargetOS>
<JSConfig>Deploy\xCode\Configuration.xml</JSConfig>
<!--TODO: Do not call this JSMainFile - this file is actually NOT deleted during the Copy step.-->
<JSMainFile>Readme.md</JSMainFile>
<CopyTests>true</CopyTests>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Documentation'">
<TargetOS>Documentation</TargetOS>
<CopyTests>true</CopyTests>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Android'">
<TargetOS>Android</TargetOS>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Android_Deploy'">
<TargetOS>Android</TargetOS>
<JSConfig>Deploy\Eclipse\Configuration.xml</JSConfig>
<JSMainFile>bootstrap.js</JSMainFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Android_Tests'">
<TargetOS>Android</TargetOS>
<JSConfig>Deploy\Eclipse\Configuration.xml</JSConfig>
<JSMainFile>bootstrap.js</JSMainFile>
<CopyTests>true</CopyTests>
</PropertyGroup>
<UsingTask TaskName="BuildTasks.CopyForPlatformBuildTask" AssemblyFile="../../Build/lib/BuildTasks.dll" />
<Target Name="AfterBuild">
<CopyForPlatformBuildTask TargetPlatform="$(TargetOS)" IncludeTests="$(CopyTests)" Platforms="iOS;Android" InputFiles="@(GeneratedJavascript)" DestinationFolder="$(OutputPath)\$(Configuration)\" JSConfigFile="$(JSConfig)" AppMainJSFile="$(JSMainFile)" ProjectDir="$(ProjectDir)" />
<Exec Condition=" '$(Configuration)' == 'Documentation' " Command="rd /q /s &quot;../../Documentation/Docs/&quot;" />
<Exec Condition=" '$(Configuration)' == 'Documentation' " Command="md &quot;../../Documentation/Docs/&quot;" />
<Exec Condition=" '$(Configuration)' == 'Documentation' " Command="node ../../Documentation/Src/SnippetsExtractor/app.js -noclean -source bin\Documentation\Tests -destination ../../Documentation/Docs/" />
<Exec Condition=" '$(Configuration)' == 'Documentation' " Command="node ../../Documentation/Src/TypeScriptAPIExtractor/app.js @(TypeScriptCompile) $(IntermediateOutputPath)\api.xml" IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="false" LogStandardErrorAsError="true" />
<Exec Condition=" '$(Configuration)' == 'Documentation' " Command="&quot;../../Documentation/Src/XMLAPIPrinting/bin/Release/XMLAPIPrinting.exe&quot; $(IntermediateOutputPath)\api.xml &quot;../../Documentation/Docs/&quot;" />
</Target>
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

66
BCL.sln
View File

@@ -1,66 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BCL", "BCL.csproj", "{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNS-UI-Diagram", "..\TNS-UI-Diagram\TNS-UI-Diagram.csproj", "{D482FB50-DF22-4809-AF14-02C0ED40E478}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Android_Deploy|Any CPU = Android_Deploy|Any CPU
Android_Tests|Any CPU = Android_Tests|Any CPU
Android|Any CPU = Android|Any CPU
Debug|Any CPU = Debug|Any CPU
Documentation|Any CPU = Documentation|Any CPU
Full|Any CPU = Full|Any CPU
iOS_Deploy|Any CPU = iOS_Deploy|Any CPU
iOS_Tests|Any CPU = iOS_Tests|Any CPU
iOS|Any CPU = iOS|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Android_Deploy|Any CPU.ActiveCfg = Android_Deploy|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Android_Deploy|Any CPU.Build.0 = Android_Deploy|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Android_Tests|Any CPU.ActiveCfg = Android_Tests|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Android_Tests|Any CPU.Build.0 = Android_Tests|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Android|Any CPU.ActiveCfg = Android|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Android|Any CPU.Build.0 = Android|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Debug|Any CPU.ActiveCfg = Documentation|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Debug|Any CPU.Build.0 = Documentation|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Full|Any CPU.ActiveCfg = Full|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Full|Any CPU.Build.0 = Full|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.iOS_Deploy|Any CPU.ActiveCfg = iOS_Deploy|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.iOS_Deploy|Any CPU.Build.0 = iOS_Deploy|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.iOS_Tests|Any CPU.ActiveCfg = iOS_Tests|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.iOS_Tests|Any CPU.Build.0 = iOS_Tests|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.iOS|Any CPU.ActiveCfg = iOS|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.iOS|Any CPU.Build.0 = iOS|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Release|Any CPU.Build.0 = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Android_Deploy|Any CPU.ActiveCfg = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Android_Deploy|Any CPU.Build.0 = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Android_Tests|Any CPU.ActiveCfg = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Android_Tests|Any CPU.Build.0 = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Android|Any CPU.ActiveCfg = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Android|Any CPU.Build.0 = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Documentation|Any CPU.Build.0 = Debug|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Full|Any CPU.ActiveCfg = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Full|Any CPU.Build.0 = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.iOS_Deploy|Any CPU.ActiveCfg = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.iOS_Deploy|Any CPU.Build.0 = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.iOS_Tests|Any CPU.ActiveCfg = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.iOS_Tests|Any CPU.Build.0 = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.iOS|Any CPU.ActiveCfg = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.iOS|Any CPU.Build.0 = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D482FB50-DF22-4809-AF14-02C0ED40E478}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

759
CodingConvention.md Normal file
View File

@@ -0,0 +1,759 @@
#TSN-Modules Coding Convention#
##Linting
*TODO: We should further verify this may work with TypeScript*
Linting is the process of running a program that will analyse code for potential errors.
For Visual Studio use this [extension][vsjslint] with JsHint mode. Settings can be imported from [here][jslintsettings]
For WebStrom set it JsHint in Settings > JavaScript > Code Quality Tools.
Following rules should be applied.
~~~ {.javascript}
/*jshint bitwise:true, camelcase:true, curly:true, eqeqeq:true, forin:true, noarg:true, noempty:true, nonew:true, undef:true, unused:true, strict:true, indent:4, quotmark:single, node:true */
~~~
[linting]:http://stackoverflow.com/questions/8503559/what-is-linting
[vsjslint]:http://visualstudiogallery.msdn.microsoft.com/1a417c37-4d6f-43ca-b753-6ea6eb5041fd
[jslintsettings]:https://github.com/telerik/everlive/blob/master/CodeConventions/JSLintSettings.xml
## Tabs vs Spaces
Use 4 spaces indentation.
+ Visual Studio: Options > Text Editor > JavaScript > Tabs. Indenting: Smart tabs; Tab: Indent Size: 4, Insert Tabs: checked. This is the default Visual Studio set up
+ JetBrains WebStorm: Settings > Code Style > JavaScript > Use tab: unchecked. All other tam settings to 4
## Line length
Try to limit your lines to 80 characters.
## Semicolons, statement Termination
Always use semicolons where it is appropriate.
*Right:*
~~~ {.javascript}
var x = 1;
~~~
*Wrong:*
~~~ {.javascript}
var x = 1
~~~
## Quotes
Use single quotes, unless you are writing JSON.
*Right:*
~~~ {.javascript}
var foo = "bar";
~~~
*Wrong:*
~~~ {.javascript}
var foo = 'bar';
~~~
## Braces
Your opening braces go on the same line as the statement.
*Right:*
~~~ {.javascript}
if (true) {
console.log('winning');
}
~~~
*Wrong:*
~~~ {.javascript}
if (true)
{
console.log('losing');
}
~~~
Also, notice the use of whitespace before and after the condition statement.
## Variable declarations
Declare one variable per var statement. Try to put those declarations at the beginning of each scope.
**NOTE:** Loops DO NOT create new scopes so declare iteration vars outside the loop.
*Right:*
~~~ {.javascript}
var keys = ['foo', 'bar'];
var values = [23, 42];
var key;
var object = {};
while (items.length) {
key = keys.pop();
object[key] = values.pop();
}
//---------------------------
var i;
for (i = 0; i < items.length; i++) {
// do something
}
~~~
*Wrong:*
~~~ {.javascript}
var keys = ['foo', 'bar'],
values = [23, 42],
object = {};
while (items.length) {
var key = keys.pop();
object[key] = values.pop();
}
//---------------------------
for (var i = 0; i < items.length; i++) {
// one may assume the "i" var is local for the loop while it is NOT
}
~~~
## Variable and property names
Variables and properties should use [lower camel case][camelcase]
capitalization. They should also be descriptive. Single character variables and
uncommon abbreviations should generally be avoided unless it is something well known as **i** in for loops
*Right:*
~~~ {.javascript}
var adminUser = db.query('SELECT * FROM users ...');
~~~
*Wrong:*
~~~ {.javascript}
var admin_user = db.query('SELECT * FROM users ...');
~~~
[camelcase]: http://en.wikipedia.org/wiki/camelCase#Variations_and_synonyms
## Type names
Type names should be capitalized using [upper camel case][camelcase].
*Right:*
~~~ {.javascript}
function UserAccount() {
this.field = 'a';
}
~~~
*Wrong:*
~~~ {.javascript}
function userAccount() {
this.field = 'a';
}
~~~
## Constants
Constants should be declared with CAPITAL letters. If the constants will be used in more than one module put them in a separate file. Use underscore to name constants with complex wording.
*Right:*
~~~ {.javascript}
var SECOND = 1 * 1000;
var MY_SECOND = SECOND;
~~~
*Wrong:*
~~~ {.javascript}
var second = 1 * 1000;
~~~
## Object / Array creation
Use trailing commas and put *short* declarations on a single line. Only quote
keys when your interpreter complains:
*Right:*
~~~ {.javascript}
var a = ['hello', 'world'];
var b = {
good: 'code',
'is generally': 'pretty',
};
~~~
*Wrong:*
~~~ {.javascript}
var a = [
'hello', 'world'
];
var b = {"good": 'code'
, is generally: 'pretty'
};
~~~
## Long Arrays
*Right:*
~~~ {.javascript}
var a = [
“this”,
“is”,
“a”,
“very”,
“long”,
“array”,
“declaration”,
“for”,
“hello”,
“world” + HOW ABOUT THE ENDING commas?
];
~~~
## Equality operator
Use the [strict comaprison operators][comparisonoperators]. The triple equality operator helps to maintain data type integrity throughout code.
*Right:*
~~~ {.javascript}
var a = 0;
if (a === '') {
console.log('winning');
}
~~~
*Wrong:*
~~~ {.javascript}
var a = 0;
if (a == '') {
console.log('losing');
}
~~~
[comparisonoperators]: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Comparison_Operators
##Short-hand oprators
Try to avoid short-hand operators except in very simple scenarios.
*Right:*
~~~ {.javascript}
var default = x || 50;
var extraLarge = 'xxl';
var small = 's'
var big = (x > 10) ? extraLarge : small;
~~~
*Wrong:*
~~~ {.javascript}
var default = checkX(x) || getDefaultSize();
var big = (x > 10) ? checkX(x)?getExtraLarge():getDefaultSize():getSmallValue();
~~~
##Curly braces
Always use curly braces even in the cases of one line conditional operations.
*Right:*
~~~ {.javascript}
if (a) {
return 'winning';
}
~~~
*Wrong:*
~~~ {.javascript}
if (a)
return 'winning';
if (a) return 'winning';
~~~
##Boolean comparisons
**Do not** directly compare with true, or false.
*Right:*
~~~ {.javascript}
if(condition) {
console.log('winning');
}
if (!condition) {
console.log('winning');
}
~~~
*Wrong:*
~~~ {.javascript}
if(condition === true) {
console.log('losing');
}
if(condition !== true) {
console.log('losing');
}
if(condition !== false) {
console.log('losing');
}
~~~
## Boolean conditions format
Do not use the **Yoda Conditions** when writing boolean expressions:
> “Yoda Conditions” — the act of using
> if(constant == variable) **instead of**
> if(variable == constant), like if(4 == foo).
> Because it’s like saying “if blue is the sky” or “if tall is the man”.
*Right:*
~~~ {.javascript}
var num;
if(num >= 0) {
console.log('winning');
}
~~~
*Wrong:*
~~~ {.javascript}
var num;
if(0 <= num) {
console.log('losing');
}
~~~
**NOTE** It is OK to use constants on the left when comparing for a range.
~~~ {.javascript}
if(0 <= num && num <= 100) {
console.log('winning');
}
~~~
## Function length
Keep your functions short. A good function fits on a slide that the people in
the last row of a big room can comfortably read. So don't count on them having
perfect vision and limit yourself to 1/2 of your screen height per function (no screen rotation :).
## Return statements
There are few important considerations here:
+ To avoid deep nesting of if-statements, always return a functions value as early
as possible. In certain routines, once you know the answer, you want to return it to the calling routine immediately. If the routine is defined in such a way that it doesn't require any cleanup, not returning immediately means that you have to write more code.
+ Minimize the number of returns in each routine. It's harder to understand a routine if, reading it at the bottom, you're unaware of the possibility that it *return*ed somewhere above.
*Right:*
~~~ {.javascript}
function getSomething(val) {
if (val < 0) {
return false;
}
if (val > 100) {
return false;
}
var res1 = doOne();
var res2 = doTwo();
var options = {
a: 1,
b: 2
};
var result = doThree(res1, res2, options);
return result;
}
~~~
*Wrong:*
~~~ {.javascript}
function getSomething(val) {
if (val >= 0) {
if (val < 100) {
var res1 = doOne();
var res2 = doTwo();
var options = {
a: 1,
b: 2
};
var result = doThree(res1, res2, options);
return result;
}
else {
return false;
}
}
else {
return false;
}
}
~~~
## Globals
Avoid using globals. If you need to store a varable as a global make sure that this happens during the bootstrapping of the application. If your code uses globals, please either put them in the begininng of the file using the jsHint convention:
~~~ {.javascript}
/* global Logger, Constants, Everlive */
~~~
or use the *global* prefix:
~~~ {.javascript}
global.Logger.log('a');
~~~
## TS Lambdas
Avoid using TS Lambdas. Exception is when the function is one-line and DOES NOT use the "this" object.
*Right:*
~~~ {.javascript}
req.on('end', () => { console.log('winning'); });
//------
var that = this;
req.on("end", function () {
exp1();
exp2();
that.doSomething();
});
~~~
*Wrong:*
~~~ {.javascript}
req.on("end", () => {
exp1();
exp2();
this.doSomething();
});
~~~
## Nested Closures
Prefer closures nested NO MORE than 2 levels. Still, this is more a common sense.
*Right:*
~~~ {.javascript}
setTimeout(function() {
client.connect(afterConnect);
}, 1000);
function afterConnect() {
console.log('winning');
}
~~~
*Wrong:*
~~~ {.javascript}
setTimeout(function() {
client.connect(function() {
console.log('losing');
});
}, 1000);
~~~
## Promises
Wrap every asyncronous method in promises rather than callbacks.
*Right:*
~~~ {.javascript}
function doAsync(arg) {
var d = promises.defer();
// make the async call
async.call(arg, function onSuccess() {
d.resolve();
}, function onError() {
d.reject();
});
return d.promise();
}
~~~
*Wrong:*
~~~ {.javascript}
function doAsync(arg, onSuccess, onError) {
async.call(arg, onSuccess, onError);
}
~~~
##Comments
Use the [JSDoc][JSDOC] convention for comments. When writing a comment always think how understandable will be for somebody who is new to this code. Even if it may look simple to you think how a guy that just joined will understand it. Always comment in the following cases:
+ When there is some non-trivial logic.
+ Some 'external' knowledge is needed which is missing in the context - workaround for driver, module bug, special 'hack' because of a bug and so on;
+ When you are creating a new class
+ Public methods - include all the arguments and if possible the types {String}, {Number}. Optional arguments should be marked too. Check the [@param tag][param]
[JSDOC]: http://usejsdoc.org/
[param]: http://usejsdoc.org/tags-param.html
##Commenting of parameters that are objects/complex types
When you have parameters that are complex objexts like *options* or other type for which the properties are not clear or is external one use the [@type-def tag][typedef]
*Right:*
~~~ {.javascript}
/**
* @typedef PropertiesHash
* @type {object}
* @property {string} id - an ID.
* @property {string} name - your name.
* @property {number} age - your age.
*/
/**
* @param {PropertiesHash} properties
*/
function checkProperties(properties) {
if(!properties.id) {
return false;
}
}
~~~
*Wrong:*
~~~ {.javascript}
/**
* @param properties
*/
function checkProperties(properties) {
if(!properties.id) {
return false;
}
}
~~~
[typedef]: http://usejsdoc.org/tags-typedef.html
##File/module structure
Typical module should have the following structure:
1. required dependencies
2. module-private declarations - variables, functions, classes, etc.
3. export variables and functions
4. export class declarations
For more information see [this file](https://github.com/telerik/xPlatCore/blob/master/JS/BCL/CreateNewModule.md)
## File naming
Use lower case for file names. Use dash to separate different words.
*Right:*
file-system
*Wrong:*
FileSystem, fileSystem, file_system
## This, that, self
When you need to keep reference to **this** use **that** as the name of the variable. Additionally, if you use the TypeScript lambda support, the compiler will take care of this automatically. The tricky part here is that it outputs **_this** which is not compliant with our convention.
*Right:*
~~~ {.javascript}
var that = this;
doSomething(function(){
that.doNothing();
});
~~~
*Wrong:*
~~~ {.javascript}
var me = this;
doSomething(function(){
me.doNothing();
});
~~~
## Private (hidden) variables and methods
Although there is the **private** keyword in TypeScript, it is only a syntax sugar. There is no such notation in JavaScript and everything is available to the users. Hence, always use underscore (**_**) to prefix private variables and methods. There are also methods which have the **public** visibility but they are meant to be used within our code ONLY. Such methods should also be prefixed with underscore.
*Right:*
~~~ {.javascript}
class Foo {
private _myBoolean: boolean;
public publicAPIMethod() {
}
public _frameworkMethod() {
// this method is for internal use only
}
private _doSomething() {
}
}
~~~
*Wrong:*
~~~ {.javascript}
class Foo {
private myBoolean: boolean;
public _publicAPIMethod() {
}
public frameworkMethod() {
// this method is for internal use only
}
private doSomething() {
}
}
~~~
## Falsy values vs. null and undefined
When possible use the falsy comparison vs. comparison with null or undefined.
*Right:*
~~~ {.javascript}
var myVar = undefined;
if(myVar) {
// myVar is defined
}
~~~
*Wrong:*
~~~ {.javascript}
var myVar = undefined;
if(typeof myVar === 'undefined') {
}
~~~
## Type comparison
Sometimes we need to explicitly check for a type. In such cases use the built-in module **"types"**.
*Right:*
~~~ {.javascript}
import types = require("utils/types");
var myVar;
if(types.isString(myVar)) {
// myVar is of type String
}
~~~
*Wrong:*
~~~ {.javascript}
var myVar = undefined;
if(typeof myVar === 'string') {
}
~~~
## TypeScript optional parameters
**Do not** use optional parameters in IMPLEMENTATION files. This is because the TS compiler generates additional array and populates its from the **arguments** object. Still, it is OK to use these in a definition file (as declarations ONLY).
*Right:*
~~~ {.javascript}
// declaration
export declare function concat(...categories: string[]): string;
// implementation
export function concat(): string {
var i;
var result: string;
// use the arguments object to iterate the parameters
for (i = 0; i < arguments.length; i++) {
// do something
}
return result;
}
~~~
*Wrong:*
~~~ {.javascript}
// declaration
export declare function concat(...categories: string[]): string;
// implementation
export function concat(...categories: string[]): string {
var i;
var result: string;
// use the arguments object to iterate the parameters
for (i = 0; i < categories.length; i++) {
// do something
}
return result;
}
~~~
## (**SUGGESTION**) TypeScript function variable names
Name your function variables with the **Func** suffix. The reader will immediately know that this variable is a function when he sees it.
*Right:*
~~~ {.javascript}
var eachChildFunc = function eachChildFunc(child: View): boolean {
child.onUnloaded();
return true;
}
this._eachChildView(eachChildFunc);
~~~
*Wrong:*
~~~ {.javascript}
var eachChild = function (child: View): boolean {
child.onUnloaded();
return true;
}
this._eachChildView(eachChild);
~~~
## Naming test functions
Name your test function with test_ so that our test runner can find them and add 'underscore' tested method/property name. Different words should be capitalized (and optionally separated by 'underscore').
*Right:*
~~~ {.javascript}
export var test_goToVisualState_NoState_ShouldResetStyledProperties = function () {
// Test code here.
}
~~~

235
CreateNewModule.md Normal file
View File

@@ -0,0 +1,235 @@
# How to create new Cross-Platform Module
1. Each module resides in a separate folder.
2. There must be a package.json file in this folder which tells the NS Runtime which is the main file of the module to load.
3. There is a declaration (*.d.ts) file describing the public API of the module.
4. When there is a ***.android.ts** named file this tells our CLI that this file is Android-specific and should be icluded in Android builds ONLY. When a build is started for the Android platform, the **.android** part of the file is stripped in the application package. For example **foo.android.js** will become ***foo.js**. Same convention works for ***.ios.ts** files.
## Declaration and implementation files
There are several major scenarios when writing modules:
### The module implementation contains pure JavaScript code ONLY and does not depend on native APIs. In this case the entire logic is executed on the JS Virtual Machine side and the TNS Runtime is not involved.
**Declaration file (foo.d.ts):**
```javascript
declare module "foo"{
function a();
class Foo {
public var1: number;
}
}
```
**Implementation file (foo.ts):**
```javascript
import definition = require("foo");
export function a(){
// do somethign here
}
// require the definition and put implements clause to ensure API consistency between the declaration and implementation
export class Foo implements definition.Foo {
public var1: number;
}
```
### The module implementation depends on native APIs ONLY and the common pure JavaScript code between platform-specific implementations is minimal.
**Declaration file (foo.d.ts):**
```javascript
declare module "foo"{
class Foo {
public running: number;
public start(): void;
public stop(): void;
}
}
```
**Android implementation file (foo.android.ts):**
```javascript
import definition = require("foo");
// require the definition and put implements clause to ensure API consistency between the declaration and implementation
export class Foo implements definition.Foo {
public running: number;
public start(): void {
// Call android APIs - e.g. android.os.SystemClock.[xxx]
this.running = true;
}
public stop(): void {
// Call android APIs - e.g. android.os.SystemClock.[xxx]
this.running = false;
}
}
```
**iOS implementation file (foo.ios.ts):**
```javascript
import definition = require("foo");
// require the definition and put implements clause to ensure API consistency between the declaration and implementation
export class Foo implements definition.Foo {
public running: number;
public start(): void {
// Call iOS APIs - e.g. Foundation.NSObject.[xxx]
this.running = true;
}
public stop(): void {
// Call iOS APIs - e.g. Foundation.NSObject.[xxx]
this.running = false;
}
}
```
### The module is more complex and contains significant part of pure JavaScript code as well as native APIs calls.
In this case we will need to reuse the common JavaScript code and to split the implementation only for the platform specific native APIs. There are two different approaches here:
* _Separate the common implementation (code) in a base class. Add two specific files that inherit the base class and provide the platform-specific implementation:_
**Declaration file (foo.d.ts):**
```javascript
declare module "foo"{
class Foo {
public running: number;
public start(): void;
public stop(): void;
}
}
```
**Common implementation file (foo-common.ts):**
```javascript
import definition = require("foo");
// require the definition and put implements clause to ensure API consistency between the declaration and implementation
export class Foo implements definition.Foo {
public running: number;
public start(): void {
this.running = true;
// add some common implementation here
}
public stop(): void {
this.running = false;
// add some common implementation here
}
}
```
**Android implementation file (foo.android.ts):**
```javascript
import common = require("foo-common");
// require the common file and extend the base common implementation
export class Foo extends common.Foo {
public start(): void {
// call the base method which does the common job
super.start();
// add platform-specific implementation - e.g. call android.os.SystemClock.[xxx]
}
public stop(): void {
// call the base method which does the common job
super.stop();
// add platform-specific implementation - e.g. call android.os.SystemClock.[xxx]
}
}
```
**iOS implementation file (foo.ios.ts):**
```javascript
import common = require("foo-common");
// require the common file and extend the base common implementation
export class Foo extends common.Foo {
public start(): void {
// call the base method which does the common job
super.start();
// add platform-specific implementation - e.g. call Foundation.NSObject.[xxx]
}
public stop(): void {
// call the base method which does the common job
super.stop();
// add platform-specific implementation - e.g. call Foundation.NSObject.[xxx]
}
}
```
* _Extract the platform specific implementation in a separate Facade and aggregate/use it within the JavaScript implementation:_
**Declaration file (foo.d.ts):**
```javascript
declare module "foo"{
class Foo {
public running: number;
public start(): void;
public stop(): void;
}
}
```
**Native Implementation Declaration file (foo-native.d.ts):**
```javascript
//@private
// The above statement marks this definition as private so that it is not visible to the users
declare module "foo-native"{
function startNative();
function stopNative();
}
```
**Android Native Implementation file (foo-native.android.ts):**
```javascript
export function startNative(){
// call native code here
}
export function stopNative(){
// call native code here
}
```
**iOS Native Implementation file (foo-native.ios.ts):**
```javascript
export function startNative(){
// call native code here
}
export function stopNative(){
// call native code here
}
```
**Common implementation file (foo.ts):**
```javascript
import definition = require("foo");
import fooNative = require("foo-native");
// require the definition and put implements clause to ensure API consistency between the declaration and implementation
export class Foo implements definition.Foo {
public running: number;
public start(): void {
this.running = true;
// do the native call through the Facade
fooNative.startNative();
}
public stop(): void {
this.running = false;
// do the native call through the Facade
fooNative.stopNative();
}
}
```

1462
CrossPlatformModules.csproj Normal file
View File

File diff suppressed because it is too large Load Diff

26
CrossPlatformModules.sln Normal file
View File

@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossPlatformModules", "CrossPlatformModules.csproj", "{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Android_Tests|Any CPU = Android_Tests|Any CPU
Cross|Any CPU = Cross|Any CPU
Documentation|Any CPU = Documentation|Any CPU
iOS_Tests|Any CPU = iOS_Tests|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Android_Tests|Any CPU.ActiveCfg = Android_Tests|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Android_Tests|Any CPU.Build.0 = Android_Tests|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Cross|Any CPU.ActiveCfg = Cross|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Cross|Any CPU.Build.0 = Cross|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.iOS_Tests|Any CPU.ActiveCfg = iOS_Tests|Any CPU
{2313F1BF-1F2D-4F11-806A-87927FA6A7C0}.iOS_Tests|Any CPU.Build.0 = iOS_Tests|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

23
DebugV8Heap.md Normal file
View File

@@ -0,0 +1,23 @@
###NOTE: This works for Android ONLY!!!
* There is the global function
```js
heapSnapshot();
```
* The function will save a V8's heap dump file in the application private files folder - e.g.
```js
data/data/com.telerik.tns.unittestapp/files/xxx.xxx.heapsnapshot
```
* Open command prompt and go the location of your ADB - e.g. [PathToADT]/sdk/platform-tools/
* Run `adb shell`
* Go to `/data/data/com.telerik.tns.unittestapp/files/`
* Run `ls` to list the files in the folder and find the *.heapsnapshot file(s).
* Run `exit` to return back to the command prompt
* Run `adb pull /data/data/com.telerik.tns.unittestapp/files/xxx.xxx.heapsnapshot LocalPath/To/Snapshot`
* Open Chrome Developer Tools (Ctrl + Shift + I within Chrome)
* Go to `Profiles` tab on the top of the tools window
* Select `Record Heap Allocations` and load the locally saved *.heapsnapshot file.

View File

@@ -1 +0,0 @@
/Configuration.xml

View File

@@ -1 +0,0 @@
/Configuration.xml

View File

@@ -1,26 +0,0 @@
You can specify output folder for Eclipse and xCode using Configuration.xml placed in respective folder. For example:
## Android
```xml
<?xml version="1.0" encoding="utf-8" ?>
<JSFolder>
<Path>C:\Users\enchev\Documents\GitHub\Kimera\android\Playground\Kimera.Skeleton\assets\tns_modules</Path>
</JSFolder>
```
## xCode
```xml
<?xml version="1.0" encoding="utf-8" ?>
<JSFolder>
<Path>Z:\TNSBridgeApp\TNSBridgeApp\TNSBridgeApp\tns_modules\</Path>
</JSFolder>
```
## UnitTestApp - Ready to run
```xml
<?xml version="1.0" encoding="utf-8" ?>
<JSFolder>
<Path>C:\Work\Git\xPlatCore\Applications\Android\UnitTestApp\assets\tns_modules</Path>
</JSFolder>
```

View File

@@ -1 +0,0 @@
/Configuration.xml

View File

@@ -1,72 +1,43 @@
Steps to build the BCL solution:
NativeScript Modules
===
The BCL solution relies on a custom build task used to filter and rename the compiled javascript files by platform.
E.g. the file `application.android.js`, containing the actual platform-specific implementation will become `application.js`.
There is also the .impl suffix for files where we have definition and implementation file with the same name, e.g.:
#What are the cross-platform modules
The cross-platform modules repository contains the framework to be used for writing code that will run on any of the platforms, supported by NativeScript.
file-system.d.ts <br/>
file-system.impl.ts
#Basics
For faster and more stable development, the modules are written in TypeScript, that gets 'transpiled' to JavaScript, which actually runs on the target device. To have that, the JavaScript code is accompanied with a set of platform-specific (native) binaries, called runtimes. These are a middle layer, running the JavaScript code on the device.
This is done to force the typescript compiler in Visual Studio to feed its definitions from the *.d.ts file rather than the implementation one.
The build task removes this private suffix and the final output is
#Code organization
Each runtime provides JavaScript wrappers over the native platform classes. The classes in the cross-platform modules are common wrappers over the native wrappers, organized in a manner, allowing the straightforward development of powerful cross-platform mobile applications.
A cross-platform class would typically have different imlementations for the different platforms. The cross-platform library must have them both and decide which one to use. To avoid runtime checking, a convention is chosen that any files, named \*.[platform].ts (and, respectively, \*.[platform].js) are valid for the specific platform only. That way, common API gets only declared in a file, named `file-system-access.d.ts` while its iOS and Android implementations get coded in the `file-system-access.ios.ts` and `file-system-access.android.ts` respectively.
files-system.js
One would notice the `apps` folder, which does not fit the notation of a module. Normally each of the subfolders of the `apps` folder would be a separate repository or a project, with its own build and packaging. For a faster and more stable development, aided with code completion and due to limitations in Visual Studio, the current setup is chosen.
The BCL itself uses a pre-built copy of the task, residing in the `Build/lib` folder.
#Steps to build the CrossPlatformModules solution:
### BuildTasks solution
#Before start
1. Make sure you have nodejs and npm installed
2. Navigate to the CrossPlatformModules directory
3. Run `npm install -g grunt-cli` (to be able to trigger the grunt build).<br/>
**Note**: Might require sudo permissions on some *nix systems
4. Run `npm install` (will install the dependencies and devDependencies)
In case you want to change the custom build task you will need to rebuild the solution and copy the newly generated assembly to the `Build/lib` folder.
[BuildTasks](https://github.com/telerik/xPlatCore/tree/master/Build/Tasks)
#Visual Studio and Project Structure
The CrossPlatformModules project calls a grunt task that transpiles the typescript code to JavaScript.
The output of this project is located at (../bin/)
A module file that cannot have a common implementation across the platforms
would have a `modulename.d.ts` file, containing the declarations of the
module API and `modulename.[platform].ts` files, containing the actual
platform-specific implementation of the module functionality.
The `modulename.d.ts` file in that case is used by Visual Studio as an intellisense
helper, forcing the Visual Studio typescript compiler to feed its definitions
from the \*.d.ts file rather than the implementation one.
### Build the BCL project
There are six different configurations of the project:
- Android <br/>
This configuration will create a `bin/Android` folder and output all the Android-related files there.
- Android_Deploy <br/>
Same as the Android configuration plus the generated javascript is copied to the tns_modules folder in the targeted Eclipse project.
The path to the project is taken from the `BCL/Deploy/Eclipse/Configuration.xml` file. The expected XML structure is:
```xml
<?xml version="1.0" encoding="utf-8" ?>
<JSFolder>
<Path>C:\Work\Git\xPlatCore\Applications\Android\UnitTestApp\assets\tns_modules</Path>
</JSFolder>
```
- Android_Tests <br/>
Same as Android_Deploy plus the Tests folder in the BCL is copied to the output directory.
- iOS <br/>
This configuration will create a `bin/iOS` folder and output all the iOS-related files there.
- iOS_Deploy <br/>
Same as the iOS configuration plus the generated javascript is copied to the JS folder in the testing xCode project.
The path to the project is taken from the `BCL/Deploy/xCode/Configuration.xml` file. The expected XML structure is:
```xml
<?xml version="1.0" encoding="utf-8" ?>
<JSFolder>
<Path>Z:\Kimera\JDBridgeApp\JDBridgeApp\js</Path>
</JSFolder>
```
In order to use this path you will need to map a shared MAC's folder and access it from your PC.
- iOS_Tests <br/>
Same as iOS_Deploy plus the Tests folder in the BCL is copied to the output directory.
### UnitTestApp - Ready to run
```xml
<?xml version="1.0" encoding="utf-8" ?>
<JSFolder>
<Path>C:\Work\Git\xPlatCore\Applications\Android\UnitTestApp\assets\tns_modules</Path>
</JSFolder>
```
When built, the project outputs npm packages, containing the fully transpiled
code. There is a package for the modules only and packages for each subfolder
of the apps folder, each representing a standalone cross-platform NativeScript
application.
### Useful links
@@ -75,3 +46,6 @@ There are six different configurations of the project:
Adds the option to "Group Items" (DependentUpon tag) within the Visual Studio Solution Explorer. Select several items, right-click -> Group Items.
[A comparison of various features and APIs across mobile platforms](https://github.com/w3c-webmob/web-api-gap/blob/master/features/compass.md)
## CLI
Run `grunt` to have the the packages built and output to the `bin/dist` subfolder.

View File

@@ -1,191 +0,0 @@
/* Notes:
1. all test function names should begin with 'test'
2. (if exists) at the beginning of module test setUpModule() module function is called
3. (if exists) at the beginning of each test setUp() module function is called
4. tests should use TKUnit.assert(condition, message) to mark error. If no assert fails test is successful
5. (if exists) at the end of each test tearDown() module function is called
6. (if exists) at the end of module test tearDownModule() module function is called
*/
import Application = require("application");
import timer = require("timer/timer");
var runTest = function (test, testName) {
test();
console.info("--- [" + testName + "] OK");
};
export var runTestModule = function (module, moduleName) {
console.info("--- " + moduleName + " TESTS BEGIN ---");
console.time(moduleName);
try {
if (module.setUpModule) {
module.setUpModule();
}
} catch (e) {
console.error("--- [" + moduleName + ".setUpModule()] FAILED: " + e.message);
}
var totalTests = 0;
var totalSuccess = 0;
var errors = new Array();
for (var testName in module) {
var testFunction = module[testName];
if ((typeof (testFunction) === "function") && (testName.substring(0, 4) == "test")) {
try {
if (module.setUp) {
module.setUp();
}
} catch (e) {
console.error("--- [" + moduleName + ".setUp()] FAILED: " + e.message);
}
try {
totalTests++;
runTest(testFunction, testName);
totalSuccess++;
} catch (e) {
errors.push(e);
console.error("--- [" + testName + "] FAILED: " + e.message);
}
try {
if (module.tearDown) {
module.tearDown();
}
} catch (e) {
console.error("--- [" + moduleName + ".tearDown()] FAILED: " + e.message);
}
}
}
try {
if (module.tearDownModule) {
module.tearDownModule();
}
} catch (e) {
console.error("--- [" + moduleName + ".tearDownModule()] FAILED: " + e.message);
}
console.timeEnd(moduleName);
console.info("--- " + moduleName + " TESTS COMPLETE --- (" + totalSuccess + " of " + totalTests + ") OK, " + (totalTests - totalSuccess) + " failed");
return { "total": totalTests, "success": totalSuccess, "failed": (totalTests - totalSuccess), "errors": errors };
};
export var assert = function (test: any, message?: string) {
if (!test) {
throw new Error(message);
}
};
export var wait = function (ms) {
if (Application.ios) {
Foundation.NSRunLoop.currentRunLoop().runUntilDate(Foundation.NSDate.dateWithTimeIntervalSinceNow(ms / 1000));
} else if (Application.android) {
java.lang.Thread.sleep(long(ms));
java.lang.Thread.yield();
}
};
export var waitUntilReady = function (isReady: () => boolean, timeoutSec?: number) {
if (!isReady) {
return;
}
if (!timeoutSec) {
// TODO: How much should be the default timeout in seconds?
timeoutSec = 20;
}
if (Application.ios) {
var waitTime = 20 / 1000;
var totalWaitTime = 0;
while (true) {
Foundation.NSRunLoop.currentRunLoop().runUntilDate(Foundation.NSDate.dateWithTimeIntervalSinceNow(waitTime));
if (isReady()) {
break;
}
totalWaitTime += waitTime;
if (timeoutSec && totalWaitTime >= timeoutSec) {
break;
}
}
} else if (Application.android) {
doModalAndroid(isReady, timeoutSec);
}
};
// Setup for the Android modal loop implementation
// TODO: If these platform-specific implementations continue to grow, think of per-platform separation (TKUnit.android)
var nextMethod;
var targetField;
var prepared;
var prepareModal = function () {
if (prepared) {
return;
}
var clsMsgQueue = java.lang.Class.forName("android.os.MessageQueue");
var clsMsg = java.lang.Class.forName("android.os.Message");
nextMethod;
var methods = clsMsgQueue.getDeclaredMethods();
var i;
for (i = 0; i < methods.length; i++) {
if (methods[i].getName() === "next") {
nextMethod = methods[i];
nextMethod.setAccessible(true);
break;
}
}
targetField;
var fields = clsMsg.getDeclaredFields();
for (i = 0; i < fields.length; i++) {
if (fields[i].getName() === "target") {
targetField = fields[i];
targetField.setAccessible(true);
break;
}
}
prepared = true;
}
var doModalAndroid = function (quitLoop: () => boolean, timeoutSec: number) {
if (!quitLoop) {
return;
}
prepareModal();
var queue = android.os.Looper.myQueue();
var quit = false;
timer.setTimeout(function () {
quit = true;
}, timeoutSec * 1000);
var msg;
while (!quit) {
msg = nextMethod.invoke(queue, null);
if (msg) {
var target = targetField.get(msg);
if (!target) {
quit = true;
} else {
target.dispatchMessage(msg);
}
msg.recycle();
}
if (!quit && quitLoop()) {
quit = true;
}
}
};

View File

@@ -1,327 +0,0 @@
import TKUnit = require("Tests/TKUnit");
import http = require("http");
require("globals");
// <snippet name="http/HOW-TO">
// # Http module
// ``` JavaScript
// var http = require("http");
// ```
// </snippet>
export var test_getString_isDefined = function () {
TKUnit.assert(typeof (http.getString) !== "undefined", "Method http.getString() should be defined!");
};
export var test_getString = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
// <snippet name="http/HOW-TO">
// ### Get string from URL
// ``` JavaScript
http.getString("http://httpbin.org/get").then(function (r) {
//// Argument (r) is string!
// <hide>
completed = true;
result = r;
// </hide>
}).fail(function (e) {
//// Argument (e) is Error!
console.log(e);
});
// ```
// </snippet>
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(typeof (result) === "string", "Result from getString() should be string!");
};
export var test_getString_fail = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.getString({ url: "hgfttp://httpbin.org/get", method: "GET", timeout: 2000 }).fail(function (e) {
completed = true;
result = e;
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(result instanceof Error, "Result from getString().fail() should be Error! Current type is " + typeof result);
};
export var test_getJSON_isDefined = function () {
TKUnit.assert(typeof (http.getJSON) !== "undefined", "Method http.getJSON() should be defined!");
};
export var test_getJSON = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
// <snippet name="http/HOW-TO">
// ### Get JSON from URL
// ``` JavaScript
http.getJSON("http://httpbin.org/get").then(function (r) {
//// Argument (r) is JSON!
// <hide>
completed = true;
result = r;
// </hide>
}).fail(function (e) {
//// Argument (e) is Error!
console.log(e);
});
// ```
// </snippet>
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(typeof (JSON.stringify(result)) === "string", "Result from getJSON() should be valid JSON object!");
};
export var test_getJSON_fail = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.getJSON({ url: "hgfttp://httpbin.org/get", method: "GET", timeout: 2000 }).fail(function (e) {
completed = true;
result = e;
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(result instanceof Error, "Result from getJSON().fail() should be Error! Current type is " + typeof result);
};
export var test_getImage_isDefined = function () {
TKUnit.assert(typeof (http.getImage) !== "undefined", "Method http.getImage() should be defined!");
};
export var test_getImage = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
// <snippet name="http/HOW-TO">
// ### Get Image from URL
// ``` JavaScript
http.getImage("http://www.google.com/images/errors/logo_sm_2.png").then(function (r) {
//// Argument (r) is Image!
// <hide>
completed = true;
result = r;
// </hide>
}).fail(function (e) {
//// Argument (e) is Error!
console.log(e);
});
// ```
// </snippet>
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(result instanceof require("image-source").ImageSource, "Result from getImage() should be valid ImageSource object!");
};
export var test_getImage_fail = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.getImage({ url: "hgfttp://www.google.com/images/errors/logo_sm_2.png", method: "GET", timeout: 2000 }).fail(function (e) {
completed = true;
result = e;
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(result instanceof Error, "Result from getImage().fail() should be Error! Current type is " + typeof result);
};
export var test_request_isDefined = function () {
TKUnit.assert(typeof (http["request"]) !== "undefined", "Method http.request() should be defined!");
};
export var test_request_shouldFailIfOptionsUrlIsNotDefined = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.request({ url: undefined, method: undefined }).fail(function (e) {
completed = true;
result = e;
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(result instanceof Error, "Result from request().fail() should be Error! Current type is " + typeof result);
};
export var test_request_responseStatusCodeShouldBeDefined = function () {
var result: http.HttpResponse;
var completed: boolean;
var isReady = function () { return completed; }
// <snippet name="http/HOW-TO">
// ### Get response status code
// ``` JavaScript
http.request({ url: "http://httpbin.org/get", method: "GET" }).then(function (response) {
//// Argument (response) is HttpResponse!
var statusCode = response.statusCode;
// <hide>
completed = true;
result = response;
// </hide>
}).fail(function (e) {
//// Argument (e) is Error!
console.log(e);
});
// ```
// </snippet>
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(typeof (result.statusCode) !== "undefined", "response.statusCode should be defined!");
};
export var test_request_responseHeadersShouldBeDefined = function () {
var result: http.HttpResponse;
var completed: boolean;
var isReady = function () { return completed; }
// <snippet name="http/HOW-TO">
// ### Get response headers
// ``` JavaScript
http.request({ url: "http://httpbin.org/get", method: "GET" }).then(function (response) {
//// Argument (response) is HttpResponse!
for (var header in response.headers) {
console.log(header + ":" + response.headers[header]);
}
// <hide>
completed = true;
result = response;
// </hide>
}).fail(function (e) {
//// Argument (e) is Error!
console.log(e);
});
// ```
// </snippet>
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(typeof (result.headers) !== "undefined", "response.headers should be defined!");
};
export var test_request_responseContentShouldBeDefined = function () {
var result: http.HttpResponse;
var completed: boolean;
var isReady = function () { return completed; }
// <snippet name="http/HOW-TO">
// ### Get response content
// ``` JavaScript
http.request({ url: "http://httpbin.org/get", method: "GET" }).then(function (response) {
//// Argument (response) is HttpResponse!
//// Content property of the response is HttpContent!
var str = response.content.toString();
var obj = response.content.toJSON();
var img = response.content.toImage();
// <hide>
completed = true;
result = response;
// </hide>
}).fail(function (e) {
//// Argument (e) is Error!
console.log(e);
});
// ```
// </snippet>
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(typeof (result.content) !== "undefined", "response.content should be defined!");
};
export var test_request_responseContentToStringShouldReturnString = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.request({ url: "http://httpbin.org/get", method: "GET" }).then(function (response) {
completed = true;
result = response.content.toString();
}).fail(function (e) {
console.log(e);
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(typeof (result) === "string", "Result from toString() should be string!");
};
export var test_request_responseContentToJSONShouldReturnJSON = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.request({ url: "http://httpbin.org/get", method: "GET" }).then(function (response) {
completed = true;
result = response.content.toJSON();
}).fail(function (e) {
console.log(e);
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(typeof (JSON.stringify(result)) === "string", "Result from toJSON() should be valid JSON object!");
};
export var test_request_responseContentToImageShouldReturnImage = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.request({ url: "http://www.google.com/images/errors/logo_sm_2.png", method: "GET" }).then(function (response) {
completed = true;
result = response.content.toImage();
}).fail(function (e) {
console.log(e);
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(result instanceof require("image-source").ImageSource, "Result from toImage() should be valid ImageSource object!");
};
export var test_request_headersSentAndReceivedProperly = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.request({
url: "http://httpbin.org/get", method: "GET",
headers: { "Content-Type": "application/json" }
}).then(function (response) {
completed = true;
result = response.headers;
}).fail(function (e) {
console.log(e);
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(result["Content-Type"] === "application/json", "Headers not sent/received properly!");
};
export var test_request_contentSentAndReceivedProperly = function () {
var result;
var completed: boolean;
var isReady = function () { return completed; }
http.request({
url: "http://httpbin.org/post", method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
content: "MyVariableOne=ValueOne&MyVariableTwo=ValueTwo"
}).then(function (response) {
completed = true;
result = response.content.toJSON();
}).fail(function (e) {
console.log(e);
});
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(result["form"]["MyVariableOne"] === "ValueOne" && result["form"]["MyVariableTwo"] === "ValueTwo", "Content not sent/received properly!");
};

View File

@@ -1,103 +0,0 @@
// <snippet name="image-source/HOW-TO">
// # Image source
// Using the image source requires the image-source module.
// ``` JavaScript
//var imageSource = require("image-source");
// ```
// The pre-required `imageSource` module is used throughout the following code snippets.
// We also use fs module defined as follows:
// ``` JavaScript
//var fs = require("file-system");
// ```
// ## Loading and saving images
// </snippet>
import imageSource = require("image-source");
import fs = require("file-system");
import app = require("application");
import TKUnit = require("Tests/TKUnit");
export var testFromResource = function () {
// <snippet name="image-source/HOW-TO">
// ### Load image using resource name
// This is similar to loading Bitmap from `R.drawable.logo` on Android or calling `[UIImage imageNamed@"logo"]` on iOS
// ``` JavaScript
var img = imageSource.fromResource("logo");
// ```
// </snippet>
TKUnit.assert(img.height > 0, "image.fromResource failed");
}
export var testFromUrl = function () {
var completed;
var result: imageSource.ImageSource;
// <snippet name="image-source/HOW-TO">
// ### Load image from URL
// ``` JavaScript
imageSource.fromUrl("http://www.google.com/images/errors/logo_sm_2.png")
.then(function (res: imageSource.ImageSource) {
//console.log("Image successfully loaded");
// <hide>
completed = true;
result = res;
// </hide>
})
.fail(function (error) {
//console.log("Error loading image: " + error);
// <hide>
completed = true;
// </hide>
});
// ```
// </snippet>
var isReady = function () {
return completed;
}
TKUnit.waitUntilReady(isReady, 3);
TKUnit.assert(typeof result !== "undefined", "Image not downloaded");
TKUnit.assert(result.height > 0, "Image not downloaded");
}
export var testSaveToFile = function () {
// <snippet name="image-source/HOW-TO">
// ### Save image source to PNG or JPG file
// ``` JavaScript
var img = imageSource.fromResource("logo");
var folder = fs.knownFolders.documents();
var path = fs.path.join(folder.path, "Test.png");
var saved = img.saveToFile(path, imageSource.ImageFormat.PNG);
// ```
// </snippet>
TKUnit.assert(saved, "Image not saved to file");
TKUnit.assert(fs.File.exists(path), "Image not saved to file");
}
export var testFromFile = function () {
// <snippet name="image-source/HOW-TO">
// ### Load image from a local file
// ``` JavaScript
var folder = fs.knownFolders.documents();
var path = fs.path.join(folder.path, "Test.png");
var img = imageSource.fromFile(path);
// ```
// </snippet>
TKUnit.assert(img.height > 0, "image.fromResource failed");
// remove the image from the file system
var file = folder.getFile("Test.png");
file.remove();
TKUnit.assert(!fs.File.exists(path), "Test.png not removed");
}
export var testNativeFields = function () {
var img = imageSource.fromResource("logo");
if (app.android) {
TKUnit.assert(img.android != null, "Image.android not updated.");
} else if (app.ios) {
TKUnit.assert(img.ios != null, "Image.ios not updated.");
}
}

View File

@@ -1,2 +0,0 @@
declare var module, require;
module.exports = require("Tests/testRunner");

View File

@@ -1,25 +0,0 @@
var TKUnit = require("Tests/TKUnit");
var allTests = {};
allTests["APPLICATION"] = require("Tests/application-tests");
allTests["FILE SYSTEM"] = require("Tests/file-system-tests");
allTests["HTTP"] = require("Tests/http-tests");
allTests["LOCATION"] = require("Tests/location-tests");
allTests["LOCAL SETTINGS"] = require("Tests/local-settings-tests");
allTests["IMAGE SOURCE"] = require("Tests/image-source-tests");
allTests["TIMER"] = require("Tests/timer-tests");
export var runAll = function (moduleName?: string) {
var totalSuccess = 0;
var totalFailed = 0;
for (var name in allTests) {
if(moduleName && (moduleName.toLowerCase() !== name.toLowerCase())) {
continue;
}
var result = TKUnit.runTestModule(allTests[name], name);
totalSuccess += result.success;
totalFailed += result.failed;
}
console.info("=== ALL TESTS COMPLETE === " + totalSuccess + " OK, " + totalFailed + " failed")
}

278237
android17.d.ts vendored
View File

File diff suppressed because one or more lines are too long

View File

@@ -1,31 +1,14 @@
To initialize the module put the following code in the main entry point file (app.js):
```js
var appModule = require("application");
appModule.init([native app instance]);
Use the frame in the following way:
### To navigate to the starting page of the application
```javascript
// put this in the bootstrap.js
var app = require("application");
var frameModule = require("ui/frame");
app.onLaunch = function(context) {
var frame = new frameModule.Frame();
frame.navigate("testPage");
}
```
iOS example:
```js
var app = require("application");
var MyViewController = UIKit.UIViewController.extends({
viewDidLoad: function() {
this.title = "Home";
var bm = require("ui/button");
var button = new bm.Button();
button.text = "test";
button.ios.frame = Foundation.CGRectMake(100, 100, 100, 40);
button.on("click", function(arg){
require("ui/dialogs").alert("Some message");
});
button.addToParent(this.view);
}
});
app.onLaunch = function(){
return new MyViewController();
}
app.init();
```

View File

@@ -1,6 +1,15 @@
require("globals");
import definition = require("application");
import cssParser = require("js-libs/reworkcss");
import fs = require("file-system");
import fileSystemAccess = require("file-system/file-system-access");
import styleScope = require("ui/styling/style-scope");
export var onLaunch: () => any = undefined;
export var cssFile: string = "app/app.css"
export var onUncaughtError: (error: definition.NativeScriptError) => void = undefined;
export var onLaunch: (context: any) => any = undefined;
export var onSuspend: () => any = undefined;
@@ -12,4 +21,17 @@ export var onLowMemory: () => any = undefined;
export var android = undefined;
export var ios = undefined;
export var ios = undefined;
export function loadCss() {
if (definition.cssFile) {
var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, definition.cssFile);
var applicationCss;
if (fs.File.exists(cssFileName)) {
// Read the CSS file.
new fileSystemAccess.FileSystemAccess().readText(cssFileName, r => { applicationCss = r; });
var applicationCssSyntaxTree = cssParser.parse(applicationCss, undefined);
definition.cssSelectorsCache = styleScope.StyleScope.createSelectorsFromSyntaxTree(applicationCssSyntaxTree);
}
}
}

View File

@@ -1,6 +1,7 @@
import appModule = require("application/application-common");
import dts = require("application");
import frame = require("ui/frame");
import types = require("utils/types");
// merge the exports of the application_common file with the exports of this file
declare var exports;
@@ -8,6 +9,8 @@ require("utils/module-merge").merge(appModule, exports);
var callbacks = android.app.Application.ActivityLifecycleCallbacks;
export var mainModule: string;
// We are using the exports object for the common events since we merge the appModule with this module's exports, which is what users will receive when require("application") is called;
// TODO: This is kind of hacky and is "pure JS in TypeScript"
@@ -93,18 +96,17 @@ var initEvents = function () {
return lifecycleCallbacks;
}
var initialized;
export var init = function (nativeApp: android.app.Application) {
if (initialized) {
return;
app.init({
getActivity: function (intent: android.content.Intent) {
return exports.android.getActivity(intent);
},
onCreate: function () {
var androidApp = new AndroidApplication(this);
exports.android = androidApp;
androidApp.init();
}
var app = new AndroidApplication(nativeApp);
exports.android = app;
app.init();
initialized = true;
}
});
class AndroidApplication implements dts.AndroidApplication {
public nativeApp: android.app.Application;
@@ -113,6 +115,7 @@ class AndroidApplication implements dts.AndroidApplication {
public foregroundActivity: android.app.Activity;
public startActivity: android.app.Activity;
public packageName: string;
public hasActionBar: boolean;
// public getActivity: (intent: android.content.Intent) => any;
public onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
@@ -123,21 +126,81 @@ class AndroidApplication implements dts.AndroidApplication {
public onActivityStopped: (activity: android.app.Activity) => void;
public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
public onActivityResult: (requestCode: number, resultCode: number, data: android.content.Intent) => void;
private _eventsToken: any;
//private _initialized: boolean;
constructor(nativeApp: any) {
this.nativeApp = nativeApp;
this.packageName = nativeApp.getPackageName();
this.context = nativeApp.getApplicationContext();
}
public getActivity(intent: android.content.Intent): any {
var currentPage = rootFrame.currentPage;
if (!currentPage) {
throw new Error("Root frame not navigated to a page.");
//private setupUI() {
// // TODO: We probably don't need this flag if onCreate is going to be called once.
// if (!this._initialized) {
// this._initialized = true;
// if (mainModule && mainModule !== "") {
// var mainPage = require(mainModule).Page;
// if (mainPage instanceof page.Page) {
// this._rootView.addView(<android.view.View>mainPage.android);
// // TODO: We need to show ActionBar if there are any toolBar items
// // or if navigation page - showNavigationBar is true
// var showActionBar = false;
// if (mainPage instanceof page.TabbedPage) {
// showActionBar = true;
// this.startActivity.getActionBar().NavigationMode = android.app.ActionBar.NAVIGATION_MODE_TABS;
// }
// else if (mainPage instanceof page.NavigationPage) {
// showActionBar = (<page.NavigationPage>mainPage).showActionBar;
// this.startActivity.getActionBar().NavigationMode = android.app.ActionBar.NAVIGATION_MODE_STANDARD;
// }
// if (showActionBar) {
// this.startActivity.getActionBar().show();
// }
// else {
// this.startActivity.getActionBar().hide();
// }
// }
// else {
// // TODO: Throw exception when/if we remove Page/Frame support.
// }
// }
// }
//}
public getActivity(intent: android.content.Intent): Object {
if (intent && intent.Action === android.content.Intent.ACTION_MAIN) {
// application's main activity
if (exports.onLaunch) {
exports.onLaunch(intent);
}
/* In the onLaunch event we expect the following setup, which ensures a root frame:
* var frame = require("ui/frame");
* var rootFrame = new frame.Frame();
* rootFrame.navigate({ pageModuleName: "mainPage" });
*/
}
return currentPage.android.getActivityExtends();
var topFrame = frame.topmost();
if (!topFrame) {
// try to navigate to the mainModule (if specified)
if (mainModule) {
topFrame = new frame.Frame();
topFrame.navigate(mainModule);
} else {
// TODO: Throw an exception?
throw new Error("A Frame must be used to navigate to a Page.");
}
}
return topFrame.android.onActivityRequested(intent);
}
public init() {
@@ -147,5 +210,20 @@ class AndroidApplication implements dts.AndroidApplication {
}
}
// The root frame of the application
export var rootFrame = new frame.Frame();
global.__onUncaughtError = function (error: Error) {
if (!types.isFunction(exports.onUncaughtError)) {
return;
}
var nsError = {
message: error.message,
name: error.name,
nativeError: (<any>error).nativeException
}
exports.onUncaughtError(nsError);
}
exports.start = function () {
dts.loadCss();
}

View File

@@ -1,142 +1,192 @@

/**
* Contains the application abstraction with all related methods.
*/
declare module "application" {
import frame = require("ui/frame");
export var rootFrame: frame.Frame;
import cssSelector = require("ui/styling/css-selector");
/**
* An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code.
*/
export interface NativeScriptError extends Error {
/**
* Represents the native error object.
*/
nativeError: any;
}
/**
* The main page path (without the file extension) for the application starting from the application root.
* For example if you have page called "main.js" in a folder called "subFolder" and your root folder is "app" you can specify mainModule like this:
* var application = require("application");
* application.mainModule = "app/subFolder/main";
* application.start();
*/
export var mainModule: string;
/**
* 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.
*/
export var cssFile: string;
/**
* Cached css selectors created from the content of the css file.
*/
export var cssSelectorsCache: Array<cssSelector.CssSelector>;
/**
* Loads css file and parses to a css syntax tree.
*/
export function loadCss(): void;
/**
* Call this method to start the application. Important: All code after this method call will not be executed!
*/
export function start();
/**
* The main entry point event. This method is expected to use the root frame to navigate to the main application page.
*/
export function onLaunch(): void;
export function onLaunch(context: any): void;
/**
* A callback to be used when an uncaught error occurs while the application is running.
* The application will be shut down after this method returns.
* Loading new UI at this point is erroneous and may lead to unpredictable results.
* The method is intended to be used for crash reports and/or application restart.
*/
export function onUncaughtError(error: NativeScriptError): void;
/**
* This method will be called when the Application is suspended.
*/
export function onSuspend();
/**
/**
* This method will be called when the Application is resumed after it has been suspended.
*/
export function onResume();
/**
/**
* This method will be called when the Application is about to exit.
*/
export function onExit();
/**
/**
* This method will be called when there is low memory on the target device.
*/
export function onLowMemory();
/**
/**
* This is the Android-specific application object instance.
* Encapsulates methods and properties specific to the Android platform.
* Will be undefined when TargetOS is iOS.
*/
export var android: AndroidApplication;
/**
/**
* This is the iOS-specific application object instance.
* Encapsulates methods and properties specific to the iOS platform.
* Will be undefined when TargetOS is Android.
*/
export var ios: iOSApplication;
/**
* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events.
* @param nativeApp The instance of the platform Application object - e.g. android.app.Application
*/
export function init(nativeApp: any);
/**
/**
* The abstraction of an Android-specific application object.
*/
interface AndroidApplication {
/**
* The android.app.Application object instance provided to the init of the module.
export interface AndroidApplication {
/**
* The [android Application](http://developer.android.com/reference/android/app/Application.html) object instance provided to the init of the module.
*/
nativeApp: android.app.Application;
/**
* The application android.content.Context object instance.
/**
* The application's [android Context](http://developer.android.com/reference/android/content/Context.html) object instance.
*/
context: android.content.Context;
/**
* The currently active (loaded) android.app.Activity. This property is automatically updated upon Activity events.
/**
* The currently active (loaded) [android Activity](http://developer.android.com/reference/android/app/Activity.html). This property is automatically updated upon Activity events.
*/
foregroundActivity: android.app.Activity;
/**
/**
* The currently active (loaded) Context. This is typically the top-level Activity that is just created.
*/
currentContext: android.content.Context;
/**
/**
* The main (start) Activity for the application.
*/
startActivity: android.app.Activity;
/**
/**
* The name of the application package.
*/
packageName: string;
/**
/**
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered.
* The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
* @param intent - Native (android) intent used to create the activity.
* Returns com.tns.NativeScriptActivity.extend implementation.
*/
getActivity(intent: android.content.Intent): any;
/**
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityCreated method.
/**
* Direct handler of the [onActivityCreated method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
/**
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
/**
* Direct handler of the [onActivityDestroyed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityDestroyed: (activity: android.app.Activity) => void;
/**
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
/**
* Direct handler of the [onActivityDestroyed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityStarted: (activity: android.app.Activity) => void;
/**
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityPaused method.
/**
* Direct handler of the [onActivityPaused method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityPaused: (activity: android.app.Activity) => void;
/**
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityResumed method.
/**
* Direct handler of the [onActivityResumed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityResumed: (activity: android.app.Activity) => void;
/**
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityStopped method.
/**
* Direct handler of the [onActivityStopped method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityStopped: (activity: android.app.Activity) => void;
/**
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method.
/**
* Direct handler of the [onActivitySaveInstanceState method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
/**
* Direct handler of the onActivityResult method.
*/
onActivityResult: (requestCode: number, resultCode: number, data: android.content.Intent) => void
}
/**
/* tslint:disable */
/**
* The abstraction of an iOS-specific application object.
*/
interface iOSApplication {
/**
export interface iOSApplication {
/* tslint:enable */
/**
* The root view controller for the application.
*/
rootController: UIKit.UIViewController;
rootController: UIViewController;
/**
* The android.app.Application object instance provided to the init of the module.
/**
* The [UIApplication](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html) object instance provided to the init of the module.
*/
nativeApp: UIKit.UIApplication;
nativeApp: UIApplication;
}
}

View File

@@ -1,116 +1,192 @@

/*
Current launch sequence for iOS looks like:
var app = require("application");
app.tk.ui.Application.current.onLaunch = function() {
log("tk.ui.Application.current.onLaunch");
var myViewController = new MyViewController();
var navController = new UIKit.UINavigationController(myViewController);
return navController;
}
log("JavaScript loading started.");
app.tk.ui.ios.initApp(null);
log("JavaScript loading ended.");
log("JavaScript loading ended.");
*/
import appModule = require("application/application-common");
import appModule = require("application/application-common");
import frame = require("ui/frame");
import utils = require("utils/utils");
import types = require("utils/types");
import view = require("ui/core/view");
import definition = require("application");
// merge the exports of the application_common file with the exports of this file
declare var exports;
require("utils/module-merge").merge(appModule, exports);
var initialized;
export var init = function (nativeApp: any) {
if (initialized) {
return;
export var mainModule: string;
class Window extends UIWindow {
private _content: view.View;
initWithFrame(frame: CGRect): UIWindow {
var window = super.initWithFrame(frame);
if (window) {
window.autoresizingMask = UIViewAutoresizing.UIViewAutoresizingNone;
}
return window;
}
var app = new iOSApplication(nativeApp);
exports.ios = app;
app.init();
public get content(): view.View {
return this._content;
}
public set content(value: view.View) {
this._content = value;
}
initialized = true;
public layoutSubviews(): void {
if (!this._content) {
// TODO: Invalid setup, throw an exception?
return;
}
var statusFrame = UIApplication.sharedApplication().statusBarFrame;
var statusBarHeight = 0;
try {
statusBarHeight = Math.min(statusFrame.size.width, statusFrame.size.height);
} catch (ex) {
console.log("exception: " + ex);
}
var isLandscape = utils.ios.isLandscape();
var iOSMajorVersion = utils.ios.MajorVersion;
// in iOS 8 when in landscape statusbar is hidden.
if (isLandscape && iOSMajorVersion > 7) {
statusBarHeight = 0;
}
var deviceFrame = UIScreen.mainScreen().bounds;
var size = deviceFrame.size;
var width = size.width;
var height = size.height;
// in iOS 7 when in landscape we switch width with height because on device they don't change even when rotated.
if (iOSMajorVersion < 8 && isLandscape) {
width = size.height;
height = size.width;
}
var origin = deviceFrame.origin;
var left = origin.x;
var top = origin.y + statusBarHeight;
var widthSpec = utils.layout.makeMeasureSpec(width, utils.layout.EXACTLY);
var heightSpec = utils.layout.makeMeasureSpec(height - statusBarHeight, utils.layout.EXACTLY);
this._content.measure(widthSpec, heightSpec);
this._content.layout(left, top, width, height);
}
}
class iOSApplication {
class TNSAppDelegate extends UIResponder implements UIApplicationDelegate {
// An array of protocols to be implemented by the native class
public static ObjCProtocols = [UIApplicationDelegate];
public window: Window;
applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary): boolean {
this.window = <Window>Window.alloc().initWithFrame(UIScreen.mainScreen().bounds);
this.window.backgroundColor = UIColor.whiteColor();
if (exports.onLaunch) {
exports.onLaunch();
}
var topFrame = frame.topmost();
if (!topFrame) {
if (mainModule) {
topFrame = new frame.Frame();
topFrame.navigate(mainModule);
} else {
// TODO: Throw an exception?
// throw new Error("A Frame must be used to navigate to a Page.");
return;
}
}
this.window.content = topFrame;
this.window.rootViewController = topFrame.ios.controller;
var app: IOSApplication = exports.ios;
app.rootController = this.window.rootViewController;
this.window.makeKeyAndVisible();
return true;
}
applicationDidBecomeActive(application: UIApplication) {
if (exports.onResume) {
exports.onResume();
}
}
applicationWillResignActive(application: UIApplication) {
//
}
applicationDidEnterBackground(application: UIApplication) {
if (exports.onSuspend) {
exports.onSuspend();
}
}
applicationWillEnterForeground(application: UIApplication) {
//
}
applicationWillTerminate(application: UIApplication) {
if (exports.onExit) {
exports.onExit();
}
}
applicationDidReceiveMemoryWarning(application: UIApplication) {
if (exports.onLowMemory) {
exports.onLowMemory();
}
}
applicationOpenURLSourceApplicationAnnotation(application: UIApplication, url: NSURL, sourceApplication: string, annotation: any): boolean {
var dictionary = new NSMutableDictionary();
dictionary.setObjectForKey(url, "TLKApplicationOpenURL");
dictionary.setObjectForKey(application, "TLKApplication");
NSNotificationCenter.defaultCenter().postNotificationNameObjectUserInfo("com.telerik.TLKApplicationOpenURL", null, dictionary);
return true; // or should we return false???
}
}
class IOSApplication implements definition.iOSApplication {
public nativeApp: any;
public rootController: any;
private _tnsAppdelegate: TNSAppDelegate;
constructor(nativeApp: any) {
constructor() {
// TODO: in iOS there is the singleton instance, while in Android such does not exist hence we pass it as argument
// this.nativeApp = nativeApp;
this.nativeApp = UIKit.UIApplication.sharedApplication();
this.nativeApp = UIApplication.sharedApplication();
}
public init() {
var that = this;
UIKit.UIResponder.extends({/*TODO: Empty parameter here, needs API improvement*/}, {
name: "TNSAppDelegate",
}).implements({
protocol: "UIApplicationDelegate",
implementation: {
applicationDidFinishLaunchingWithOptions: function () {
log("Application launched: applicationDidFinishLaunchingWithOptions.");
this._tnsAppdelegate = new TNSAppDelegate();
}
}
this.window = new UIKit.UIWindow(UIKit.UIScreen.mainScreen().bounds);
this.window.backgroundColor = UIKit.UIColor.whiteColor();
this.window.makeKeyAndVisible();
// TODO: If we have nested require(application) calls we may enter unfinished module state, which will create two delegates, resulting in an exception
var app = new IOSApplication();
exports.ios = app;
app.init();
if (exports.onLaunch) {
that.rootController = exports.onLaunch();
this.window.rootViewController = that.rootController;
} else {
log("Missing Application.onLaunch");
}
exports.start = function () {
appModule.loadCss();
try {
// The "UIApplicationMain" enters a modal loop and the call will not return while the application is running.
// This try-catch block here will catch JavaScript errors but no Objective C ones.
// TODO: We need to implement better error handling for our native calls and to use the "error" parameter of the iOS APIs.
UIApplicationMain(0, null, null, "TNSAppDelegate");
}
catch (error) {
// At this point the main application loop is exited and no UI May be created.
if (!types.isFunction(exports.onUncaughtError)) {
return;
}
log("applicationDidFinishLaunchingWithOptions finished.");
return true;
},
applicationDidBecomeActive: function (application) {
log("applicationDidBecomeActive: " + application);
if (exports.onResume) {
exports.onResume();
}
},
applicationWillResignActive: function (application) {
log("applicationWillResignActive: " + application);
},
applicationDidEnterBackground: function (application) {
log("applicationDidEnterBackground: " + application);
if (exports.onSuspend) {
exports.onSuspend();
}
},
applicationWillEnterForeground: function (application) {
log("applicationWillEnterForeground: " + application);
},
applicationWillTerminate: function (application) {
log("applicationWillTerminate: " + application);
if (exports.onExit) {
exports.onExit();
}
},
applicationDidReceiveMemoryWarning: function (application) {
log("applicationDidReceiveMemoryWarning: " + application);
if (exports.onLowMemory) {
exports.onLowMemory();
}
}
}
});
exports.onUncaughtError(error);
}
}

View File

@@ -1,2 +0,0 @@
declare var module, require;
module.exports = require("application/application");

2
application/package.json Normal file
View File

@@ -0,0 +1,2 @@
{ "name" : "application",
"main" : "application.js" }

View File

@@ -0,0 +1,2 @@
{ "name" : "side-bar",
"main" : "side-bar.js" }

View File

@@ -0,0 +1,62 @@
import definition = require("side-bar");
import view = require("ui/core/view");
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
export class SideBar extends view.View implements definition.SideBar {
public static slideContentWidthProperty = new dependencyObservable.Property("slideContentWidth", "SideBar", new proxy.PropertyMetadata(280, dependencyObservable.PropertyMetadataSettings.AffectsLayout));
public static slideContentProperty = new dependencyObservable.Property("slideContent", "SideBar", new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsLayout));
public static mainContentProperty = new dependencyObservable.Property("mainContent", "SideBar", new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsLayout));
get slideContentWidth(): number {
return this._getValue(SideBar.slideContentWidthProperty);
}
set slideContentWidth(value: number) {
this._setValue(SideBar.slideContentWidthProperty, value);
}
get slideContent(): view.View {
return this._getValue(SideBar.slideContentProperty);
}
set slideContent(value: view.View) {
this._setValue(SideBar.slideContentProperty, value);
}
get mainContent(): view.View {
return this._getValue(SideBar.mainContentProperty);
}
set mainContent(value: view.View) {
this._setValue(SideBar.mainContentProperty, value);
}
public openSlideContent(): void {
//
}
public closeSlideContent(): void {
//
}
get _childrenCount(): number {
var count = 0;
if (this.slideContent) {
count++;
}
if (this.mainContent) {
count++;
}
return count;
}
public _eachChildView(callback: (child: view.View) => boolean) {
if (this.mainContent) {
callback(this.mainContent);
}
if (this.slideContent) {
callback(this.slideContent);
}
}
}

View File

@@ -0,0 +1,68 @@
import common = require("./side-bar-common");
import view = require("ui/core/view");
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
import utils = require("utils/utils");
declare var com: any;
function onMainContentPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var bar = <SideBar>data.object;
var newContent = <view.View> data.newValue;
if (bar.android && newContent instanceof view.View) {
bar.android.setMainContent(newContent.android);
}
}
(<proxy.PropertyMetadata>common.SideBar.mainContentProperty.metadata).onSetNativeValue = onMainContentPropertyChanged;
function onSlideContentPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var bar = <SideBar>data.object;
var newContent = <view.View> data.newValue;
if (bar.android && newContent instanceof view.View) {
bar.android.setDrawerContent(newContent.android);
}
}
(<proxy.PropertyMetadata>common.SideBar.slideContentProperty.metadata).onSetNativeValue = onSlideContentPropertyChanged;
function onSlideContentWidthPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var bar = <SideBar>data.object;
if (bar.android) {
bar.android.setDrawerSize(utils.layout.getDisplayDensity() * data.newValue);
}
}
(<proxy.PropertyMetadata>common.SideBar.slideContentWidthProperty.metadata).onSetNativeValue = onSlideContentWidthPropertyChanged;
export class SideBar extends common.SideBar {
public _createUI() {
this._android = new com.telerik.android.primitives.widget.sidedrawer.SideDrawer(this._context);
this._android.setDrawerSize(utils.layout.getDisplayDensity() * 280);
if (this.mainContent instanceof view.View) {
this._addView(this.mainContent);
}
if (this.slideContent instanceof view.View) {
this._addView(this.slideContent);
}
}
private _android: any;
get android(): any {
return this._android;
}
public _onBindingContextChanged(oldValue: any, newValue: any) {
super._onBindingContextChanged(oldValue, newValue);
if (this.mainContent instanceof view.View) {
this.mainContent.bindingContext = this.bindingContext;
}
if (this.slideContent instanceof view.View) {
this.slideContent.bindingContext = this.bindingContext;
}
}
}

View File

@@ -0,0 +1,23 @@
/**
*
*/
declare module "side-bar" {
import view = require("ui/core/view");
import dependencyObservable = require("ui/core/dependency-observable");
export class SideBar extends view.View {
android: any;
ios: any;
slideContentWidth: number;
slideContent: view.View;
mainContent: view.View;
openSlideContent(): void;
closeSlideContent(): void;
public static slideContentProperty: dependencyObservable.Property;
public static mainContentProperty: dependencyObservable.Property;
}
}

View File

@@ -0,0 +1,108 @@
import common = require("./side-bar-common");
import view = require("ui/core/view");
import contentView = require("ui/content-view");
import frame = require("ui/frame");
import dependencyObservable = require("ui/core/dependency-observable");
import proxy = require("ui/core/proxy");
import utils = require("utils/utils");
declare var TKSideDrawer: any;
function onMainContentPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var bar = <SideBar>data.object;
var newContent = <view.View> data.newValue;
if (newContent instanceof view.View) {
bar._mainContentHost.content = newContent;
}
}
(<proxy.PropertyMetadata>common.SideBar.mainContentProperty.metadata).onSetNativeValue = onMainContentPropertyChanged;
function onSlideContentPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var bar = <SideBar>data.object;
var newContent = <view.View> data.newValue;
if (newContent instanceof view.View) {
bar._slideContentHost.content = newContent;
}
}
(<proxy.PropertyMetadata>common.SideBar.slideContentProperty.metadata).onSetNativeValue = onSlideContentPropertyChanged;
export class SideBar extends common.SideBar {
public _mainContentHost: contentView.ContentView
public _slideContentHost: contentView.ContentView
constructor() {
super();
this._mainContentHost = new contentView.ContentView();
this._slideContentHost = new contentView.ContentView();
this._ios = TKSideDrawer.alloc().initWithHostview(this._mainContentHost.ios);
this._ios.content = this._slideContentHost.ios
this._ios.headerView = null;
this._ios.footerView = null;
}
private _ios: any;
get ios(): any {
return this._ios;
}
get _nativeView(): UIView {
return this._ios;
}
public openSlideContent(): void {
this.ios.show();
}
public closeSlideContent(): void {
this.ios.dismiss();
}
public onLoaded() {
this.parent._addView(this._mainContentHost);
this._addView(this._slideContentHost);
super.onLoaded();
this.ios.viewController = frame.topmost().currentPage.ios;
}
public _onBindingContextChanged(oldValue: any, newValue: any) {
super._onBindingContextChanged(oldValue, newValue);
if (this._mainContentHost instanceof view.View) {
this._mainContentHost.bindingContext = this.bindingContext;
}
if (this._slideContentHost instanceof view.View) {
this._slideContentHost.bindingContext = this.bindingContext;
}
}
public onLayout(left: number, top: number, right: number, bottom: number): void {
var width = right - left;
var height = bottom - top;
this._slideContentHost.layout(0, 0, this.slideContentWidth, height);
this._mainContentHost.layout(0, 0, width, height);
}
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
view.View.measureChild(this, this._slideContentHost, utils.layout.makeMeasureSpec(this.slideContentWidth, utils.layout.EXACTLY), heightMeasureSpec);
var result = view.View.measureChild(this, this._mainContentHost, widthMeasureSpec, heightMeasureSpec);
var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
var widthAndState = view.View.resolveSizeAndState(result.measuredWidth, width, widthMode, 0);
var heightAndState = view.View.resolveSizeAndState(result.measuredHeight, height, heightMode, 0);
this.setMeasuredDimension(widthAndState, heightAndState);
}
}

View File

@@ -0,0 +1,528 @@
import observable = require("data/observable");
export class AppViewModel extends observable.Observable {
constructor() {
super();
this.selectedIndex = 0;
}
private _sessions: Array<SessionModel>;
get sessions(): Array<SessionModel> {
return this._sessions;
}
get favorites(): Array<SessionModel> {
return this.sessions.filter(i=> { return i.favorite });
}
get speakers(): Array<Speakers> {
return speakers;
}
private _search = "";
get search(): string {
return this._search;
}
set search(value: string) {
if (this._search !== value) {
this._search = value;
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "search", value: value });
this.filter();
}
}
private _selectedIndex;
get selectedIndex(): number {
return this._selectedIndex;
}
set selectedIndex(value: number) {
if (this._selectedIndex !== value) {
this._selectedIndex = value;
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "selectedIndex", value: value });
if (this.search !== "") {
this.search = "";
} else {
this.filter();
}
}
}
private filter() {
this._sessions = sessions.filter(s=> {
return s.start.getDay() === dates[this.selectedIndex].getDay()
&& s.title.toLocaleLowerCase().indexOf(this.search.toLocaleLowerCase()) >= 0;
});
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "sessions", value: this._sessions });
}
}
export class SessionModel extends observable.Observable implements Session {
constructor(source?: Session) {
super();
if (source) {
this._title = source.title;
this._room = source.room;
this._start = source.start;
this._end = source.end;
}
}
private _title: string;
private _start: Date;
private _end: Date;
private _room: string;
private _favorite: boolean;
get title(): string {
return this._title;
}
get room(): string {
return this._room;
}
get start(): Date {
return this._start;
}
get end(): Date {
return this._end;
}
get range(): string {
var startMinutes = this.start.getMinutes() + "";
var endMinutes = this.end.getMinutes() + "";
return this.start.getHours() + ':' + (startMinutes.length === 1 ? '0' + startMinutes : startMinutes) +
' - ' + this.end.getHours() + ':' + (endMinutes.length === 1 ? '0' + endMinutes : endMinutes);
}
get canBeFavorited(): boolean {
return this.title.indexOf("Registration") === -1 && this.title.indexOf("Lunch") === -1 && this.title.indexOf("PM Break") === -1;
}
get favorite(): boolean {
return this._favorite;
}
set favorite(value: boolean) {
if (this._favorite !== value) {
this._favorite = value;
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "favorite", value: this._favorite });
}
}
}
var sessions: Array<SessionModel> = [
new SessionModel({
title: "Registration",
start: new Date(2015, 5, 3, 8, 30),
end: new Date(2015, 5, 3, 9, 30),
room: ""
}),
new SessionModel({
title: "NativeScript Deep Dive",
start: new Date(2015, 5, 3, 9, 30),
end: new Date(2015, 5, 3, 12, 30),
room: "Workshop Room 1"
}),
new SessionModel({
title: "Smart Design for Smartphones",
start: new Date(2015, 5, 3, 9, 30),
end: new Date(2015, 5, 3, 12, 30),
room: "Workshop Room 2"
}),
new SessionModel({
title: "Modern .NET Apps!",
start: new Date(2015, 5, 3, 9, 30),
end: new Date(2015, 5, 3, 12, 30),
room: "Workshop Room 3"
}),
new SessionModel({
title: "Telerik Sitefinity as a Data Integration Platform",
start: new Date(2015, 5, 3, 9, 30),
end: new Date(2015, 5, 3, 12, 30),
room: "Workshop Room 4"
}),
new SessionModel({
title: "Lunch",
start: new Date(2015, 5, 3, 9, 30),
end: new Date(2015, 5, 3, 12, 30),
room: ""
}),
new SessionModel({
title: "NativeScript Deep Dive",
start: new Date(2015, 5, 3, 1, 30),
end: new Date(2015, 5, 3, 4, 30),
room: "Workshop Room 1"
}),
new SessionModel({
title: "Smart Design for Smartphones",
start: new Date(2015, 5, 3, 1, 30),
end: new Date(2015, 5, 3, 4, 30),
room: "Workshop Room 2"
}),
new SessionModel({
title: "Responsive Apps with Telerik DevCraft",
start: new Date(2015, 5, 3, 1, 30),
end: new Date(2015, 5, 3, 4, 30),
room: "Workshop Room 3"
}),
new SessionModel({
title: "ASP .NET MVC Development in Telerik Sitefinity",
start: new Date(2015, 5, 3, 1, 30),
end: new Date(2015, 5, 3, 4, 30),
room: "Workshop Room 4"
}), new SessionModel({
title: "Registration",
start: new Date(2015, 5, 4, 7, 30),
end: new Date(2015, 5, 4, 9, 0),
room: ""
}), new SessionModel({
title: "Telerik Keynote",
start: new Date(2015, 5, 4, 9, 0),
end: new Date(2015, 5, 4, 10, 30),
room: "General Session"
}), new SessionModel({
title: "A Lap Around NativeScript",
start: new Date(2015, 5, 4, 10, 45),
end: new Date(2015, 5, 4, 11, 30),
room: "Conference Room 1"
}), new SessionModel({
title: "Kendo UI Building Blocks",
start: new Date(2015, 5, 4, 10, 45),
end: new Date(2015, 5, 4, 11, 30),
room: "Conference Room 2"
}), new SessionModel({
title: "CRUD with ASP.NET MVC, Web API, EF and Kendo UI",
start: new Date(2015, 5, 4, 10, 45),
end: new Date(2015, 5, 4, 11, 30),
room: "Conference Room 3"
}), new SessionModel({
title: "Best Practices for Understanding and Implementing Website Project Requirements",
start: new Date(2015, 5, 4, 10, 45),
end: new Date(2015, 5, 4, 11, 30),
room: "Conference Room 4"
}), new SessionModel({
title: "Getting Started with ScreenBuilder",
start: new Date(2015, 5, 4, 11, 45),
end: new Date(2015, 5, 4, 12, 30),
room: "Conference Room 1"
}), new SessionModel({
title: "Getting Started with AngularJS",
start: new Date(2015, 5, 4, 11, 45),
end: new Date(2015, 5, 4, 12, 30),
room: "Conference Room 2"
}), new SessionModel({
title: "Zero to Hipster with the M.I.K.E. Stack",
start: new Date(2015, 5, 4, 11, 45),
end: new Date(2015, 5, 4, 12, 30),
room: "Conference Room 3"
}), new SessionModel({
title: "Content Meets Commerce, Email and Analytics to Build the New Data-Driven Marketing Machine",
start: new Date(2015, 5, 4, 11, 45),
end: new Date(2015, 5, 4, 12, 30),
room: "Conference Room 4"
}), new SessionModel({
title: "Lunch",
start: new Date(2015, 5, 4, 12, 30),
end: new Date(2015, 5, 4, 1, 30),
room: ""
}), new SessionModel({
title: "Hybrid vs Native vs Web: Which is Right for Me?",
start: new Date(2015, 5, 4, 1, 30),
end: new Date(2015, 5, 4, 2, 15),
room: "Conference Room 1"
}), new SessionModel({
title: "AngularJS Directives For Kendo UI",
start: new Date(2015, 5, 4, 1, 30),
end: new Date(2015, 5, 4, 2, 15),
room: "Conference Room 2"
}), new SessionModel({
title: "Using Kendo UI in SharePoint/Office 365",
start: new Date(2015, 5, 4, 1, 30),
end: new Date(2015, 5, 4, 2, 15),
room: "Conference Room 3"
}), new SessionModel({
title: "Develop the Next Generation of Content-Driven Mobile Apps",
start: new Date(2015, 5, 4, 1, 30),
end: new Date(2015, 5, 4, 2, 15),
room: "Conference Room 3"
}), new SessionModel({
title: "PM Break",
start: new Date(2015, 5, 4, 2, 15),
end: new Date(2015, 5, 4, 2, 30),
room: ""
}), new SessionModel({
title: "AppBuilder in 45 Minutes",
start: new Date(2015, 5, 4, 2, 30),
end: new Date(2015, 5, 4, 3, 15),
room: "Conference Room 1"
}), new SessionModel({
title: "Mastering JavaScript",
start: new Date(2015, 5, 4, 2, 30),
end: new Date(2015, 5, 4, 3, 15),
room: "Conference Room 2"
}), new SessionModel({
title: "Building Mobile Apps with Visual Studio",
start: new Date(2015, 5, 4, 2, 30),
end: new Date(2015, 5, 4, 3, 15),
room: "Conference Room 3"
}), new SessionModel({
title: "Building a CRM Portal in 60 Minutes",
start: new Date(2015, 5, 4, 2, 30),
end: new Date(2015, 5, 4, 3, 15),
room: "Conference Room 4"
}), new SessionModel({
title: "NativeScript Extensibility",
start: new Date(2015, 5, 4, 3, 30),
end: new Date(2015, 5, 4, 4, 15),
room: "Conference Room 1"
}), new SessionModel({
title: "There's a Cordova Plugin for that!",
start: new Date(2015, 5, 4, 3, 30),
end: new Date(2015, 5, 4, 4, 15),
room: "Conference Room 2"
}), new SessionModel({
title: "AngularJS and Kendo UI",
start: new Date(2015, 5, 4, 3, 30),
end: new Date(2015, 5, 4, 4, 15),
room: "Conference Room 3"
}), new SessionModel({
title: "Continuous Delivery and Telerik Sitefinity",
start: new Date(2015, 5, 4, 3, 30),
end: new Date(2015, 5, 4, 4, 15),
room: "Conference Room 4"
}), new SessionModel({
title: "Telerik Leadership Panel - Q&A",
start: new Date(2015, 5, 4, 4, 30),
end: new Date(2015, 5, 4, 5, 15),
room: "Conference Room 1"
}), new SessionModel({
title: "Accelerate your Agile Adoption",
start: new Date(2015, 5, 4, 4, 30),
end: new Date(2015, 5, 4, 5, 15),
room: "Conference Room 2"
}), new SessionModel({
title: "No Kidding, Real World Tester/Developer Collaboration",
start: new Date(2015, 5, 4, 4, 30),
end: new Date(2015, 5, 4, 5, 15),
room: "Conference Room 3"
}), new SessionModel({
title: "Sitefinity",
start: new Date(2015, 5, 4, 4, 30),
end: new Date(2015, 5, 4, 5, 15),
room: "Conference Room 4"
}), new SessionModel({
title: "Attendee Appreciation Party",
start: new Date(2015, 5, 4, 7, 0),
end: new Date(2015, 5, 4, 10, 30),
room: ""
}), new SessionModel({
title: "Registration",
start: new Date(2015, 5, 5, 8, 0),
end: new Date(2015, 5, 5, 9, 0),
room: ""
}), new SessionModel({
title: "Sitefinity Keynote",
start: new Date(2015, 5, 5, 9, 0),
end: new Date(2015, 5, 5, 10, 30),
room: "General Session"
}), new SessionModel({
title: "Introduction to Mobile Testing and Device Cloud",
start: new Date(2015, 5, 5, 10, 45),
end: new Date(2015, 5, 5, 11, 30),
room: "Conference Room 1"
}), new SessionModel({
title: "Data is Beautiful with Kendo UI DataViz",
start: new Date(2015, 5, 5, 10, 45),
end: new Date(2015, 5, 5, 11, 30),
room: "Conference Room 2"
}), new SessionModel({
title: "Mastering How to Visualize Data in ASP.NET MVC",
start: new Date(2015, 5, 5, 10, 45),
end: new Date(2015, 5, 5, 11, 30),
room: "Conference Room 3"
}), new SessionModel({
title: "Using Sitefinity to Power Web 3.0 Experiences",
start: new Date(2015, 5, 5, 10, 45),
end: new Date(2015, 5, 5, 11, 30),
room: "Conference Room 4"
}), new SessionModel({
title: "Building Offline-Ready Mobile Apps",
start: new Date(2015, 5, 5, 11, 45),
end: new Date(2015, 5, 5, 12, 30),
room: "Conference Room 1"
}), new SessionModel({
title: "Kendo UI Mobile: What It Can And Can't Do For You",
start: new Date(2015, 5, 5, 11, 45),
end: new Date(2015, 5, 5, 12, 30),
room: "Conference Room 2"
}), new SessionModel({
title: "ASP.NET with Telerik UI!",
start: new Date(2015, 5, 5, 11, 45),
end: new Date(2015, 5, 5, 12, 30),
room: "Conference Room 3"
}), new SessionModel({
title: "Cross-Channel Data Integration with Digital Experience Cloud",
start: new Date(2015, 5, 5, 11, 45),
end: new Date(2015, 5, 5, 12, 30),
room: "Conference Room 4"
}), new SessionModel({
title: "Lunch",
start: new Date(2015, 5, 5, 12, 30),
end: new Date(2015, 5, 5, 1, 30),
room: ""
}), new SessionModel({
title: "Performance Tuning Your Mobile Web Apps",
start: new Date(2015, 5, 5, 1, 30),
end: new Date(2015, 5, 5, 2, 15),
room: "Conference Room 1"
}), new SessionModel({
title: "Improving Applications with Telerik Analytics",
start: new Date(2015, 5, 5, 1, 30),
end: new Date(2015, 5, 5, 2, 15),
room: "Conference Room 2"
}), new SessionModel({
title: "Reporting vs Dashboards vs UI Data Apps",
start: new Date(2015, 5, 5, 1, 30),
end: new Date(2015, 5, 5, 2, 15),
room: "Conference Room 3"
}), new SessionModel({
title: "Modern MVC and Front-End Development with Telerik Sitefinity",
start: new Date(2015, 5, 5, 1, 30),
end: new Date(2015, 5, 5, 2, 15),
room: "Conference Room 4"
}), new SessionModel({
title: "PM Break",
start: new Date(2015, 5, 5, 2, 15),
end: new Date(2015, 5, 5, 2, 30),
room: ""
}), new SessionModel({
title: "Telerik Native Mobile UI for iOS and Android",
start: new Date(2015, 5, 5, 2, 30),
end: new Date(2015, 5, 5, 3, 15),
room: "Conference Room 1"
}), new SessionModel({
title: "IoT and the Telerik Platform",
start: new Date(2015, 5, 5, 2, 30),
end: new Date(2015, 5, 5, 3, 15),
room: "Conference Room 2"
}), new SessionModel({
title: "Debugging with Fiddler",
start: new Date(2015, 5, 5, 2, 30),
end: new Date(2015, 5, 5, 3, 15),
room: "Conference Room 3"
}), new SessionModel({
title: "Anticipating & Planning of Peak Online Traffic for Professional Football's Biggest Games",
start: new Date(2015, 5, 5, 2, 30),
end: new Date(2015, 5, 5, 3, 15),
room: "Conference Room 4"
}), new SessionModel({
title: "Building a Mobile App API using MongoDB and Node.js",
start: new Date(2015, 5, 5, 3, 30),
end: new Date(2015, 5, 5, 4, 15),
room: "Conference Room 1"
}), new SessionModel({
title: "Advanced Kendo UI",
start: new Date(2015, 5, 5, 3, 30),
end: new Date(2015, 5, 5, 4, 15),
room: "Conference Room 2"
}), new SessionModel({
title: "Building Touch Apps with UI for WPF",
start: new Date(2015, 5, 5, 3, 30),
end: new Date(2015, 5, 5, 4, 15),
room: "Conference Room 3"
}), new SessionModel({
title: "Making the Most Out of Sitefinity Personalization",
start: new Date(2015, 5, 5, 3, 30),
end: new Date(2015, 5, 5, 4, 15),
room: "Conference Room 4"
}), new SessionModel({
title: "Closing Keynote",
start: new Date(2015, 5, 5, 4, 30),
end: new Date(2015, 5, 5, 5, 15),
room: "General Session"
})];
var dates: Array<Date> = [new Date(2015, 5, 3), new Date(2015, 5, 4), new Date(2015, 5, 5)];
interface Session {
title: string;
start: Date;
end: Date;
room: string;
}
interface Speakers {
name: string;
title: string;
company: string;
picture: string;
}
var speakers: Array<Speakers> = [
{
name: "Todd Anglin",
title: "Vice President of Product Strategy",
company: "Telerik",
picture: "~/app/images/todd.png"
},
{
name: "Aaron Mahimainathan",
title: "Senior Vice President, Platform & Tools",
company: "Telerik",
picture: "~/app/images/aaron.png"
},
{
name: "Burke Holland",
title: "Director of Developer Relations",
company: "Telerik",
picture: "~/app/images/burke.png"
},
{
name: "Brian Rinaldi",
title: "Developer Content Manager",
company: "Telerik",
picture: "~/app/images/brian.png"
},
{
name: "TJ VanToll",
title: "Senior Developer Advocate",
company: "Telerik",
picture: "~/app/images/tj.png"
},
{
name: "Jen Looper",
title: "Developer Advocate",
company: "Telerik",
picture: "~/app/images/jen.png"
},
{
name: "Brandon Satrom",
title: "Director of Product Management",
company: "Telerik",
picture: "~/app/images/brandon.png"
},
{
name: "Michael Crump",
title: "Senior Developer Advocate",
company: "Telerik",
picture: "~/app/images/michael.png"
},
{
name: "Sam Basu",
title: "Developer Advocate",
company: "Telerik",
picture: "~/app/images/sam.png"
},
{
name: "Svetla Yankova",
title: "Product Marketing Manager",
company: "Telerik",
picture: "~/app/images/svetla.png"
}];

7
apps/TelerikNEXT/app.ts Normal file
View File

@@ -0,0 +1,7 @@
import application = require("application");
// Set the start module for the application
application.mainModule = "app/main-page";
// Start the application
application.start();

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

View File

@@ -0,0 +1,23 @@
Label, Button, Image {
margin: 5;
}
.speakerPicture {
width: 100;
height: 100;
}
.speakerTitle, .speakerCompany {
font-size: 18;
color: #07ab9e;
}
.speakerName {
font-size: 22;
color: black;
}
.title {
font-size: 22;
color: black;
}

View File

@@ -0,0 +1,16 @@
import observable = require("data/observable");
import pages = require("ui/page");
import gestures = require("ui/gestures");
import appViewModel = require("./app-view-model");
export function pageLoaded(args: observable.EventData) {
var page = <pages.Page>args.object;
page.bindingContext = new appViewModel.AppViewModel();
}
export function toggleFavorite(args: gestures.GestureEventData) {
var item = <appViewModel.SessionModel>args.view.bindingContext;
item.favorite = !item.favorite;
}

View File

@@ -0,0 +1,84 @@
<Page xmlns="http://www.nativescript.org/tns.xsd"
loaded="pageLoaded" xmlns:tsb="app/TelerikUI/side-bar">
<tsb:SideBar title="TelerikNEXT">
<tsb:SideBar.slideContent>
<StackLayout style="background-color: white">
<Border style="background-color: gray">
<Label>
<Label.formattedText>
<FormattedString fontSize="26" foregroundColor="#FFFFFF">
<FormattedString.spans>
<Span text="TelerikNEXT" />
</FormattedString.spans>
</FormattedString>
</Label.formattedText>
</Label>
</Border>
<Button text="My agenda" horizontalAlignment="left" />
<Button text="Explore all sessions" horizontalAlignment="left" />
<Button text="About" horizontalAlignment="left"/>
</StackLayout>
</tsb:SideBar.slideContent>
<tsb:SideBar.mainContent>
<GridLayout rows="auto, auto, *">
<SegmentedBar selectedIndex="{{ selectedIndex }}" >
<SegmentedBar.items>
<SegmentedBarEntry title="MAY 3" />
<SegmentedBarEntry title="MAY 4" />
<SegmentedBarEntry title="MAY 5" />
</SegmentedBar.items>
</SegmentedBar>
<StackLayout style="background-color: #fac950;padding: 5;" row="1">
<SearchBar text="{{ search }}" />
</StackLayout>
<ListView items="{{ sessions }}" row="2">
<ListView.itemTemplate>
<GridLayout columns="*, auto" style.backgroundColor="{{ canBeFavorited ? '#ffffff' : '#fffbf0' }}">
<StackLayout>
<Label>
<Label.formattedText>
<FormattedString fontSize="18" foregroundColor="#a17201">
<FormattedString.spans>
<Span text="{{ 'Time: ' }}" />
<Span text="{{ range }}" fontAttributes="Bold" />
</FormattedString.spans>
</FormattedString>
</Label.formattedText>
</Label>
<Label text="{{ room ? 'Room: ' + room : '' }}">
<Label.formattedText>
<FormattedString fontSize="12" foregroundColor="#a17201">
<FormattedString.spans>
<Span text="{{ room ? 'Room: ' : '' }}" />
<Span text="{{ room }}" fontAttributes="Bold" />
</FormattedString.spans>
</FormattedString>
</Label.formattedText>
</Label>
<Label text="{{ title }}" textWrap="true" cssClass="title" />
</StackLayout>
<Image url="{{ favorite ? '~/app/images/fav.png' : '~/app/images/addfav.png' }}" style.visibility="{{ canBeFavorited ? 'visible' : 'collapsed' }}"
tap="toggleFavorite" width="32" height="32" col="1" vertical-align="center"/>
</GridLayout>
</ListView.itemTemplate>
</ListView>
</GridLayout>
</tsb:SideBar.mainContent>
</tsb:SideBar>
</Page>

View File

@@ -0,0 +1,4 @@
{
"name": "TelerikNEXT",
"main": "app.js"
}

View File

@@ -0,0 +1,3 @@
import application = require("application");
application.mainModule = "app/mainPage";
application.start();

View File

@@ -0,0 +1,56 @@
import pagesModule = require("ui/page");
import enums = require("ui/enums");
import absoluteLayoutModule = require("ui/layouts/absolute-layout");
import labelModule = require("ui/label");
import colorModule = require("color");
export function createPage() {
var colors = [
new colorModule.Color("Red"),
new colorModule.Color("LightGreen"),
new colorModule.Color("LightBlue"),
new colorModule.Color("Yellow")
];
var c = 0;
function generateChild(width?: number, height?: number) {
var label = new labelModule.Label();
if (!width) {
width = 80 + Math.round(Math.random() * 40);
}
if (!height) {
height = 80 + Math.round(Math.random() * 40);
}
label.width = width;
label.height = height;
label.text = "L" + c + "(" + label.width + "x" + label.height + ")";
label.style.textAlignment = enums.TextAlignment.center;
label.style.backgroundColor = colors[c % 4];
c++;
return label;
}
var absLayout = new absoluteLayoutModule.AbsoluteLayout();
absLayout.width = 300;
absLayout.height = 300;
absLayout.style.backgroundColor = new colorModule.Color("LightGray");
var x = 0.0;
var y = 0.0;
for (var i = 0; i < 10; i++) {
var child = generateChild(50, 50);
absoluteLayoutModule.AbsoluteLayout.setLeft(child, x);
absoluteLayoutModule.AbsoluteLayout.setTop(child, y);
absLayout.addChild(child);
x += 25;
y += 25;
}
var page = new pagesModule.Page();
page.content = absLayout;
return page;
}
//export var Page = page;

View File

@@ -0,0 +1,2 @@
{ "name" : "absolute-layout-demo",
"main" : "app.js" }

7
apps/cuteness.io/app.ts Normal file
View File

@@ -0,0 +1,7 @@
import application = require("application");
// Set the start module for the application
application.mainModule = "app/main-page";
// Start the application
application.start();

View File

@@ -0,0 +1,14 @@
Page {
background-color: #363940;
}
.detailsTitle {
color: #FFFFFF;
font-size: 30;
margin: 10;
}
ActivityIndicator {
width: 50;
height: 50;
}

View File

@@ -0,0 +1,10 @@
import pages = require("ui/page");
import observable = require("data/observable");
// Event handler for Page "navigatedTo" event attached in details-page.xml
export function pageNavigatedTo(args: observable.EventData) {
// Get the event sender
var page = <pages.Page>args.object;
page.bindingContext = page.navigationContext;
}

View File

@@ -0,0 +1,24 @@
<Page xmlns="http://www.nativescript.org/tns.xsd" navigatedTo="pageNavigatedTo">
<GridLayout rows="*, auto">
<ScrollView>
<StackLayout>
<Image source="{{ imageSource }}" stretch="aspectFill"/>
<Label text="{{ title }}" cssClass="detailsTitle" textWrap="true" />
</StackLayout>
</ScrollView>
<StackLayout orientation="horizontal" row="1">
<Label margin="2">
<Label.formattedText>
<FormattedString fontSize="20" foregroundColor="#C6C6C6">
<FormattedString.spans>
<Span text="{{ author ? 'by ' + author : '' }}"/>
<Span text="{{ num_comments ? ' | ' : '' }}" />
<Span text="{{ num_comments ? num_comments + ' comments' : '' }}" foregroundColor="#10C2B0"/>
</FormattedString.spans>
</FormattedString>
</Label.formattedText>
</Label>
</StackLayout>
<ActivityIndicator busy="{{ isLoading }}" />
</GridLayout>
</Page>

View File

@@ -0,0 +1,29 @@
.title {
font-size: 20;
margin: 3;
}
.author {
font-size: 14;
horizontal-align: left;
vertical-align: bottom;
margin: 3;
}
.comments {
color: #10C2B0;
font-size: 14;
vertical-align: bottom;
margin: 3;
}
.thumbnail {
width: 72;
height: 72;
margin: 3;
vertical-align: top;
}
TabView {
background-color: white;
}

View File

@@ -0,0 +1,34 @@
import observable = require("data/observable");
import pages = require("ui/page");
import frames = require("ui/frame");
import listView = require("ui/list-view");
import redditAppViewModel = require("./reddit-app-view-model");
var appViewModel = new redditAppViewModel.AppViewModel();
// Event handler for Page "loaded" event attached in main-page.xml
export function pageLoaded(args: observable.EventData) {
// Get the event sender
var page = <pages.Page>args.object;
page.bindingContext = appViewModel;
// Enable platform specific feature (in this case Android page caching)
if (frames.topmost().android) {
frames.topmost().android.cachePagesOnNavigate = true;
}
}
export function listViewItemTap(args: listView.ItemEventData) {
// Navigate to the details page with context set to the data item for specified index
frames.topmost().navigate({
moduleName: "app/details-page",
context: appViewModel.redditItems.getItem(args.index)
});
}
export function listViewLoadMoreItems(args: observable.EventData) {
// Increase model items length with model items loadSize property value
appViewModel.redditItems.length += appViewModel.redditItems.loadSize;
}

View File

@@ -0,0 +1,30 @@
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<TabView>
<TabView.items>
<TabEntry title="List">
<TabEntry.view>
<ListView items="{{ redditItems }}" isScrolling="{{ isScrolling }}" itemTap="listViewItemTap" loadMoreItems="listViewLoadMoreItems">
<ListView.itemTemplate>
<!-- Binding in template property of an component will use the bindingContext provided by the component. -->
<GridLayout columns="auto, *, auto" rows="auto, 25">
<Image source="{{ thumbnailImageSource || defaultThumbnailImageSource }}" cssClass="thumbnail" rowSpan="2"/>
<Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" col="1" colSpan="2" minHeight="50" />
<Label text="{{ author ? 'by ' + author : '' }}" cssClass="author" col="1" row="1" />
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" cssClass="comments" col="2" row="1" />
</GridLayout>
<!-- End of tempplate. -->
</ListView.itemTemplate>
</ListView>
</TabEntry.view>
</TabEntry>
<TabEntry title="About">
<TabEntry.view>
<StackLayout>
<Image margin="10" url="~/app/res/telerik-logo.png" />
<Label margin="10" textWrap="true" text="{{ aboutText }}" />
</StackLayout>
</TabEntry.view>
</TabEntry>
</TabView.items>
</TabView>
</Page>

View File

@@ -0,0 +1,2 @@
{ "name" : "testsapp",
"main" : "app.js" }

View File

@@ -0,0 +1,88 @@
import imageSource = require("image-source");
import virtualArray = require("data/virtual-array");
import http = require("http");
import observable = require("data/observable");
import imageCache = require("ui/image-cache");
import redditModel = require("./reddit-model");
import redditViewModel = require("./reddit-item-view-model");
var aboutText = "Cuteness is a proof of concept app demonstrating the Telerik's NativeScript for writing native mobile applications using JavaScript.";
export var defaultThumbnailImageSource = imageSource.fromFile("~/app/res/reddit-logo.png");
export var defaultNoThumbnailImageSource = imageSource.fromFile("~/app/res/no-image.png");
var redditUrl = "http://www.reddit.com/r/aww.json?limit=";
var after: string;
var ISSCROLLING = "isLoading";
// initialize the image cache for the main list
export var cache = new imageCache.Cache();
cache.invalid = defaultNoThumbnailImageSource;
cache.placeholder = defaultThumbnailImageSource;
cache.maxRequests = 5;
export class AppViewModel extends observable.Observable {
private _redditItems: virtualArray.VirtualArray<redditViewModel.RedditViewModel>;
get redditItems(): virtualArray.VirtualArray<redditViewModel.RedditViewModel> {
if (!this._redditItems) {
this._redditItems = new virtualArray.VirtualArray<redditViewModel.RedditViewModel>(1000);
this._redditItems.loadSize = 50;
this._redditItems.on(virtualArray.knownEvents.itemsLoading, (args: virtualArray.ItemsLoading) => {
http.getJSON<redditModel.Data>(redditUrl + args.count +
(after ? "&after=" + after : "")).then(result => {
var itemsToLoad = result.data.children.map(i=> {
return new redditViewModel.RedditViewModel(i.data);
});
this._redditItems.load(args.index, itemsToLoad);
var lastItem = itemsToLoad[itemsToLoad.length - 1];
if (lastItem) {
after = itemsToLoad[itemsToLoad.length - 1].source.name;
}
}, (e) => { console.log(e.message) })
.catch(function(e) {
setTimeout(function() { throw e; });
});
;
});
}
return this._redditItems;
}
private _isScrolling = false;
get isScrolling(): boolean {
return this._isScrolling;
}
set isScrolling(value: boolean) {
if (this._isScrolling !== value) {
this._isScrolling = value;
if (value) {
cache.disableDownload();
}
else {
cache.enableDownload();
}
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: ISSCROLLING, value: value });
}
}
get aboutText(): string {
return aboutText;
}
get defaultThumbnailImageSource(): imageSource.ImageSource {
return defaultThumbnailImageSource;
}
get defaultNoThumbnailImageSource(): imageSource.ImageSource {
return defaultNoThumbnailImageSource;
}
}

View File

@@ -0,0 +1,102 @@
import observable = require("data/observable");
import imageSource = require("image-source");
import redditModel = require("./reddit-model");
import redditAppViewModel = require("./reddit-app-view-model");
var firstThumbnailImageSource = imageSource.fromFile("~/app/res/first-image.png");
var defaultImageSource = imageSource.fromFile("~/app/res/reddit-logo-transparent.png");
var ISLOADING = "isLoading";
var THUMBNAIL_IMAGE_SOURCE = "thumbnailImageSource";
var IMAGE_SOURCE = "imageSource";
export class RedditViewModel extends observable.Observable {
private _source: redditModel.ItemData;
constructor(source: redditModel.ItemData) {
super();
this._source = source;
if (this._source) {
var property: string;
for (property in this._source) {
this.set(property, this._source[property]);
}
}
}
get source(): redditModel.ItemData {
return this._source;
}
private _isLoading = false;
get isLoading(): boolean {
return this._isLoading;
}
set isLoading(value: boolean) {
if (this._isLoading !== value) {
this._isLoading = value;
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: ISLOADING, value: value });
}
}
private _thumbnailImageSource: imageSource.ImageSource;
get thumbnailImageSource(): imageSource.ImageSource {
if (this._source) {
if (this._source.title === "reddit 101") {
this._thumbnailImageSource = firstThumbnailImageSource;
} else if (redditAppViewModel.cache) {
var url = this._source.thumbnail;
var imgSource = redditAppViewModel.cache.get(url);
if (imgSource) {
this._thumbnailImageSource = imgSource;
}
else if (_isValidImageUrl(url)) {
this.isLoading = true;
redditAppViewModel.cache.push({
key: url,
url: url,
completed: (result: imageSource.ImageSource, key: string) => {
if (url === key) {
this.isLoading = false;
this._thumbnailImageSource = result;
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: THUMBNAIL_IMAGE_SOURCE, value: result });
}
}
});
} else {
this._thumbnailImageSource = redditAppViewModel.defaultNoThumbnailImageSource;
}
}
}
return this._thumbnailImageSource || redditAppViewModel.defaultThumbnailImageSource;
}
get imageSource(): imageSource.ImageSource {
if (this._source) {
var url = this._source.url;
if (_isValidImageUrl(url)) {
this.isLoading = true;
imageSource.fromUrl(url).then(result => {
this.isLoading = false;
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: IMAGE_SOURCE, value: result });
});
}
}
return defaultImageSource;
}
}
function _isValidImageUrl(url: string): boolean {
return url && (url.indexOf(".png") !== -1 || url.indexOf(".jpg") !== -1);
}

57
apps/cuteness.io/reddit-model.d.ts vendored Normal file
View File

@@ -0,0 +1,57 @@
export interface Data {
kind: string;
data: Items;
}
export interface Items {
modhash: string;
children: Array<Item>;
}
export interface Item {
kind: string;
data: ItemData;
}
export interface ItemData {
domain: any;
banned_by: any;
media_embed: any;
subreddit: any;
selftext_html: any;
selftext: any;
likes: any;
secure_media: any;
link_flair_text: any;
id: string;
gilded: any;
secure_media_embed: any;
clicked: boolean;
stickied: boolean;
author: any;
media: any;
score: number;
approved_by: any;
over_18: boolean;
hidden: boolean;
thumbnail: string;
subreddit_id: any;
edited: boolean;
link_flair_css_class: any;
author_flair_css_class: any;
downs: number;
saved: boolean;
is_self: boolean;
permalink: string;
name: string;
created: number;
url: string;
author_flair_text: string;
title: string;
created_utc: number;
ups: number;
num_comments: number;
visited: boolean;
num_reports: any;
distinguished: any
}

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -0,0 +1,3 @@
import application = require("application");
application.mainModule = "app/main-page";
application.start();

View File

@@ -0,0 +1,51 @@
import observableModule = require("data/observable");
import pagesModule = require("ui/page");
import textFieldModule = require("ui/text-field");
import textViewModule = require("ui/text-view");
import buttonModule = require("ui/button");
import labelModule = require("ui/label");
import model = require("./model");
import colorModule = require("color");
import stackLayoutModule = require("ui/layouts/stack-layout");
import enums = require("ui/enums");
var stackLayout: stackLayoutModule.StackLayout;
var textField: textFieldModule.TextField;
var textView: textViewModule.TextView;
var button: buttonModule.Button;
var label: labelModule.Label;
export function onPageLoaded(args: observableModule.EventData) {
var page = <pagesModule.Page>args.object;
stackLayout = page.getViewById<stackLayoutModule.StackLayout>("stack");
button = page.getViewById<buttonModule.Button>("button");
label = page.getViewById<labelModule.Label>("label");
if (stackLayout.android) {
stackLayout.android.setClickable(true);
stackLayout.android.setFocusableInTouchMode(true);
}
textField = page.getViewById<textFieldModule.TextField>("textField");
textField.style.backgroundColor = new colorModule.Color("LightGray");
textView = page.getViewById<textViewModule.TextView>("textView");
textView.style.backgroundColor = new colorModule.Color("BlanchedAlmond");
var viewModel = new model.WebViewModel();
page.bindingContext = viewModel;
}
export function onTap(args: observableModule.EventData) {
if (textField.updateTextTrigger === enums.UpdateTextTrigger.focusLost) {
textField.updateTextTrigger = enums.UpdateTextTrigger.textChanged;
textView.updateTextTrigger = enums.UpdateTextTrigger.textChanged;
button.text = "textChanged";
}
else {
textField.updateTextTrigger = enums.UpdateTextTrigger.focusLost;
textView.updateTextTrigger = enums.UpdateTextTrigger.focusLost;
button.text = "focusLost";
}
}

View File

@@ -0,0 +1,8 @@
<Page loaded="onPageLoaded">
<StackLayout id="stack">
<Button id="button" text="textChanged" height="100" margin="20" tap="onTap" backgroundColor="Red"/>
<Label id="label" text="{{ text }}" height="100" margin="20"/>
<TextField id="textField" text="{{ text }}" margin="20" updateTextTrigger="textChanged"/>
<TextView id="textView" text="{{ text }}" height="100" margin="20" updateTextTrigger="textChanged"/>
</StackLayout>
</Page>

View File

@@ -0,0 +1,17 @@
import observable = require("data/observable");
export class WebViewModel extends observable.Observable {
constructor() {
super();
}
private _text: string;
get text(): string {
return this._text;
}
set text(value: string) {
console.log(value);
this._text = value;
this.notify({ object: this, eventName: observable.knownEvents.propertyChange, propertyName: "text", value: value });
}
}

View File

@@ -0,0 +1,2 @@
{ "name" : "editable-text-demo",
"main" : "app.js" }

3
apps/gallery-app/app.ts Normal file
View File

@@ -0,0 +1,3 @@
import application = require("application");
application.mainModule = "app/main-page";
application.start();

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<ScrollView>
<Label textWrap="true" text="Lorem ipsum dolor sit amet, qui ex sonet alterum epicurei, autem ponderum theophrastus vix no. Eros dolores at vim, quo euismod necessitatibus at. Cu magna dolorem ceteros his. Eos ei atomorum voluptatibus. Nec omnis solum persecuti ei, at mei dicta senserit. Et posse accusam eum, eam ignota alienum antiopam an, at sit labore tritani. Ei choro atomorum qui, veniam ornatus in pri.
Tantas delenit facilis usu ei, eum eu eius menandri appellantur, qui elitr philosophia id. Eos et mazim tamquam facilis, ex sit vituperata interpretaris, nihil insolens antiopam vel ne. Munere putant instructior in qui. Cetero fuisset te eum, cu mentitum oporteat senserit vis, quod nobis option ex sit.
Option consulatu id ius, fabulas inimicus eloquentiam usu no. An mel virtute minimum iracundia, oratio feugiat id usu. Te modus tation laoreet eum. Gubergren concludaturque eum cu. Ex epicuri quaestio vel.
Ut mei nonumes definitiones, quo at recusabo adversarium. Iusto scaevola mea no, ei albucius platonem assueverit his. Iudico impetus deterruisset id per, at nec tollit graeci mentitum. Pro quod erat et. Eam error eruditi vocibus at, eos ea tale mazim, in gubergren splendide pro. No oblique democritum mel, malis dicat dissentias id mel. Congue senserit nam at.
Id altera labore labores mel, invenire posidonium suscipiantur duo ad. Nibh populo ne vim, vidisse convenire intellegat mea no, legere placerat democritum sea ne. Et mei virtute sapientem. Ut eam saperet deterruisset. Est ex harum omnium complectitur, quidam postulant constituto sed in, soleat quaeque ei sea. Vix dicit equidem vivendum ea, mea natum graecis civibus cu, summo persecuti te sed. Ne mei vocibus perfecto referrentur, quo ei legere civibus lucilius.
Lorem ipsum dolor sit amet, qui ex sonet alterum epicurei, autem ponderum theophrastus vix no. Eros dolores at vim, quo euismod necessitatibus at. Cu magna dolorem ceteros his. Eos ei atomorum voluptatibus. Nec omnis solum persecuti ei, at mei dicta senserit. Et posse accusam eum, eam ignota alienum antiopam an, at sit labore tritani. Ei choro atomorum qui, veniam ornatus in pri.
Tantas delenit facilis usu ei, eum eu eius menandri appellantur, qui elitr philosophia id. Eos et mazim tamquam facilis, ex sit vituperata interpretaris, nihil insolens antiopam vel ne. Munere putant instructior in qui. Cetero fuisset te eum, cu mentitum oporteat senserit vis, quod nobis option ex sit.
Option consulatu id ius, fabulas inimicus eloquentiam usu no. An mel virtute minimum iracundia, oratio feugiat id usu. Te modus tation laoreet eum. Gubergren concludaturque eum cu. Ex epicuri quaestio vel.
Ut mei nonumes definitiones, quo at recusabo adversarium. Iusto scaevola mea no, ei albucius platonem assueverit his. Iudico impetus deterruisset id per, at nec tollit graeci mentitum. Pro quod erat et. Eam error eruditi vocibus at, eos ea tale mazim, in gubergren splendide pro. No oblique democritum mel, malis dicat dissentias id mel. Congue senserit nam at.
Id altera labore labores mel, invenire posidonium suscipiantur duo ad. Nibh populo ne vim, vidisse convenire intellegat mea no, legere placerat democritum sea ne. Et mei virtute sapientem. Ut eam saperet deterruisset. Est ex harum omnium complectitur, quidam postulant constituto sed in, soleat quaeque ei sea. Vix dicit equidem vivendum ea, mea natum graecis civibus cu, summo persecuti te sed. Ne mei vocibus perfecto referrentur, quo ei legere civibus lucilius." />
</ScrollView>
</Page>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<TabView>
<TabView.items>
<TabEntry title="First">
<TabEntry.view>
<GridLayout>
<Label text="First Tab" verticalAlignment="center" horizontalAlignment="center"/>
</GridLayout>
</TabEntry.view>
</TabEntry>
<TabEntry title="Second">
<TabEntry.view>
<GridLayout>
<Label text="Second Tab" verticalAlignment="center" horizontalAlignment="center"/>
</GridLayout>
</TabEntry.view>
</TabEntry>
</TabView.items>
</TabView>
</Page>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<WebView margin="10" url="http://www.telerik.com/nativescript"/>
</Page>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<AbsoluteLayout>
<Button text="1" left="50" top="50" width="100" height="100" style="background-color: red;"/>
<Button text="2" left="200" top="100" width="100" height="300" style="background-color: lightblue;"/>
<Button text="3" left="50" top="280" width="200" height="100" style="background-color: lightgreen;"/>
</AbsoluteLayout>
</Page>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<DockLayout stretchLastChild="true">
<Button dock="left" text="left" style="background-color: red; margin: 5;"/>/>
<Button dock="top" text="top" style="background-color: lightblue; margin: 5;"/>
<Button dock="right" text="right" style="background-color: lightgreen; margin: 5;"/>
<Button dock="bottom" text="bottom" style="background-color: lightpink; margin: 5;"/>
<Button text="fill" style="background-color: wheat; margin: 5;"/>
</DockLayout>
</Page>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<GridLayout columns="*,*,*" rows="*,*,*">
<Button text="1" style="background-color: red; margin: 5;"/>
<Button text="2" col="1" style="background-color: lightblue; margin: 5;"/>
<Button text="3" col="2" rowSpan="2" style="background-color: lightgreen; margin: 5;"/>
<Button text="4" row="1" rowSpan="2" colSpan="2" style="background-color: lightpink; margin: 5;"/>
<Button text="5" row="2" col="2" style="background-color: wheat; margin: 5;"/>
</GridLayout>
</Page>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<StackLayout>
<Button text="button 1" style="background-color: red; margin: 5;"/>
<Button text="button 2" style="background-color: lightblue; margin: 5;"/>
<Button text="button 3" style="background-color: lightgreen; margin: 5;"/>
</StackLayout>
</Page>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<WrapLayout>
<Button text="1" width="150" height="100" style="background-color: red; margin: 5;"/>
<Button text="2" width="100" height="150" style="background-color: lightblue; margin: 5;"/>
<Button text="3" width="200" height="120" style="background-color: lightgreen; margin: 5;"/>
<Button text="4" width="100" height="50" style="background-color: lightpink; margin: 5;"/>
<Button text="5" width="250" height="100" style="background-color: wheat; margin: 5;"/>
</WrapLayout>
</Page>

View File

@@ -0,0 +1,13 @@
Page {
background-color: white;
}
ScrollView {
margin: 10;
}
.title {
horizontal-align: center;
font-size: 24;
margin: 6 0;
}

View File

@@ -0,0 +1,9 @@
import observable = require("data/observable");
import frame = require("ui/frame");
export function itemTap(args: observable.EventData) {
frame.topmost().navigate({
moduleName: "app/" + args.object.get("tag"),
});
}

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<ScrollView>
<StackLayout>
<Label cssClass="title" text="Layouts" />
<StackLayout>
<Button tag="layouts/stack-layout" text="StackLayout" tap="itemTap" />
<Button tag="layouts/grid-layout" text="GridLayout" tap="itemTap" />
<Button tag="layouts/wrap-layout" text="WrapLayout" tap="itemTap" />
<Button tag="layouts/dock-layout" text="DockLayout" tap="itemTap" />
<Button tag="layouts/absolute-layout" text="AbsoluteLayout" tap="itemTap" />
</StackLayout>
<Label cssClass="title" text="Content" />
<StackLayout>
<Button tag="content/tab-view" text="TabView" tap="itemTap" />
<Button tag="content/web-view" text="WebView" tap="itemTap" />
<Button tag="content/scroll-view" text="ScrollView" tap="itemTap" />
</StackLayout>
<Label cssClass="title" text="Views" />
<StackLayout>
<Button tag="views/button" text="Button" tap="itemTap" />
<Button tag="views/label" text="Label" tap="itemTap" />
<Button tag="views/text-field" text="TextField" tap="itemTap" />
<Button tag="views/text-view" text="TextView" tap="itemTap" />
<Button tag="views/switch" text="Switch" tap="itemTap" />
<Button tag="views/slider" text="Slider" tap="itemTap" />
<Button tag="views/progress" text="Progress" tap="itemTap" />
<Button tag="views/activity-indicator" text="ActivityIndicator" tap="itemTap" />
<Button tag="views/image" text="Image" tap="itemTap" />
<Button tag="views/search-bar" text="SearchBar" tap="itemTap" />
<Button tag="views/list-view" text="ListView" tap="itemTap" />
<Button tag="views/dialogs" text="Dialogs" tap="itemTap" />
</StackLayout>
</StackLayout>
</ScrollView>
</Page>

View File

@@ -0,0 +1,2 @@
{ "name" : "gallery-app",
"main" : "app.js" }

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<ActivityIndicator busy="true" verticalAlignment="center" horizontalAlignment="center"/>
</Page>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<Button text="button" verticalAlignment="center" horizontalAlignment="center"/>
</Page>

View File

@@ -0,0 +1,17 @@
import dialogs = require("ui/dialogs");
export function alertTapped(args) {
dialogs.alert("Hi there!");
}
export function confirmTapped(args) {
dialogs.confirm("Are you sure?");
}
export function promptTapped(args) {
dialogs.prompt("Enter name", "John Doe");
}
export function loginTapped(args) {
dialogs.login("Login:", "username");
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<StackLayout>
<Button text="alert" tap="alertTapped"/>
<Button text="confirm" tap="confirmTapped"/>
<Button text="prompt" tap="promptTapped"/>
<Button text="login" tap="loginTapped"/>
</StackLayout>
</Page>

View File

@@ -0,0 +1,10 @@
import fs = require("file-system");
import imageSource = require("image-source");
export function pageLoaded(args) {
var page = args.object;
var telerikLogo = imageSource.fromFile(fs.path.join(__dirname, "../res/telerik-logo.png"));
page.bindingContext = { imageSource: telerikLogo };
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page loaded="pageLoaded">
<Image margin="10" source="{{ imageSource }}" verticalAlignment="center" horizontalAlignment="center"/>
</Page>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<Label text="The quick brown fox jumps over the lazy dog." verticalAlignment="center" horizontalAlignment="center"/>
</Page>

View File

@@ -0,0 +1,10 @@
export function pageLoaded(args) {
var page = args.object;
var itemsArr = [];
for (var i = 1; i <= 64; i++) {
itemsArr.push({ title: "List item " + i });
}
page.bindingContext = { items: itemsArr };
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page loaded="pageLoaded">
<ListView items="{{ items }}">
<ListView.itemTemplate>
<StackLayout>
<Label text="{{ title }}" margin="5 10" horizontalAlignment="center"/>
</StackLayout>
</ListView.itemTemplate>
</ListView>
</Page>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<Progress verticalAlignment="center" maxValue="100" value="60" margin="10"/>
</Page>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<SearchBar width="250" verticalAlignemnt="center" horizontalAlignemnt="center"/>
</Page>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<Slider verticalAlignment="center" value="60" maxValue="100" margin="10"/>
</Page>

Some files were not shown because too many files have changed in this diff Show More