rails-angularjs2 2.0.0.pre.alpha.30 → 2.0.0.pre.alpha.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/rails-angularjs2/version.rb +1 -1
- data/vendor/assets/javascripts/angular2.dev.js +3411 -2481
- data/vendor/assets/javascripts/angular2.js +2931 -2452
- data/vendor/assets/javascripts/angular2.min.js +16 -17
- data/vendor/assets/javascripts/angular2.sfx.dev.js +3871 -2621
- data/vendor/assets/javascripts/router.dev.js +563 -243
- data/vendor/assets/javascripts/router.dev.js.map +1 -1
- data/vendor/assets/javascripts/test_lib.dev.js +1524 -0
- data/vendor/assets/javascripts/test_lib.dev.js.map +1 -0
- metadata +4 -2
@@ -1,4 +1,70 @@
|
|
1
1
|
"format register";
|
2
|
+
System.register("angular2/src/router/lifecycle_annotations_impl", ["angular2/src/facade/lang"], function($__export) {
|
3
|
+
"use strict";
|
4
|
+
var __moduleName = "angular2/src/router/lifecycle_annotations_impl";
|
5
|
+
var __decorate,
|
6
|
+
__metadata,
|
7
|
+
CONST,
|
8
|
+
CONST_EXPR,
|
9
|
+
RouteLifecycleHook,
|
10
|
+
CanActivate,
|
11
|
+
canReuse,
|
12
|
+
canDeactivate,
|
13
|
+
onActivate,
|
14
|
+
onReuse,
|
15
|
+
onDeactivate;
|
16
|
+
return {
|
17
|
+
setters: [function($__m) {
|
18
|
+
CONST = $__m.CONST;
|
19
|
+
CONST_EXPR = $__m.CONST_EXPR;
|
20
|
+
}],
|
21
|
+
execute: function() {
|
22
|
+
__decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
23
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
24
|
+
return Reflect.decorate(decorators, target, key, desc);
|
25
|
+
switch (arguments.length) {
|
26
|
+
case 2:
|
27
|
+
return decorators.reduceRight(function(o, d) {
|
28
|
+
return (d && d(o)) || o;
|
29
|
+
}, target);
|
30
|
+
case 3:
|
31
|
+
return decorators.reduceRight(function(o, d) {
|
32
|
+
return (d && d(target, key)), void 0;
|
33
|
+
}, void 0);
|
34
|
+
case 4:
|
35
|
+
return decorators.reduceRight(function(o, d) {
|
36
|
+
return (d && d(target, key, o)) || o;
|
37
|
+
}, desc);
|
38
|
+
}
|
39
|
+
};
|
40
|
+
__metadata = (this && this.__metadata) || function(k, v) {
|
41
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
42
|
+
return Reflect.metadata(k, v);
|
43
|
+
};
|
44
|
+
RouteLifecycleHook = (($traceurRuntime.createClass)(function(name) {
|
45
|
+
this.name = name;
|
46
|
+
}, {}, {}));
|
47
|
+
$__export("RouteLifecycleHook", RouteLifecycleHook);
|
48
|
+
$__export("RouteLifecycleHook", RouteLifecycleHook = __decorate([CONST(), __metadata('design:paramtypes', [String])], RouteLifecycleHook));
|
49
|
+
CanActivate = (($traceurRuntime.createClass)(function(fn) {
|
50
|
+
this.fn = fn;
|
51
|
+
}, {}, {}));
|
52
|
+
$__export("CanActivate", CanActivate);
|
53
|
+
$__export("CanActivate", CanActivate = __decorate([CONST(), __metadata('design:paramtypes', [Function])], CanActivate));
|
54
|
+
canReuse = CONST_EXPR(new RouteLifecycleHook("canReuse"));
|
55
|
+
$__export("canReuse", canReuse);
|
56
|
+
canDeactivate = CONST_EXPR(new RouteLifecycleHook("canDeactivate"));
|
57
|
+
$__export("canDeactivate", canDeactivate);
|
58
|
+
onActivate = CONST_EXPR(new RouteLifecycleHook("onActivate"));
|
59
|
+
$__export("onActivate", onActivate);
|
60
|
+
onReuse = CONST_EXPR(new RouteLifecycleHook("onReuse"));
|
61
|
+
$__export("onReuse", onReuse);
|
62
|
+
onDeactivate = CONST_EXPR(new RouteLifecycleHook("onDeactivate"));
|
63
|
+
$__export("onDeactivate", onDeactivate);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
});
|
67
|
+
|
2
68
|
System.register("angular2/src/router/instruction", ["angular2/src/facade/collection", "angular2/src/facade/lang"], function($__export) {
|
3
69
|
"use strict";
|
4
70
|
var __moduleName = "angular2/src/router/instruction";
|
@@ -8,9 +74,6 @@ System.register("angular2/src/router/instruction", ["angular2/src/facade/collect
|
|
8
74
|
normalizeBlank,
|
9
75
|
RouteParams,
|
10
76
|
Instruction;
|
11
|
-
function shouldReuseComponent(instr1, instr2) {
|
12
|
-
return instr1.component == instr2.component && StringMapWrapper.equals(instr1.params(), instr2.params());
|
13
|
-
}
|
14
77
|
return {
|
15
78
|
setters: [function($__m) {
|
16
79
|
StringMapWrapper = $__m.StringMapWrapper;
|
@@ -48,28 +111,42 @@ System.register("angular2/src/router/instruction", ["angular2/src/facade/collect
|
|
48
111
|
}
|
49
112
|
}
|
50
113
|
}
|
51
|
-
return ($traceurRuntime.createClass)(Instruction, {
|
52
|
-
params: function() {
|
114
|
+
return ($traceurRuntime.createClass)(Instruction, {params: function() {
|
53
115
|
if (isBlank(this._params)) {
|
54
116
|
this._params = this._recognizer.parseParams(this.capturedUrl);
|
55
117
|
}
|
56
118
|
return this._params;
|
57
|
-
},
|
58
|
-
hasChild: function() {
|
59
|
-
return isPresent(this.child);
|
60
|
-
},
|
61
|
-
reuseComponentsFrom: function(oldInstruction) {
|
62
|
-
var nextInstruction = this;
|
63
|
-
while (nextInstruction.reuse = shouldReuseComponent(nextInstruction, oldInstruction) && isPresent(oldInstruction = oldInstruction.child) && isPresent(nextInstruction = nextInstruction.child))
|
64
|
-
;
|
65
|
-
}
|
66
|
-
}, {});
|
119
|
+
}}, {});
|
67
120
|
}());
|
68
121
|
$__export("Instruction", Instruction);
|
69
122
|
}
|
70
123
|
};
|
71
124
|
});
|
72
125
|
|
126
|
+
System.register("angular2/src/router/lifecycle_annotations", ["angular2/src/util/decorators", "angular2/src/router/lifecycle_annotations_impl"], function($__export) {
|
127
|
+
"use strict";
|
128
|
+
var __moduleName = "angular2/src/router/lifecycle_annotations";
|
129
|
+
var makeDecorator,
|
130
|
+
CanActivateAnnotation,
|
131
|
+
CanActivate;
|
132
|
+
return {
|
133
|
+
setters: [function($__m) {
|
134
|
+
makeDecorator = $__m.makeDecorator;
|
135
|
+
}, function($__m) {
|
136
|
+
CanActivateAnnotation = $__m.CanActivate;
|
137
|
+
$__export("canReuse", $__m.canReuse);
|
138
|
+
$__export("canDeactivate", $__m.canDeactivate);
|
139
|
+
$__export("onActivate", $__m.onActivate);
|
140
|
+
$__export("onReuse", $__m.onReuse);
|
141
|
+
$__export("onDeactivate", $__m.onDeactivate);
|
142
|
+
}],
|
143
|
+
execute: function() {
|
144
|
+
CanActivate = makeDecorator(CanActivateAnnotation);
|
145
|
+
$__export("CanActivate", CanActivate);
|
146
|
+
}
|
147
|
+
};
|
148
|
+
});
|
149
|
+
|
73
150
|
System.register("angular2/src/router/location_strategy", ["angular2/src/facade/lang"], function($__export) {
|
74
151
|
"use strict";
|
75
152
|
var __moduleName = "angular2/src/router/location_strategy";
|
@@ -289,7 +366,8 @@ System.register("angular2/src/router/hash_location_strategy", ["angular2/src/dom
|
|
289
366
|
return '';
|
290
367
|
},
|
291
368
|
path: function() {
|
292
|
-
|
369
|
+
var path = this._location.hash;
|
370
|
+
return path.length > 0 ? path.substring(1) : path;
|
293
371
|
},
|
294
372
|
pushState: function(state, title, url) {
|
295
373
|
this._history.pushState(state, title, '#' + url);
|
@@ -609,6 +687,7 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
609
687
|
IMPLEMENTS,
|
610
688
|
escapeRegex,
|
611
689
|
Segment,
|
690
|
+
TouchMap,
|
612
691
|
ContinuationSegment,
|
613
692
|
StaticSegment,
|
614
693
|
DynamicSegment,
|
@@ -623,6 +702,17 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
623
702
|
return obj.toString();
|
624
703
|
}
|
625
704
|
}
|
705
|
+
function parseAndAssignMatrixParams(keyValueMap, matrixString) {
|
706
|
+
if (matrixString[0] == ';') {
|
707
|
+
matrixString = matrixString.substring(1);
|
708
|
+
}
|
709
|
+
matrixString.split(';').forEach((function(entry) {
|
710
|
+
var tuple = entry.split('=');
|
711
|
+
var key = tuple[0];
|
712
|
+
var value = tuple.length > 1 ? tuple[1] : true;
|
713
|
+
keyValueMap[key] = value;
|
714
|
+
}));
|
715
|
+
}
|
626
716
|
function parsePathString(route) {
|
627
717
|
if (StringWrapper.startsWith(route, "/")) {
|
628
718
|
route = StringWrapper.substring(route, 1);
|
@@ -699,16 +789,44 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
699
789
|
};
|
700
790
|
Segment = (function() {
|
701
791
|
function Segment() {}
|
702
|
-
return ($traceurRuntime.createClass)(Segment, {
|
792
|
+
return ($traceurRuntime.createClass)(Segment, {generate: function(params) {
|
793
|
+
return '';
|
794
|
+
}}, {});
|
703
795
|
}());
|
704
796
|
$__export("Segment", Segment);
|
797
|
+
TouchMap = (function() {
|
798
|
+
function TouchMap(map) {
|
799
|
+
var $__0 = this;
|
800
|
+
this.map = StringMapWrapper.create();
|
801
|
+
this.keys = StringMapWrapper.create();
|
802
|
+
if (isPresent(map)) {
|
803
|
+
StringMapWrapper.forEach(map, (function(value, key) {
|
804
|
+
$__0.map[key] = isPresent(value) ? value.toString() : null;
|
805
|
+
$__0.keys[key] = true;
|
806
|
+
}));
|
807
|
+
}
|
808
|
+
}
|
809
|
+
return ($traceurRuntime.createClass)(TouchMap, {
|
810
|
+
get: function(key) {
|
811
|
+
StringMapWrapper.delete(this.keys, key);
|
812
|
+
return this.map[key];
|
813
|
+
},
|
814
|
+
getUnused: function() {
|
815
|
+
var $__0 = this;
|
816
|
+
var unused = StringMapWrapper.create();
|
817
|
+
var keys = StringMapWrapper.keys(this.keys);
|
818
|
+
ListWrapper.forEach(keys, (function(key) {
|
819
|
+
unused[key] = StringMapWrapper.get($__0.map, key);
|
820
|
+
}));
|
821
|
+
return unused;
|
822
|
+
}
|
823
|
+
}, {});
|
824
|
+
}());
|
705
825
|
ContinuationSegment = (function($__super) {
|
706
826
|
function ContinuationSegment() {
|
707
827
|
$traceurRuntime.superConstructor(ContinuationSegment).apply(this, arguments);
|
708
828
|
}
|
709
|
-
return ($traceurRuntime.createClass)(ContinuationSegment, {
|
710
|
-
return '';
|
711
|
-
}}, {}, $__super);
|
829
|
+
return ($traceurRuntime.createClass)(ContinuationSegment, {}, {}, $__super);
|
712
830
|
}(Segment));
|
713
831
|
StaticSegment = (function($__super) {
|
714
832
|
function StaticSegment(string) {
|
@@ -716,6 +834,7 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
716
834
|
this.string = string;
|
717
835
|
this.name = '';
|
718
836
|
this.regex = escapeRegex(string);
|
837
|
+
this.regex += '(;[^\/]+)?';
|
719
838
|
}
|
720
839
|
return ($traceurRuntime.createClass)(StaticSegment, {generate: function(params) {
|
721
840
|
return this.string;
|
@@ -725,10 +844,10 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
725
844
|
this.name = name;
|
726
845
|
this.regex = "([^/]+)";
|
727
846
|
}, {generate: function(params) {
|
728
|
-
if (!StringMapWrapper.contains(params, this.name)) {
|
847
|
+
if (!StringMapWrapper.contains(params.map, this.name)) {
|
729
848
|
throw new BaseException(("Route generator for '" + this.name + "' was not included in parameters passed."));
|
730
849
|
}
|
731
|
-
return normalizeString(
|
850
|
+
return normalizeString(params.get(this.name));
|
732
851
|
}}, {}));
|
733
852
|
DynamicSegment = __decorate([IMPLEMENTS(Segment), __metadata('design:paramtypes', [String])], DynamicSegment);
|
734
853
|
StarSegment = (function() {
|
@@ -737,11 +856,11 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
737
856
|
this.regex = "(.+)";
|
738
857
|
}
|
739
858
|
return ($traceurRuntime.createClass)(StarSegment, {generate: function(params) {
|
740
|
-
return normalizeString(
|
859
|
+
return normalizeString(params.get(this.name));
|
741
860
|
}}, {});
|
742
861
|
}());
|
743
|
-
paramMatcher =
|
744
|
-
wildcardMatcher =
|
862
|
+
paramMatcher = /^:([^\/]+)$/g;
|
863
|
+
wildcardMatcher = /^\*([^\/]+)$/g;
|
745
864
|
PathRecognizer = (function() {
|
746
865
|
function PathRecognizer(path, handler) {
|
747
866
|
var $__0 = this;
|
@@ -768,9 +887,20 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
768
887
|
}
|
769
888
|
return ($traceurRuntime.createClass)(PathRecognizer, {
|
770
889
|
parseParams: function(url) {
|
890
|
+
var segmentsLimit = this.segments.length - 1;
|
891
|
+
var containsStarSegment = segmentsLimit >= 0 && this.segments[segmentsLimit] instanceof StarSegment;
|
892
|
+
var matrixString;
|
893
|
+
if (!containsStarSegment) {
|
894
|
+
var matches = RegExpWrapper.firstMatch(RegExpWrapper.create('^(.*\/[^\/]+?)(;[^\/]+)?\/?$'), url);
|
895
|
+
if (isPresent(matches)) {
|
896
|
+
url = matches[1];
|
897
|
+
matrixString = matches[2];
|
898
|
+
}
|
899
|
+
url = StringWrapper.replaceAll(url, /(;[^\/]+)(?=(\/|\Z))/g, '');
|
900
|
+
}
|
771
901
|
var params = StringMapWrapper.create();
|
772
902
|
var urlPart = url;
|
773
|
-
for (var i = 0; i
|
903
|
+
for (var i = 0; i <= segmentsLimit; i++) {
|
774
904
|
var segment = this.segments[i];
|
775
905
|
if (segment instanceof ContinuationSegment) {
|
776
906
|
continue;
|
@@ -778,15 +908,37 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
778
908
|
var match = RegExpWrapper.firstMatch(RegExpWrapper.create('/' + segment.regex), urlPart);
|
779
909
|
urlPart = StringWrapper.substring(urlPart, match[0].length);
|
780
910
|
if (segment.name.length > 0) {
|
781
|
-
|
911
|
+
params[segment.name] = match[1];
|
782
912
|
}
|
783
913
|
}
|
914
|
+
if (isPresent(matrixString) && matrixString.length > 0 && matrixString[0] == ';') {
|
915
|
+
parseAndAssignMatrixParams(params, matrixString);
|
916
|
+
}
|
784
917
|
return params;
|
785
918
|
},
|
786
919
|
generate: function(params) {
|
787
|
-
|
788
|
-
|
789
|
-
|
920
|
+
var paramTokens = new TouchMap(params);
|
921
|
+
var applyLeadingSlash = false;
|
922
|
+
var url = '';
|
923
|
+
for (var i = 0; i < this.segments.length; i++) {
|
924
|
+
var segment = this.segments[i];
|
925
|
+
var s = segment.generate(paramTokens);
|
926
|
+
applyLeadingSlash = applyLeadingSlash || (segment instanceof ContinuationSegment);
|
927
|
+
if (s.length > 0) {
|
928
|
+
url += (i > 0 ? '/' : '') + s;
|
929
|
+
}
|
930
|
+
}
|
931
|
+
var unusedParams = paramTokens.getUnused();
|
932
|
+
StringMapWrapper.forEach(unusedParams, (function(value, key) {
|
933
|
+
url += ';' + key;
|
934
|
+
if (isPresent(value)) {
|
935
|
+
url += '=' + value;
|
936
|
+
}
|
937
|
+
}));
|
938
|
+
if (applyLeadingSlash) {
|
939
|
+
url += '/';
|
940
|
+
}
|
941
|
+
return url;
|
790
942
|
},
|
791
943
|
resolveComponentType: function() {
|
792
944
|
return this.handler.resolveComponentType();
|
@@ -798,209 +950,38 @@ System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lan
|
|
798
950
|
};
|
799
951
|
});
|
800
952
|
|
801
|
-
System.register("angular2/src/router/
|
953
|
+
System.register("angular2/src/router/route_lifecycle_reflector", ["angular2/src/facade/lang", "angular2/src/router/lifecycle_annotations_impl", "angular2/src/reflection/reflection"], function($__export) {
|
802
954
|
"use strict";
|
803
|
-
var __moduleName = "angular2/src/router/
|
804
|
-
var
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
ChildRouter,
|
819
|
-
SLASH;
|
820
|
-
function splitAndFlattenLinkParams(linkParams) {
|
821
|
-
return ListWrapper.reduce(linkParams, (function(accumulation, item) {
|
822
|
-
if (isString(item)) {
|
823
|
-
return ListWrapper.concat(accumulation, StringWrapper.split(item, SLASH));
|
955
|
+
var __moduleName = "angular2/src/router/route_lifecycle_reflector";
|
956
|
+
var Type,
|
957
|
+
CanActivate,
|
958
|
+
reflector;
|
959
|
+
function hasLifecycleHook(e, type) {
|
960
|
+
if (!(type instanceof Type))
|
961
|
+
return false;
|
962
|
+
return e.name in type.prototype;
|
963
|
+
}
|
964
|
+
function getCanActivateHook(type) {
|
965
|
+
var annotations = reflector.annotations(type);
|
966
|
+
for (var i = 0; i < annotations.length; i += 1) {
|
967
|
+
var annotation = annotations[i];
|
968
|
+
if (annotation instanceof CanActivate) {
|
969
|
+
return annotation.fn;
|
824
970
|
}
|
825
|
-
|
826
|
-
|
827
|
-
}), []);
|
971
|
+
}
|
972
|
+
return null;
|
828
973
|
}
|
974
|
+
$__export("hasLifecycleHook", hasLifecycleHook);
|
975
|
+
$__export("getCanActivateHook", getCanActivateHook);
|
829
976
|
return {
|
830
977
|
setters: [function($__m) {
|
831
|
-
|
832
|
-
EventEmitter = $__m.EventEmitter;
|
833
|
-
ObservableWrapper = $__m.ObservableWrapper;
|
978
|
+
Type = $__m.Type;
|
834
979
|
}, function($__m) {
|
835
|
-
|
980
|
+
CanActivate = $__m.CanActivate;
|
836
981
|
}, function($__m) {
|
837
|
-
|
838
|
-
isString = $__m.isString;
|
839
|
-
StringWrapper = $__m.StringWrapper;
|
840
|
-
isPresent = $__m.isPresent;
|
841
|
-
isArray = $__m.isArray;
|
842
|
-
BaseException = $__m.BaseException;
|
982
|
+
reflector = $__m.reflector;
|
843
983
|
}],
|
844
984
|
execute: function() {
|
845
|
-
_resolveToTrue = PromiseWrapper.resolve(true);
|
846
|
-
_resolveToFalse = PromiseWrapper.resolve(false);
|
847
|
-
Router = (function() {
|
848
|
-
function Router(registry, _pipeline, parent, hostComponent) {
|
849
|
-
this.registry = registry;
|
850
|
-
this._pipeline = _pipeline;
|
851
|
-
this.parent = parent;
|
852
|
-
this.hostComponent = hostComponent;
|
853
|
-
this.navigating = false;
|
854
|
-
this.previousUrl = null;
|
855
|
-
this._currentInstruction = null;
|
856
|
-
this._currentNavigation = _resolveToTrue;
|
857
|
-
this._outlet = null;
|
858
|
-
this._subject = new EventEmitter();
|
859
|
-
}
|
860
|
-
return ($traceurRuntime.createClass)(Router, {
|
861
|
-
childRouter: function(hostComponent) {
|
862
|
-
return new ChildRouter(this, hostComponent);
|
863
|
-
},
|
864
|
-
registerOutlet: function(outlet) {
|
865
|
-
this._outlet = outlet;
|
866
|
-
if (isPresent(this._currentInstruction)) {
|
867
|
-
return outlet.activate(this._currentInstruction);
|
868
|
-
}
|
869
|
-
return _resolveToTrue;
|
870
|
-
},
|
871
|
-
config: function(config) {
|
872
|
-
var $__0 = this;
|
873
|
-
if (isArray(config)) {
|
874
|
-
config.forEach((function(configObject) {
|
875
|
-
$__0.registry.config($__0.hostComponent, configObject);
|
876
|
-
}));
|
877
|
-
} else {
|
878
|
-
this.registry.config(this.hostComponent, config);
|
879
|
-
}
|
880
|
-
return this.renavigate();
|
881
|
-
},
|
882
|
-
navigate: function(url) {
|
883
|
-
var $__0 = this;
|
884
|
-
if (this.navigating) {
|
885
|
-
return this._currentNavigation;
|
886
|
-
}
|
887
|
-
this.lastNavigationAttempt = url;
|
888
|
-
return this._currentNavigation = this.recognize(url).then((function(matchedInstruction) {
|
889
|
-
if (isBlank(matchedInstruction)) {
|
890
|
-
return _resolveToFalse;
|
891
|
-
}
|
892
|
-
if (isPresent($__0._currentInstruction)) {
|
893
|
-
matchedInstruction.reuseComponentsFrom($__0._currentInstruction);
|
894
|
-
}
|
895
|
-
$__0._startNavigating();
|
896
|
-
var result = $__0.commit(matchedInstruction).then((function(_) {
|
897
|
-
$__0._finishNavigating();
|
898
|
-
ObservableWrapper.callNext($__0._subject, matchedInstruction.accumulatedUrl);
|
899
|
-
}));
|
900
|
-
return PromiseWrapper.catchError(result, (function(err) {
|
901
|
-
$__0._finishNavigating();
|
902
|
-
throw err;
|
903
|
-
}));
|
904
|
-
}));
|
905
|
-
},
|
906
|
-
_startNavigating: function() {
|
907
|
-
this.navigating = true;
|
908
|
-
},
|
909
|
-
_finishNavigating: function() {
|
910
|
-
this.navigating = false;
|
911
|
-
},
|
912
|
-
subscribe: function(onNext) {
|
913
|
-
ObservableWrapper.subscribe(this._subject, onNext);
|
914
|
-
},
|
915
|
-
commit: function(instruction) {
|
916
|
-
this._currentInstruction = instruction;
|
917
|
-
if (isPresent(this._outlet)) {
|
918
|
-
return this._outlet.activate(instruction);
|
919
|
-
}
|
920
|
-
return _resolveToTrue;
|
921
|
-
},
|
922
|
-
deactivate: function() {
|
923
|
-
if (isPresent(this._outlet)) {
|
924
|
-
return this._outlet.deactivate();
|
925
|
-
}
|
926
|
-
return _resolveToTrue;
|
927
|
-
},
|
928
|
-
recognize: function(url) {
|
929
|
-
return this.registry.recognize(url, this.hostComponent);
|
930
|
-
},
|
931
|
-
renavigate: function() {
|
932
|
-
var destination = isBlank(this.previousUrl) ? this.lastNavigationAttempt : this.previousUrl;
|
933
|
-
if (isBlank(destination)) {
|
934
|
-
return this._currentNavigation;
|
935
|
-
}
|
936
|
-
return this.navigate(destination);
|
937
|
-
},
|
938
|
-
generate: function(linkParams) {
|
939
|
-
var normalizedLinkParams = splitAndFlattenLinkParams(linkParams);
|
940
|
-
var first = ListWrapper.first(normalizedLinkParams);
|
941
|
-
var rest = ListWrapper.slice(normalizedLinkParams, 1);
|
942
|
-
var router = this;
|
943
|
-
if (first == '') {
|
944
|
-
while (isPresent(router.parent)) {
|
945
|
-
router = router.parent;
|
946
|
-
}
|
947
|
-
} else if (first == '..') {
|
948
|
-
router = router.parent;
|
949
|
-
while (ListWrapper.first(rest) == '..') {
|
950
|
-
rest = ListWrapper.slice(rest, 1);
|
951
|
-
router = router.parent;
|
952
|
-
if (isBlank(router)) {
|
953
|
-
throw new BaseException(("Link \"" + ListWrapper.toJSON(linkParams) + "\" has too many \"../\" segments."));
|
954
|
-
}
|
955
|
-
}
|
956
|
-
} else if (first != '.') {
|
957
|
-
throw new BaseException(("Link \"" + ListWrapper.toJSON(linkParams) + "\" must start with \"/\", \"./\", or \"../\""));
|
958
|
-
}
|
959
|
-
if (rest[rest.length - 1] == '') {
|
960
|
-
ListWrapper.removeLast(rest);
|
961
|
-
}
|
962
|
-
if (rest.length < 1) {
|
963
|
-
var msg = ("Link \"" + ListWrapper.toJSON(linkParams) + "\" must include a route name.");
|
964
|
-
throw new BaseException(msg);
|
965
|
-
}
|
966
|
-
var url = '';
|
967
|
-
if (isPresent(router.parent) && isPresent(router.parent._currentInstruction)) {
|
968
|
-
url = router.parent._currentInstruction.capturedUrl;
|
969
|
-
}
|
970
|
-
return url + '/' + this.registry.generate(rest, router.hostComponent);
|
971
|
-
}
|
972
|
-
}, {});
|
973
|
-
}());
|
974
|
-
$__export("Router", Router);
|
975
|
-
RootRouter = (function($__super) {
|
976
|
-
function RootRouter(registry, pipeline, location, hostComponent) {
|
977
|
-
var $__0;
|
978
|
-
$traceurRuntime.superConstructor(RootRouter).call(this, registry, pipeline, null, hostComponent);
|
979
|
-
this._location = location;
|
980
|
-
this._location.subscribe(($__0 = this, function(change) {
|
981
|
-
return $__0.navigate(change['url']);
|
982
|
-
}));
|
983
|
-
this.registry.configFromComponent(hostComponent);
|
984
|
-
this.navigate(location.path());
|
985
|
-
}
|
986
|
-
return ($traceurRuntime.createClass)(RootRouter, {commit: function(instruction) {
|
987
|
-
var $__0 = this;
|
988
|
-
return $traceurRuntime.superGet(this, RootRouter.prototype, "commit").call(this, instruction).then((function(_) {
|
989
|
-
$__0._location.go(instruction.accumulatedUrl);
|
990
|
-
}));
|
991
|
-
}}, {}, $__super);
|
992
|
-
}(Router));
|
993
|
-
$__export("RootRouter", RootRouter);
|
994
|
-
ChildRouter = (function($__super) {
|
995
|
-
function ChildRouter(parent, hostComponent) {
|
996
|
-
$traceurRuntime.superConstructor(ChildRouter).call(this, parent.registry, parent._pipeline, parent, hostComponent);
|
997
|
-
this.parent = parent;
|
998
|
-
}
|
999
|
-
return ($traceurRuntime.createClass)(ChildRouter, {navigate: function(url) {
|
1000
|
-
return this.parent.navigate(url);
|
1001
|
-
}}, {}, $__super);
|
1002
|
-
}(Router));
|
1003
|
-
SLASH = new RegExp('/');
|
1004
985
|
}
|
1005
986
|
};
|
1006
987
|
});
|
@@ -1213,6 +1194,284 @@ System.register("angular2/src/router/route_recognizer", ["angular2/src/facade/la
|
|
1213
1194
|
};
|
1214
1195
|
});
|
1215
1196
|
|
1197
|
+
System.register("angular2/src/router/router", ["angular2/src/facade/async", "angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/router/route_lifecycle_reflector"], function($__export) {
|
1198
|
+
"use strict";
|
1199
|
+
var __moduleName = "angular2/src/router/router";
|
1200
|
+
var PromiseWrapper,
|
1201
|
+
EventEmitter,
|
1202
|
+
ObservableWrapper,
|
1203
|
+
ListWrapper,
|
1204
|
+
isBlank,
|
1205
|
+
isString,
|
1206
|
+
StringWrapper,
|
1207
|
+
isPresent,
|
1208
|
+
isArray,
|
1209
|
+
BaseException,
|
1210
|
+
getCanActivateHook,
|
1211
|
+
_resolveToTrue,
|
1212
|
+
_resolveToFalse,
|
1213
|
+
Router,
|
1214
|
+
RootRouter,
|
1215
|
+
ChildRouter,
|
1216
|
+
SLASH;
|
1217
|
+
function splitAndFlattenLinkParams(linkParams) {
|
1218
|
+
return ListWrapper.reduce(linkParams, (function(accumulation, item) {
|
1219
|
+
if (isString(item)) {
|
1220
|
+
return ListWrapper.concat(accumulation, StringWrapper.split(item, SLASH));
|
1221
|
+
}
|
1222
|
+
accumulation.push(item);
|
1223
|
+
return accumulation;
|
1224
|
+
}), []);
|
1225
|
+
}
|
1226
|
+
function canActivateOne(nextInstruction, currentInstruction) {
|
1227
|
+
var next = _resolveToTrue;
|
1228
|
+
if (isPresent(nextInstruction.child)) {
|
1229
|
+
next = canActivateOne(nextInstruction.child, isPresent(currentInstruction) ? currentInstruction.child : null);
|
1230
|
+
}
|
1231
|
+
return next.then((function(res) {
|
1232
|
+
if (res == false) {
|
1233
|
+
return false;
|
1234
|
+
}
|
1235
|
+
if (nextInstruction.reuse) {
|
1236
|
+
return true;
|
1237
|
+
}
|
1238
|
+
var hook = getCanActivateHook(nextInstruction.component);
|
1239
|
+
if (isPresent(hook)) {
|
1240
|
+
return hook(nextInstruction, currentInstruction);
|
1241
|
+
}
|
1242
|
+
return true;
|
1243
|
+
}));
|
1244
|
+
}
|
1245
|
+
return {
|
1246
|
+
setters: [function($__m) {
|
1247
|
+
PromiseWrapper = $__m.PromiseWrapper;
|
1248
|
+
EventEmitter = $__m.EventEmitter;
|
1249
|
+
ObservableWrapper = $__m.ObservableWrapper;
|
1250
|
+
}, function($__m) {
|
1251
|
+
ListWrapper = $__m.ListWrapper;
|
1252
|
+
}, function($__m) {
|
1253
|
+
isBlank = $__m.isBlank;
|
1254
|
+
isString = $__m.isString;
|
1255
|
+
StringWrapper = $__m.StringWrapper;
|
1256
|
+
isPresent = $__m.isPresent;
|
1257
|
+
isArray = $__m.isArray;
|
1258
|
+
BaseException = $__m.BaseException;
|
1259
|
+
}, function($__m) {
|
1260
|
+
getCanActivateHook = $__m.getCanActivateHook;
|
1261
|
+
}],
|
1262
|
+
execute: function() {
|
1263
|
+
_resolveToTrue = PromiseWrapper.resolve(true);
|
1264
|
+
_resolveToFalse = PromiseWrapper.resolve(false);
|
1265
|
+
Router = (function() {
|
1266
|
+
function Router(registry, _pipeline, parent, hostComponent) {
|
1267
|
+
this.registry = registry;
|
1268
|
+
this._pipeline = _pipeline;
|
1269
|
+
this.parent = parent;
|
1270
|
+
this.hostComponent = hostComponent;
|
1271
|
+
this.navigating = false;
|
1272
|
+
this._currentInstruction = null;
|
1273
|
+
this._currentNavigation = _resolveToTrue;
|
1274
|
+
this._outlet = null;
|
1275
|
+
this._subject = new EventEmitter();
|
1276
|
+
}
|
1277
|
+
return ($traceurRuntime.createClass)(Router, {
|
1278
|
+
childRouter: function(hostComponent) {
|
1279
|
+
return new ChildRouter(this, hostComponent);
|
1280
|
+
},
|
1281
|
+
registerOutlet: function(outlet) {
|
1282
|
+
this._outlet = outlet;
|
1283
|
+
if (isPresent(this._currentInstruction)) {
|
1284
|
+
return outlet.commit(this._currentInstruction);
|
1285
|
+
}
|
1286
|
+
return _resolveToTrue;
|
1287
|
+
},
|
1288
|
+
config: function(config) {
|
1289
|
+
var $__0 = this;
|
1290
|
+
if (isArray(config)) {
|
1291
|
+
config.forEach((function(configObject) {
|
1292
|
+
$__0.registry.config($__0.hostComponent, configObject);
|
1293
|
+
}));
|
1294
|
+
} else {
|
1295
|
+
this.registry.config(this.hostComponent, config);
|
1296
|
+
}
|
1297
|
+
return this.renavigate();
|
1298
|
+
},
|
1299
|
+
navigate: function(url) {
|
1300
|
+
var $__0 = this;
|
1301
|
+
return this._currentNavigation = this._currentNavigation.then((function(_) {
|
1302
|
+
$__0.lastNavigationAttempt = url;
|
1303
|
+
$__0._startNavigating();
|
1304
|
+
return $__0._afterPromiseFinishNavigating($__0.recognize(url).then((function(matchedInstruction) {
|
1305
|
+
if (isBlank(matchedInstruction)) {
|
1306
|
+
return false;
|
1307
|
+
}
|
1308
|
+
return $__0._reuse(matchedInstruction).then((function(_) {
|
1309
|
+
return $__0._canActivate(matchedInstruction);
|
1310
|
+
})).then((function(result) {
|
1311
|
+
if (!result) {
|
1312
|
+
return false;
|
1313
|
+
}
|
1314
|
+
return $__0._canDeactivate(matchedInstruction).then((function(result) {
|
1315
|
+
if (result) {
|
1316
|
+
return $__0.commit(matchedInstruction).then((function(_) {
|
1317
|
+
$__0._emitNavigationFinish(matchedInstruction.accumulatedUrl);
|
1318
|
+
return true;
|
1319
|
+
}));
|
1320
|
+
}
|
1321
|
+
}));
|
1322
|
+
}));
|
1323
|
+
})));
|
1324
|
+
}));
|
1325
|
+
},
|
1326
|
+
_emitNavigationFinish: function(url) {
|
1327
|
+
ObservableWrapper.callNext(this._subject, url);
|
1328
|
+
},
|
1329
|
+
_afterPromiseFinishNavigating: function(promise) {
|
1330
|
+
var $__0 = this;
|
1331
|
+
return PromiseWrapper.catchError(promise.then((function(_) {
|
1332
|
+
return $__0._finishNavigating();
|
1333
|
+
})), (function(err) {
|
1334
|
+
$__0._finishNavigating();
|
1335
|
+
throw err;
|
1336
|
+
}));
|
1337
|
+
},
|
1338
|
+
_reuse: function(instruction) {
|
1339
|
+
var $__0 = this;
|
1340
|
+
if (isBlank(this._outlet)) {
|
1341
|
+
return _resolveToFalse;
|
1342
|
+
}
|
1343
|
+
return this._outlet.canReuse(instruction).then((function(result) {
|
1344
|
+
instruction.reuse = result;
|
1345
|
+
if (isPresent($__0._outlet.childRouter) && isPresent(instruction.child)) {
|
1346
|
+
return $__0._outlet.childRouter._reuse(instruction.child);
|
1347
|
+
}
|
1348
|
+
}));
|
1349
|
+
},
|
1350
|
+
_canActivate: function(instruction) {
|
1351
|
+
return canActivateOne(instruction, this._currentInstruction);
|
1352
|
+
},
|
1353
|
+
_canDeactivate: function(instruction) {
|
1354
|
+
var $__0 = this;
|
1355
|
+
if (isBlank(this._outlet)) {
|
1356
|
+
return _resolveToTrue;
|
1357
|
+
}
|
1358
|
+
var next;
|
1359
|
+
if (isPresent(instruction) && instruction.reuse) {
|
1360
|
+
next = _resolveToTrue;
|
1361
|
+
} else {
|
1362
|
+
next = this._outlet.canDeactivate(instruction);
|
1363
|
+
}
|
1364
|
+
return next.then((function(result) {
|
1365
|
+
if (result == false) {
|
1366
|
+
return false;
|
1367
|
+
}
|
1368
|
+
if (isPresent($__0._outlet.childRouter)) {
|
1369
|
+
return $__0._outlet.childRouter._canDeactivate(isPresent(instruction) ? instruction.child : null);
|
1370
|
+
}
|
1371
|
+
return true;
|
1372
|
+
}));
|
1373
|
+
},
|
1374
|
+
commit: function(instruction) {
|
1375
|
+
this._currentInstruction = instruction;
|
1376
|
+
if (isPresent(this._outlet)) {
|
1377
|
+
return this._outlet.commit(instruction);
|
1378
|
+
}
|
1379
|
+
return _resolveToTrue;
|
1380
|
+
},
|
1381
|
+
_startNavigating: function() {
|
1382
|
+
this.navigating = true;
|
1383
|
+
},
|
1384
|
+
_finishNavigating: function() {
|
1385
|
+
this.navigating = false;
|
1386
|
+
},
|
1387
|
+
subscribe: function(onNext) {
|
1388
|
+
ObservableWrapper.subscribe(this._subject, onNext);
|
1389
|
+
},
|
1390
|
+
deactivate: function(instruction) {
|
1391
|
+
if (isPresent(this._outlet)) {
|
1392
|
+
return this._outlet.deactivate(instruction);
|
1393
|
+
}
|
1394
|
+
return _resolveToTrue;
|
1395
|
+
},
|
1396
|
+
recognize: function(url) {
|
1397
|
+
return this.registry.recognize(url, this.hostComponent);
|
1398
|
+
},
|
1399
|
+
renavigate: function() {
|
1400
|
+
if (isBlank(this.lastNavigationAttempt)) {
|
1401
|
+
return this._currentNavigation;
|
1402
|
+
}
|
1403
|
+
return this.navigate(this.lastNavigationAttempt);
|
1404
|
+
},
|
1405
|
+
generate: function(linkParams) {
|
1406
|
+
var normalizedLinkParams = splitAndFlattenLinkParams(linkParams);
|
1407
|
+
var first = ListWrapper.first(normalizedLinkParams);
|
1408
|
+
var rest = ListWrapper.slice(normalizedLinkParams, 1);
|
1409
|
+
var router = this;
|
1410
|
+
if (first == '') {
|
1411
|
+
while (isPresent(router.parent)) {
|
1412
|
+
router = router.parent;
|
1413
|
+
}
|
1414
|
+
} else if (first == '..') {
|
1415
|
+
router = router.parent;
|
1416
|
+
while (ListWrapper.first(rest) == '..') {
|
1417
|
+
rest = ListWrapper.slice(rest, 1);
|
1418
|
+
router = router.parent;
|
1419
|
+
if (isBlank(router)) {
|
1420
|
+
throw new BaseException(("Link \"" + ListWrapper.toJSON(linkParams) + "\" has too many \"../\" segments."));
|
1421
|
+
}
|
1422
|
+
}
|
1423
|
+
} else if (first != '.') {
|
1424
|
+
throw new BaseException(("Link \"" + ListWrapper.toJSON(linkParams) + "\" must start with \"/\", \"./\", or \"../\""));
|
1425
|
+
}
|
1426
|
+
if (rest[rest.length - 1] == '') {
|
1427
|
+
ListWrapper.removeLast(rest);
|
1428
|
+
}
|
1429
|
+
if (rest.length < 1) {
|
1430
|
+
var msg = ("Link \"" + ListWrapper.toJSON(linkParams) + "\" must include a route name.");
|
1431
|
+
throw new BaseException(msg);
|
1432
|
+
}
|
1433
|
+
var url = '';
|
1434
|
+
if (isPresent(router.parent) && isPresent(router.parent._currentInstruction)) {
|
1435
|
+
url = router.parent._currentInstruction.capturedUrl;
|
1436
|
+
}
|
1437
|
+
return url + '/' + this.registry.generate(rest, router.hostComponent);
|
1438
|
+
}
|
1439
|
+
}, {});
|
1440
|
+
}());
|
1441
|
+
$__export("Router", Router);
|
1442
|
+
RootRouter = (function($__super) {
|
1443
|
+
function RootRouter(registry, pipeline, location, hostComponent) {
|
1444
|
+
var $__0;
|
1445
|
+
$traceurRuntime.superConstructor(RootRouter).call(this, registry, pipeline, null, hostComponent);
|
1446
|
+
this._location = location;
|
1447
|
+
this._location.subscribe(($__0 = this, function(change) {
|
1448
|
+
return $__0.navigate(change['url']);
|
1449
|
+
}));
|
1450
|
+
this.registry.configFromComponent(hostComponent);
|
1451
|
+
this.navigate(location.path());
|
1452
|
+
}
|
1453
|
+
return ($traceurRuntime.createClass)(RootRouter, {commit: function(instruction) {
|
1454
|
+
var $__0 = this;
|
1455
|
+
return $traceurRuntime.superGet(this, RootRouter.prototype, "commit").call(this, instruction).then((function(_) {
|
1456
|
+
$__0._location.go(instruction.accumulatedUrl);
|
1457
|
+
}));
|
1458
|
+
}}, {}, $__super);
|
1459
|
+
}(Router));
|
1460
|
+
$__export("RootRouter", RootRouter);
|
1461
|
+
ChildRouter = (function($__super) {
|
1462
|
+
function ChildRouter(parent, hostComponent) {
|
1463
|
+
$traceurRuntime.superConstructor(ChildRouter).call(this, parent.registry, parent._pipeline, parent, hostComponent);
|
1464
|
+
this.parent = parent;
|
1465
|
+
}
|
1466
|
+
return ($traceurRuntime.createClass)(ChildRouter, {navigate: function(url) {
|
1467
|
+
return this.parent.navigate(url);
|
1468
|
+
}}, {}, $__super);
|
1469
|
+
}(Router));
|
1470
|
+
SLASH = new RegExp('/');
|
1471
|
+
}
|
1472
|
+
};
|
1473
|
+
});
|
1474
|
+
|
1216
1475
|
System.register("angular2/src/router/route_registry", ["angular2/src/router/route_recognizer", "angular2/src/router/instruction", "angular2/src/facade/collection", "angular2/src/facade/async", "angular2/src/facade/lang", "angular2/src/router/route_config_impl", "angular2/src/reflection/reflection", "angular2/di"], function($__export) {
|
1217
1476
|
"use strict";
|
1218
1477
|
var __moduleName = "angular2/src/router/route_registry";
|
@@ -1413,7 +1672,11 @@ System.register("angular2/src/router/route_registry", ["angular2/src/router/rout
|
|
1413
1672
|
return handler.resolveComponentType().then((function(componentType) {
|
1414
1673
|
$__0.configFromComponent(componentType);
|
1415
1674
|
if (partialMatch.unmatchedUrl.length == 0) {
|
1416
|
-
|
1675
|
+
if (recognizer.terminal) {
|
1676
|
+
return new Instruction(componentType, partialMatch.matchedUrl, recognizer);
|
1677
|
+
} else {
|
1678
|
+
return null;
|
1679
|
+
}
|
1417
1680
|
}
|
1418
1681
|
return $__0.recognize(partialMatch.unmatchedUrl, componentType).then((function(childInstruction) {
|
1419
1682
|
if (isBlank(childInstruction)) {
|
@@ -1461,13 +1724,15 @@ System.register("angular2/src/router/route_registry", ["angular2/src/router/rout
|
|
1461
1724
|
};
|
1462
1725
|
});
|
1463
1726
|
|
1464
|
-
System.register("angular2/src/router/router_outlet", ["angular2/src/facade/async", "angular2/src/facade/lang", "angular2/src/core/annotations/decorators", "angular2/core", "angular2/di", "angular2/src/router/router", "angular2/src/router/instruction"], function($__export) {
|
1727
|
+
System.register("angular2/src/router/router_outlet", ["angular2/src/facade/async", "angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/core/annotations/decorators", "angular2/core", "angular2/di", "angular2/src/router/router", "angular2/src/router/instruction", "angular2/src/router/lifecycle_annotations", "angular2/src/router/route_lifecycle_reflector"], function($__export) {
|
1465
1728
|
"use strict";
|
1466
1729
|
var __moduleName = "angular2/src/router/router_outlet";
|
1467
1730
|
var __decorate,
|
1468
1731
|
__metadata,
|
1469
1732
|
__param,
|
1470
1733
|
PromiseWrapper,
|
1734
|
+
StringMapWrapper,
|
1735
|
+
isBlank,
|
1471
1736
|
isPresent,
|
1472
1737
|
Directive,
|
1473
1738
|
Attribute,
|
@@ -1477,11 +1742,16 @@ System.register("angular2/src/router/router_outlet", ["angular2/src/facade/async
|
|
1477
1742
|
bind,
|
1478
1743
|
routerMod,
|
1479
1744
|
RouteParams,
|
1745
|
+
hookMod,
|
1746
|
+
hasLifecycleHook,
|
1480
1747
|
RouterOutlet;
|
1481
1748
|
return {
|
1482
1749
|
setters: [function($__m) {
|
1483
1750
|
PromiseWrapper = $__m.PromiseWrapper;
|
1484
1751
|
}, function($__m) {
|
1752
|
+
StringMapWrapper = $__m.StringMapWrapper;
|
1753
|
+
}, function($__m) {
|
1754
|
+
isBlank = $__m.isBlank;
|
1485
1755
|
isPresent = $__m.isPresent;
|
1486
1756
|
}, function($__m) {
|
1487
1757
|
Directive = $__m.Directive;
|
@@ -1496,6 +1766,10 @@ System.register("angular2/src/router/router_outlet", ["angular2/src/facade/async
|
|
1496
1766
|
routerMod = $__m;
|
1497
1767
|
}, function($__m) {
|
1498
1768
|
RouteParams = $__m.RouteParams;
|
1769
|
+
}, function($__m) {
|
1770
|
+
hookMod = $__m;
|
1771
|
+
}, function($__m) {
|
1772
|
+
hasLifecycleHook = $__m.hasLifecycleHook;
|
1499
1773
|
}],
|
1500
1774
|
execute: function() {
|
1501
1775
|
__decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
@@ -1529,38 +1803,82 @@ System.register("angular2/src/router/router_outlet", ["angular2/src/facade/async
|
|
1529
1803
|
this._elementRef = _elementRef;
|
1530
1804
|
this._loader = _loader;
|
1531
1805
|
this._parentRouter = _parentRouter;
|
1532
|
-
this.
|
1806
|
+
this.childRouter = null;
|
1533
1807
|
this._componentRef = null;
|
1534
1808
|
this._currentInstruction = null;
|
1535
1809
|
this._parentRouter.registerOutlet(this);
|
1536
1810
|
}, {
|
1537
|
-
|
1811
|
+
commit: function(instruction) {
|
1538
1812
|
var $__0 = this;
|
1539
|
-
|
1540
|
-
|
1813
|
+
var next;
|
1814
|
+
if (instruction.reuse) {
|
1815
|
+
next = this._reuse(instruction);
|
1816
|
+
} else {
|
1817
|
+
next = this.deactivate(instruction).then((function(_) {
|
1818
|
+
return $__0._activate(instruction);
|
1819
|
+
}));
|
1820
|
+
}
|
1821
|
+
return next.then((function(_) {
|
1822
|
+
return $__0._commitChild(instruction);
|
1823
|
+
}));
|
1824
|
+
},
|
1825
|
+
_commitChild: function(instruction) {
|
1826
|
+
if (isPresent(this.childRouter)) {
|
1827
|
+
return this.childRouter.commit(instruction.child);
|
1828
|
+
} else {
|
1829
|
+
return PromiseWrapper.resolve(true);
|
1541
1830
|
}
|
1831
|
+
},
|
1832
|
+
_activate: function(instruction) {
|
1833
|
+
var $__0 = this;
|
1834
|
+
var previousInstruction = this._currentInstruction;
|
1542
1835
|
this._currentInstruction = instruction;
|
1543
|
-
this.
|
1544
|
-
var
|
1545
|
-
|
1546
|
-
return this.deactivate().then((function(_) {
|
1547
|
-
return $__0._loader.loadNextToLocation(instruction.component, $__0._elementRef, bindings);
|
1548
|
-
})).then((function(componentRef) {
|
1836
|
+
this.childRouter = this._parentRouter.childRouter(instruction.component);
|
1837
|
+
var bindings = Injector.resolve([bind(RouteParams).toValue(new RouteParams(instruction.params())), bind(routerMod.Router).toValue(this.childRouter)]);
|
1838
|
+
return this._loader.loadNextToLocation(instruction.component, this._elementRef, bindings).then((function(componentRef) {
|
1549
1839
|
$__0._componentRef = componentRef;
|
1550
|
-
|
1840
|
+
if (hasLifecycleHook(hookMod.onActivate, instruction.component)) {
|
1841
|
+
return $__0._componentRef.instance.onActivate(instruction, previousInstruction);
|
1842
|
+
}
|
1551
1843
|
}));
|
1552
1844
|
},
|
1553
|
-
|
1845
|
+
canDeactivate: function(nextInstruction) {
|
1846
|
+
if (isBlank(this._currentInstruction)) {
|
1847
|
+
return PromiseWrapper.resolve(true);
|
1848
|
+
}
|
1849
|
+
if (hasLifecycleHook(hookMod.canDeactivate, this._currentInstruction.component)) {
|
1850
|
+
return PromiseWrapper.resolve(this._componentRef.instance.canDeactivate(nextInstruction, this._currentInstruction));
|
1851
|
+
}
|
1852
|
+
return PromiseWrapper.resolve(true);
|
1853
|
+
},
|
1854
|
+
canReuse: function(nextInstruction) {
|
1855
|
+
var result;
|
1856
|
+
if (isBlank(this._currentInstruction) || this._currentInstruction.component != nextInstruction.component) {
|
1857
|
+
result = false;
|
1858
|
+
} else if (hasLifecycleHook(hookMod.canReuse, this._currentInstruction.component)) {
|
1859
|
+
result = this._componentRef.instance.canReuse(nextInstruction, this._currentInstruction);
|
1860
|
+
} else {
|
1861
|
+
result = nextInstruction == this._currentInstruction || StringMapWrapper.equals(nextInstruction.params(), this._currentInstruction.params());
|
1862
|
+
}
|
1863
|
+
return PromiseWrapper.resolve(result);
|
1864
|
+
},
|
1865
|
+
_reuse: function(instruction) {
|
1866
|
+
var previousInstruction = this._currentInstruction;
|
1867
|
+
this._currentInstruction = instruction;
|
1868
|
+
return PromiseWrapper.resolve(hasLifecycleHook(hookMod.onReuse, this._currentInstruction.component) ? this._componentRef.instance.onReuse(instruction, previousInstruction) : true);
|
1869
|
+
},
|
1870
|
+
deactivate: function(nextInstruction) {
|
1554
1871
|
var $__0 = this;
|
1555
|
-
return (isPresent(this.
|
1872
|
+
return (isPresent(this.childRouter) ? this.childRouter.deactivate(isPresent(nextInstruction) ? nextInstruction.child : null) : PromiseWrapper.resolve(true)).then((function(_) {
|
1873
|
+
if (isPresent($__0._componentRef) && isPresent($__0._currentInstruction) && hasLifecycleHook(hookMod.onDeactivate, $__0._currentInstruction.component)) {
|
1874
|
+
return $__0._componentRef.instance.onDeactivate(nextInstruction, $__0._currentInstruction);
|
1875
|
+
}
|
1876
|
+
})).then((function(_) {
|
1556
1877
|
if (isPresent($__0._componentRef)) {
|
1557
1878
|
$__0._componentRef.dispose();
|
1558
1879
|
$__0._componentRef = null;
|
1559
1880
|
}
|
1560
1881
|
}));
|
1561
|
-
},
|
1562
|
-
canDeactivate: function(instruction) {
|
1563
|
-
return PromiseWrapper.resolve(true);
|
1564
1882
|
}
|
1565
1883
|
}, {}));
|
1566
1884
|
$__export("RouterOutlet", RouterOutlet);
|
@@ -1569,7 +1887,7 @@ System.register("angular2/src/router/router_outlet", ["angular2/src/facade/async
|
|
1569
1887
|
};
|
1570
1888
|
});
|
1571
1889
|
|
1572
|
-
System.register("angular2/router", ["angular2/src/router/router", "angular2/src/router/router_outlet", "angular2/src/router/router_link", "angular2/src/router/instruction", "angular2/src/router/route_registry", "angular2/src/router/location_strategy", "angular2/src/router/hash_location_strategy", "angular2/src/router/html5_location_strategy", "angular2/src/router/location", "angular2/src/router/pipeline", "angular2/src/router/route_config_decorator", "angular2/src/core/application_tokens", "angular2/di", "angular2/src/facade/lang"], function($__export) {
|
1890
|
+
System.register("angular2/router", ["angular2/src/router/router", "angular2/src/router/router_outlet", "angular2/src/router/router_link", "angular2/src/router/instruction", "angular2/src/router/route_registry", "angular2/src/router/location_strategy", "angular2/src/router/hash_location_strategy", "angular2/src/router/html5_location_strategy", "angular2/src/router/location", "angular2/src/router/pipeline", "angular2/src/router/route_config_decorator", "angular2/src/router/lifecycle_annotations", "angular2/src/core/application_tokens", "angular2/di", "angular2/src/facade/lang"], function($__export) {
|
1573
1891
|
"use strict";
|
1574
1892
|
var __moduleName = "angular2/router";
|
1575
1893
|
var LocationStrategy,
|
@@ -1628,6 +1946,8 @@ System.register("angular2/router", ["angular2/src/router/router", "angular2/src/
|
|
1628
1946
|
if (!$__exportNames[p])
|
1629
1947
|
$__export(p, $__m[p]);
|
1630
1948
|
});
|
1949
|
+
}, function($__m) {
|
1950
|
+
$__export("CanActivate", $__m.CanActivate);
|
1631
1951
|
}, function($__m) {
|
1632
1952
|
appComponentTypeToken = $__m.appComponentTypeToken;
|
1633
1953
|
}, function($__m) {
|