]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/misc/help.component.ts
Handle when autoplay fails
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / misc / help.component.ts
index a4a223cd6108d87b047ddfe9c039b8806f8f9989..89dd1dae5b0a6d919b86aa8bbe65533dd9a074b5 100644 (file)
@@ -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,17 +53,9 @@ 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">Markdown</a> compatible that supports:' +
+    return '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> ' +
+      'compatible that supports:' +
       this.createMarkdownList(rules)
   }