2015-10-07 12:47:57 +03:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-09 23:19:35 +03:00
|
|
|
import {RedocComponent, BaseComponent} from '../base';
|
2015-10-27 20:44:08 +03:00
|
|
|
import SchemaManager from '../../utils/SchemaManager';
|
2015-12-26 20:44:39 +03:00
|
|
|
|
2015-10-27 20:44:08 +03:00
|
|
|
import ApiInfo from '../ApiInfo/api-info';
|
2015-12-21 00:34:20 +03:00
|
|
|
import ApiLogo from '../ApiLogo/api-logo';
|
2015-10-27 20:44:08 +03:00
|
|
|
import MethodsList from '../MethodsList/methods-list';
|
2015-11-16 02:10:04 +03:00
|
|
|
import SideMenu from '../SideMenu/side-menu';
|
2015-12-26 20:44:39 +03:00
|
|
|
import StickySidebar from '../../common/components/StickySidebar/sticky-sidebar';
|
|
|
|
|
2015-12-14 18:20:40 +03:00
|
|
|
import {ChangeDetectionStrategy} from 'angular2/core';
|
2015-12-26 20:44:39 +03:00
|
|
|
import {ElementRef} from 'angular2/core';
|
|
|
|
import {BrowserDomAdapter} from 'angular2/platform/browser';
|
|
|
|
import detectScollParent from 'scrollparent';
|
|
|
|
|
2015-10-07 12:47:57 +03:00
|
|
|
|
2015-10-09 23:19:35 +03:00
|
|
|
@RedocComponent({
|
2015-10-07 12:47:57 +03:00
|
|
|
selector: 'redoc',
|
2015-12-26 20:44:39 +03:00
|
|
|
providers: [SchemaManager, BrowserDomAdapter],
|
2015-10-07 12:47:57 +03:00
|
|
|
templateUrl: './lib/components/Redoc/redoc.html',
|
2015-11-16 02:15:06 +03:00
|
|
|
styleUrls: ['./lib/components/Redoc/redoc.css'],
|
2015-12-26 20:44:39 +03:00
|
|
|
directives: [ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar],
|
2015-11-29 14:37:19 +03:00
|
|
|
changeDetection: ChangeDetectionStrategy.Default
|
2015-10-07 12:47:57 +03:00
|
|
|
})
|
2015-10-27 20:44:08 +03:00
|
|
|
export default class Redoc extends BaseComponent {
|
2015-12-26 20:44:39 +03:00
|
|
|
constructor(schemaMgr, elementRef) {
|
2015-10-09 23:19:35 +03:00
|
|
|
super(schemaMgr);
|
2015-12-26 20:44:39 +03:00
|
|
|
this.element = elementRef.nativeElement;
|
|
|
|
|
|
|
|
let DOM = new BrowserDomAdapter();
|
|
|
|
let el = this.element;
|
|
|
|
this.options = {};
|
|
|
|
|
|
|
|
//parse options (top level component doesn't support inputs)
|
|
|
|
this.options.scrollParent = detectScollParent(el);
|
|
|
|
this.options.scrollOffsetTop = parseInt(DOM.getAttribute(el, 'scroll-y-offset')) || 0;
|
2015-10-07 12:47:57 +03:00
|
|
|
}
|
|
|
|
}
|
2015-12-26 20:44:39 +03:00
|
|
|
Redoc.parameters = Redoc.parameters.concat([[ElementRef]]);
|
|
|
|
|
|
|
|
// this doesn't work in side-menu.js because of some circular references issue
|
|
|
|
SideMenu.parameters = SideMenu.parameters.concat([[Redoc]]);
|