aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-29 09:18:00 +0100
committerChocobozzz <me@florianbigard.com>2017-12-29 09:18:00 +0100
commiteacf925ea668ba48c30f4e8e3c117d8daaebfe77 (patch)
tree596be586962e8d2bae90561d0781e24b09acf8b8 /client/src
parent59651eee5600839cdc62911a211d61457d8456b7 (diff)
downloadPeerTube-eacf925ea668ba48c30f4e8e3c117d8daaebfe77.tar.gz
PeerTube-eacf925ea668ba48c30f4e8e3c117d8daaebfe77.tar.zst
PeerTube-eacf925ea668ba48c30f4e8e3c117d8daaebfe77.zip
Comment textarea focus on init
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.html2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.ts9
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.html2
3 files changed, 10 insertions, 3 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
index 792053614..365fc8f6c 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
@@ -1,6 +1,6 @@
1<form novalidate [formGroup]="form" (ngSubmit)="formValidated()"> 1<form novalidate [formGroup]="form" (ngSubmit)="formValidated()">
2 <div class="form-group"> 2 <div class="form-group">
3 <textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }"> 3 <textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }" #textarea>
4 </textarea> 4 </textarea>
5 <div *ngIf="formErrors.text" class="form-error"> 5 <div *ngIf="formErrors.text" class="form-error">
6 {{ formErrors.text }} 6 {{ formErrors.text }}
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
index d05232202..a6525987e 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
@@ -1,4 +1,4 @@
1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 1import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms' 2import { FormBuilder, FormGroup } from '@angular/forms'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { Observable } from 'rxjs/Observable' 4import { Observable } from 'rxjs/Observable'
@@ -17,6 +17,7 @@ import { VideoCommentService } from './video-comment.service'
17export class VideoCommentAddComponent extends FormReactive implements OnInit { 17export class VideoCommentAddComponent extends FormReactive implements OnInit {
18 @Input() video: Video 18 @Input() video: Video
19 @Input() parentComment: VideoComment 19 @Input() parentComment: VideoComment
20 @Input() focusOnInit = false
20 21
21 @Output() commentCreated = new EventEmitter<VideoCommentCreate>() 22 @Output() commentCreated = new EventEmitter<VideoCommentCreate>()
22 23
@@ -28,6 +29,8 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
28 'text': VIDEO_COMMENT_TEXT.MESSAGES 29 'text': VIDEO_COMMENT_TEXT.MESSAGES
29 } 30 }
30 31
32 @ViewChild('textarea') private textareaElement: ElementRef
33
31 constructor ( 34 constructor (
32 private formBuilder: FormBuilder, 35 private formBuilder: FormBuilder,
33 private notificationsService: NotificationsService, 36 private notificationsService: NotificationsService,
@@ -46,6 +49,10 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
46 49
47 ngOnInit () { 50 ngOnInit () {
48 this.buildForm() 51 this.buildForm()
52
53 if (this.focusOnInit === true) {
54 this.textareaElement.nativeElement.focus()
55 }
49 } 56 }
50 57
51 formValidated () { 58 formValidated () {
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html
index 9608a1033..ffaf722cd 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html
@@ -10,7 +10,7 @@
10 </div> 10 </div>
11 11
12 <my-video-comment-add 12 <my-video-comment-add
13 *ngIf="isUserLoggedIn() && inReplyToCommentId === comment.id" [video]="video" [parentComment]="comment" 13 *ngIf="isUserLoggedIn() && inReplyToCommentId === comment.id" [video]="video" [parentComment]="comment" [focusOnInit]="true"
14 (commentCreated)="onCommentReplyCreated($event)" 14 (commentCreated)="onCommentReplyCreated($event)"
15 ></my-video-comment-add> 15 ></my-video-comment-add>
16 16