updated angular to rc + refactor

This commit is contained in:
Roman Hotsiy 2016-05-06 00:48:41 +03:00
parent a272dacc95
commit d2eca9fcde
59 changed files with 204 additions and 193 deletions

View File

@ -41,6 +41,7 @@ gulp.task('inlineTemplates', ['sass'], function() {
var JS_DEV_DEPS = [ var JS_DEV_DEPS = [
'lib/utils/browser-update.js', 'lib/utils/browser-update.js',
'node_modules/zone.js/dist/zone.js', 'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/reflect-metadata/Reflect.js', 'node_modules/reflect-metadata/Reflect.js',
'node_modules/babel-polyfill/dist/polyfill.js' 'node_modules/babel-polyfill/dist/polyfill.js'
]; ];

View File

@ -9,7 +9,7 @@ import OptionsManager from '../../options';
templateUrl: './lib/components/ApiInfo/api-info.html' templateUrl: './lib/components/ApiInfo/api-info.html'
}) })
@Reflect.metadata('parameters', [[SchemaManager], [OptionsManager]]) @Reflect.metadata('parameters', [[SchemaManager], [OptionsManager]])
export default class ApiInfo extends BaseComponent { export class ApiInfo extends BaseComponent {
constructor(schemaMgr, optionsMgr) { constructor(schemaMgr, optionsMgr) {
super(schemaMgr); super(schemaMgr);
this.optionsMgr = optionsMgr; this.optionsMgr = optionsMgr;

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
.api-info-header { .api-info-header {
font-weight: normal; font-weight: normal;

View File

@ -4,13 +4,14 @@ import { getChildDebugElement } from 'tests/helpers';
import {Component, provide} from '@angular/core'; import {Component, provide} from '@angular/core';
import { import {
TestComponentBuilder,
async,
inject, inject,
async,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
} from '@angular/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import ApiInfo from 'lib/components/ApiInfo/api-info'; import ApiInfo from 'lib/components/ApiInfo/api-info';
import SchemaManager from 'lib/utils/SchemaManager'; import SchemaManager from 'lib/utils/SchemaManager';

View File

@ -7,7 +7,7 @@ import {RedocComponent, BaseComponent} from '../base';
styleUrls: ['./lib/components/ApiLogo/api-logo.css'], styleUrls: ['./lib/components/ApiLogo/api-logo.css'],
templateUrl: './lib/components/ApiLogo/api-logo.html' templateUrl: './lib/components/ApiLogo/api-logo.html'
}) })
export default class ApiLogo extends BaseComponent { export class ApiLogo extends BaseComponent {
constructor(schemaMgr) { constructor(schemaMgr) {
super(schemaMgr); super(schemaMgr);
} }

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
img { img {
max-height: 150px; max-height: 150px;

View File

@ -4,13 +4,14 @@ import { getChildDebugElement } from 'tests/helpers';
import {Component, provide} from '@angular/core'; import {Component, provide} from '@angular/core';
import { import {
TestComponentBuilder,
async,
inject, inject,
async,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
} from '@angular/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import ApiLogo from 'lib/components/ApiLogo/api-logo'; import ApiLogo from 'lib/components/ApiLogo/api-logo';
import SchemaManager from 'lib/utils/SchemaManager'; import SchemaManager from 'lib/utils/SchemaManager';

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
$lines-width: 1px; $lines-width: 1px;
$bullet-size: 1px; $bullet-size: 1px;
$cell-spacing: 25px; $cell-spacing: 25px;

View File

@ -4,7 +4,7 @@ import {Component, ElementRef, ViewContainerRef} from '@angular/core';
import {CORE_DIRECTIVES} from '@angular/common'; import {CORE_DIRECTIVES} from '@angular/common';
import {DynamicComponentLoader} from '@angular/core'; import {DynamicComponentLoader} from '@angular/core';
import JsonSchema from './json-schema'; import {JsonSchema} from './json-schema';
import OptionsManager from '../../options'; import OptionsManager from '../../options';
import SchemaManager from '../../utils/SchemaManager'; import SchemaManager from '../../utils/SchemaManager';
@ -19,7 +19,7 @@ var cache = {};
directives: [CORE_DIRECTIVES] directives: [CORE_DIRECTIVES]
}) })
@Reflect.metadata('parameters', [[SchemaManager], [ViewContainerRef], [ElementRef], [DynamicComponentLoader], [OptionsManager]]) @Reflect.metadata('parameters', [[SchemaManager], [ViewContainerRef], [ElementRef], [DynamicComponentLoader], [OptionsManager]])
export default class JsonSchemaLazy { export class JsonSchemaLazy {
constructor(schemaMgr, viewRef, elementRef, dcl, optionsMgr) { constructor(schemaMgr, viewRef, elementRef, dcl, optionsMgr) {
this.viewRef = viewRef; this.viewRef = viewRef;

View File

@ -6,12 +6,14 @@ import {DynamicComponentLoader} from '@angular/core';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter'; import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import { import {
TestComponentBuilder,
inject, inject,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
} from '@angular/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import JsonSchemaLazy from 'lib/components/JsonSchema/json-schema-lazy'; import JsonSchemaLazy from 'lib/components/JsonSchema/json-schema-lazy';
import SchemaManager from 'lib/utils/SchemaManager'; import SchemaManager from 'lib/utils/SchemaManager';

View File

@ -3,7 +3,7 @@
import { ElementRef } from '@angular/core'; import { ElementRef } from '@angular/core';
import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { RedocComponent, BaseComponent, SchemaManager } from '../base';
import {DropDown} from '../../common/components/DropDown/dropdown'; import { DropDown } from '../..//shared/components/index';
import JsonPointer from '../../utils/JsonPointer'; import JsonPointer from '../../utils/JsonPointer';
@RedocComponent({ @RedocComponent({
@ -14,7 +14,7 @@ import JsonPointer from '../../utils/JsonPointer';
inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'skipReadOnly'] inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'skipReadOnly']
}) })
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) @Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
export default class JsonSchema extends BaseComponent { export class JsonSchema extends BaseComponent {
constructor(schemaMgr, elementRef) { constructor(schemaMgr, elementRef) {
super(schemaMgr); super(schemaMgr);
this.$element = elementRef.nativeElement; this.$element = elementRef.nativeElement;

View File

@ -5,12 +5,13 @@ import {Component, provide} from '@angular/core';
import OptionsManager from 'lib/options'; import OptionsManager from 'lib/options';
import { import {
TestComponentBuilder,
inject, inject,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
} from '@angular/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import JsonSchema from 'lib/components/JsonSchema/json-schema'; import JsonSchema from 'lib/components/JsonSchema/json-schema';
import SchemaManager from 'lib/utils/SchemaManager'; import SchemaManager from 'lib/utils/SchemaManager';

View File

@ -20,7 +20,7 @@
</span> </span>
<div *ngIf="data.bodyParam"> <div *ngIf="data.bodyParam">
<br> <br>
<request-samples [pointer]="pointer" [bodySchemaPtr]="data.bodyParam._pointer"> <request-samples [pointer]="pointer" [schemaPointer]="data.bodyParam._pointer">
</request-samples> </request-samples>
</div> </div>
<div> <div>

View File

@ -1,22 +1,30 @@
'use strict'; 'use strict';
import { forwardRef } from '@angular/core';
import { JsonPointer } from '../../utils/JsonPointer'; import { JsonPointer } from '../../utils/JsonPointer';
import { RedocComponent, BaseComponent } from '../base'; import { RedocComponent, BaseComponent } from '../base';
import ParamsList from '../ParamsList/params-list'; import {
import ResponsesList from '../ResponsesList/responses-list'; ParamsList,
import ResponsesSamples from '../ResponsesSamples/responses-samples'; ResponsesList,
import SchemaSample from '../SchemaSample/schema-sample'; ResponsesSamples,
import RequestSamples from '../RequestSamples/request-samples'; SchemaSample,
RequestSamples
} from '../index';
@RedocComponent({ @RedocComponent({
selector: 'method', selector: 'method',
templateUrl: './lib/components/Method/method.html', templateUrl: './lib/components/Method/method.html',
styleUrls: ['./lib/components/Method/method.css'], styleUrls: ['./lib/components/Method/method.css'],
directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples], directives: [
forwardRef(() => ParamsList),
forwardRef(() => ResponsesList),
forwardRef(() => ResponsesSamples),
forwardRef(() => SchemaSample),
forwardRef(() => RequestSamples)],
inputs: ['tag'] inputs: ['tag']
}) })
export default class Method extends BaseComponent { export class Method extends BaseComponent {
constructor(schemaMgr) { constructor(schemaMgr) {
super(schemaMgr); super(schemaMgr);
} }

View File

@ -1,5 +1,5 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
@import '../../common/styles/share-link'; @import '../../shared/styles/share-link';
:host { :host {
padding-bottom: 100px; padding-bottom: 100px;

View File

@ -5,13 +5,14 @@ import {Component, provide} from '@angular/core';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter'; import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import { import {
TestComponentBuilder,
async,
inject, inject,
async,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
} from '@angular/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import Method from 'lib/components/Method/method'; import Method from 'lib/components/Method/method';
import SchemaManager from 'lib/utils/SchemaManager'; import SchemaManager from 'lib/utils/SchemaManager';

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import { RedocComponent, BaseComponent } from '../base'; import { RedocComponent, BaseComponent } from '../base';
import Method from '../Method/method'; import { Method } from '../index';
import { EncodeURIComponentPipe } from '../../utils/pipes'; import { EncodeURIComponentPipe } from '../../utils/pipes';
@RedocComponent({ @RedocComponent({
@ -11,7 +11,7 @@ import {EncodeURIComponentPipe} from '../../utils/pipes';
directives: [Method], directives: [Method],
pipes: [EncodeURIComponentPipe] pipes: [EncodeURIComponentPipe]
}) })
export default class MethodsList extends BaseComponent { export class MethodsList extends BaseComponent {
constructor(schemaMgr) { constructor(schemaMgr) {
super(schemaMgr); super(schemaMgr);

View File

@ -1,5 +1,5 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
@import '../../common/styles/share-link'; @import '../../shared/styles/share-link';
.tag-info { .tag-info {
padding: 40px; padding: 40px;

View File

@ -6,13 +6,14 @@ import OptionsManager from 'lib/options';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter'; import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import { import {
TestComponentBuilder,
inject, inject,
async, async,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
} from '@angular/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import MethodsList from 'lib/components/MethodsList/methods-list'; import MethodsList from 'lib/components/MethodsList/methods-list';
import SchemaManager from 'lib/utils/SchemaManager'; import SchemaManager from 'lib/utils/SchemaManager';

View File

@ -1,8 +1,7 @@
'use strict'; 'use strict';
import { RedocComponent, BaseComponent } from '../base'; import { RedocComponent, BaseComponent } from '../base';
import JsonSchema from '../JsonSchema/json-schema'; import { JsonSchema, JsonSchemaLazy } from '../index';
import JsonSchemaLazy from '../JsonSchema/json-schema-lazy';
function safePush(obj, prop, item) { function safePush(obj, prop, item) {
if (!obj[prop]) obj[prop] = []; if (!obj[prop]) obj[prop] = [];
@ -15,7 +14,7 @@ function safePush(obj, prop, item) {
styleUrls: ['./lib/components/ParamsList/params-list.css'], styleUrls: ['./lib/components/ParamsList/params-list.css'],
directives: [JsonSchema, JsonSchemaLazy] directives: [JsonSchema, JsonSchemaLazy]
}) })
export default class ParamsList extends BaseComponent { export class ParamsList extends BaseComponent {
constructor(schemaMgr) { constructor(schemaMgr) {
super(schemaMgr); super(schemaMgr);
} }

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
$hint-color: #999999; $hint-color: #999999;

View File

@ -1,20 +1,25 @@
'use strict'; 'use strict';
import {ChangeDetectionStrategy, provide, enableProdMode} from '@angular/core'; import {provide, enableProdMode} from '@angular/core';
import {ElementRef} from '@angular/core'; import {ElementRef} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic'; import {bootstrap} from '@angular/platform-browser-dynamic';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter'; import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import detectScollParent from 'scrollparent'; import detectScollParent from 'scrollparent';
import {RedocComponent, BaseComponent} from '../base'; import {RedocComponent, BaseComponent} from '../base';
import SchemaManager from '../../utils/SchemaManager'; import SchemaManager from '../../utils/SchemaManager';
import ApiInfo from '../ApiInfo/api-info'; import {
import ApiLogo from '../ApiLogo/api-logo'; ApiInfo,
import MethodsList from '../MethodsList/methods-list'; ApiLogo,
import SideMenu from '../SideMenu/side-menu'; MethodsList,
import StickySidebar from '../../common/components/StickySidebar/sticky-sidebar'; SideMenu
} from '../index';
import { StickySidebar } from '../../shared/components/index';
import OptionsManager from '../../options'; import OptionsManager from '../../options';
import {redocEvents} from '../../events'; import { RedocEventsService } from '../../services/index';
import './redoc-loading-styles.css!css'; import './redoc-loading-styles.css!css';
@ -25,23 +30,30 @@ var _modeLocked = false;
selector: 'redoc', selector: 'redoc',
providers: [ providers: [
SchemaManager, SchemaManager,
BrowserDomAdapter BrowserDomAdapter,
RedocEventsService
], ],
templateUrl: './lib/components/Redoc/redoc.html', templateUrl: './lib/components/Redoc/redoc.html',
styleUrls: ['./lib/components/Redoc/redoc.css'], styleUrls: ['./lib/components/Redoc/redoc.css'],
directives: [ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar], directives: [ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar]
changeDetection: ChangeDetectionStrategy.Default
}) })
@Reflect.metadata('parameters', [ @Reflect.metadata('parameters', [
[SchemaManager], [OptionsManager], [ElementRef]]) [SchemaManager], [OptionsManager], [ElementRef], [RedocEventsService]])
export default class Redoc extends BaseComponent { export class Redoc extends BaseComponent {
constructor(schemaMgr, optionsMgr, elementRef) { constructor(schemaMgr, optionsMgr, elementRef, events) {
super(schemaMgr); super(schemaMgr);
this.element = elementRef.nativeElement; this.element = elementRef.nativeElement;
//parse options (top level component doesn't support inputs) //parse options (top level component doesn't support inputs)
optionsMgr.parseOptions( this.element ); optionsMgr.parseOptions( this.element );
optionsMgr.options.$scrollParent = detectScollParent( this.element ); optionsMgr.options.$scrollParent = detectScollParent( this.element );
this.options = optionsMgr.options; this.options = optionsMgr.options;
this.events = events;
}
ngAfterViewInit() {
setTimeout( () => {
this.events.bootstrapped.next();
});
} }
static showLoadingAnimation() { static showLoadingAnimation() {
@ -82,8 +94,6 @@ export default class Redoc extends BaseComponent {
(appRef) => { (appRef) => {
Redoc.hideLoadingAnimation(); Redoc.hideLoadingAnimation();
Redoc.appRef = appRef; Redoc.appRef = appRef;
// setTimeout to allow cached elements to init
setTimeout(() => redocEvents.bootstrapped.next());
console.log('ReDoc bootstrapped!'); console.log('ReDoc bootstrapped!');
}, },
error => { error => {

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
:host { :host {
display: block; display: block;

View File

@ -5,13 +5,14 @@ import {Component, ViewMetadata, provide} from '@angular/core';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter'; import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import { import {
TestComponentBuilder,
inject, inject,
async, async,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
} from '@angular/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import Redoc from 'lib/components/Redoc/redoc'; import Redoc from 'lib/components/Redoc/redoc';
import SchemaManager from 'lib/utils/SchemaManager'; import SchemaManager from 'lib/utils/SchemaManager';

View File

@ -1,8 +1,8 @@
<header *ngIf="data.bodySchemaPtr || data.samples.length"> Request samples </header> <header *ngIf="data.schemaPointer || data.samples.length"> Request samples </header>
<schema-sample *ngIf="!data.samples.length" [pointer]="data.bodySchemaPtr"> </schema-sample> <schema-sample *ngIf="!data.samples.length" [pointer]="data.schemaPointer"> </schema-sample>
<tabs *ngIf="data.samples.length" (change)=changeLangNotify($event)> <tabs *ngIf="data.samples.length" (change)=changeLangNotify($event)>
<tab tabTitle="JSON"> <tab tabTitle="JSON">
<schema-sample [pointer]="data.bodySchemaPtr"> </schema-sample> <schema-sample [pointer]="data.schemaPointer"> </schema-sample>
</tab> </tab>
<tab *ngFor="let sample of data.samples" [tabTitle]="sample.lang"> <tab *ngFor="let sample of data.samples" [tabTitle]="sample.lang">
<pre innerHtml="{{sample.source | prism:sample.lang}}"></pre> <pre innerHtml="{{sample.source | prism:sample.lang}}"></pre>

View File

@ -1,49 +1,50 @@
'use strict'; 'use strict';
import {ViewChildren, QueryList, ChangeDetectorRef, ChangeDetectionStrategy} from '@angular/core'; import { forwardRef, ViewChildren, QueryList } from '@angular/core';
import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { RedocComponent, BaseComponent, SchemaManager } from '../base';
import JsonPointer from '../../utils/JsonPointer'; import JsonPointer from '../../utils/JsonPointer';
import {Tabs, Tab} from '../../common/components/Tabs/tabs'; import { Tabs, Tab } from '../..//shared/components/index';
import SchemaSample from '../SchemaSample/schema-sample'; import { SchemaSample } from '../index';
import { PrismPipe } from '../../utils/pipes'; import { PrismPipe } from '../../utils/pipes';
import {redocEvents} from '../../events'; import { RedocEventsService } from '../../services/index';
@RedocComponent({ @RedocComponent({
selector: 'request-samples', selector: 'request-samples',
templateUrl: './lib/components/RequestSamples/request-samples.html', templateUrl: './lib/components/RequestSamples/request-samples.html',
styleUrls: ['./lib/components/RequestSamples/request-samples.css'], styleUrls: ['./lib/components/RequestSamples/request-samples.css'],
directives: [SchemaSample, Tabs, Tab], directives: [forwardRef(() =>SchemaSample), Tabs, Tab],
inputs: ['bodySchemaPtr'], inputs: ['schemaPointer'],
pipes: [PrismPipe], pipes: [PrismPipe]
changeDetection: ChangeDetectionStrategy.OnPush
}) })
@Reflect.metadata('parameters', [[SchemaManager], [new ViewChildren(Tabs), QueryList], [ChangeDetectorRef]]) @Reflect.metadata('parameters', [[SchemaManager], [RedocEventsService], [new ViewChildren(Tabs), QueryList]])
export default class RequestSamples extends BaseComponent { export class RequestSamples extends BaseComponent {
constructor(schemaMgr, tabs, changeDetector) { constructor(schemaMgr, events, childQuery) {
super(schemaMgr); super(schemaMgr);
tabs.changes.subscribe(_ => { childQuery.changes.subscribe(() => {
this.tabs = tabs.first; this.childTabs = childQuery.first;
this.subscribeForEvents(_);
}); });
this.changeDetector = changeDetector; this.events = events;
}
init() {
this.subscribeForEvents();
} }
changeLangNotify(lang) { changeLangNotify(lang) {
redocEvents.samplesLanguageChanged.next(lang); this.events.samplesLanguageChanged.next(lang);
} }
subscribeForEvents() { subscribeForEvents() {
if (!this.tabs) return; this.events.samplesLanguageChanged.subscribe((sampleLang) => {
redocEvents.samplesLanguageChanged.subscribe((sampleLang) => { if (!this.childTabs) return;
this.tabs.selectyByTitle(sampleLang); this.childTabs.selectyByTitle(sampleLang);
this.changeDetector.markForCheck();
}); });
} }
prepareModel() { prepareModel() {
this.data = {}; this.data = {};
this.data.bodySchemaPtr = JsonPointer.join(this.bodySchemaPtr, 'schema'); this.data.schemaPointer = JsonPointer.join(this.schemaPointer, 'schema');
this.data.samples = this.componentSchema['x-code-samples'] || []; this.data.samples = this.componentSchema['x-code-samples'] || [];
} }
} }

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
header { header {
font-family: $headers-font; font-family: $headers-font;

View File

@ -2,9 +2,8 @@
import {RedocComponent, BaseComponent, SchemaManager} from '../base'; import {RedocComponent, BaseComponent, SchemaManager} from '../base';
import JsonPointer from '../../utils/JsonPointer'; import JsonPointer from '../../utils/JsonPointer';
import JsonSchema from '../JsonSchema/json-schema'; import { JsonSchema, JsonSchemaLazy } from '../index';
import JsonSchemaLazy from '../JsonSchema/json-schema-lazy'; import {Zippy} from '../../shared/components/index';
import Zippy from '../../common/components/Zippy/zippy';
import {statusCodeType} from '../../utils/helpers'; import {statusCodeType} from '../../utils/helpers';
import OptionsManager from '../../options'; import OptionsManager from '../../options';
@ -19,7 +18,7 @@ function isNumeric(n) {
directives: [JsonSchema, Zippy, JsonSchemaLazy] directives: [JsonSchema, Zippy, JsonSchemaLazy]
}) })
@Reflect.metadata('parameters', [[SchemaManager], [OptionsManager]]) @Reflect.metadata('parameters', [[SchemaManager], [OptionsManager]])
export default class ResponsesList extends BaseComponent { export class ResponsesList extends BaseComponent {
constructor(schemaMgr, optionsMgr) { constructor(schemaMgr, optionsMgr) {
super(schemaMgr); super(schemaMgr);
this.options = optionsMgr.options; this.options = optionsMgr.options;

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
.responses-list-header { .responses-list-header {
font-size: 18px; font-size: 18px;

View File

@ -1,9 +1,10 @@
'use strict'; 'use strict';
import { forwardRef } from '@angular/core';
import { RedocComponent, BaseComponent } from '../base'; import { RedocComponent, BaseComponent } from '../base';
import JsonPointer from '../../utils/JsonPointer'; import JsonPointer from '../../utils/JsonPointer';
import {Tabs, Tab} from '../../common/components/Tabs/tabs'; import { Tabs, Tab } from '../../shared/components/index';
import SchemaSample from '../SchemaSample/schema-sample'; import { SchemaSample } from '../index';
import { statusCodeType } from '../../utils/helpers'; import { statusCodeType } from '../../utils/helpers';
@ -20,9 +21,9 @@ function hasExample(response) {
selector: 'responses-samples', selector: 'responses-samples',
templateUrl: './lib/components/ResponsesSamples/responses-samples.html', templateUrl: './lib/components/ResponsesSamples/responses-samples.html',
styleUrls: ['./lib/components/ResponsesSamples/responses-samples.css'], styleUrls: ['./lib/components/ResponsesSamples/responses-samples.css'],
directives: [SchemaSample, Tabs, Tab] directives: [forwardRef( ()=> SchemaSample), Tabs, Tab]
}) })
export default class ResponsesSamples extends BaseComponent { export class ResponsesSamples extends BaseComponent {
constructor(schemaMgr) { constructor(schemaMgr) {
super(schemaMgr); super(schemaMgr);
} }

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
tab, tabs { tab, tabs {
display: block; display: block;

View File

@ -4,8 +4,8 @@ import {ElementRef} from '@angular/core';
import SchemaSampler from 'json-schema-instantiator'; import SchemaSampler from 'json-schema-instantiator';
import {JsonFormatter} from '../../utils/JsonFormatterPipe';
import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { RedocComponent, BaseComponent, SchemaManager } from '../base';
import { JsonFormatter } from '../../utils/JsonFormatterPipe';
@RedocComponent({ @RedocComponent({
selector: 'schema-sample', selector: 'schema-sample',
@ -14,7 +14,7 @@ import {RedocComponent, BaseComponent, SchemaManager} from '../base';
styleUrls: ['./lib/components/SchemaSample/schema-sample.css'] styleUrls: ['./lib/components/SchemaSample/schema-sample.css']
}) })
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) @Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
export default class SchemaSample extends BaseComponent { export class SchemaSample extends BaseComponent {
constructor(schemaMgr, elementRef) { constructor(schemaMgr, elementRef) {
super(schemaMgr); super(schemaMgr);
this.element = elementRef.nativeElement; this.element = elementRef.nativeElement;

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
pre { pre {
background-color: transparent; background-color: transparent;

View File

@ -1,11 +1,11 @@
<div class="mobile-nav" (click)="toggleMobileNav()"> <div #mobile class="mobile-nav" (click)="toggleMobileNav()">
<span class="menu-header"> API Reference: </span> <span class="menu-header"> API Reference: </span>
<span class="selected-item-info"> <span class="selected-item-info">
<span class="selected-tag"> {{activeCatCaption}} </span> <span class="selected-tag"> {{activeCatCaption}} </span>
<span class="selected-endpoint">{{activeItemCaption}}</span> <span class="selected-endpoint">{{activeItemCaption}}</span>
</span> </span>
</div> </div>
<div id="resources-nav"> <div #desktop id="resources-nav">
<h5 class="menu-header"> API reference </h5> <h5 class="menu-header"> API reference </h5>
<div *ngFor="let cat of data.menu; let idx = index" class="menu-cat"> <div *ngFor="let cat of data.menu; let idx = index" class="menu-cat">

View File

@ -5,7 +5,7 @@ import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_a
import { global } from '@angular/core/src/facade/lang'; import { global } from '@angular/core/src/facade/lang';
import { RedocComponent, BaseComponent, SchemaManager } from '../base'; import { RedocComponent, BaseComponent, SchemaManager } from '../base';
import {redocEvents} from '../../events'; import { RedocEventsService } from '../../services/index';
import OptionsManager from '../../options'; import OptionsManager from '../../options';
const CHANGE = { const CHANGE = {
@ -26,9 +26,9 @@ const INVIEW_POSITION = {
styleUrls: ['./lib/components/SideMenu/side-menu.css'] styleUrls: ['./lib/components/SideMenu/side-menu.css']
}) })
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef], @Reflect.metadata('parameters', [[SchemaManager], [ElementRef],
[BrowserDomAdapter], [OptionsManager]]) [BrowserDomAdapter], [OptionsManager], [RedocEventsService]])
export default class SideMenu extends BaseComponent { export class SideMenu extends BaseComponent {
constructor(schemaMgr, elementRef, dom, optionsMgr) { constructor(schemaMgr, elementRef, dom, optionsMgr, events) {
super(schemaMgr); super(schemaMgr);
this.$element = elementRef.nativeElement; this.$element = elementRef.nativeElement;
this.dom = dom; this.dom = dom;
@ -39,14 +39,14 @@ export default class SideMenu extends BaseComponent {
this.activeMethodIdx = -1; this.activeMethodIdx = -1;
this.prevOffsetY = null; this.prevOffsetY = null;
redocEvents.bootstrapped.subscribe(() => this.hashScroll()); this.events = events;
this.activeCatCaption = ''; this.activeCatCaption = '';
this.activeItemCaption = ''; this.activeItemCaption = '';
} }
init() { init() {
this.events.bootstrapped.subscribe(() => this.hashScroll());
this.bindEvents(); this.bindEvents();
this.$mobileNav = this.dom.querySelector(this.$element, '.mobile-nav'); this.$mobileNav = this.dom.querySelector(this.$element, '.mobile-nav');
this.$resourcesNav = this.dom.querySelector(this.$element, '#resources-nav'); this.$resourcesNav = this.dom.querySelector(this.$element, '#resources-nav');

View File

@ -1,4 +1,4 @@
@import '../../common/styles/variables'; @import '../../shared/styles/variables';
$mobile-menu-compact-breakpoint: 550px; $mobile-menu-compact-breakpoint: 550px;
.menu-header { .menu-header {

View File

@ -6,13 +6,14 @@ import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_a
import OptionsManager from 'lib/options'; import OptionsManager from 'lib/options';
import { import {
TestComponentBuilder,
inject, inject,
async, async,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
} from '@angular/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import {redocEvents} from 'lib/events'; import {redocEvents} from 'lib/events';
import MethodsList from 'lib/components/MethodsList/methods-list'; import MethodsList from 'lib/components/MethodsList/methods-list';

View File

@ -1,42 +1,15 @@
'use strict'; 'use strict';
import ApiInfo from './ApiInfo/api-info'; export * from './ApiInfo/api-info';
import ApiLogo from './ApiLogo/api-logo'; export * from './ApiLogo/api-logo';
import Method from './Method/method.js'; export * from './JsonSchema/json-schema';
import MethodsList from './MethodsList/methods-list'; export * from './JsonSchema/json-schema-lazy';
import ParamsList from './ParamsList/params-list'; export * from './ParamsList/params-list';
import Redoc from './Redoc/redoc'; export * from './RequestSamples/request-samples';
import ResponsesList from './ResponsesList/responses-list'; export * from './ResponsesList/responses-list';
import ResponsesSamples from './ResponsesSamples/responses-samples'; export * from './ResponsesSamples/responses-samples';
import SchemaSample from './SchemaSample/schema-sample'; export * from './SchemaSample/schema-sample';
import SideMenu from './SideMenu/side-menu'; export * from './SideMenu/side-menu';
import JsonSchema from './JsonSchema/json-schema'; export * from './Method/method';
export * from './MethodsList/methods-list';
const REDOC_COMPONENTS = [ export * from './Redoc/redoc';
ApiInfo,
ApiLogo,
JsonSchema,
Method,
MethodsList,
ParamsList,
Redoc,
ResponsesList,
ResponsesSamples,
SchemaSample,
SideMenu
];
export {
ApiInfo,
ApiLogo,
JsonSchema,
Method,
MethodsList,
ParamsList,
Redoc,
ResponsesList,
ResponsesSamples,
SchemaSample,
SideMenu,
REDOC_COMPONENTS
};

View File

@ -1,10 +0,0 @@
'use strict';
import {EventEmitter} from '@angular/core';
var bootsrEmmiter = new EventEmitter();
var langChanged = new EventEmitter();
export var redocEvents = {
bootstrapped: bootsrEmmiter,
samplesLanguageChanged: langChanged
};

View File

@ -0,0 +1,10 @@
'use strict';
import {EventEmitter} from '@angular/core';
export class RedocEventsService {
constructor() {
this.bootstrapped = new EventEmitter();
this.samplesLanguageChanged = new EventEmitter();
}
}

3
lib/services/index.js Normal file
View File

@ -0,0 +1,3 @@
'use strict';
export * from './events.service.js';

View File

@ -14,7 +14,7 @@ import 'Robdel12/DropKick/build/css/dropkick.css!css';
</select> </select>
`, `,
directives: [CORE_DIRECTIVES], directives: [CORE_DIRECTIVES],
styleUrls: ['./lib/common/components/DropDown/dropdown.css'] styleUrls: ['./lib/shared/components/DropDown/drop-down.css']
}) })
@Reflect.metadata('parameters', [[ElementRef]]) @Reflect.metadata('parameters', [[ElementRef]])
export class DropDown { export class DropDown {

View File

@ -8,7 +8,7 @@ import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_a
inputs: ['scrollParent', 'scrollYOffset'] inputs: ['scrollParent', 'scrollYOffset']
}) })
@Reflect.metadata('parameters', [[ElementRef], [BrowserDomAdapter]]) @Reflect.metadata('parameters', [[ElementRef], [BrowserDomAdapter]])
export default class StickySidebar { export class StickySidebar {
constructor(elementRef, dom) { constructor(elementRef, dom) {
this.$element = elementRef.nativeElement; this.$element = elementRef.nativeElement;
this.dom = dom; this.dom = dom;

View File

@ -12,7 +12,7 @@ import {
it it
} from '@angular/testing'; } from '@angular/testing';
import StickySidebar from 'lib/common/components/StickySidebar/sticky-sidebar'; import { StickySidebar } from 'lib/shared/components/index';
describe('Common components', () => { describe('Common components', () => {
describe('StickySidebar Component', () => { describe('StickySidebar Component', () => {

View File

@ -14,7 +14,7 @@ import {CORE_DIRECTIVES} from '@angular/common';
<ng-content></ng-content> <ng-content></ng-content>
`, `,
directives: [CORE_DIRECTIVES], directives: [CORE_DIRECTIVES],
styleUrls: ['./lib/common/components/Tabs/tabs.css'] styleUrls: ['./lib/shared/components/Tabs/tabs.css']
}) })
export class Tabs { export class Tabs {
constructor() { constructor() {

View File

@ -10,7 +10,7 @@ import {
it it
} from '@angular/testing'; } from '@angular/testing';
import {Tabs, Tab} from 'lib/common/components/Tabs/tabs'; import {Tabs, Tab} from 'lib/shared/components/index';
describe('Common components', () => { describe('Common components', () => {
describe('Tabs Component', () => { describe('Tabs Component', () => {

View File

@ -7,11 +7,11 @@ import {CORE_DIRECTIVES} from '@angular/common';
selector: 'zippy', selector: 'zippy',
events: ['open', 'close'], events: ['open', 'close'],
inputs: ['title', 'visible', 'type', 'empty'], inputs: ['title', 'visible', 'type', 'empty'],
templateUrl: './lib/common/components/Zippy/zippy.html', templateUrl: './lib/shared/components/Zippy/zippy.html',
styleUrls: ['./lib/common/components/Zippy/zippy.css'], styleUrls: ['./lib/shared/components/Zippy/zippy.css'],
directives: [CORE_DIRECTIVES] directives: [CORE_DIRECTIVES]
}) })
export default class Zippy { export class Zippy {
constructor() { constructor() {
this.type = 'general'; this.type = 'general';

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
import { getChildDebugElement, mouseclick } from 'tests/helpers'; import { getChildDebugElement, mouseclick } from 'tests/helpers';
import {Component} from '@angular/core';
import { Component } from '@angular/core';
import { import {
TestComponentBuilder, TestComponentBuilder,
inject, inject,
@ -10,7 +10,7 @@ import {
it it
} from '@angular/testing'; } from '@angular/testing';
import Zippy from 'lib/common/components/Zippy/zippy'; import { Zippy } from 'lib/shared/components/index';
describe('Common components', () => { describe('Common components', () => {
describe('Zippy Component', () => { describe('Zippy Component', () => {

View File

@ -0,0 +1,5 @@
'use strict';
export * from './DropDown/drop-down';
export * from './StickySidebar/sticky-sidebar';
export * from './Tabs/tabs';
export * from './Zippy/zippy';

View File

@ -69,6 +69,9 @@
"map": { "map": {
"http": "npm:stream-http@2.3.0" "http": "npm:stream-http@2.3.0"
} }
},
"npm:@angular/core@2.0.0-rc.1": {
"format": "esm"
} }
} }
}, },

View File

@ -149,7 +149,6 @@ System.config({
"process": "github:jspm/nodelibs-process@0.1.2" "process": "github:jspm/nodelibs-process@0.1.2"
}, },
"npm:@angular/core@2.0.0-rc.1": { "npm:@angular/core@2.0.0-rc.1": {
"process": "github:jspm/nodelibs-process@0.1.2",
"rxjs": "npm:rxjs@5.0.0-beta.6", "rxjs": "npm:rxjs@5.0.0-beta.6",
"zone.js": "npm:zone.js@0.6.12" "zone.js": "npm:zone.js@0.6.12"
}, },

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import {By} from 'angular2/platform/browser'; import {By} from '@angular/platform-browser';
/** Gets a child DebugElement by tag name. */ /** Gets a child DebugElement by tag name. */
export function getChildDebugElement(parent, tagName) { export function getChildDebugElement(parent, tagName) {