]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/misc/help.component.ts
Add help concerning NSFW videos in upload
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / misc / help.component.ts
index 19ac38b589adcaf3fdc4e43062e1261950fd4751..0373a63de72f4cfdbc1f18b90a482e637bb50f99 100644 (file)
@@ -1,6 +1,5 @@
-import { Component, ElementRef, HostListener, Input, OnInit, ViewChild } from '@angular/core'
+import { Component, Input, OnChanges, OnInit } from '@angular/core'
 import { MarkdownService } from '@app/videos/shared'
-import { TooltipDirective } from 'ngx-bootstrap/tooltip'
 
 @Component({
   selector: 'my-help',
@@ -8,18 +7,24 @@ import { TooltipDirective } from 'ngx-bootstrap/tooltip'
   templateUrl: './help.component.html'
 })
 
-export class HelpComponent implements OnInit {
-  @ViewChild('tooltipDirective') tooltipDirective: TooltipDirective
+export class HelpComponent implements OnInit, OnChanges {
   @Input() preHtml = ''
   @Input() postHtml = ''
   @Input() customHtml = ''
   @Input() helpType: 'custom' | 'markdownText' | 'markdownEnhanced' = 'custom'
+  @Input() tooltipPlacement = 'right'
 
   mainHtml = ''
 
-  constructor (private elementRef: ElementRef) { }
-
   ngOnInit () {
+    this.init()
+  }
+
+  ngOnChanges () {
+    this.init()
+  }
+
+  private init () {
     if (this.helpType === 'custom') {
       this.mainHtml = this.customHtml
       return
@@ -36,15 +41,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 '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> ' +
       'compatible that supports:' +