--- /dev/null
+<span
+ class="date-toggle"
+ [title]="getTitle()"
+ [innerHtml]="getContent()"
+ (click)="toggle()"
+></span>
--- /dev/null
+.date-toggle {
+ &:hover {
+ cursor: default
+ }
+}
--- /dev/null
+import { Component, Input, OnInit, OnChanges } from '@angular/core'
+import { DatePipe } from '@angular/common'
+import { FromNowPipe } from '../angular/from-now.pipe'
+
+@Component({
+ selector: 'my-date-toggle',
+ templateUrl: './date-toggle.component.html',
+ styleUrls: [ './date-toggle.component.scss' ],
+ providers: [ DatePipe, FromNowPipe ]
+})
+export class DateToggleComponent implements OnInit, OnChanges {
+ @Input() date: Date
+ @Input() toggled = false
+
+ dateRelative: string
+ dateAbsolute: string
+
+ constructor (
+ private datePipe: DatePipe,
+ private fromNowPipe: FromNowPipe
+ ) { }
+
+ ngOnInit () {
+ this.updateDates()
+ }
+
+ ngOnChanges () {
+ this.updateDates()
+ }
+
+ toggle () {
+ this.toggled = !this.toggled
+ }
+
+ getTitle () {
+ return this.toggled ? this.dateRelative : this.dateAbsolute
+ }
+
+ getContent () {
+ return this.toggled ? this.dateAbsolute : this.dateRelative
+ }
+
+ private updateDates () {
+ this.dateRelative = this.fromNowPipe.transform(this.date)
+ this.dateAbsolute = this.datePipe.transform(this.date, 'long')
+ }
+}
import { InstanceService } from '@app/shared/instance/instance.service'
import { HtmlRendererService, LinkifierService, MarkdownService } from '@app/shared/renderer'
import { ConfirmComponent } from '@app/shared/confirm/confirm.component'
+import { DateToggleComponent } from '@app/shared/date/date-toggle.component'
import { SmallLoaderComponent } from '@app/shared/misc/small-loader.component'
import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
import { PreviewUploadComponent } from '@app/shared/images/preview-upload.component'
TopMenuDropdownComponent,
UserNotificationsComponent,
ConfirmComponent,
+ DateToggleComponent,
GlobalIconComponent,
PreviewUploadComponent
TopMenuDropdownComponent,
UserNotificationsComponent,
ConfirmComponent,
+ DateToggleComponent,
GlobalIconComponent,
PreviewUploadComponent,
</a>
<span class="video-miniature-created-at-views">
- <ng-container *ngIf="displayOptions.date">{{ video.publishedAt | myFromNow }}</ng-container>
+ <my-date-toggle *ngIf="displayOptions.date" [date]="video.publishedAt"></my-date-toggle>
<ng-container *ngIf="displayOptions.date && displayOptions.views"> - </ng-container>
<ng-container i18n *ngIf="displayOptions.views">{{ video.views | myNumberFormatter }} views</ng-container>
</span>
<div class="d-block d-md-none"> <!-- only shown on medium devices, has its conterpart for larger viewports below -->
<h1 class="video-info-name">{{ video.name }}</h1>
<div i18n class="video-info-date-views">
- Published {{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views
+ Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle> - {{ video.views | myNumberFormatter }} views
</div>
</div>
<h1 class="video-info-name">{{ video.name }}</h1>
<div i18n class="video-info-date-views">
- Published {{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views
+ Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle> - {{ video.views | myNumberFormatter }} views
</div>
</div>