1 | class Directive_Traceur {
|
2 | constructor(options) {
|
3 | this.template = options.template;
|
4 | this.selector = options.selector;
|
5 | this.injections = options.injections || [];
|
6 | this.scope = options.scope;
|
7 | }
|
8 | }
|
9 |
|
10 | class Route_Traceur {
|
11 | constructor(options) {
|
12 | this.scopeName = options.scopeName;
|
13 | this.route = options.route;
|
14 | this.params = options.params || [];
|
15 | this.parameterNames = [];
|
16 |
|
17 | this.routeArray = options.route.split("/");
|
18 | for (let i = 0; i < this.routeArray.length; i++) {
|
19 | var n = this.routeArray[i];
|
20 | if (n[0] == "$") {
|
21 | this.parameterNames.push(n.substr(1));
|
22 | } else {
|
23 | this.parameterNames.push(undefined);
|
24 | }
|
25 | }
|
26 | }
|
27 | }
|
28 |
|
29 |
|
30 | function Directive(options) {
|
31 | return function(target) {
|
32 | target.annotations = [options];
|
33 | target.template = options.template;
|
34 | target.selector = options.selector;
|
35 | target.injections = options.injections || [];
|
36 | target.scope = options.scope;
|
37 |
|
38 | return target;
|
39 | };
|
40 | }
|
41 |
|
42 |
|
43 | function Route(options) {
|
44 | return function(target) {
|
45 | target.annotations = [options];
|
46 | target.scopeName = options.scopeName;
|
47 | target.route = options.route;
|
48 | target.params = options.params || [];
|
49 | target.parameterNames = [];
|
50 |
|
51 | target.routeArray = options.routeArray = options.route.split("/");
|
52 | for (let i = 0; i < target.routeArray.length; i++) {
|
53 | var n = target.routeArray[i];
|
54 | if (n[0] == "$") {
|
55 | target.parameterNames.push(n.substr(1));
|
56 | } else {
|
57 | target.parameterNames.push(undefined);
|
58 | }
|
59 | }
|
60 | };
|
61 | }
|
62 |
|
63 |
|
64 | export function globalify() {
|
65 |
|
66 | if (typeof $traceurRuntime !== "undefined") {
|
67 | window.Directive = Directive_Traceur;
|
68 | window.Route = Route_Traceur;
|
69 | } else {
|
70 | window.Directive = Directive;
|
71 | window.Route = Route;
|
72 | }
|
73 |
|
74 | }
|
75 | globalify(); |
\ | No newline at end of file |