1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var __metadata = (this && this.__metadata) || function (k, v) {
|
9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10 | };
|
11 | var core_1 = require('@angular/core');
|
12 | var router_1 = require('@angular/router');
|
13 | var current_api_1 = require('./current-api');
|
14 | var dynamic_base_module_1 = require('./dynamic-base-module');
|
15 | var page_title_service_1 = require('./page-title.service');
|
16 | var ApiPageComponent = (function () {
|
17 | function ApiPageComponent(route, viewContainerRef, compiler, activated, router, seo) {
|
18 | this.route = route;
|
19 | this.viewContainerRef = viewContainerRef;
|
20 | this.compiler = compiler;
|
21 | this.activated = activated;
|
22 | this.router = router;
|
23 | this.seo = seo;
|
24 | }
|
25 | ApiPageComponent.prototype.fixLinks = function (content, urlPrefix) {
|
26 | var path = content.replace(/href="(#.*?)"/g, function (match, group) {
|
27 | return 'href="' + urlPrefix + group + '"';
|
28 | });
|
29 | if (path.charAt(0) === '/') {
|
30 | path = path.substr(1);
|
31 | }
|
32 | return path;
|
33 | };
|
34 | ApiPageComponent.prototype.ngOnInit = function () {
|
35 | var _this = this;
|
36 | this.route.data.subscribe(function (data) {
|
37 | _this.activated.updateCurrentApi(data);
|
38 | var content = _this.fixLinks(data.resolveData.jsDoc, _this.router.url).replace(/name="(.*?)"/g, function (match, group) {
|
39 | return 'name="' + group + '" class="anchor-offset"';
|
40 | });
|
41 | _this.seo.setSeoDescription(content);
|
42 | _this.seo.addKeywords([
|
43 | 'api',
|
44 | 'api-docs',
|
45 | 'reference',
|
46 | 'usage'
|
47 | ].concat((data.apiFile.apiTitle || data.apiFile.name || ' ').split(' ') || []));
|
48 | var DynamicComponent = (function () {
|
49 | function DynamicComponent() {
|
50 | }
|
51 | DynamicComponent = __decorate([
|
52 | core_1.Component({
|
53 | selector: 'tutorial-container',
|
54 | template: content
|
55 | }),
|
56 | __metadata('design:paramtypes', [])
|
57 | ], DynamicComponent);
|
58 | return DynamicComponent;
|
59 | }());
|
60 | var DynamicModule = (function () {
|
61 | function DynamicModule() {
|
62 | }
|
63 | DynamicModule = __decorate([
|
64 | core_1.NgModule({
|
65 | imports: [dynamic_base_module_1.DummyModule],
|
66 | declarations: [DynamicComponent]
|
67 | }),
|
68 | __metadata('design:paramtypes', [])
|
69 | ], DynamicModule);
|
70 | return DynamicModule;
|
71 | }());
|
72 | var factories = _this.compiler.compileModuleAndAllComponentsSync(DynamicModule);
|
73 | var compFactory = factories.componentFactories.find(function (x) { return x.componentType === DynamicComponent; });
|
74 | var injector = core_1.ReflectiveInjector.fromResolvedProviders([], _this.viewContainerRef.parentInjector);
|
75 | _this.viewContainerRef.createComponent(compFactory, 0, injector, []);
|
76 | });
|
77 | };
|
78 | ApiPageComponent = __decorate([
|
79 | core_1.Component({
|
80 | selector: 'api-page',
|
81 | template: ""
|
82 | }),
|
83 | core_1.Injectable(),
|
84 | __metadata('design:paramtypes', [router_1.ActivatedRoute, core_1.ViewContainerRef, core_1.Compiler, current_api_1.ActivatedApi, router_1.Router, page_title_service_1.PageTitleService])
|
85 | ], ApiPageComponent);
|
86 | return ApiPageComponent;
|
87 | }());
|
88 | exports.ApiPageComponent = ApiPageComponent;
|
89 |
|
\ | No newline at end of file |