diff --git a/public/_includes/_util-fns.jade b/public/_includes/_util-fns.jade index cf1090a6a5..0bb81db082 100644 --- a/public/_includes/_util-fns.jade +++ b/public/_includes/_util-fns.jade @@ -1,11 +1,28 @@ //- Mixins and associated functions -- var _docsFor = 'ts'; // or 'dart' or 'js'. +//- _docsFor: used to identify the language this version of the docs if for; +//- Should be one of: 'ts', 'dart' or 'js'. Set in lang specific _util-fns file. +- var _docsFor = ''; +//- Simple "macros" used via interpolation in text: +//- e.g., the #{_priv}el variable has an `@Input` #{_decorator}. + +//- Use #{_decorator} whereever the word "decorator" is expected, provided it is not +//- preceded by the article "a". (E.g., will be "annotation" for Dart) +- var _decorator = 'decorator'; + +//- Used to prefix identifiers that are private. In Dart this will be '_'. +- var _priv = ''; + +//- Use to conditionally include the block that follows +ifDocsFor(...). +//- Generally favor use of Jade named blocks instead. ifDocsFor is convenient +//- for prose that should appear only in one language version. mixin ifDocsFor(lang) if _docsFor.toLowerCase() === lang.toLowerCase() block +//- Use to map inlined (prose) TS paths into, say, Dart paths via the +//- adjustExamplePath transformer function. mixin adjExPath(path) if adjustExamplePath | #{adjustExamplePath(path)} diff --git a/public/docs/_examples/attribute-directives/dart/lib/app_component.dart b/public/docs/_examples/attribute-directives/dart/lib/app_component.dart index 2494fc3fd7..29f44ea6e9 100644 --- a/public/docs/_examples/attribute-directives/dart/lib/app_component.dart +++ b/public/docs/_examples/attribute-directives/dart/lib/app_component.dart @@ -6,7 +6,7 @@ import 'highlight_directive.dart'; @Component( selector: 'my-app', templateUrl: 'app_component.html', - directives: const [Highlight]) + directives: const [HighlightDirective]) class AppComponent { String color; } diff --git a/public/docs/_examples/attribute-directives/dart/lib/app_component.html b/public/docs/_examples/attribute-directives/dart/lib/app_component.html index b8fd63c8e3..f174bebbbb 100644 --- a/public/docs/_examples/attribute-directives/dart/lib/app_component.html +++ b/public/docs/_examples/attribute-directives/dart/lib/app_component.html @@ -7,14 +7,14 @@ Yellow Cyan - -
Highlight me!
- + +Highlight me!
+ -
+
Highlight me too!
-
Highlight me!
diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart index a6c0856cc4..e6190a443c 100644 --- a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart +++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart @@ -2,51 +2,42 @@ // #docregion full import 'package:angular2/core.dart'; -@Directive(selector: '[my-highlight]', host: const { +@Directive(selector: '[myHighlight]', host: const { '(mouseenter)': 'onMouseEnter()', '(mouseleave)': 'onMouseLeave()' }) // #docregion class-1 -class Highlight { - // #enddocregion class-1 -// #enddocregion full - /* -// #docregion highlight - @Input() myHighlight: string; -// #enddocregion highlight - */ -// #docregion full -// #docregion class-1 -// #docregion color - @Input('my-highlight') String highlightColor; -// #enddocregion color - +class HighlightDirective { String _defaultColor = 'red'; + final dynamic _el; + + HighlightDirective(ElementRef elRef) : _el = elRef.nativeElement; // #enddocregion class-1 + // #docregion defaultColor @Input() set defaultColor(String colorName) { _defaultColor = (colorName ?? _defaultColor); } // #enddocregion defaultColor -// #docregion class-1 + // #docregion class-1 - final ElementRef _element; + // #docregion color + @Input('myHighlight') String highlightColor; + // #enddocregion color + + // #docregion mouse-enter + void onMouseEnter() { _highlight(highlightColor ?? _defaultColor); } + // #enddocregion mouse-enter + void onMouseLeave() { _highlight(); } -// #docregion mouse-enter - onMouseEnter() { - _highlight(highlightColor ?? _defaultColor); + void _highlight([String color]) { + if(_el != null) _el.style.backgroundColor = color; } - -// #enddocregion mouse-enter - onMouseLeave() { - _highlight(null); - } - - void _highlight(String color) { - _element.nativeElement.style.backgroundColor = color; - } - - Highlight(this._element); } // #enddocregion class-1 // #enddocregion full +/* +// #docregion highlight +@Input() String myHighlight; +// #enddocregion highlight +*/ diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart index 3b79e66a3b..2ce0e35919 100644 --- a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart +++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart @@ -3,9 +3,9 @@ library attribute_directives.highlight_directive; import 'package:angular2/core.dart'; -@Directive(selector: '[my-highlight]') -class Highlight { - Highlight(ElementRef element) { +@Directive(selector: '[myHighlight]') +class HighlightDirective { + HighlightDirective(ElementRef element) { element.nativeElement.style.backgroundColor = 'yellow'; } } diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart index 8c540b3a6a..8546f36279 100644 --- a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart +++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart @@ -1,32 +1,28 @@ // #docregion import 'package:angular2/core.dart'; -@Directive(selector: '[my-highlight]', -// #docregion host +@Directive(selector: '[myHighlight]', + // #docregion host host: const { '(mouseenter)': 'onMouseEnter()', '(mouseleave)': 'onMouseLeave()' } -// #enddocregion host - ) -class Highlight { - final ElementRef _element; -// #docregion mouse-methods - onMouseEnter() { - _highlight("yellow"); - } + // #enddocregion host +) +class HighlightDirective { + // #docregion ctor + final dynamic _el; - onMouseLeave() { - _highlight(null); + HighlightDirective(ElementRef elRef) : _el = elRef.nativeElement; + // #enddocregion ctor + + // #docregion mouse-methods + void onMouseEnter() { _highlight("yellow"); } + void onMouseLeave() { _highlight(); } + + void _highlight([String color]) { + if (_el != null) _el.style.backgroundColor = color; } // #enddocregion mouse-methods - - void _highlight(String color) { - _element.nativeElement.style.backgroundColor = color; - } - -// #docregion ctor - Highlight(this._element); -// #enddocregion ctor } // #enddocregion diff --git a/public/docs/_examples/attribute-directives/ts/app/app.component.1.html b/public/docs/_examples/attribute-directives/ts/app/app.component.1.html index 177c90f5da..7843d3cdf2 100644 --- a/public/docs/_examples/attribute-directives/ts/app/app.component.1.html +++ b/public/docs/_examples/attribute-directives/ts/app/app.component.1.html @@ -1,4 +1,4 @@Highlight me!
+ diff --git a/public/docs/_examples/attribute-directives/ts/app/app.component.html b/public/docs/_examples/attribute-directives/ts/app/app.component.html index 35b5d43aae..e4e445b1a8 100644 --- a/public/docs/_examples/attribute-directives/ts/app/app.component.html +++ b/public/docs/_examples/attribute-directives/ts/app/app.component.html @@ -7,10 +7,9 @@ Yellow Cyan - - +Highlight me!
- + @@ -18,5 +17,4 @@ Highlight me too! - - \ No newline at end of file + diff --git a/public/docs/_examples/attribute-directives/ts/app/highlight.directive.1.ts b/public/docs/_examples/attribute-directives/ts/app/highlight.directive.1.ts index afaf652026..f8c1a95ea1 100644 --- a/public/docs/_examples/attribute-directives/ts/app/highlight.directive.1.ts +++ b/public/docs/_examples/attribute-directives/ts/app/highlight.directive.1.ts @@ -1,13 +1,9 @@ // #docregion import { Directive, ElementRef, Input } from '@angular/core'; -@Directive({ - selector: '[myHighlight]' -}) - +@Directive({ selector: '[myHighlight]' }) export class HighlightDirective { constructor(el: ElementRef) { el.nativeElement.style.backgroundColor = 'yellow'; } } -// #enddocregion \ No newline at end of file diff --git a/public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts b/public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts index 95b79c42ce..6ec9842602 100644 --- a/public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts +++ b/public/docs/_examples/attribute-directives/ts/app/highlight.directive.ts @@ -9,39 +9,28 @@ import { Directive, ElementRef, Input } from '@angular/core'; '(mouseleave)': 'onMouseLeave()' } }) - // #docregion class-1 export class HighlightDirective { - private _defaultColor = 'red'; - private el:HTMLElement; -// #enddocregion class-1 -// #enddocregion full - /* -// #docregion highlight - @Input() myHighlight: string; -// #enddocregion highlight - */ -// #docregion full + private el: HTMLElement; + + constructor(el: ElementRef) { this.el = el.nativeElement; } + // #enddocregion class-1 -// #docregion defaultColor + // #docregion defaultColor @Input() set defaultColor(colorName:string){ this._defaultColor = colorName || this._defaultColor; } -// #enddocregion defaultColor -// #docregion class-1 + // #enddocregion defaultColor + // #docregion class-1 -// #docregion color + // #docregion color @Input('myHighlight') highlightColor: string; -// #enddocregion color + // #enddocregion color -// #enddocregion class-1 -// #docregion class-1 - constructor(el: ElementRef) { this.el = el.nativeElement; } - -// #docregion mouse-enter + // #docregion mouse-enter onMouseEnter() { this.highlight(this.highlightColor || this._defaultColor); } -// #enddocregion mouse-enter + // #enddocregion mouse-enter onMouseLeave() { this.highlight(null); } private highlight(color:string) { @@ -50,3 +39,8 @@ export class HighlightDirective { } // #enddocregion class-1 // #enddocregion full +/* +// #docregion highlight +@Input() myHighlight: string; +// #enddocregion highlight +*/ diff --git a/public/docs/_examples/attribute-directives/ts/index.html b/public/docs/_examples/attribute-directives/ts/index.html index 6bfef2480d..99b6749fbd 100644 --- a/public/docs/_examples/attribute-directives/ts/index.html +++ b/public/docs/_examples/attribute-directives/ts/index.html @@ -19,10 +19,7 @@ System.import('app').catch(function(err){ console.error(err); }); - -