openaire-library/landingPages/landing-utils/addThis.component.ts

51 lines
1003 B
TypeScript
Raw Normal View History

import {
AfterContentInit,
AfterViewInit,
Component,
ElementRef,
EventEmitter,
Input,
OnInit,
Output,
ViewChild
} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
interface addthis {
layers: Refresh;
init: Function;
toolbox: Function;
}
interface Refresh {
refresh: Function;
}
declare var addthis: addthis;
@Component({
selector: 'addThis',
template: `
<p class="addthis_inline_share_toolbox"></p>
`
})
export class AddThisComponent implements OnInit {
@Output() event: EventEmitter<boolean> = new EventEmitter<boolean>();
constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.route.queryParams.subscribe(data => {
if (typeof document !== 'undefined' && typeof addthis !== 'undefined') {
if(addthis.layers && addthis.layers.refresh) {
addthis.layers.refresh();
} else {
this.event.emit(false);
}
} else {
this.event.emit(false);
}
});
}
}