Add this: show a message when the share buttons are not loaded

This commit is contained in:
argirok 2022-05-06 17:00:52 +03:00
parent 84cb6b6d96
commit 150b26a5d5
1 changed files with 23 additions and 7 deletions

View File

@ -1,6 +1,7 @@
import {Component, EventEmitter, Inject, OnInit, Output, RendererFactory2, ViewEncapsulation} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {DOCUMENT} from "@angular/common";
import {Subscriber} from "rxjs";
interface addthis {
layers: Refresh;
@ -17,20 +18,29 @@ declare var addthis: addthis;
@Component({
selector: 'addThis',
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 {
sub;
subs=[];
showWarning = false;
constructor(private route: ActivatedRoute, @Inject(DOCUMENT) private document, private rendererFactory: RendererFactory2) {}
ngOnDestroy() {
if(this.sub) {
this.sub.unsubscribe();
public ngOnDestroy() {
for(let value of this.subs){
if (value instanceof Subscriber) {
value.unsubscribe();
} else if (value instanceof Function) {
value();
}
}
}
ngOnInit() {
this.sub = this.route.queryParams.subscribe(data => {
this.subs.push(this.route.queryParams.subscribe(data => {
this.showWarning = false;
try {
if (!this.document.getElementById('addThisScript') && typeof document !== 'undefined') {
// console.log(" create script AddThis");
@ -56,10 +66,16 @@ export class AddThisComponent implements OnInit {
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) {
// console.error(e)
}
});
}));
}
}