Class atribute registered and used instead cssClass

This commit is contained in:
Vladimir Enchev
2015-09-18 09:47:55 +03:00
parent 601dffcbab
commit 744de9670e
19 changed files with 63 additions and 58 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<Page.actionBar>
<ActionBar title="Title" cssClass="custom-action-bar">
<ActionBar title="Title" class="custom-action-bar">
<ActionBar.actionItems>
<ActionItem text="hi" />
</ActionBar.actionItems>

View File

@ -3,7 +3,7 @@
<ScrollView>
<StackLayout>
<Image imageSource="{{ imageSource }}" stretch="aspectFill"/>
<Label text="{{ title }}" cssClass="detailsTitle" textWrap="true" />
<Label text="{{ title }}" class="detailsTitle" textWrap="true" />
</StackLayout>
</ScrollView>
<StackLayout orientation="horizontal" row="1">

View File

@ -7,10 +7,10 @@
<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 src="{{ thumbnailImage }}" 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" />
<Image src="{{ thumbnailImage }}" class="thumbnail" rowSpan="2"/>
<Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" col="1" colSpan="2" minHeight="50" />
<Label text="{{ author ? 'by ' + author : '' }}" class="author" col="1" row="1" />
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" class="comments" col="2" row="1" />
</GridLayout>
<!-- End of tempplate. -->
</ListView.itemTemplate>

View File

@ -3,7 +3,7 @@
<ScrollView>
<StackLayout>
<Image imageSource="{{ imageSource }}" stretch="aspectFill"/>
<Label text="{{ title }}" cssClass="detailsTitle" textWrap="true" />
<Label text="{{ title }}" class="detailsTitle" textWrap="true" />
</StackLayout>
</ScrollView>
<StackLayout orientation="horizontal" row="1">

View File

@ -7,10 +7,10 @@
<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 src="{{ thumbnailImage }}" 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" />
<Image src="{{ thumbnailImage }}" class="thumbnail" rowSpan="2"/>
<Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" col="1" colSpan="2" minHeight="50" />
<Label text="{{ author ? 'by ' + author : '' }}" class="author" col="1" row="1" />
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" class="comments" col="2" row="1" />
</GridLayout>
<!-- End of tempplate. -->
</ListView.itemTemplate>

View File

@ -2,7 +2,7 @@
<Page>
<ScrollView>
<StackLayout>
<Label cssClass="title" text="Layouts" />
<Label class="title" text="Layouts" />
<StackLayout>
<Button tag="layouts/stack-layout" text="StackLayout" tap="itemTap" />
<Button tag="layouts/grid-layout" text="GridLayout" tap="itemTap" />
@ -11,7 +11,7 @@
<Button tag="layouts/absolute-layout" text="AbsoluteLayout" tap="itemTap" />
</StackLayout>
<Label cssClass="title" text="Content" />
<Label class="title" text="Content" />
<StackLayout>
<Button tag="content/tab-view" text="TabView" tap="itemTap" />
<Button tag="content/web-view" text="WebView" tap="itemTap" />
@ -20,7 +20,7 @@
<Button tag="content/border" text="Border" tap="itemTap" />
</StackLayout>
<Label cssClass="title" text="Views" />
<Label class="title" text="Views" />
<StackLayout>
<Button tag="views/button" text="Button" tap="itemTap" />
<Button tag="views/label" text="Label" tap="itemTap" />

View File

@ -2,10 +2,10 @@
<StackLayout>
<StackLayout verticalAlignment="center" horizontalAlignment="center" margin="50">
<Image loaded="imageLoaded" />
<TextField cssClass="nameField" text="Captain" margin="10" />
<TextField cssClass="familyNameField" text="America" margin="10" />
<TextField cssClass="passwordField" secure="true" hint="Password (leave empty)" margin="10" />
<Button cssClass="loginButton" text="Login" margin="10" tap="loginButtonTap" />
<TextField class="nameField" text="Captain" margin="10" />
<TextField class="familyNameField" text="America" margin="10" />
<TextField class="passwordField" secure="true" hint="Password (leave empty)" margin="10" />
<Button class="loginButton" text="Login" margin="10" tap="loginButtonTap" />
</StackLayout>
</StackLayout>
</Page>

View File

@ -1,7 +1,7 @@
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<StackLayout>
<Label text="Tap the button" cssClass="title"/>
<Label text="Tap the button" class="title"/>
<Button text="TAP" tap="{{ tapAction }}" />
<Label text="{{ message }}" cssClass="message" textWrap="true"/>
<Label text="{{ message }}" class="message" textWrap="true"/>
</StackLayout>
</Page>

