Add tooltip to likes/dislikes bar
authorChocobozzz <me@florianbigard.com>
Thu, 21 Dec 2017 09:49:52 +0000 (10:49 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 21 Dec 2017 09:49:52 +0000 (10:49 +0100)
client/src/app/videos/+video-watch/video-watch.component.html
client/src/app/videos/+video-watch/video-watch.component.ts
client/src/app/videos/+video-watch/video-watch.module.ts
client/src/sass/include/_bootstrap.scss
client/src/sass/video-js-custom.scss

index e9ca336dd41a5f81ea897640c5dc78b4e501673f..d9b5724303a78c4c86bb9a579ae7833659057c04 100644 (file)
@@ -65,7 +65,9 @@
           {{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views
         </div>
 
-        <div *ngIf="video.likes !== 0 || video.dislikes !== 0" class="video-info-likes-dislikes-bar">
+        <div
+          class="video-info-likes-dislikes-bar"
+          *ngIf="video.likes !== 0 || video.dislikes !== 0"  [tooltip]="likesBarTooltipText">
           <div class="likes-bar" [ngStyle]="{ 'width.%': video.likesPercent }"></div>
         </div>
       </div>
index df4cfa66687b9c2a48f36097867323036fd3b476..c388b138b3e1cec6b526b69ff57a3161d37d85e9 100644 (file)
@@ -44,6 +44,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   completeVideoDescription: string
   shortVideoDescription: string
   videoHTMLDescription = ''
+  likesBarTooltipText = ''
 
   private paramsSub: Subscription
 
@@ -228,23 +229,24 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   removeVideo (event: Event) {
     event.preventDefault()
 
-    this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe(
-      res => {
-        if (res === false) return
+    this.confirmService.confirm('Do you really want to delete this video?', 'Delete')
+      .subscribe(
+        res => {
+          if (res === false) return
 
-        this.videoService.removeVideo(this.video.id)
-          .subscribe(
-            status => {
-              this.notificationsService.success('Success', `Video ${this.video.name} deleted.`)
+          this.videoService.removeVideo(this.video.id)
+            .subscribe(
+              status => {
+                this.notificationsService.success('Success', `Video ${this.video.name} deleted.`)
 
-              // Go back to the video-list.
-              this.router.navigate([ '/videos/list' ])
-            },
+                // Go back to the video-list.
+                this.router.navigate([ '/videos/list' ])
+              },
 
-            error => this.notificationsService.error('Error', error.text)
-          )
-      }
-    )
+              error => this.notificationsService.error('Error', error.text)
+            )
+        }
+      )
   }
 
   private updateVideoDescription (description: string) {
@@ -261,6 +263,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     this.videoHTMLDescription = this.markdownService.markdownToHTML(this.video.description)
   }
 
+  private setVideoLikesBarTooltipText () {
+    this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes`
+  }
+
   private handleError (err: any) {
     const errorMessage: string = typeof err === 'string' ? err : err.message
     let message = ''
@@ -346,6 +352,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
         }
 
         this.setVideoDescriptionHTML()
+        this.setVideoLikesBarTooltipText()
 
         this.setOpenGraphTags()
         this.checkUserRating()
index 18319de1a7e241678e641f41cb29a1bb5a7cc365..d0ed29d063ffe18ead6615d65e9ea0495824e210 100644 (file)
@@ -4,6 +4,7 @@ import { VideoWatchRoutingModule } from './video-watch-routing.module'
 import { MarkdownService } from '../shared'
 import { SharedModule } from '../../shared'
 import { ClipboardModule } from 'ngx-clipboard'
+import { TooltipModule } from 'ngx-bootstrap/tooltip';
 
 import { VideoWatchComponent } from './video-watch.component'
 import { VideoReportComponent } from './video-report.component'
@@ -14,7 +15,8 @@ import { VideoDownloadComponent } from './video-download.component'
   imports: [
     VideoWatchRoutingModule,
     SharedModule,
-    ClipboardModule
+    ClipboardModule,
+    TooltipModule.forRoot()
   ],
 
   declarations: [
index 4f0e2893e99eacedc9b5b62a46552399227906d6..bbf0fda226a0961a73c0c9392d642dba49447a81 100644 (file)
@@ -41,7 +41,7 @@
 
 // Components w/ JavaScript
 @import "~bootstrap-sass/assets/stylesheets/bootstrap/modals";
-//@import "~bootstrap-sass/assets/stylesheets/bootstrap/tooltip";
+@import "~bootstrap-sass/assets/stylesheets/bootstrap/tooltip";
 //@import "~bootstrap-sass/assets/stylesheets/bootstrap/popovers";
 //@import "~bootstrap-sass/assets/stylesheets/bootstrap/carousel";
 
index 72487499587ce11ffdb1697449a30f47786e3701..715464ce89ed1ead75bc87097010a4a26dfeed6f 100644 (file)
@@ -50,12 +50,14 @@ $control-bar-height: 34px;
     display: block;
     visibility: hidden;
     opacity: 0;
+    transition-delay: 0.5s;
+    transition: visibility 0.5s, opacity 0.5s;
   }
 
   &.vjs-waiting .vjs-loading-spinner {
     visibility: visible;
     opacity: 1;
-    transition: visibility 0.5s, opacity 0.5s;
+
   }
 
   .vjs-control-bar,