Merge pull request #1079 from NativeScript/white-space

white-space CSS support added
This commit is contained in:
Vladimir Enchev
2015-11-12 15:39:32 +02:00
23 changed files with 321 additions and 78 deletions

View File

@@ -1,17 +1,18 @@
var obj;
export function loaded(args) {
obj = args.object;
}
import view = require("ui/core/view");
import observable = require("data/observable");
import label = require("ui/label");
export function butonTap(args) {
if (obj.style.textDecoration === "underline") {
obj.style.textDecoration = "line-through";
} else if (obj.style.textDecoration === "line-through") {
obj.style.textDecoration = "line-through underline";
} else if (obj.style.textDecoration === "line-through underline") {
obj.style.textDecoration = "none";
} else if (obj.style.textDecoration === "none") {
obj.style.textDecoration = "underline";
var btn = <view.View>args.object;
var lbl = <label.Label>btn.parent.getViewById("Label1");
if (lbl.style.textDecoration === "underline") {
lbl.style.textDecoration = "line-through";
} else if (lbl.style.textDecoration === "line-through") {
lbl.style.textDecoration = "line-through underline";
} else if (lbl.style.textDecoration === "line-through underline") {
lbl.style.textDecoration = "none";
} else if (lbl.style.textDecoration === "none") {
lbl.style.textDecoration = "underline";
}
}

View File

@@ -2,7 +2,7 @@
<ScrollView>
<StackLayout>
<Button text="Change" tap="butonTap" />
<Label text="Text" style.textDecoration="underline" loaded="loaded"/>
<Label id="Label1" text="Text" style.textDecoration="underline" />
<Label text="Label" style="text-decoration:none" />
<Label text="Label" style="text-decoration:underline" />

View File

@@ -0,0 +1,14 @@
import view = require("ui/core/view");
import observable = require("data/observable");
import label = require("ui/label");
export function butonTap(args: observable.EventData) {
var btn = <view.View>args.object;
var lbl = <label.Label>btn.parent.getViewById("Label1");
if (lbl.style.whiteSpace === "normal") {
lbl.style.whiteSpace = "nowrap";
} else if (lbl.style.whiteSpace === "nowrap") {
lbl.style.whiteSpace = "normal";
}
}

View File

@@ -0,0 +1,20 @@
<Page >
<ScrollView>
<StackLayout width="50">
<Button text="Change" tap="butonTap" />
<Label id="Label1" text="Text Text" style.whiteSpace="normal" />
<Label text="Label Normal" style="white-space:normal" />
<Label text="Label Nowrap" style="white-space:nowrap" />
<TextField text="TextField Normal" style="white-space:normal" />
<TextField text="TextField Nowrap" style="white-space:nowrap" />
<TextView text="TextView Normal" style="white-space:normal" />
<TextView text="TextView Nowrap" style="white-space:nowrap" />
<Button text="Button Normal" style="white-space:normal" />
<Button text="Button Nowrap" style="white-space:nowrap" />
</StackLayout>
</ScrollView>
</Page>

View File

@@ -90,4 +90,6 @@ examples.set("webview", "web-view/web-view");
examples.set("webtest", "web-view/web-view-test");
examples.set("decoration", "css/text-decoration");
examples.set("whitespace", "css/white-space");
//VM.set("selected", "tabAll");