View File

@ -1,4 +1,4 @@
<StackLayout xmlns="http://www.nativescript.org/tns.xsd">
<Label text="{{ title }}" cssClass="detail-title"/>
<Label text="{{ info }}" cssClass="info" textWrap="true"/>
<Label text="{{ title }}" class="detail-title"/>
<Label text="{{ info }}" class="info" textWrap="true"/>
</StackLayout>

View File

@ -2,11 +2,11 @@
xmlns:app="."
loaded="pageLoaded">
<GridLayout rows="auto, *" columns="300, *">
<Label text="Master Details Page" cssClass="title" colSpan="2" />
<Label text="Master Details Page" class="title" colSpan="2" />
<ListView items="{{ items }}" itemTap="listViewItemTap" row="1">
<ListView.itemTemplate>
<Label text="{{ title }}" cssClass="listItem" />
<Label text="{{ title }}" class="listItem" />
</ListView.itemTemplate>
</ListView>

View File

@ -1,11 +1,11 @@
<Page xmlns="http://www.nativescript.org/tns.xsd"
loaded="pageLoaded">
<GridLayout rows="auto, *">
<Label text="Items Page" cssClass="title" />
<Label text="Items Page" class="title" />
<ListView items="{{ items }}" itemTap="listViewItemTap" row="1">
<ListView.itemTemplate>
<Label text="{{ title }}" cssClass="listItem" />
<Label text="{{ title }}" class="listItem" />
</ListView.itemTemplate>
</ListView>
</GridLayout>

View File

@ -1,34 +1,34 @@
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<StackLayout cssClass="content">
<StackLayout class="content">
<!-- Profile sttings -->
<Label cssClass="header" text="Profile"/>
<GridLayout cssClass="field-group" columns="auto, 50, *" rows="auto, auto, auto">
<Label class="header" text="Profile"/>
<GridLayout class="field-group" columns="auto, 50, *" rows="auto, auto, auto">
<!-- Name -->
<Label cssClass="field" text="Name"/>
<Button cssClass="field-dialog-button" text="{{ name }}" tap="{{ promptName }}" col="1" colSpan="2"/>
<Label class="field" text="Name"/>
<Button class="field-dialog-button" text="{{ name }}" tap="{{ promptName }}" col="1" colSpan="2"/>
<!-- Height -->
<Label cssClass="field" text="Height" row="1"/>
<TextField cssClass="field-value" text="{{ height }}" keyboardType="number" row="1" col="1"/>
<Label cssClass="field-unit" text="cm" col="2" row="1"/>
<Label class="field" text="Height" row="1"/>
<TextField class="field-value" text="{{ height }}" keyboardType="number" row="1" col="1"/>
<Label class="field-unit" text="cm" col="2" row="1"/>
<!-- Weight -->
<Label cssClass="field" text="Weight" row="2"/>
<TextField cssClass="field-value" text="{{ weight }}" keyboardType="number" row="2" col="1"/>
<Label cssClass="field-unit" text="kg" row="2" col="2"/>
<Label class="field" text="Weight" row="2"/>
<TextField class="field-value" text="{{ weight }}" keyboardType="number" row="2" col="1"/>
<Label class="field-unit" text="kg" row="2" col="2"/>
</GridLayout>
<!-- Notifications settings -->
<Label cssClass="header" text="Notifications"/>
<GridLayout cssClass="field-group" columns="*, auto" rows="auto, auto, auto">
<Label class="header" text="Notifications"/>
<GridLayout class="field-group" columns="*, auto" rows="auto, auto, auto">
<!-- Notifications -->
<Label cssClass="field" text="Vibrate"/>
<Switch cssClass="field-value" checked="{{ vibrateEnabled }}" col="1"/>
<Label class="field" text="Vibrate"/>
<Switch class="field-value" checked="{{ vibrateEnabled }}" col="1"/>
<!-- Notifications -->
<Label cssClass="field" text="Sound" row="1"/>
<Switch cssClass="field-value" checked="{{ soundEnabled }}" row="1" col="1"/>
<Label class="field" text="Sound" row="1"/>
<Switch class="field-value" checked="{{ soundEnabled }}" row="1" col="1"/>
<Slider maxValue="100" value="{{ soundVolume }}" isEnabled="{{ soundEnabled }}" row="2" colSpan="2"/>
</GridLayout>
</StackLayout>

View File

