From 240458d0c95133bfb03a3f695a1b4e5cb63e20ef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 9 Jan 2020 09:30:08 +0100 Subject: [PATCH] Remove ElementEvent --- .../timestamp-route-transformer.directive.ts | 14 ++++++-------- client/src/app/shared/misc/utils.ts | 8 +------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/client/src/app/shared/angular/timestamp-route-transformer.directive.ts b/client/src/app/shared/angular/timestamp-route-transformer.directive.ts index 6e17957f8..f4d9aeb1f 100644 --- a/client/src/app/shared/angular/timestamp-route-transformer.directive.ts +++ b/client/src/app/shared/angular/timestamp-route-transformer.directive.ts @@ -1,6 +1,4 @@ -import { Directive, ElementRef, HostListener, Output, EventEmitter } from '@angular/core' -import { Router } from '@angular/router' -import { ElementEvent } from '@app/shared/misc/utils' +import { Directive, EventEmitter, HostListener, Output } from '@angular/core' @Directive({ selector: '[timestampRouteTransformer]' @@ -8,13 +6,13 @@ import { ElementEvent } from '@app/shared/misc/utils' export class TimestampRouteTransformerDirective { @Output() timestampClicked = new EventEmitter() - constructor (private el: ElementRef, private router: Router) { } - @HostListener('click', ['$event']) - public onClick ($event: ElementEvent) { - if ($event.target.hasAttribute('href')) { + public onClick ($event: Event) { + const target = $event.target as HTMLLinkElement + + if (target.hasAttribute('href')) { const ngxLink = document.createElement('a') - ngxLink.href = $event.target.getAttribute('href') + ngxLink.href = target.getAttribute('href') // we only care about reflective links if (ngxLink.host !== window.location.host) return diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts index 096fd61e2..3d1e906a2 100644 --- a/client/src/app/shared/misc/utils.ts +++ b/client/src/app/shared/misc/utils.ts @@ -1,13 +1,8 @@ -// Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript - import { DatePipe } from '@angular/common' import { environment } from '../../../environments/environment' import { AuthService } from '../../core/auth' -type ElementEvent = Omit & { - target: HTMLElement -} - +// Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript function getParameterByName (name: string, url: string) { if (!url) url = window.location.href name = name.replace(/[\[\]]/g, '\\$&') @@ -194,7 +189,6 @@ function isXPercentInViewport (el: HTMLElement, percentVisible: number) { } export { - ElementEvent, sortBy, durationToString, lineFeedToHtml,