diff --git a/apps/tests/gestures-tests.ts b/apps/tests/gestures-tests.ts index 47ccd6be0..c8639856d 100644 --- a/apps/tests/gestures-tests.ts +++ b/apps/tests/gestures-tests.ts @@ -1,226 +1,168 @@ /* tslint:disable:no-unused-variable */ -// -// # Gestures -// Detecting user gestures requires the "ui/gestures" module. -// ``` JavaScript +// >> gestures-require import gestures = require("ui/gestures"); -// ``` -// +// << gestures-require import labelModule = require("ui/label"); export var test_DummyTestForSnippetOnly0 = function () { - // - // ### Double Tap - // ``` JavaScript + // >> gestures-double-tap var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.doubleTap, function (args: gestures.GestureEventData) { console.log("Double Tap"); }); - // ``` - // + // << gestures-double-tap } export var test_DummyTestForSnippetOnly01 = function () { - // - // ### Double Tap - // ``` JavaScript + // >> gestures-double-tap-alt var label = new labelModule.Label(); var observer = label.on("doubleTap", function (args: gestures.GestureEventData) { console.log("Double Tap"); }); - // ``` - // + // << gestures-double-tap-alt } export var test_DummyTestForSnippetOnly1 = function () { - // - // ### Long Press - // ``` JavaScript + // >> gestures-long-press var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.longPress, function (args: gestures.GestureEventData) { console.log("Long Press"); }); - // ``` - // + // << gestures-long-press } export var test_DummyTestForSnippetOnly11 = function () { - // - // ### Long Press - // ``` JavaScript + // >> gestures-long-press-alt var label = new labelModule.Label(); var observer = label.on("longPress", function (args: gestures.GestureEventData) { console.log("Long Press"); }); - // ``` - // + // << gestures-long-press-alt } export var test_DummyTestForSnippetOnly2 = function () { - // - // ### Pan - // ``` JavaScript + // >> gestures-pan var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.pan, function (args: gestures.PanGestureEventData) { console.log("Pan deltaX:" + args.deltaX + "; deltaY:" + args.deltaY + ";"); }); - // ``` - // + // << gestures-pan } export var test_DummyTestForSnippetOnly22 = function () { - // - // ### Pan - // ``` JavaScript + // >> gestures-pan-alt var label = new labelModule.Label(); var observer = label.on("pan", function (args: gestures.PanGestureEventData) { console.log("Pan deltaX:" + args.deltaX + "; deltaY:" + args.deltaY + ";"); }); - // ``` - // + // << gestures-pan-alt } export var test_DummyTestForSnippetOnly3 = function () { - // - // ### Pinch - // ``` JavaScript + // >> gestures-pan-pinch var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.pinch, function (args: gestures.PinchGestureEventData) { console.log("Pinch scale: " + args.scale); }); - // ``` - // + // << gestures-pan-pinch } export var test_DummyTestForSnippetOnly33 = function () { - // - // ### Pinch - // ``` JavaScript + // >> gestures-pan-pinch-alt var label = new labelModule.Label(); var observer = label.on("pinch", function (args: gestures.PinchGestureEventData) { console.log("Pinch scale: " + args.scale); }); - // ``` - // + // << gestures-pan-pinch-alt } export var test_DummyTestForSnippetOnly4 = function () { - // - // ### Rotation - // ``` JavaScript + // >> gestures-rotation var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.rotation, function (args: gestures.RotationGestureEventData) { console.log("Rotation: " + args.rotation); }); - // ``` - // + // << gestures-rotation } export var test_DummyTestForSnippetOnly44 = function () { - // - // ### Rotation - // ``` JavaScript + // >> gestures-rotation-alt var label = new labelModule.Label(); var observer = label.on("rotation", function (args: gestures.RotationGestureEventData) { console.log("Rotation: " + args.rotation); }); - // ``` - // + // << gestures-rotation-alt } export var test_DummyTestForSnippetOnly5 = function () { - // - // ### Swipe - // ``` JavaScript + // >> gestures-swipe var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.swipe, function (args: gestures.SwipeGestureEventData) { console.log("Swipe direction: " + args.direction); }); - // ``` - // + // << gestures-swipe } export var test_DummyTestForSnippetOnly55 = function () { - // - // ### Swipe - // ``` JavaScript + // >> gestures-swipe-alt var label = new labelModule.Label(); var observer = label.on("swipe", function (args: gestures.SwipeGestureEventData) { console.log("Swipe direction: " + args.direction); }); - // ``` - // + // << gestures-swipe-alt } export var test_DummyTestForSnippetOnly6 = function () { - // - // ### Tap - // ``` JavaScript + // >> gestures-tap var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.tap, function (args: gestures.GestureEventData) { console.log("Tap"); }); - // ``` - // + // << gestures-tap } export var test_DummyTestForSnippetOnly66 = function () { - // - // ### Tap - // ``` JavaScript + // >> gestures-tap-alt var label = new labelModule.Label(); var observer = label.on("tap", function (args: gestures.GestureEventData) { console.log("Tap"); }); - // ``` - // + // << gestures-tap-alt } export var test_DummyTestForSnippetOnly7 = function () { - // - // ### Stop observing - // ``` JavaScript + // >> gestures-stop-observe var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.tap, function (args: gestures.GestureEventData) { console.log("Tap"); }); observer.disconnect(); - // ``` - // + // << gestures-stop-observe } export var test_DummyTestForSnippetOnly8 = function () { - // - // ### Multiple gestures - // ``` JavaScript + // >> gestures-multiple var label = new labelModule.Label(); var observer = label.on(gestures.GestureTypes.tap | gestures.GestureTypes.doubleTap | gestures.GestureTypes.longPress, function (args: gestures.GestureEventData) { console.log("Event: " + args.eventName); }); - // ``` - // + // << gestures-multiple } export var test_DummyTestForSnippetOnly88 = function () { - // - // ### Multiple gestures as comma separated string - // ``` JavaScript + // >> gestures-string var label = new labelModule.Label(); var observer = label.on("tap, doubleTap, longPress", function (args: gestures.GestureEventData) { console.log("Event: " + args.eventName); }); - // ``` - // + // << gestures-string } export var test_DummyTestForSnippetOnly9 = function () { - // - // ### Events combined with gestures as comma separated string - // ``` JavaScript + // >> gestures-events-string var label = new labelModule.Label(); var observer = label.on("loaded, tap, longPress", function (args: gestures.GestureEventData) { console.log("Event: " + args.eventName); }); - // ``` - // + // << gestures-events-string } \ No newline at end of file diff --git a/apps/tests/gestures.md b/apps/tests/gestures.md new file mode 100644 index 000000000..205604b38 --- /dev/null +++ b/apps/tests/gestures.md @@ -0,0 +1,62 @@ +--- +nav-title: "gestures How-To" +title: "How-To" +description: "Examples for using gestures" +--- +# Gestures +Detecting user gestures requires the "ui/gestures" module. + + +### Double Tap + + +### Double Tap + + +### Long Press + + +### Long Press + + +### Pan + + +### Pan + + +### Pinch + + +### Pinch + + +### Rotation + + +### Rotation + + +### Swipe + + +### Swipe + + +### Tap + + +### Tap + + +### Stop observing + + +### Multiple gestures + + +### Multiple gestures as comma separated string + + +### Events combined with gestures as comma separated string + diff --git a/apps/tests/ui/html-view/htm-view.md b/apps/tests/ui/html-view/htm-view.md new file mode 100644 index 000000000..937a7b177 --- /dev/null +++ b/apps/tests/ui/html-view/htm-view.md @@ -0,0 +1,20 @@ +--- +nav-title: "HtmlView How-To" +title: "How-To" +description: "Examples for using HtmlView" +--- +# HtmlView +Using a HtmlView requires the html-view module. + + +### Declaring a HtmlView. +``` XML + + {%raw%}{%endraw%} + +``` +### Creating a HtmlView + + +### Using HtmlView + diff --git a/apps/tests/ui/html-view/html-view-tests.ts b/apps/tests/ui/html-view/html-view-tests.ts index a0fd6dfe7..bb0b47c0a 100644 --- a/apps/tests/ui/html-view/html-view-tests.ts +++ b/apps/tests/ui/html-view/html-view-tests.ts @@ -2,31 +2,14 @@ import helper = require("../helper"); import types = require("utils/types"); -// -// # HtmlView -// Using a HtmlView requires the html-view module. -// ``` JavaScript +// >> htmlview-require import htmlViewModule = require("ui/html-view"); -// ``` -// - -// -// ### Declaring a HtmlView. -//``` XML -// -// {%raw%}{%endraw%} -// -//``` - -//  +// << htmlview-require var _createHtmlViewFunc = function (): htmlViewModule.HtmlView { - // - // ### Creating a HtmlView - // ``` JavaScript + // >> htmlview-create var htmlView = new htmlViewModule.HtmlView(); - // ``` - // + // << htmlview-create return htmlView; } @@ -35,12 +18,9 @@ export var testLoadHTMLString = function () { let htmlView = _createHtmlViewFunc(); page.content = htmlView; - // - // ### Using HtmlView - // ``` JavaScript + // >> htmlview-using htmlView.html = 'Test'; - // ``` - // + // << htmlview-using if (htmlView.ios) { TKUnit.assert(!types.isNullOrUndefined(htmlView.ios.attributedText), "HTML string not loaded properly. Actual: " + htmlView.ios.attributedText); diff --git a/apps/tests/ui/image-cache/image-cache-tests.ts b/apps/tests/ui/image-cache/image-cache-tests.ts index faa239d70..914f0059b 100644 --- a/apps/tests/ui/image-cache/image-cache-tests.ts +++ b/apps/tests/ui/image-cache/image-cache-tests.ts @@ -1,17 +1,11 @@ -//  -// # ImageCache -// Using the ImageCache requires the "ui/image-cache" module. -// ``` JavaScript +// >> image-cache-require import imageCacheModule = require("ui/image-cache"); import imageSource = require("image-source"); import fs = require("file-system"); -// ``` -// +// << image-cache-require export function test_DummyTestForSnippetOnly() { - // - // ### Requesting Images - // ``` JavaScript + // >> image-cache-request-images var cache = new imageCacheModule.Cache(); cache.placeholder = imageSource.fromFile(fs.path.join(__dirname, "res/no-image.png")); cache.maxRequests = 5; @@ -42,6 +36,5 @@ export function test_DummyTestForSnippetOnly() { //// Disable download while scrolling cache.disableDownload(); - // ``` - // + // << image-cache-request-images } \ No newline at end of file diff --git a/apps/tests/ui/image-cache/image-cache.md b/apps/tests/ui/image-cache/image-cache.md new file mode 100644 index 000000000..fc8d99f10 --- /dev/null +++ b/apps/tests/ui/image-cache/image-cache.md @@ -0,0 +1,11 @@ +--- +nav-title: "image-cache How-To" +title: "How-To" +description: "Examples for using image-cache" +--- +# ImageCache +Using the ImageCache requires the "ui/image-cache" module. + + +### Requesting Images + diff --git a/apps/tests/ui/image/image-tests.ts b/apps/tests/ui/image/image-tests.ts index 69e12e512..0817f652a 100644 --- a/apps/tests/ui/image/image-tests.ts +++ b/apps/tests/ui/image/image-tests.ts @@ -1,28 +1,7 @@ import TKUnit = require("../../TKUnit"); -// -// # Image -// Using an image requires the Image module to be loaded. -// ``` JavaScript +// >> img-require import ImageModule = require("ui/image"); -// ``` - -// Binding the image source property to a view-model property. -//``` XML -// -// -// -// {%raw%}{%endraw%} -// -// -// -// -// -// -// -// -//``` - -// +// << img-require import types = require("utils/types"); import ImageSourceModule = require("image-source"); @@ -43,13 +22,10 @@ export var test_Image_Members = function () { /* TODO: We need a way to programmatically add an image to resources and then load it from, otherwise we do not know if there is such resource in the target native app. export var test_settingImageSource = function () { - // - // ### How to create an image and set its source. - // ``` JavaScript + // >> img-create var image = new ImageModule.Image(); image.imageSource = ImageSourceModule.fromResource("logo"); - // ``` - // + // << img-create var testFunc = function (views: Array) { var testImage = views[0]; @@ -67,13 +43,10 @@ export var test_settingImageSource = function () { */ export var test_SettingImageSrc = function (done) { - // - // ### How to create an image and set its src. - // ``` JavaScript + // >> img-create-src var image = new ImageModule.Image(); image.src = "https://www.google.com/images/errors/logo_sm_2.png"; - // ``` - // + // << img-create-src image.src = null; @@ -108,13 +81,10 @@ export var test_SettingImageSrc = function (done) { } export var test_SettingImageSrcToFileWithinApp = function (done) { - // - // ### How to create an image and set its src to file within the application. - // ``` JavaScript + // >> img-create-local var image = new ImageModule.Image(); image.src = "~/logo.png"; - // ``` - // + // << img-create-local var testFunc = function (views: Array) { var testImage = views[0]; @@ -132,13 +102,10 @@ export var test_SettingImageSrcToFileWithinApp = function (done) { } export var test_SettingImageSrcToDataURI = function (done) { - // - // ### How to create an image and set its src to Data URI. - // ``` JavaScript + // >> img-create-datauri var image = new ImageModule.Image(); image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAAXNSR0IArs4c6QAAABxpRE9UAAAAAgAAAAAAAAACAAAAKAAAAAIAAAACAAAARiS4uJEAAAASSURBVBgZYvjPwABHSMz/DAAAAAD//0GWpK0AAAAOSURBVGNgYPiPhBgQAACEvQv1D5y/pAAAAABJRU5ErkJggg=="; - // ``` - // + // << img-create-datauri var testFunc = function (views: Array) { var testImage = views[0]; @@ -157,17 +124,14 @@ export var test_SettingImageSrcToDataURI = function (done) { } export var test_SettingStretch_AspectFit = function () { - // - // ### How to set image stretching. - // ``` JavaScript + // >> img-set-stretch var image = new ImageModule.Image(); image.imageSource = ImageSourceModule.fromFile(imagePath); //// There are 4 modes of stretching none, fill, aspectFill, aspectFit //// The default value is aspectFit. //// Image stretch can be set by using ImageModule.stretch enum. image.stretch = enumsModule.Stretch.aspectFit; - // ``` - // + // << img-set-stretch var testFunc = function (views: Array) { var testImage = views[0]; diff --git a/apps/tests/ui/image/image.md b/apps/tests/ui/image/image.md new file mode 100644 index 000000000..86d26500b --- /dev/null +++ b/apps/tests/ui/image/image.md @@ -0,0 +1,38 @@ +--- +nav-title: "Image How-To" +title: "How-To" +description: "Examples for using Image" +--- +# Image +Using an image requires the Image module to be loaded. + + +Binding the image source property to a view-model property. +``` XML + + + + {%raw%}{%endraw%} + + + + + + + + +``` +### How to create an image and set its source. + + +### How to create an image and set its src. + + +### How to create an image and set its src to file within the application. + + +### How to create an image and set its src to Data URI. + + +### How to set image stretching. + diff --git a/apps/tests/ui/label/label-tests.ts b/apps/tests/ui/label/label-tests.ts index fad074b18..4b17b708d 100644 --- a/apps/tests/ui/label/label-tests.ts +++ b/apps/tests/ui/label/label-tests.ts @@ -2,21 +2,10 @@ import testModule = require("../../ui-test"); import styling = require("ui/styling"); -// -// # Label -// Using a label requires the Label module. -// ``` JavaScript +//>> label-require import LabelModule = require("ui/label"); -// ``` +// << label-require -// ### Binding the Label text property to a view-model property. -//``` XML -// -// {%raw%} -//``` - -// import types = require("utils/types"); import colorModule = require("color"); import utils = require("utils/utils"); @@ -43,24 +32,18 @@ export class LabelTest extends testModule.UITest { } public snippet_Set_Text_TNS() { - // - // ### How to set label text content - // ``` JavaScript + // >> label-settext var label = new LabelModule.Label(); var expectedValue = "Expected Value"; label.text = expectedValue; - // ``` - // + // << label-settext } public snippet_Set_TextWrap_TNS() { - // - // ### How to turn on text wrapping for a label - // ``` JavaScript + // >> label-textwrap var label = new LabelModule.Label(); label.textWrap = true; - // ``` - // + // << label-textwrap } public test_Set_Text_TNS() { @@ -249,15 +232,12 @@ export class LabelTest extends testModule.UITest { "color: ", color, "; ", "font-size: ", fontSize, ";}"].join(""); - // - // ### How to style a label via css class - // ``` JavaScript + // >> label-cssclass label.text = "The quick brown fox jumps over the lazy dog."; label.className = "title"; //// after that all we have to do is to set a similar css entry within parent page css property //// label.parentPage.css = ".title {background-color: #C6C6C6; color: #10C2B0; font-size: 14;}"; - // ``` - // + // << label-cssclass var actualTextSize; var expSize; @@ -316,15 +296,12 @@ export class LabelTest extends testModule.UITest { this.testPage.css = testCss; this.waitUntilTestElementIsLoaded(); - // - // ### How to style a label via css type - // ``` JavaScript + // >> label-cssclass-type label.text = "The quick brown fox jumps over the lazy dog."; //// in order to style label with a "type style scope" just put a similar css entry //// testLabel.parentPage.css = "label {background-color: #C6C6C6; color: #10C2B0; font-size: 14;}"; //// all labels within the parent page will be styled according to css values - // ``` - // + // << label-cssclass-type var expectedBackgroundColor = new colorModule.Color(backgroundColor); var actualBackgroundColor = label.style.backgroundColor; TKUnit.assertEqual(expectedBackgroundColor.hex, actualBackgroundColor.hex); @@ -349,15 +326,12 @@ export class LabelTest extends testModule.UITest { this.testPage.css = testCss; this.waitUntilTestElementIsLoaded(); - // - // ### How to style a label via css control identifier - // ``` JavaScript + // >> label-css-identifier label.text = "The quick brown fox jumps over the lazy dog."; label.id = "testLabel"; //// after that all we have to do is to set a similar css entry within parent page css property //// label.parentPage.css = "#testLabel {background-color: #C6C6C6; color: #10C2B0; font-size: 14;}"; - // ``` - // + // << label-css-identifier var expectedBackgroundColor = new colorModule.Color(backgroundColor); var actualBackgroundColor = label.style.backgroundColor; @@ -372,9 +346,7 @@ export class LabelTest extends testModule.UITest { } public test_BindingToText() { - // - // ### How to bind text property of a label to an observable model - // ``` JavaScript + // >> label-observable var label = new LabelModule.Label(); var expValue = "Expected Value"; var sourceModel = new observableModule.Observable(); @@ -385,8 +357,7 @@ export class LabelTest extends testModule.UITest { label.bind(bindingOptions, sourceModel); sourceModel.set("sourceProperty", expValue); //// console.log(label.text); --> prints: "Expected Value" - // ``` - // + // << label-observable TKUnit.assertEqual(label.text, expValue); } diff --git a/apps/tests/ui/label/label.md b/apps/tests/ui/label/label.md new file mode 100644 index 000000000..a4f53b73a --- /dev/null +++ b/apps/tests/ui/label/label.md @@ -0,0 +1,32 @@ +--- +nav-title: "Label How-To" +title: "How-To" +description: "Examples for using Label" +--- +# Label +Using a label requires the Label module. + + +### Binding the Label text property to a view-model property. +``` XML + + {%raw%} +``` +### How to set label text content + + +### How to turn on text wrapping for a label + + +### How to style a label via css class + + +### How to style a label via css type + + +### How to style a label via css control identifier + + +### How to bind text property of a label to an observable model +