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

61 lines
1.3 KiB
TypeScript
Raw Normal View History

import {Component, ElementRef, Input} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
interface addthis {
layers: refresh;
init: Function;
toolbox: Function;
}
interface refresh {
refresh: Function;
}
declare var addthis: addthis;
// declare var loadAddThis: any;
//<addThis ></addThis>
@Component({
selector: 'addThis',
template: `
<p class="addthis_inline_share_toolbox"></p>
`
})
export class AddThisComponent {
private sub:any;
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
this.sub = this.route.queryParams.subscribe(data => {
if (typeof document !== 'undefined' && typeof addthis !== 'undefined') {
try{
//console.log("AddThis: try load");
// addthis.toolbox();
// addthis.init();
addthis.layers.refresh();
}catch (e) {
// console.log("AddThis may didn't load properly");
// try{
// addthis.init();
// addthis.layers.refresh();
// console.log("AddThis: one more");
// }catch (e) {
// console.log("AddThis error again");
// }
}
}
// if (typeof document !== 'undefined' ) {
// console.log("AddThis: try load");
// loadAddThis();
//
//
// }
});
}
}