mirror of https://github.com/abpframework/abp.git
5 changed files with 47 additions and 5 deletions
@ -0,0 +1,46 @@ |
|||
import { |
|||
AfterViewInit, |
|||
ChangeDetectorRef, |
|||
Directive, |
|||
ElementRef, |
|||
HostBinding, |
|||
Input, |
|||
NgModule, |
|||
} from '@angular/core'; |
|||
|
|||
@Directive({ |
|||
selector: '[abpEllipsis]', |
|||
}) |
|||
export class EllipsisDirective implements AfterViewInit { |
|||
@Input('abpEllipsis') |
|||
width: string; |
|||
|
|||
@HostBinding('title') |
|||
@Input() |
|||
title: string; |
|||
|
|||
@Input('abpEllipsisEnabled') |
|||
enabled = true; |
|||
|
|||
@HostBinding('class.abp-ellipsis-inline') |
|||
get inlineClass() { |
|||
return this.enabled && this.width; |
|||
} |
|||
|
|||
@HostBinding('class.abp-ellipsis') |
|||
get class() { |
|||
return this.enabled && !this.width; |
|||
} |
|||
|
|||
@HostBinding('style.max-width') |
|||
get maxWidth() { |
|||
return this.enabled && this.width ? this.width || '170px' : undefined; |
|||
} |
|||
|
|||
constructor(private cdRef: ChangeDetectorRef, private elRef: ElementRef) {} |
|||
|
|||
ngAfterViewInit() { |
|||
this.title = this.title || (this.elRef.nativeElement as HTMLElement).innerText; |
|||
this.cdRef.detectChanges(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue