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";
import {Author} from "../result-preview/result-preview";
import {AlertModal} from "../modal/alert";
@Component({
selector: 'showAuthors',
template: `
`
})
export class ShowAuthorsComponent {
@Input() authors: Author[];
@Input() authorsLimit: number = 30;
@Input() showAll: boolean = true;
@Input() small: boolean = true;
@Input() modal: AlertModal;
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;
}
copyToClipboard(element: HTMLInputElement) {
element.select();
if (typeof document !== 'undefined') {
document.execCommand('copy');
}
}
public scroll() {
HelperFunctions.scroll();
}
public onClick() {
if(this.modal) {
this.modal.cancel();
}
}
}