diff options
Diffstat (limited to 'client/src/app/shared/misc/help.component.ts')
-rw-r--r-- | client/src/app/shared/misc/help.component.ts | 30 |
1 files changed, 19 insertions, 11 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 @@ | |||
1 | import { Component, ElementRef, HostListener, Input, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, HostListener, Input, OnInit, ViewChild, OnChanges } from '@angular/core' |
2 | import { MarkdownService } from '@app/videos/shared' | 2 | import { MarkdownService } from '@app/videos/shared' |
3 | import { TooltipDirective } from 'ngx-bootstrap/tooltip' | 3 | import { 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 | ||
11 | export class HelpComponent implements OnInit { | 11 | export 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:' + |