Add this: show a message when the share buttons are not loaded
This commit is contained in:
parent
84cb6b6d96
commit
150b26a5d5
|
@ -1,6 +1,7 @@
|
||||||
import {Component, EventEmitter, Inject, OnInit, Output, RendererFactory2, ViewEncapsulation} from '@angular/core';
|
import {Component, EventEmitter, Inject, OnInit, Output, RendererFactory2, ViewEncapsulation} from '@angular/core';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {DOCUMENT} from "@angular/common";
|
import {DOCUMENT} from "@angular/common";
|
||||||
|
import {Subscriber} from "rxjs";
|
||||||
|
|
||||||
interface addthis {
|
interface addthis {
|
||||||
layers: Refresh;
|
layers: Refresh;
|
||||||
|
@ -17,20 +18,29 @@ declare var addthis: addthis;
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'addThis',
|
selector: 'addThis',
|
||||||
template: `
|
template: `
|
||||||
<div class="addthis_inline_share_toolbox_lcx9_8cfy"></div>
|
<div id="addThis" class="addthis_inline_share_toolbox_lcx9_8cfy"></div>
|
||||||
|
<div *ngIf="showWarning" class="uk-alert uk-alert-warning uk-animation-fade" >
|
||||||
|
Do the share buttons not appear? Please make sure, any blocking addon is disabled, and then reload the page.
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class AddThisComponent implements OnInit {
|
export class AddThisComponent implements OnInit {
|
||||||
sub;
|
subs=[];
|
||||||
|
showWarning = false;
|
||||||
constructor(private route: ActivatedRoute, @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2) {}
|
constructor(private route: ActivatedRoute, @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2) {}
|
||||||
ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
if(this.sub) {
|
for(let value of this.subs){
|
||||||
this.sub.unsubscribe();
|
if (value instanceof Subscriber) {
|
||||||
|
value.unsubscribe();
|
||||||
|
} else if (value instanceof Function) {
|
||||||
|
value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.sub = this.route.queryParams.subscribe(data => {
|
this.subs.push(this.route.queryParams.subscribe(data => {
|
||||||
|
this.showWarning = false;
|
||||||
try {
|
try {
|
||||||
if (!this.document.getElementById('addThisScript') && typeof document !== 'undefined') {
|
if (!this.document.getElementById('addThisScript') && typeof document !== 'undefined') {
|
||||||
// console.log(" create script AddThis");
|
// console.log(" create script AddThis");
|
||||||
|
@ -56,10 +66,16 @@ export class AddThisComponent implements OnInit {
|
||||||
addthis.layers.refresh();
|
addthis.layers.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.subs.push(setTimeout(() => {
|
||||||
|
if(this.document.getElementById('addThis') && this.document.getElementById('addThis').innerText.length ==0){
|
||||||
|
this.showWarning = true;
|
||||||
|
}
|
||||||
|
}, 2000));
|
||||||
|
|
||||||
}catch (e) {
|
}catch (e) {
|
||||||
// console.error(e)
|
// console.error(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue