Browse Source

Delay tooltip.

pull/662/head
Sebastian 5 years ago
parent
commit
0f7a9072a0
  1. 38
      frontend/app/framework/angular/modals/tooltip.directive.ts
  2. 4
      frontend/app/shared/components/schema-category.component.html

38
frontend/app/framework/angular/modals/tooltip.directive.ts

@ -7,18 +7,22 @@
// tslint:disable: directive-selector
import { Directive, ElementRef, HostListener, Input, Renderer2 } from '@angular/core';
import { Directive, ElementRef, HostListener, Input, OnDestroy, Renderer2 } from '@angular/core';
import { DialogService, Tooltip } from '@app/framework/internal';
@Directive({
selector: '[title]'
})
export class TooltipDirective {
export class TooltipDirective implements OnDestroy {
private titleText: string;
private timer: any;
@Input()
public titlePosition = 'top-right';
@Input()
public titleDelay = 1000;
@Input()
public set title(value: string) {
this.titleText = value;
@ -33,25 +37,47 @@ export class TooltipDirective {
) {
}
public ngOnDestroy() {
this.hide();
}
@HostListener('mouseenter')
public onMouseEnter() {
this.hide();
if (this.titleText) {
this.dialogs.tooltip(new Tooltip(this.element.nativeElement, this.titleText, this.titlePosition));
if (this.titleDelay > 0) {
this.timer = setTimeout(() => {
this.show();
}, this.titleDelay);
} else {
this.show();
}
}
}
@HostListener('mouseleave')
public onMouseLeave() {
if (this.titleText) {
this.dialogs.tooltip(new Tooltip(this.element.nativeElement, null, this.titlePosition));
}
this.hide();
}
@HostListener('click')
public onClick() {
this.hide();
}
private hide() {
if (this.titleText) {
this.dialogs.tooltip(new Tooltip(this.element.nativeElement, null, this.titlePosition));
}
if (this.timer) {
clearTimeout(this.timer);
}
}
private show() {
this.dialogs.tooltip(new Tooltip(this.element.nativeElement, this.titleText, this.titlePosition));
}
private unsetAttribute() {

4
frontend/app/shared/components/schema-category.component.html

@ -68,8 +68,8 @@
<ng-template #simpleMode>
<li *ngFor="let schema of filteredSchemas; trackBy: trackBySchema" class="nav-item">
<a class="nav-link" [routerLink]="schemaRoute(schema)" routerLinkActive="active">
<span class="schema-name" *ngIf="forContent">{{schema.displayName}}</span>
<a class="nav-link" [routerLink]="schemaRoute(schema)" routerLinkActive="active" title="{{schema.displayName}}" titlePosition="top-left">
<span class="schema-name">{{schema.displayName}}</span>
</a>
</li>
</ng-template>

Loading…
Cancel
Save