From 5afdd0a52f2f1fa79ed9bf241b5a525366658fa1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Mar 2018 17:05:46 +0200 Subject: Add initial video quota info in registration form --- client/src/app/shared/misc/help.component.ts | 30 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'client/src/app/shared/misc/help.component.ts') diff --git a/client/src/app/shared/misc/help.component.ts b/client/src/app/shared/misc/help.component.ts index 19ac38b58..89dd1dae5 100644 --- a/client/src/app/shared/misc/help.component.ts +++ b/client/src/app/shared/misc/help.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, HostListener, Input, OnInit, ViewChild } from '@angular/core' +import { Component, ElementRef, HostListener, Input, OnInit, ViewChild, OnChanges } from '@angular/core' import { MarkdownService } from '@app/videos/shared' import { TooltipDirective } from 'ngx-bootstrap/tooltip' @@ -8,7 +8,7 @@ import { TooltipDirective } from 'ngx-bootstrap/tooltip' templateUrl: './help.component.html' }) -export class HelpComponent implements OnInit { +export class HelpComponent implements OnInit, OnChanges { @ViewChild('tooltipDirective') tooltipDirective: TooltipDirective @Input() preHtml = '' @Input() postHtml = '' @@ -20,6 +20,23 @@ export class HelpComponent implements OnInit { constructor (private elementRef: ElementRef) { } ngOnInit () { + this.init() + } + + ngOnChanges () { + this.init() + } + + @HostListener('document:click', ['$event.target']) + public onClick (targetElement) { + const clickedInside = this.elementRef.nativeElement.contains(targetElement) + + if (this.tooltipDirective.isOpen && !clickedInside) { + this.tooltipDirective.hide() + } + } + + private init () { if (this.helpType === 'custom') { this.mainHtml = this.customHtml return @@ -36,15 +53,6 @@ export class HelpComponent implements OnInit { } } - @HostListener('document:click', ['$event.target']) - public onClick (targetElement) { - const clickedInside = this.elementRef.nativeElement.contains(targetElement) - - if (this.tooltipDirective.isOpen && !clickedInside) { - this.tooltipDirective.hide() - } - } - private formatMarkdownSupport (rules: string[]) { return 'Markdown ' + 'compatible that supports:' + -- cgit v1.2.3