1
0
mirror of https://github.com/NicolasConstant/sengi synced 2025-01-06 13:57:13 +01:00

databind all found elements, fix the hashtags bug

This commit is contained in:
Nicolas Constant 2019-07-07 14:14:12 -04:00
parent 6786c95d91
commit 09fcfab98a
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688

View File

@ -159,50 +159,57 @@ export class DatabindedTextComponent implements OnInit {
ngAfterViewInit() {
for (const hashtag of this.hashtags) {
let classname = this.getClassNameForHastag(hashtag);
let el = this.contentElement.nativeElement.querySelector(`.${classname}`);
let els = <Element[]>this.contentElement.nativeElement.querySelectorAll(`.${classname}`);
this.renderer.listen(el, 'click', (event) => {
event.preventDefault();
event.stopImmediatePropagation();
for (const el of els) {
this.renderer.listen(el, 'click', (event) => {
event.preventDefault();
event.stopImmediatePropagation();
this.selectHashtag(hashtag);
return false;
});
this.selectHashtag(hashtag);
return false;
});
}
}
for (const account of this.accounts) {
let classname = this.getClassNameForAccount(account);
let el = this.contentElement.nativeElement.querySelector(`.${classname}`);
let els = this.contentElement.nativeElement.querySelectorAll(`.${classname}`);
this.renderer.listen(el, 'click', (event) => {
event.preventDefault();
event.stopImmediatePropagation();
for (const el of els) {
this.renderer.listen(el, 'click', (event) => {
event.preventDefault();
event.stopImmediatePropagation();
this.selectAccount(account);
return false;
});
this.selectAccount(account);
return false;
});
}
}
for (const link of this.links) {
let classname = this.getClassNameForLink(link);
let el = this.contentElement.nativeElement.querySelector(`.${classname}`);
this.renderer.listen(el, 'click', (event) => {
event.preventDefault();
event.stopImmediatePropagation();
let els = this.contentElement.nativeElement.querySelectorAll(`.${classname}`);
window.open(link, '_blank');
return false;
});
this.renderer.listen(el, 'mouseup', (event) => {
if (event.which === 2) {
for (const el of els) {
this.renderer.listen(el, 'click', (event) => {
event.preventDefault();
event.stopImmediatePropagation();
window.open(link, '_blank');
return false;
}
});
});
this.renderer.listen(el, 'mouseup', (event) => {
if (event.which === 2) {
event.preventDefault();
event.stopImmediatePropagation();
window.open(link, '_blank');
return false;
}
});
}
}
}