import {Component, Inject, Input, PLATFORM_ID} from '@angular/core';
import {ActivatedRoute} from "@angular/router";
import {HelperFunctions} from '../HelperFunctions.class';
import {RouterHelper} from "../routerHelper.class";
import {EnvProperties} from '../properties/env-properties';
import {isPlatformBrowser} from "@angular/common";
@Component({
selector: 'showAuthors',
template: `
`
})
export class ShowAuthorsComponent {
@Input() authors: {"fullName": string, "orcid": string}[];
@Input() authorsLimit: number = 30;
@Input() showAll: boolean = true;
public numberOfAuthors: number;
public properties:EnvProperties;
public routerHelper:RouterHelper = new RouterHelper();
testBrowser: boolean;
constructor (private route: ActivatedRoute, @Inject(PLATFORM_ID) private platformId: string) {
this.testBrowser = isPlatformBrowser(platformId);
}
ngOnInit() {
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
});
this.numberOfAuthors = this.authorsLimit;
if(typeof window !== 'undefined') {
let orcid_clipboard;
let Clipboard;
Clipboard = require('clipboard');
if(this.authors) {
this.authors.forEach((author, index) => {
if (author && author.orcid) {
orcid_clipboard = new Clipboard('.orcid_clipboard_btn_auhtor_' + index);
}
});
}
}
}
public quote(params: string):string {
return '"'+params+'"';
}
public scroll() {
HelperFunctions.scroll();
}
}