Merge branch 'release/v1.3.0' into develop
[oweals/peertube.git] / client / src / app / shared / misc / help.component.ts
index 9defd9aa4cc54920d397a2521e1cf96347f0a53e..f3426f70ff4246a2e8aff0ac3ce1167f06a3c454 100644 (file)
@@ -1,5 +1,6 @@
 import { Component, Input, OnChanges, OnInit } from '@angular/core'
-import { MarkdownService } from '@app/videos/shared'
+import { I18n } from '@ngx-translate/i18n-polyfill'
+import { MarkdownService } from '@app/shared/renderer'
 
 @Component({
   selector: 'my-help',
@@ -12,9 +13,13 @@ export class HelpComponent implements OnInit, OnChanges {
   @Input() postHtml = ''
   @Input() customHtml = ''
   @Input() helpType: 'custom' | 'markdownText' | 'markdownEnhanced' = 'custom'
+  @Input() tooltipPlacement = 'right'
 
+  isPopoverOpened = false
   mainHtml = ''
 
+  constructor (private i18n: I18n) { }
+
   ngOnInit () {
     this.init()
   }
@@ -23,6 +28,14 @@ export class HelpComponent implements OnInit, OnChanges {
     this.init()
   }
 
+  onPopoverHidden () {
+    this.isPopoverOpened = false
+  }
+
+  onPopoverShown () {
+    this.isPopoverOpened = true
+  }
+
   private init () {
     if (this.helpType === 'custom') {
       this.mainHtml = this.customHtml
@@ -41,18 +54,18 @@ export class HelpComponent implements OnInit, OnChanges {
   }
 
   private formatMarkdownSupport (rules: string[]) {
-    return '<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> ' +
-      'compatible that supports:' +
+    // tslint:disable:max-line-length
+    return this.i18n('<a href="https://en.wikipedia.org/wiki/Markdown#Example" target="_blank" rel="noopener noreferrer">Markdown</a> compatible that supports:') +
       this.createMarkdownList(rules)
   }
 
   private createMarkdownList (rules: string[]) {
     const rulesToText = {
-      'emphasis': 'Emphasis',
-      'link': 'Links',
-      'newline': 'New lines',
-      'list': 'Lists',
-      'image': 'Images'
+      'emphasis': this.i18n('Emphasis'),
+      'link': this.i18n('Links'),
+      'newline': this.i18n('New lines'),
+      'list': this.i18n('Lists'),
+      'image': this.i18n('Images')
     }
 
     const bullets = rules.map(r => rulesToText[r])