2023-03-28 10:37:44 +02:00
|
|
|
import {Component, ElementRef, Input, ViewChild} from '@angular/core';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2023-03-28 10:37:44 +02:00
|
|
|
selector: 'showTitle',
|
|
|
|
template: `
|
|
|
|
<h1 [ngClass]="classNames" class="uk-h6">
|
|
|
|
<ng-container *ngTemplateOutlet="_title;"></ng-container>
|
|
|
|
</h1>
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2023-03-28 10:37:44 +02:00
|
|
|
<ng-template #_title>
|
|
|
|
<div *ngIf="title != undefined" class="landingTitle uk-text-break">
|
|
|
|
<span *ngIf="title['url'] != undefined && title['url'] != null && title['url'] != ''"
|
|
|
|
class="custom-external">
|
|
|
|
<a *ngIf="title['name'] != undefined && title['name'] != ''"
|
|
|
|
href="{{title['url']}}" target="_blank"
|
|
|
|
[innerHTML]="title['name']">
|
|
|
|
</a>
|
|
|
|
<a *ngIf="title['name'] == undefined || title['name'] == ''"
|
|
|
|
href="{{title['url']}}" target="_blank">
|
|
|
|
[no title available]
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
<span *ngIf="(title['name'] != undefined && title['name'] != '') &&
|
|
|
|
(title['url'] == undefined || title['url'] == null || title['url'] == '')"
|
|
|
|
[innerHTML]="title['name']">
|
|
|
|
</span>
|
|
|
|
<span *ngIf="(title['name'] == undefined || title['name'] == '') &&
|
|
|
|
(title['url'] == undefined || title['url'] == null || title['url'] == '')">
|
|
|
|
[no title available]
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-05-15 16:28:33 +02:00
|
|
|
<div *ngIf="titleName" #titleDiv class="uk-text-break multi-line-ellipsis" [ngClass]="isSticky ? 'lines-1' : 'lines-5'">
|
2023-03-28 10:37:44 +02:00
|
|
|
<span [innerHTML]="titleName" [attr.uk-tooltip]="showTitleTooltip ? 'cls: uk-active uk-width-large' : 'cls: uk-invisible'"
|
|
|
|
[title]="titleName"></span>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="!titleName && !title">
|
|
|
|
<span>No title available</span>
|
|
|
|
</div>
|
|
|
|
</ng-template>
|
|
|
|
`
|
|
|
|
})
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
export class ShowTitleComponent {
|
2018-06-28 16:52:45 +02:00
|
|
|
@Input() titleName: string;
|
2017-12-19 13:53:46 +01:00
|
|
|
@Input() title: { [key: string]: string };
|
|
|
|
@Input() iconClass:string;
|
2019-09-05 10:49:33 +02:00
|
|
|
@Input() classNames: string = "";
|
2023-05-15 16:28:33 +02:00
|
|
|
@Input() isSticky: boolean = false;
|
2023-03-28 10:37:44 +02:00
|
|
|
@ViewChild("titleDiv") titleDiv: ElementRef;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2020-11-11 15:43:13 +01:00
|
|
|
constructor () {}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2023-03-28 10:37:44 +02:00
|
|
|
get showTitleTooltip():boolean {
|
|
|
|
return !!this.titleDiv && (this.titleDiv.nativeElement.clientHeight >= 5 * 21);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|