]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/menu/language-chooser.component.ts
Gracefully downsize search bar for mobile devices
[github/Chocobozzz/PeerTube.git] / client / src / app / menu / language-chooser.component.ts
index 45fa73e762a15dea6a001badc95d1e1a166afd85..43f622dfb1baf5f168de652c1358bc75d6b3a6be 100644 (file)
@@ -1,6 +1,7 @@
 import { Component, ElementRef, ViewChild } from '@angular/core'
 import { I18N_LOCALES } from '../../../../shared'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import { sortBy } from '@app/shared/misc/utils'
 
 @Component({
   selector: 'my-language-chooser',
@@ -8,17 +9,19 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
   styleUrls: [ './language-chooser.component.scss' ]
 })
 export class LanguageChooserComponent {
-  @ViewChild('modal') modal: ElementRef
+  @ViewChild('modal', { static: true }) modal: ElementRef
 
   languages: { id: string, label: string }[] = []
 
   constructor (private modalService: NgbModal) {
-    this.languages = Object.keys(I18N_LOCALES)
-      .map(k => ({ id: k, label: I18N_LOCALES[k] }))
+    const l = Object.keys(I18N_LOCALES)
+                    .map(k => ({ id: k, label: I18N_LOCALES[k] }))
+
+    this.languages = sortBy(l, 'label')
   }
 
   show () {
-    this.modalService.open(this.modal)
+    this.modalService.open(this.modal, { centered: true })
   }
 
   buildLanguageLink (lang: { id: string }) {