mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
How-To md files with markdown-snippet-injector
This commit is contained in:
@ -1,27 +1,19 @@
|
|||||||
// <snippet module="ui/frame" title="frame">
|
// >> frame-require
|
||||||
// # Frame
|
|
||||||
// To perform navigation, you will need a reference to the topmost frame of the application.
|
|
||||||
// ``` JavaScript
|
|
||||||
import frameModule = require("ui/frame");
|
import frameModule = require("ui/frame");
|
||||||
var topmost = frameModule.topmost();
|
var topmost = frameModule.topmost();
|
||||||
// ```
|
// << frame-require
|
||||||
// </snippet>
|
|
||||||
import labelModule = require("ui/label");
|
import labelModule = require("ui/label");
|
||||||
import pagesModule = require("ui/page");
|
import pagesModule = require("ui/page");
|
||||||
|
|
||||||
export var ignore_test_DummyTestForSnippetOnly0 = function () {
|
export var ignore_test_DummyTestForSnippetOnly0 = function () {
|
||||||
// <snippet module="ui/frame" title="frame">
|
// >> frame-navigating
|
||||||
// ### Navigating to a Module
|
|
||||||
// ``` JavaScript
|
|
||||||
topmost.navigate("details-page");
|
topmost.navigate("details-page");
|
||||||
// ```
|
// << frame-navigating
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var ignore_test_DummyTestForSnippetOnly1 = function () {
|
export var ignore_test_DummyTestForSnippetOnly1 = function () {
|
||||||
// <snippet module="ui/frame" title="frame">
|
// >> frame-factory-func
|
||||||
// ### Navigating with a Factory Function
|
|
||||||
// ``` JavaScript
|
|
||||||
var factoryFunc = function () {
|
var factoryFunc = function () {
|
||||||
var label = new labelModule.Label();
|
var label = new labelModule.Label();
|
||||||
label.text = "Hello, world!";
|
label.text = "Hello, world!";
|
||||||
@ -30,29 +22,22 @@ export var ignore_test_DummyTestForSnippetOnly1 = function () {
|
|||||||
return page;
|
return page;
|
||||||
};
|
};
|
||||||
topmost.navigate(factoryFunc);
|
topmost.navigate(factoryFunc);
|
||||||
// ```
|
// <<frame-factory-func
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var ignore_test_DummyTestForSnippetOnly2 = function () {
|
export var ignore_test_DummyTestForSnippetOnly2 = function () {
|
||||||
// <snippet module="ui/frame" title="frame">
|
// >> frame-naventry
|
||||||
// ### Navigating with NavigationEntry
|
|
||||||
// ``` JavaScript
|
|
||||||
var navigationEntry = {
|
var navigationEntry = {
|
||||||
moduleName: "details-page",
|
moduleName: "details-page",
|
||||||
context: { info: "something you want to pass to your page" },
|
context: { info: "something you want to pass to your page" },
|
||||||
animated: false
|
animated: false
|
||||||
};
|
};
|
||||||
topmost.navigate(navigationEntry);
|
topmost.navigate(navigationEntry);
|
||||||
// ```
|
// << frame-naventry
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var ignore_test_DummyTestForSnippetOnly3 = function () {
|
export var ignore_test_DummyTestForSnippetOnly3 = function () {
|
||||||
// <snippet module="ui/frame" title="frame">
|
// >> frame-back
|
||||||
// ### Navigating Back
|
|
||||||
// ``` JavaScript
|
|
||||||
topmost.goBack();
|
topmost.goBack();
|
||||||
// ```
|
// << frame-back
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
20
apps/tests/frame.md
Normal file
20
apps/tests/frame.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
nav-title: "frame How-To"
|
||||||
|
title: "How-To"
|
||||||
|
description: "Examples for using frame"
|
||||||
|
---
|
||||||
|
# Frame
|
||||||
|
To perform navigation, you will need a reference to the topmost frame of the application.
|
||||||
|
<snippet id='frame-require'/>
|
||||||
|
|
||||||
|
### Navigating to a Module
|
||||||
|
<snippet id='frame-navigating'/>
|
||||||
|
|
||||||
|
### Navigating with a Factory Function
|
||||||
|
<snippet id='frame-factory-func'/>
|
||||||
|
|
||||||
|
### Navigating with NavigationEntry
|
||||||
|
<snippet id='frame-naventry'/>
|
||||||
|
|
||||||
|
### Navigating Back
|
||||||
|
<snippet id='frame-back'/>
|
@ -5,28 +5,15 @@ import imageModule = require("ui/image");
|
|||||||
import platform = require("platform");
|
import platform = require("platform");
|
||||||
import color = require("color");
|
import color = require("color");
|
||||||
|
|
||||||
// <snippet module="ui/activity-indicator" title="activity-indicator">
|
// >> activity-indicator-require
|
||||||
// # ActivityIndicator
|
|
||||||
// Using the activity indicator requires the ActivityIndicator module.
|
|
||||||
// ``` JavaScript
|
|
||||||
import activityIndicatorModule = require("ui/activity-indicator");
|
import activityIndicatorModule = require("ui/activity-indicator");
|
||||||
// ```
|
// << activity-indicator-require
|
||||||
// ### Binding the activity indicator busy property to a view-model property.
|
|
||||||
//``` XML
|
|
||||||
// <Page>
|
|
||||||
// {%raw%}<ActivityIndicator busy="{{ isLoading }}" />{%endraw%}
|
|
||||||
// </Page>
|
|
||||||
//```
|
|
||||||
// </snippet>
|
|
||||||
|
|
||||||
var ASYNC = 0.2;
|
var ASYNC = 0.2;
|
||||||
export function test_default_TNS_values() {
|
export function test_default_TNS_values() {
|
||||||
// <snippet module="ui/activity-indicator" title="activity-indicator">
|
// >> activity-indicator-create
|
||||||
// ### Creating an activity indicator
|
|
||||||
// ``` JavaScript
|
|
||||||
var indicator = new activityIndicatorModule.ActivityIndicator();
|
var indicator = new activityIndicatorModule.ActivityIndicator();
|
||||||
// ```
|
// << activity-indicator-create
|
||||||
// </snippet>
|
|
||||||
|
|
||||||
TKUnit.assertEqual(indicator.busy, false, "Default indicator.busy");
|
TKUnit.assertEqual(indicator.busy, false, "Default indicator.busy");
|
||||||
}
|
}
|
||||||
@ -76,9 +63,7 @@ if (platform.device.os === platform.platformNames.ios) {
|
|||||||
function binding_busy_to_image() {
|
function binding_busy_to_image() {
|
||||||
/* tslint:enable:no-unused-variable */
|
/* tslint:enable:no-unused-variable */
|
||||||
|
|
||||||
// <snippet module="ui/activity-indicator" title="activity-indicator">
|
// >> activity-indicator-loading
|
||||||
// ### Showing activity indicator while image is loading
|
|
||||||
// ``` JavaScript
|
|
||||||
var image = new imageModule.Image();
|
var image = new imageModule.Image();
|
||||||
var indicator = new activityIndicatorModule.ActivityIndicator();
|
var indicator = new activityIndicatorModule.ActivityIndicator();
|
||||||
indicator.width = 100;
|
indicator.width = 100;
|
||||||
@ -89,8 +74,7 @@ function binding_busy_to_image() {
|
|||||||
sourceProperty: "isLoading",
|
sourceProperty: "isLoading",
|
||||||
targetProperty: "busy"
|
targetProperty: "busy"
|
||||||
}, image);
|
}, image);
|
||||||
// ```
|
// << activity-indicator-loading
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNativeBusy(indicator: activityIndicatorModule.ActivityIndicator): boolean {
|
function getNativeBusy(indicator: activityIndicatorModule.ActivityIndicator): boolean {
|
||||||
|
@ -5,9 +5,8 @@ description: "Examples for using activity-indicator"
|
|||||||
---
|
---
|
||||||
# ActivityIndicator
|
# ActivityIndicator
|
||||||
Using the activity indicator requires the ActivityIndicator module.
|
Using the activity indicator requires the ActivityIndicator module.
|
||||||
``` JavaScript
|
<snippet id='activity-indicator-require'/>
|
||||||
var activityIndicatorModule = require("ui/activity-indicator");
|
|
||||||
```
|
|
||||||
### Binding the activity indicator busy property to a view-model property.
|
### Binding the activity indicator busy property to a view-model property.
|
||||||
``` XML
|
``` XML
|
||||||
<Page>
|
<Page>
|
||||||
@ -15,18 +14,7 @@ var activityIndicatorModule = require("ui/activity-indicator");
|
|||||||
</Page>
|
</Page>
|
||||||
```
|
```
|
||||||
### Creating an activity indicator
|
### Creating an activity indicator
|
||||||
``` JavaScript
|
<snippet id='activity-indicator-create'/>
|
||||||
var indicator = new activityIndicatorModule.ActivityIndicator();
|
|
||||||
```
|
|
||||||
### Showing activity indicator while image is loading
|
### Showing activity indicator while image is loading
|
||||||
``` JavaScript
|
<snippet id='activity-indicator-loading'/>
|
||||||
var image = new imageModule.Image();
|
|
||||||
var indicator = new activityIndicatorModule.ActivityIndicator();
|
|
||||||
indicator.width = 100;
|
|
||||||
indicator.height = 100;
|
|
||||||
// Bind the busy property of the indicator to the isLoading property of the image
|
|
||||||
indicator.bind({
|
|
||||||
sourceProperty: "isLoading",
|
|
||||||
targetProperty: "busy"
|
|
||||||
}, image);
|
|
||||||
```
|
|
||||||
|
@ -7,13 +7,9 @@ import stackLayoutModule = require("ui/layouts/stack-layout");
|
|||||||
import colorModule = require("color");
|
import colorModule = require("color");
|
||||||
import enums = require("ui/enums");
|
import enums = require("ui/enums");
|
||||||
|
|
||||||
// <snippet module="ui/animation" title="animation">
|
// >> animation-require
|
||||||
// # Animation
|
|
||||||
// Animating view properties requires the "ui/animation" module.
|
|
||||||
// ``` JavaScript
|
|
||||||
import animation = require("ui/animation");
|
import animation = require("ui/animation");
|
||||||
// ```
|
// << animation-require
|
||||||
// </snippet>
|
|
||||||
|
|
||||||
export var test_AnimatingProperties = function(done) {
|
export var test_AnimatingProperties = function(done) {
|
||||||
var mainPage: pageModule.Page;
|
var mainPage: pageModule.Page;
|
||||||
@ -31,9 +27,7 @@ export var test_AnimatingProperties = function(done) {
|
|||||||
helper.navigate(pageFactory);
|
helper.navigate(pageFactory);
|
||||||
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
||||||
|
|
||||||
// <snippet module="ui/animation" title="animation">
|
// >> animation-properties
|
||||||
// # Animating properties
|
|
||||||
// ``` JavaScript
|
|
||||||
label.animate({
|
label.animate({
|
||||||
opacity: 0.75,
|
opacity: 0.75,
|
||||||
backgroundColor: new colorModule.Color("Red"),
|
backgroundColor: new colorModule.Color("Red"),
|
||||||
@ -47,19 +41,18 @@ export var test_AnimatingProperties = function(done) {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
////console.log("Animation finished.");
|
////console.log("Animation finished.");
|
||||||
// <hide>
|
// >> (hide)
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
done();
|
done();
|
||||||
// </hide>
|
// << (hide)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
// <hide>
|
// >> (hide)
|
||||||
done(e);
|
done(e);
|
||||||
// </hide>
|
// << (hide)
|
||||||
});
|
});
|
||||||
// ```
|
// << animation-properties
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_CancellingAnimation = function(done) {
|
export var test_CancellingAnimation = function(done) {
|
||||||
@ -78,20 +71,18 @@ export var test_CancellingAnimation = function(done) {
|
|||||||
helper.navigate(pageFactory);
|
helper.navigate(pageFactory);
|
||||||
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
||||||
|
|
||||||
// <snippet module="ui/animation" title="animation">
|
// >> animation-cancel
|
||||||
// # Cancelling animation
|
|
||||||
// ``` JavaScript
|
|
||||||
var animation1 = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 500 });
|
var animation1 = label.createAnimation({ translate: { x: 100, y: 100 }, duration: 500 });
|
||||||
animation1.play()
|
animation1.play()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
////console.log("Animation finished");
|
////console.log("Animation finished");
|
||||||
// <hide>
|
// >> (hide)
|
||||||
throw new Error("Cancelling Animation - Should not be in the Promise Then()");
|
throw new Error("Cancelling Animation - Should not be in the Promise Then()");
|
||||||
// </hide>
|
// << (hide)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
////console.log("Animation cancelled");
|
////console.log("Animation cancelled");
|
||||||
// <hide>
|
// >> (hide)
|
||||||
if (!e) {
|
if (!e) {
|
||||||
done(new Error("Cancel path did not have proper error"));
|
done(new Error("Cancel path did not have proper error"));
|
||||||
} else if (e.toString() === "Error: Animation cancelled.") {
|
} else if (e.toString() === "Error: Animation cancelled.") {
|
||||||
@ -99,11 +90,10 @@ export var test_CancellingAnimation = function(done) {
|
|||||||
} else {
|
} else {
|
||||||
done(e);
|
done(e);
|
||||||
}
|
}
|
||||||
// </hide>
|
// << (hide)
|
||||||
});
|
});
|
||||||
animation1.cancel();
|
animation1.cancel();
|
||||||
// ```
|
// << animation-cancel
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_CancellingAnimate = function(done) {
|
export var test_CancellingAnimate = function(done) {
|
||||||
@ -122,19 +112,17 @@ export var test_CancellingAnimate = function(done) {
|
|||||||
helper.navigate(pageFactory);
|
helper.navigate(pageFactory);
|
||||||
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
||||||
|
|
||||||
// <snippet module="ui/animation" title="animation">
|
// >> animation-cancel2
|
||||||
// # Cancelling animation
|
|
||||||
// ``` JavaScript
|
|
||||||
var animation1 = label.animate({ translate: { x: 100, y: 100 }, duration: 500 })
|
var animation1 = label.animate({ translate: { x: 100, y: 100 }, duration: 500 })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
////console.log("Animation finished");
|
////console.log("Animation finished");
|
||||||
// <hide>
|
// >> (hide)
|
||||||
throw new Error("Cancelling Animate - Should not be in Promise Then()");
|
throw new Error("Cancelling Animate - Should not be in Promise Then()");
|
||||||
// </hide>
|
// << (hide)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
////console.log("Animation cancelled");
|
////console.log("Animation cancelled");
|
||||||
// <hide>
|
// >> (hide)
|
||||||
if (!e) {
|
if (!e) {
|
||||||
done(new Error("Cancel path did not have proper error"));
|
done(new Error("Cancel path did not have proper error"));
|
||||||
} else if (e.toString() === "Error: Animation cancelled.") {
|
} else if (e.toString() === "Error: Animation cancelled.") {
|
||||||
@ -142,11 +130,10 @@ export var test_CancellingAnimate = function(done) {
|
|||||||
} else {
|
} else {
|
||||||
done(e);
|
done(e);
|
||||||
}
|
}
|
||||||
// </hide>
|
// << (hide)
|
||||||
});
|
});
|
||||||
animation1.cancel();
|
animation1.cancel();
|
||||||
// ```
|
// << animation-cancel2
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_ChainingAnimations = function(done) {
|
export var test_ChainingAnimations = function(done) {
|
||||||
@ -164,9 +151,7 @@ export var test_ChainingAnimations = function(done) {
|
|||||||
helper.navigate(pageFactory);
|
helper.navigate(pageFactory);
|
||||||
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
||||||
|
|
||||||
// <snippet module="ui/animation" title="animation">
|
// >> animation-chaining
|
||||||
// # Chaining animations
|
|
||||||
// ``` JavaScript
|
|
||||||
label.animate({ opacity: 0 })
|
label.animate({ opacity: 0 })
|
||||||
.then(() => label.animate({ opacity: 1 }))
|
.then(() => label.animate({ opacity: 1 }))
|
||||||
.then(() => label.animate({ translate: { x: 200, y: 200 } }))
|
.then(() => label.animate({ translate: { x: 200, y: 200 } }))
|
||||||
@ -177,19 +162,18 @@ export var test_ChainingAnimations = function(done) {
|
|||||||
.then(() => label.animate({ rotate: 0 }))
|
.then(() => label.animate({ rotate: 0 }))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
////console.log("Animation finished");
|
////console.log("Animation finished");
|
||||||
// <hide>
|
// >> (hide)
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
done();
|
done();
|
||||||
// </hide>
|
// << (hide)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
// <hide>
|
// >> (hide)
|
||||||
done(e);
|
done(e);
|
||||||
// </hide>
|
// << (hide)
|
||||||
});
|
});
|
||||||
// ```
|
// << animation-chaining
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_ReusingAnimations = function(done) {
|
export var test_ReusingAnimations = function(done) {
|
||||||
@ -208,9 +192,7 @@ export var test_ReusingAnimations = function(done) {
|
|||||||
helper.navigate(pageFactory);
|
helper.navigate(pageFactory);
|
||||||
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
TKUnit.waitUntilReady(() => { return label.isLoaded });
|
||||||
|
|
||||||
// <snippet module="ui/animation" title="animation">
|
// >> animation-reusing
|
||||||
// # Reusing animations
|
|
||||||
// ``` JavaScript
|
|
||||||
var animation1 = label.createAnimation({ translate: { x: 100, y: 100 } });
|
var animation1 = label.createAnimation({ translate: { x: 100, y: 100 } });
|
||||||
var animation2 = label.createAnimation({ translate: { x: 0, y: 0 } });
|
var animation2 = label.createAnimation({ translate: { x: 0, y: 0 } });
|
||||||
|
|
||||||
@ -222,19 +204,18 @@ export var test_ReusingAnimations = function(done) {
|
|||||||
.then(() => animation2.play())
|
.then(() => animation2.play())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
////console.log("Animation finished");
|
////console.log("Animation finished");
|
||||||
// <hide>
|
// >> (hide)
|
||||||
assertIOSNativeTransformIsCorrect(label);
|
assertIOSNativeTransformIsCorrect(label);
|
||||||
done();
|
done();
|
||||||
// </hide>
|
// << (hide)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
// <hide>
|
// >> (hide)
|
||||||
done(e);
|
done(e);
|
||||||
// </hide>
|
// << (hide)
|
||||||
});
|
});
|
||||||
// ```
|
// << animation-reusing
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_AnimatingMultipleViews = function(done) {
|
export var test_AnimatingMultipleViews = function(done) {
|
||||||
@ -260,9 +241,7 @@ export var test_AnimatingMultipleViews = function(done) {
|
|||||||
helper.navigate(pageFactory);
|
helper.navigate(pageFactory);
|
||||||
TKUnit.waitUntilReady(() => { return label1.isLoaded && label2.isLoaded });
|
TKUnit.waitUntilReady(() => { return label1.isLoaded && label2.isLoaded });
|
||||||
|
|
||||||
// <snippet module="ui/animation" title="animation">
|
// >> animation-multiple-views
|
||||||
// # Animating multiple views simultaneously
|
|
||||||
// ``` JavaScript
|
|
||||||
var animations: Array<animation.AnimationDefinition> = [
|
var animations: Array<animation.AnimationDefinition> = [
|
||||||
{ target: label1, translate: { x: 200, y: 200 }, duration: 1000, delay: 0 },
|
{ target: label1, translate: { x: 200, y: 200 }, duration: 1000, delay: 0 },
|
||||||
{ target: label2, translate: { x: 200, y: 200 }, duration: 1000, delay: 333 },
|
{ target: label2, translate: { x: 200, y: 200 }, duration: 1000, delay: 333 },
|
||||||
@ -272,21 +251,20 @@ export var test_AnimatingMultipleViews = function(done) {
|
|||||||
a.play()
|
a.play()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
////console.log("Animations finished");
|
////console.log("Animations finished");
|
||||||
// <hide>
|
// >> (hide)
|
||||||
assertIOSNativeTransformIsCorrect(label1);
|
assertIOSNativeTransformIsCorrect(label1);
|
||||||
assertIOSNativeTransformIsCorrect(label2);
|
assertIOSNativeTransformIsCorrect(label2);
|
||||||
assertIOSNativeTransformIsCorrect(label3);
|
assertIOSNativeTransformIsCorrect(label3);
|
||||||
done();
|
done();
|
||||||
// </hide>
|
// << (hide)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
// <hide>
|
// >> (hide)
|
||||||
done(e);
|
done(e);
|
||||||
// </hide>
|
// << (hide)
|
||||||
});
|
});
|
||||||
// ```
|
// << animation-multiple-views
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_AnimateOpacity = function(done) {
|
export var test_AnimateOpacity = function(done) {
|
||||||
|
23
apps/tests/ui/animation/animation.md
Normal file
23
apps/tests/ui/animation/animation.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
nav-title: "animation How-To"
|
||||||
|
title: "How-To"
|
||||||
|
description: "Examples for using animation"
|
||||||
|
---
|
||||||
|
# Animation
|
||||||
|
Animating view properties requires the "ui/animation" module.
|
||||||
|
<snippet id='animation-require'/>
|
||||||
|
|
||||||
|
# Animating properties
|
||||||
|
<snippet id='animation-properties'/>
|
||||||
|
|
||||||
|
# Cancelling animation
|
||||||
|
<snippet id='animation-cancel'/>
|
||||||
|
|
||||||
|
# Chaining animations
|
||||||
|
<snippet id='animation-chaining'/>
|
||||||
|
|
||||||
|
# Reusing animations
|
||||||
|
<snippet id='animation-reusing'/>
|
||||||
|
|
||||||
|
# Animating multiple views simultaneously
|
||||||
|
<snippet id='animation-multiple-views'/>
|
@ -1,16 +1,3 @@
|
|||||||
// <snippet module="ui/border" title="Border">
|
// >> border-require
|
||||||
// # Border
|
var borderModule = require("ui/border");
|
||||||
// Using borders requires the "ui/border" module.
|
// << border-require
|
||||||
// ``` JavaScript
|
|
||||||
// var borderModule = require("ui/border");
|
|
||||||
// ```
|
|
||||||
|
|
||||||
// ### Declaring a Border.
|
|
||||||
//``` XML
|
|
||||||
// <Page>
|
|
||||||
// <Border borderRadius="10" borderWidth="1" borderColor="#FF0000">
|
|
||||||
// <Button text="OK"/>
|
|
||||||
// </Border>
|
|
||||||
// </Page>
|
|
||||||
//```
|
|
||||||
// </snippet>
|
|
||||||
|
17
apps/tests/ui/border/border.md
Normal file
17
apps/tests/ui/border/border.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
nav-title: "Border How-To"
|
||||||
|
title: "How-To"
|
||||||
|
description: "Examples for using Border"
|
||||||
|
---
|
||||||
|
# Border
|
||||||
|
Using borders requires the "ui/border" module.
|
||||||
|
<snippet id='border-require'/>
|
||||||
|
|
||||||
|
### Declaring a Border.
|
||||||
|
``` XML
|
||||||
|
<Page>
|
||||||
|
<Border borderRadius="10" borderWidth="2" borderColor="#FF0000">
|
||||||
|
<Button text="OK"/>
|
||||||
|
</Border>
|
||||||
|
</Page>
|
||||||
|
```
|
@ -8,28 +8,14 @@ import enums = require("ui/enums");
|
|||||||
import formattedStringModule = require("text/formatted-string");
|
import formattedStringModule = require("text/formatted-string");
|
||||||
import spanModule = require("text/span");
|
import spanModule = require("text/span");
|
||||||
|
|
||||||
// <snippet module="ui/button" title="button">
|
// >> button-require
|
||||||
// # Button
|
|
||||||
// ### Declaring button module
|
|
||||||
// Button module is required to use any button feature.
|
|
||||||
// ``` JavaScript
|
|
||||||
import buttonModule = require("ui/button");
|
import buttonModule = require("ui/button");
|
||||||
// ```
|
// << button-require
|
||||||
|
|
||||||
// Other frequently used modules when working with buttons include:
|
// >> button-require-others
|
||||||
// ``` JavaScript
|
|
||||||
import bindable = require("ui/core/bindable");
|
import bindable = require("ui/core/bindable");
|
||||||
import observable = require("data/observable");
|
import observable = require("data/observable");
|
||||||
// ```
|
// << button-require-others
|
||||||
|
|
||||||
// ### Attaching event handler for the button tap event.
|
|
||||||
//``` XML
|
|
||||||
// <Page>
|
|
||||||
// <Button tap="buttonTap" />
|
|
||||||
// </Page>
|
|
||||||
//```
|
|
||||||
|
|
||||||
// </snippet>
|
|
||||||
|
|
||||||
export var testSetText = function () {
|
export var testSetText = function () {
|
||||||
helper.buildUIAndRunTest(_createButtonFunc(), _testSetText);
|
helper.buildUIAndRunTest(_createButtonFunc(), _testSetText);
|
||||||
@ -90,24 +76,18 @@ export var testMemoryLeak = function (done) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _createButtonFunc = function (): buttonModule.Button {
|
var _createButtonFunc = function (): buttonModule.Button {
|
||||||
// <snippet module="ui/button" title="button">
|
// >>button-create
|
||||||
// ### Creating a button
|
|
||||||
// ``` JavaScript
|
|
||||||
var button = new buttonModule.Button();
|
var button = new buttonModule.Button();
|
||||||
// ```
|
// << button-create
|
||||||
// </snippet>
|
|
||||||
button.text = "Button";
|
button.text = "Button";
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _testSetText = function (views: Array<viewModule.View>) {
|
var _testSetText = function (views: Array<viewModule.View>) {
|
||||||
var button = <buttonModule.Button>views[0];
|
var button = <buttonModule.Button>views[0];
|
||||||
// <snippet module="ui/button" title="button">
|
// >> button-settext
|
||||||
// ### Setting the text of a button
|
|
||||||
// ``` JavaScript
|
|
||||||
button.text = "Hello, world!";
|
button.text = "Hello, world!";
|
||||||
// ```
|
// << button-settext
|
||||||
// </snippet>
|
|
||||||
|
|
||||||
var expectedValue = button.text;
|
var expectedValue = button.text;
|
||||||
var actualValue = buttonTestsNative.getNativeText(button);
|
var actualValue = buttonTestsNative.getNativeText(button);
|
||||||
@ -119,17 +99,14 @@ var _testOnClick = function (views: Array<viewModule.View>) {
|
|||||||
var button = <buttonModule.Button>views[0];
|
var button = <buttonModule.Button>views[0];
|
||||||
|
|
||||||
var actualValue = false;
|
var actualValue = false;
|
||||||
// <snippet module="ui/button" title="button">
|
// >> button-tap
|
||||||
// ### Responding to the tap event
|
|
||||||
// ``` JavaScript
|
|
||||||
button.on(buttonModule.Button.tapEvent, function (args: observable.EventData) {
|
button.on(buttonModule.Button.tapEvent, function (args: observable.EventData) {
|
||||||
//// Do something
|
//// Do something
|
||||||
// <hide>
|
// >> (hide)
|
||||||
actualValue = true;
|
actualValue = true;
|
||||||
// </hide>
|
// << (hide)
|
||||||
});
|
});
|
||||||
// ```
|
// << button-tap
|
||||||
// </snippet>
|
|
||||||
|
|
||||||
buttonTestsNative.performNativeClick(button);
|
buttonTestsNative.performNativeClick(button);
|
||||||
TKUnit.assert(actualValue === true, "Actual: " + actualValue + "; Expected: " + true);
|
TKUnit.assert(actualValue === true, "Actual: " + actualValue + "; Expected: " + true);
|
||||||
@ -138,9 +115,7 @@ var _testOnClick = function (views: Array<viewModule.View>) {
|
|||||||
var _testBindTextDirectlyToModel = function (views: Array<viewModule.View>) {
|
var _testBindTextDirectlyToModel = function (views: Array<viewModule.View>) {
|
||||||
var button = <buttonModule.Button>views[0];
|
var button = <buttonModule.Button>views[0];
|
||||||
|
|
||||||
// <snippet module="ui/button" title="button">
|
// >> button-bind
|
||||||
// ### Binding text property directly to model
|
|
||||||
// ``` JavaScript
|
|
||||||
var model = new observable.Observable();
|
var model = new observable.Observable();
|
||||||
model.set("buttonTitle", "OK");
|
model.set("buttonTitle", "OK");
|
||||||
var options: bindable.BindingOptions = {
|
var options: bindable.BindingOptions = {
|
||||||
@ -149,16 +124,15 @@ var _testBindTextDirectlyToModel = function (views: Array<viewModule.View>) {
|
|||||||
}
|
}
|
||||||
button.bind(options, model);
|
button.bind(options, model);
|
||||||
//// button.text is now "OK"
|
//// button.text is now "OK"
|
||||||
// <hide>
|
// >> (hide)
|
||||||
TKUnit.assert(button.text === "OK", "Actual: " + button.text + "; Expected: " + "OK");
|
TKUnit.assert(button.text === "OK", "Actual: " + button.text + "; Expected: " + "OK");
|
||||||
// </hide>
|
// << (hide)
|
||||||
model.set("buttonTitle", "Cancel");
|
model.set("buttonTitle", "Cancel");
|
||||||
//// button.text is now "Cancel"
|
//// button.text is now "Cancel"
|
||||||
// <hide>
|
// >> (hide)
|
||||||
TKUnit.assert(button.text === "Cancel", "Actual: " + button.text + "; Expected: " + "Cancel");
|
TKUnit.assert(button.text === "Cancel", "Actual: " + button.text + "; Expected: " + "Cancel");
|
||||||
// </hide>
|
// << (hide)
|
||||||
// ```
|
// << button-bind
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _testBindTextToBindingContext = function (views: Array<viewModule.View>) {
|
var _testBindTextToBindingContext = function (views: Array<viewModule.View>) {
|
||||||
|
30
apps/tests/ui/button/button.md
Normal file
30
apps/tests/ui/button/button.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
nav-title: "button How-To"
|
||||||
|
title: "How-To"
|
||||||
|
description: "Examples for using button"
|
||||||
|
---
|
||||||
|
# Button
|
||||||
|
### Declaring button module
|
||||||
|
Button module is required to use any button feature.
|
||||||
|
<snippet id='button-require'/>
|
||||||
|
|
||||||
|
Other frequently used modules when working with buttons include:
|
||||||
|
<snippet id='button-require-others'/>
|
||||||
|
|
||||||
|
### Attaching event handler for the button tap event.
|
||||||
|
``` XML
|
||||||
|
<Page>
|
||||||
|
<Button tap="buttonTap" />
|
||||||
|
</Page>
|
||||||
|
```
|
||||||
|
### Creating a button
|
||||||
|
<snippet id='button-create'/>
|
||||||
|
|
||||||
|
### Setting the text of a button
|
||||||
|
<snippet id='button-settext'/>
|
||||||
|
|
||||||
|
### Responding to the tap event
|
||||||
|
<snippet id='button-tap'/>
|
||||||
|
|
||||||
|
### Binding text property directly to model
|
||||||
|
<snippet id='button-bind'/>
|
@ -4,13 +4,9 @@ import datePickerTestsNative = require("./date-picker-tests-native");
|
|||||||
import color = require("color");
|
import color = require("color");
|
||||||
import platform = require("platform");
|
import platform = require("platform");
|
||||||
|
|
||||||
// <snippet module="ui/date-picker" title="DatePicker">
|
// >> date-picker-require
|
||||||
// # DatePicker
|
|
||||||
// Using a DatePicker requires the "ui/date-picker" module.
|
|
||||||
// ``` JavaScript
|
|
||||||
import datePickerModule = require("ui/date-picker");
|
import datePickerModule = require("ui/date-picker");
|
||||||
// ```
|
// << date-picker-require
|
||||||
// </snippet>
|
|
||||||
|
|
||||||
function assertDate(datePicker: datePickerModule.DatePicker, expectedYear: number, expectedMonth: number, expectedDay: number) {
|
function assertDate(datePicker: datePickerModule.DatePicker, expectedYear: number, expectedMonth: number, expectedDay: number) {
|
||||||
TKUnit.assertEqual(datePicker.year, expectedYear, "datePicker.year");
|
TKUnit.assertEqual(datePicker.year, expectedYear, "datePicker.year");
|
||||||
@ -62,16 +58,13 @@ export class DatePickerTest extends testModule.UITest<datePickerModule.DatePicke
|
|||||||
|
|
||||||
public test_DummyForCodeSnippet() {
|
public test_DummyForCodeSnippet() {
|
||||||
let datePicker = new datePickerModule.DatePicker();
|
let datePicker = new datePickerModule.DatePicker();
|
||||||
// <snippet module="ui/date-picker" title="DatePicker">
|
// >> date-picker-configure
|
||||||
// ## Configuring a DatePicker
|
|
||||||
// ``` JavaScript
|
|
||||||
datePicker.year = 1980;
|
datePicker.year = 1980;
|
||||||
datePicker.month = 2;
|
datePicker.month = 2;
|
||||||
datePicker.day = 9;
|
datePicker.day = 9;
|
||||||
datePicker.minDate = new Date(1975, 0, 29);
|
datePicker.minDate = new Date(1975, 0, 29);
|
||||||
datePicker.maxDate = new Date(2045, 4, 12);
|
datePicker.maxDate = new Date(2045, 4, 12);
|
||||||
// ```
|
// << date-picker-configure
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public test_set_color() {
|
public test_set_color() {
|
||||||
|
11
apps/tests/ui/date-picker/date-picker.md
Normal file
11
apps/tests/ui/date-picker/date-picker.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
nav-title: "DatePicker How-To"
|
||||||
|
title: "How-To"
|
||||||
|
description: "Examples for using DatePicker"
|
||||||
|
---
|
||||||
|
# DatePicker
|
||||||
|
Using a DatePicker requires the "ui/date-picker" module.
|
||||||
|
<snippet id='date-picker-require'/>
|
||||||
|
|
||||||
|
## Configuring a DatePicker
|
||||||
|
<snippet id='date-picker-configure'/>
|
@ -1,15 +1,9 @@
|
|||||||
// <snippet module="ui/dialogs" title="dialogs">
|
// >> dialog-require
|
||||||
// # Dialogs
|
|
||||||
// Displaying dialogs requires the "ui/dialogs" module.
|
|
||||||
// ``` JavaScript
|
|
||||||
import dialogs = require("ui/dialogs");
|
import dialogs = require("ui/dialogs");
|
||||||
// ```
|
// << dialog-require
|
||||||
// </snippet>
|
|
||||||
|
|
||||||
export function test_DummyTestForSnippetOnly0() {
|
export function test_DummyTestForSnippetOnly0() {
|
||||||
// <snippet module="ui/dialogs" title="dialogs">
|
// >> dialog-action
|
||||||
// ### Action
|
|
||||||
// ``` JavaScript
|
|
||||||
var options = {
|
var options = {
|
||||||
title: "Race Selection",
|
title: "Race Selection",
|
||||||
message: "Choose your race",
|
message: "Choose your race",
|
||||||
@ -19,14 +13,11 @@ export function test_DummyTestForSnippetOnly0() {
|
|||||||
dialogs.action(options).then((result) => {
|
dialogs.action(options).then((result) => {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
});
|
});
|
||||||
// ```
|
// << dialog-action
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_DummyTestForSnippetOnly1() {
|
export function test_DummyTestForSnippetOnly1() {
|
||||||
// <snippet module="ui/dialogs" title="dialogs">
|
// >> dialog-confirm
|
||||||
// ### Confirm
|
|
||||||
// ``` JavaScript
|
|
||||||
var options = {
|
var options = {
|
||||||
title: "Race Selection",
|
title: "Race Selection",
|
||||||
message: "Are you sure you want to be an Elf?",
|
message: "Are you sure you want to be an Elf?",
|
||||||
@ -38,14 +29,11 @@ export function test_DummyTestForSnippetOnly1() {
|
|||||||
//// result can be true/false/undefined
|
//// result can be true/false/undefined
|
||||||
console.log(result);
|
console.log(result);
|
||||||
});
|
});
|
||||||
// ```
|
// << dialog-confirm
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_DummyTestForSnippetOnly2() {
|
export function test_DummyTestForSnippetOnly2() {
|
||||||
// <snippet module="ui/dialogs" title="dialogs">
|
// >> dialog-alert
|
||||||
// ### Alert
|
|
||||||
// ``` JavaScript
|
|
||||||
var options = {
|
var options = {
|
||||||
title: "Race Selection",
|
title: "Race Selection",
|
||||||
message: "Race Chosen: Elf",
|
message: "Race Chosen: Elf",
|
||||||
@ -54,14 +42,11 @@ export function test_DummyTestForSnippetOnly2() {
|
|||||||
dialogs.alert(options).then(() => {
|
dialogs.alert(options).then(() => {
|
||||||
console.log("Race Chosen!");
|
console.log("Race Chosen!");
|
||||||
});
|
});
|
||||||
// ```
|
// << dialog-alert
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_DummyTestForSnippetOnly3() {
|
export function test_DummyTestForSnippetOnly3() {
|
||||||
// <snippet module="ui/dialogs" title="dialogs">
|
// >> dialog-login
|
||||||
// ### Login
|
|
||||||
// ``` JavaScript
|
|
||||||
var options = {
|
var options = {
|
||||||
title: "Login",
|
title: "Login",
|
||||||
message: "Login",
|
message: "Login",
|
||||||
@ -72,14 +57,11 @@ export function test_DummyTestForSnippetOnly3() {
|
|||||||
//// true or false.
|
//// true or false.
|
||||||
console.log(loginResult.result);
|
console.log(loginResult.result);
|
||||||
});
|
});
|
||||||
// ```
|
// << dialog-login
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function test_DummyTestForSnippetOnly4() {
|
export function test_DummyTestForSnippetOnly4() {
|
||||||
// <snippet module="ui/dialogs" title="dialogs">
|
// >> dialog-prompt
|
||||||
// ### Prompt
|
|
||||||
// ``` JavaScript
|
|
||||||
var options = {
|
var options = {
|
||||||
title: "Name",
|
title: "Name",
|
||||||
defaultText: "Enter your name",
|
defaultText: "Enter your name",
|
||||||
@ -88,6 +70,5 @@ export function test_DummyTestForSnippetOnly4() {
|
|||||||
dialogs.prompt(options).then((result: dialogs.PromptResult) => {
|
dialogs.prompt(options).then((result: dialogs.PromptResult) => {
|
||||||
console.log("Hello, " + result.text);
|
console.log("Hello, " + result.text);
|
||||||
});
|
});
|
||||||
// ```
|
// << dialog-prompt
|
||||||
// </snippet>
|
|
||||||
}
|
}
|
23
apps/tests/ui/dialogs/dialog.md
Normal file
23
apps/tests/ui/dialogs/dialog.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
nav-title: "dialogs How-To"
|
||||||
|
title: "How-To"
|
||||||
|
description: "Examples for using dialogs"
|
||||||
|
---
|
||||||
|
# Dialogs
|
||||||
|
Displaying dialogs requires the "ui/dialogs" module.
|
||||||
|
<snippet id='dialog-require'/>
|
||||||
|
|
||||||
|
### Action
|
||||||
|
<snippet id='dialog-action'/>
|
||||||
|
|
||||||
|
### Confirm
|
||||||
|
<snippet id='dialog-confirm'/>
|
||||||
|
|
||||||
|
### Alert
|
||||||
|
<snippet id='dialog-alert'/>
|
||||||
|
|
||||||
|
### Login
|
||||||
|
<snippet id='dialog-login'/>
|
||||||
|
|
||||||
|
### Prompt
|
||||||
|
<snippet id='dialog-prompt'/>
|
Reference in New Issue
Block a user