aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/misc/help.component.ts30
-rw-r--r--client/src/app/shared/misc/utils.ts5
2 files changed, 19 insertions, 16 deletions
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 @@
1import { Component, ElementRef, HostListener, Input, OnInit, ViewChild } from '@angular/core' 1import { Component, ElementRef, HostListener, Input, OnInit, ViewChild, OnChanges } from '@angular/core'
2import { MarkdownService } from '@app/videos/shared' 2import { MarkdownService } from '@app/videos/shared'
3import { TooltipDirective } from 'ngx-bootstrap/tooltip' 3import { TooltipDirective } from 'ngx-bootstrap/tooltip'
4 4
@@ -8,7 +8,7 @@ import { TooltipDirective } from 'ngx-bootstrap/tooltip'
8 templateUrl: './help.component.html' 8 templateUrl: './help.component.html'
9}) 9})
10 10
11export class HelpComponent implements OnInit { 11export class HelpComponent implements OnInit, OnChanges {
12 @ViewChild('tooltipDirective') tooltipDirective: TooltipDirective 12 @ViewChild('tooltipDirective') tooltipDirective: TooltipDirective
13 @Input() preHtml = '' 13 @Input() preHtml = ''
14 @Input() postHtml = '' 14 @Input() postHtml = ''
@@ -20,6 +20,23 @@ export class HelpComponent implements OnInit {
20 constructor (private elementRef: ElementRef) { } 20 constructor (private elementRef: ElementRef) { }
21 21
22 ngOnInit () { 22 ngOnInit () {
23 this.init()
24 }
25
26 ngOnChanges () {
27 this.init()
28 }
29
30 @HostListener('document:click', ['$event.target'])
31 public onClick (targetElement) {
32 const clickedInside = this.elementRef.nativeElement.contains(targetElement)
33
34 if (this.tooltipDirective.isOpen && !clickedInside) {
35 this.tooltipDirective.hide()
36 }
37 }
38
39 private init () {
23 if (this.helpType === 'custom') { 40 if (this.helpType === 'custom') {
24 this.mainHtml = this.customHtml 41 this.mainHtml = this.customHtml
25 return 42 return
@@ -36,15 +53,6 @@ export class HelpComponent implements OnInit {
36 } 53 }
37 } 54 }
38 55
39 @HostListener('document:click', ['$event.target'])
40 public onClick (targetElement) {
41 const clickedInside = this.elementRef.nativeElement.contains(targetElement)
42
43 if (this.tooltipDirective.isOpen && !clickedInside) {
44 this.tooltipDirective.hide()
45 }
46 }
47
48 private formatMarkdownSupport (rules: string[]) { 56 private formatMarkdownSupport (rules: string[]) {
49 return '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> ' + 57 return '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> ' +
50 'compatible that supports:' + 58 '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) {
17 return decodeURIComponent(results[2].replace(/\+/g, ' ')) 17 return decodeURIComponent(results[2].replace(/\+/g, ' '))
18} 18}
19 19
20function viewportHeight () {
21 return Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
22}
23
24function populateAsyncUserVideoChannels (authService: AuthService, channel: any[]) { 20function populateAsyncUserVideoChannels (authService: AuthService, channel: any[]) {
25 return new Promise(res => { 21 return new Promise(res => {
26 authService.userInformationLoaded 22 authService.userInformationLoaded
@@ -99,7 +95,6 @@ function isInMobileView () {
99} 95}
100 96
101export { 97export {
102 viewportHeight,
103 getParameterByName, 98 getParameterByName,
104 populateAsyncUserVideoChannels, 99 populateAsyncUserVideoChannels,
105 getAbsoluteAPIUrl, 100 getAbsoluteAPIUrl,