@ -3,16 +3,16 @@
<TabView.items>
<TabViewItem title="First">
<TabViewItem.view>
<StackLayout cssClass="tab-content">
<Label text="First View" cssClass="title"/>
<StackLayout class="tab-content">
<Label text="First View" class="title"/>
<Label text="This is the content of the first tab." textWrap="true"/>
</StackLayout>
</TabViewItem.view>
</TabViewItem>
<TabViewItem title="Second">
<TabViewItem.view>
<StackLayout cssClass="tab-content">
<Label text="Second View" cssClass="title"/>
<StackLayout class="tab-content">
<Label text="Second View" class="title"/>
<Label text="This is the content of the second tab." textWrap="true"/>
</StackLayout>
</TabViewItem.view>

View File

@ -57,7 +57,7 @@ import labelModule = require("ui/label");
// <Page>
// {%raw%}<ListView items="{{ myItems }}">
// <ListView.itemTemplate>
// <Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" />
// <Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" />
// </ListView.itemTemplate>
// </ListView>{%endraw%}
// </Page>

View File

@ -32,7 +32,7 @@ import labelModule = require("ui/label");
// <Page>
// {%raw%}<Repeater items="{{ myItems }}">
// <Repeater.itemTemplate>
// <Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" />
// <Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" />
// </Repeater.itemTemplate>
// </Repeater>{%endraw%}
// </Page>

View File

@ -1,4 +1,4 @@
<StackLayout xmlns:customControls="xml-declaration/mymodule" cssClass="MySecondCustomStackLayout">
<StackLayout xmlns:customControls="xml-declaration/mymodule" class="MySecondCustomStackLayout">
<Label id="Label1" text="mymodulewithxml" />
<Button text="Click!" tap="buttonTap2" />
</StackLayout>

View File

@ -201,7 +201,7 @@ export function test_parse_ShouldResolveExportsFromCodeFileForTemplates() {
export function test_parse_ShouldApplyCssFromCssFile() {
var newPage: Page;
var pageFactory = function (): Page {
newPage = <Page>builder.parse("<Page cssFile='~/xml-declaration/custom-css-file.css'><Label cssClass='MyClass' /></Page>");
newPage = <Page>builder.parse("<Page cssFile='~/xml-declaration/custom-css-file.css'><Label class='MyClass' /></Page>");
return newPage;
};
@ -218,7 +218,7 @@ export function test_parse_ShouldApplyCssFromCssFile() {
export function test_parse_ShouldResolveExportsFromCodeFileAndApplyCssFile() {
var newPage: Page;
var pageFactory = function (): Page {
newPage = <Page>builder.parse("<Page codeFile='~/xml-declaration/custom-code-file' cssFile='~/xml-declaration/custom-css-file.css' loaded='loaded'><Label cssClass='MyClass' /></Page>");
newPage = <Page>builder.parse("<Page codeFile='~/xml-declaration/custom-code-file' cssFile='~/xml-declaration/custom-css-file.css' loaded='loaded'><Label class='MyClass' /></Page>");
return newPage;
};

View File

@ -1,10 +1,10 @@
<Page>
<GridLayout rows="*,*,*" columns="*,*">
<Image row="0" col="0" src="~/image-view/gravatar.png" cssClass="one"/>
<Image row="0" col="1" src="~/image-view/gravatar.png" cssClass="two"/>
<Image row="1" col="0" src="~/image-view/gravatar.png" cssClass="three"/>
<Image row="1" col="1" src="~/image-view/gravatar.png" cssClass="four"/>
<Image row="2" col="0" src="~/image-view/gravatar.png" cssClass="five"/>
<Image row="2" col="1" src="~/image-view/gravatar.png" cssClass="six"/>
<Image row="0" col="0" src="~/image-view/gravatar.png" class="one"/>
<Image row="0" col="1" src="~/image-view/gravatar.png" class="two"/>
<Image row="1" col="0" src="~/image-view/gravatar.png" class="three"/>
<Image row="1" col="1" src="~/image-view/gravatar.png" class="four"/>
<Image row="2" col="0" src="~/image-view/gravatar.png" class="five"/>
<Image row="2" col="1" src="~/image-view/gravatar.png" class="six"/>
</GridLayout>
</Page>

View File

@ -14,6 +14,11 @@ import utils = require("utils/utils");
import color = require("color");
import animationModule = require("ui/animation");
import observable = require("data/observable");
import {registerSpecialProperty} from "ui/builder/special-properties";
registerSpecialProperty("class", (instance: definition.View, propertyValue: string) => {
instance.cssClass = propertyValue;
});
export function isEventOrGesture(name: string, view: View): boolean {
if (types.isString(name)) {