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 ++++++++++++++++++---------- client/src/app/shared/misc/utils.ts | 5 ----- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'client/src/app/shared') 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:' + diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts index d520b1a7b..99f6b3cf0 100644 --- a/client/src/app/shared/misc/utils.ts +++ b/client/src/app/shared/misc/utils.ts @@ -17,10 +17,6 @@ function getParameterByName (name: string, url: string) { return decodeURIComponent(results[2].replace(/\+/g, ' ')) } -function viewportHeight () { - return Math.max(document.documentElement.clientHeight, window.innerHeight || 0) -} - function populateAsyncUserVideoChannels (authService: AuthService, channel: any[]) { return new Promise(res => { authService.userInformationLoaded @@ -99,7 +95,6 @@ function isInMobileView () { } export { - viewportHeight, getParameterByName, populateAsyncUserVideoChannels, getAbsoluteAPIUrl, -- cgit v1.2.3