Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: third_party/pkg/angular/lib/directive/ng_form.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular.directive; 1 part of angular.directive;
2 2
3 /** 3 /**
4 * The form directive listens on submission requests and, depending, 4 * The form directive listens on submission requests and, depending,
5 * on if an action is set, the form will automatically either allow 5 * on if an action is set, the form will automatically either allow
6 * or prevent the default browser submission from occurring. 6 * or prevent the default browser submission from occurring.
7 */ 7 */
8 @Decorator( 8 @NgDirective(
9 selector: 'form', 9 selector: 'form',
10 module: NgForm.module) 10 publishTypes : const <Type>[NgControl],
11 @Decorator( 11 visibility: NgDirective.CHILDREN_VISIBILITY)
12 @NgDirective(
12 selector: 'fieldset', 13 selector: 'fieldset',
13 module: NgForm.module) 14 publishTypes : const <Type>[NgControl],
14 @Decorator( 15 visibility: NgDirective.CHILDREN_VISIBILITY)
16 @NgDirective(
15 selector: '.ng-form', 17 selector: '.ng-form',
16 module: NgForm.module) 18 publishTypes : const <Type>[NgControl],
17 @Decorator( 19 visibility: NgDirective.CHILDREN_VISIBILITY)
20 @NgDirective(
18 selector: '[ng-form]', 21 selector: '[ng-form]',
19 module: NgForm.module, 22 publishTypes : const <Type>[NgControl],
20 map: const { 'ng-form': '@name' }) 23 visibility: NgDirective.CHILDREN_VISIBILITY)
21 class NgForm extends NgControl { 24 class NgForm extends NgControl implements Map<String, NgControl> {
22 static final Module _module = new Module()
23 ..factory(NgControl, (i) => i.get(NgForm));
24 static module() => _module;
25
26 final Scope _scope;
27
28 /** 25 /**
29 * Instantiates a new instance of NgForm. Upon creation, the instance of the 26 * Instantiates a new instance of NgForm. Upon creation, the instance of the
30 * class will be bound to the formName property on the scope (where formName 27 * class will be bound to the formName property on the scope (where formName
31 * refers to the name value acquired from the name attribute present on the 28 * refers to the name value acquired from the name attribute present on the
32 * form DOM element). 29 * form DOM element).
33 * 30 *
34 * * [scope] - The scope to bind the form instance to. 31 * * [scope] - The scope to bind the form instance to.
35 * * [element] - The form DOM element. 32 * * [element] - The form DOM element.
36 * * [injector] - An instance of Injector. 33 * * [injector] - An instance of Injector.
37 */ 34 */
38 NgForm(this._scope, NgElement element, Injector injector, Animate animate) : 35 NgForm(Scope scope, dom.Element element, Injector injector) :
39 super(element, injector, animate) { 36 super(scope, element, injector) {
40 37
41 if (!element.node.attributes.containsKey('action')) { 38 if (!element.attributes.containsKey('action')) {
42 element.node.onSubmit.listen((event) { 39 element.onSubmit.listen((event) {
43 event.preventDefault(); 40 event.preventDefault();
44 onSubmit(valid == true); 41 _scope.broadcast('submitNgControl', valid == null ? false : valid);
45 if (valid == true) { 42 reset();
46 reset();
47 }
48 }); 43 });
49 } 44 }
50 } 45 }
51 46
52 /**
53 * The name of the control. This is usually fetched via the name attribute th at is
54 * present on the element that the control is bound to.
55 */
56 @NgAttr('name') 47 @NgAttr('name')
57 get name => _name; 48 get name => _name;
58 set name(String value) { 49 set name(value) {
59 if (value != null) { 50 super.name = value;
60 super.name = value; 51 _scope.context[name] = this;
61 _scope.context[name] = this; 52 }
53
54 //FIXME: fix this reflection bug that shows up when Map is implemented
55 operator []=(String key, value) {
56 if (key == 'name') {
57 name = value;
58 } else {
59 _controlByName[key] = value;
62 } 60 }
63 } 61 }
64 62
65 /** 63 //FIXME: fix this reflection bug that shows up when Map is implemented
66 * The list of associated child controls. 64 operator[](name) {
67 */ 65 if (name == 'valid') {
68 get controls => _controlByName; 66 return valid;
67 } else if (name == 'invalid') {
68 return invalid;
69 } else {
70 return _controlByName[name];
71 }
72 }
69 73
70 /** 74 bool get isEmpty => false;
71 * Returns the child control that is associated with the given name. If multi ple 75 bool get isNotEmpty => !isEmpty;
72 * child controls contain the same name then the first instance will be retur ned. 76 get values => null;
73 */ 77 get keys => null;
74 NgControl operator[](String name) => 78 get length => null;
75 controls.containsKey(name) ? controls[name][0] : null; 79 clear() => null;
80 remove(_) => null;
81 containsKey(_) => false;
82 containsValue(_) => false;
83 addAll(_) => null;
84 forEach(_) => null;
85 putIfAbsent(_, __) => null;
76 } 86 }
77 87
78 class NgNullForm extends NgNullControl implements NgForm { 88 class NgNullForm extends NgNullControl implements NgForm {
79 var _scope; 89 NgNullForm() {}
80 90
81 NgNullForm() {}
82 operator []=(String key, value) {}
83 operator[](name) {} 91 operator[](name) {}
92 operator []=(String name, value) {}
84 93
85 get controls => null; 94 bool get isEmpty => false;
95 bool get isNotEmpty => true;
96 get values => null;
97 get keys => null;
98 get length => null;
99 clear() => null;
100 remove(_) => null;
101 containsKey(_) => false;
102 containsValue(_) => false;
103 addAll(_) => null;
104 forEach(_) => null;
105 putIfAbsent(_, __) => null;
86 } 106 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/directive/ng_events.dart ('k') | third_party/pkg/angular/lib/directive/ng_if.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698